diff options
author | Christian Schneider | 2007-01-24 12:36:24 +0000 |
---|---|---|
committer | Christian Schneider | 2007-01-24 12:36:24 +0000 |
commit | 23c257265ab9c3d88408b1c58f82df22e06e17bd (patch) | |
tree | c42d76e72212c83e7ed17c69194d4a259947ce0f | |
parent | 70a8d4b8041833696ab8c8fdc57429782ba2485f (diff) | |
download | itools-23c257265ab9c3d88408b1c58f82df22e06e17bd.tar.gz itools-23c257265ab9c3d88408b1c58f82df22e06e17bd.tar.bz2 itools-23c257265ab9c3d88408b1c58f82df22e06e17bd.zip |
Minor style cleanup and simplified setlocale logic
-rw-r--r-- | it.class | 20 |
1 files changed, 6 insertions, 14 deletions
@@ -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; } |