From 23c257265ab9c3d88408b1c58f82df22e06e17bd Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Wed, 24 Jan 2007 12:36:24 +0000 Subject: Minor style cleanup and simplified setlocale logic --- it.class | 20 ++++++-------------- 1 file 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; } -- cgit v1.2.3