summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--it.class20
1 files changed, 6 insertions, 14 deletions
diff --git a/it.class b/it.class
index 2b61fda..e79f228 100644
--- a/it.class
+++ b/it.class
@@ -212,17 +212,14 @@ function match($pattern, $string, $p = array())
$flags |= PREG_OFFSET_CAPTURE;
$oldlocale = setlocale( LC_CTYPE, 0 );
-
- if ($oldlocale != 'de_CH')
- setlocale(LC_CTYPE, 'de_CH');
+ setlocale(LC_CTYPE, 'de_CH');
if ($p['all'])
$r = preg_match_all(it::convertregex($pattern, $p), $string, $m, $flags | PREG_PATTERN_ORDER, $p['offset']);
else
$r = preg_match(it::convertregex($pattern, $p), $string, $m, $flags, $p['offset']);
- if ($oldlocale != 'de_CH')
- setlocale(LC_CTYPE, $oldlocale);
+ setlocale(LC_CTYPE, $oldlocale);
if (!$r) # no match
$result = $p['all'] ? array() : false;
@@ -248,18 +245,13 @@ function replace($replacements, $string, $p = array())
{
$patterns = array();
- foreach (array_keys( $replacements ) as $pat)
- $patterns[] = it::convertregex($pat, $p);
+ foreach (array_keys($replacements) as $pattern)
+ $patterns[] = it::convertregex($pattern, $p);
$oldlocale = setlocale(LC_CTYPE, 0);
-
- if ($oldlocale != 'de_CH')
- setlocale(LC_CTYPE, 'de_CH');
-
+ setlocale(LC_CTYPE, 'de_CH');
$result = preg_replace($patterns, array_values($replacements), $string, isset($p['limit']) ? $p['limit'] : -1);
-
- if ($oldlocale != 'de_CH')
- setlocale(LC_CTYPE, $oldlocale);
+ setlocale(LC_CTYPE, $oldlocale);
return $result;
}