From a58285fd06c8113c45377c655dd43cef6337e815 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 11 Jan 2007 19:06:07 +0000 Subject: Aktualisierung auf MediaWiki 1.9.0 --- includes/normal/RandomTest.php | 1 + includes/normal/Utf8Test.php | 2 ++ includes/normal/UtfNormal.php | 54 +++++++++++++++++++++++------------ includes/normal/UtfNormalGenerate.php | 1 + includes/normal/UtfNormalTest.php | 2 +- 5 files changed, 40 insertions(+), 20 deletions(-) (limited to 'includes/normal') diff --git a/includes/normal/RandomTest.php b/includes/normal/RandomTest.php index e2601366..b86ab7c3 100644 --- a/includes/normal/RandomTest.php +++ b/includes/normal/RandomTest.php @@ -68,6 +68,7 @@ function showDiffs( $a, $b ) { $diffs = new Diff( $ota, $nta ); $formatter = new TableDiffFormatter(); $funky = $formatter->format( $diffs ); + $matches = array(); preg_match_all( '/(.*?)<\/span>/', $funky, $matches ); foreach( $matches[1] as $bit ) { $hex = bin2hex( $bit ); diff --git a/includes/normal/Utf8Test.php b/includes/normal/Utf8Test.php index 71069598..34ab69c8 100644 --- a/includes/normal/Utf8Test.php +++ b/includes/normal/Utf8Test.php @@ -45,6 +45,7 @@ if( !$in ) { $columns = 0; while( false !== ( $line = fgets( $in ) ) ) { + $matches = array(); if( preg_match( '/^(Here come the tests:\s*)\|$/', $line, $matches ) ) { $columns = strpos( $line, '|' ); break; @@ -86,6 +87,7 @@ $failed = 0; $success = 0; $total = 0; while( false !== ( $line = fgets( $in ) ) ) { + $matches = array(); if( preg_match( '/^(\d+)\s+(.*?)\s*\|/', $line, $matches ) ) { $section = $matches[1]; print $line; diff --git a/includes/normal/UtfNormal.php b/includes/normal/UtfNormal.php index af3809d5..d8eac7b8 100644 --- a/includes/normal/UtfNormal.php +++ b/includes/normal/UtfNormal.php @@ -124,8 +124,9 @@ class UtfNormal { * * @param string $string a UTF-8 string * @return string a clean, shiny, normalized UTF-8 string + * @static */ - function cleanUp( $string ) { + static function cleanUp( $string ) { if( NORMALIZE_ICU ) { # We exclude a few chars that ICU would not. $string = preg_replace( @@ -153,8 +154,9 @@ class UtfNormal { * * @param string $string a valid UTF-8 string. Input is not validated. * @return string a UTF-8 string in normal form C + * @static */ - function toNFC( $string ) { + static function toNFC( $string ) { if( NORMALIZE_ICU ) return utf8_normalize( $string, UNORM_NFC ); elseif( UtfNormal::quickIsNFC( $string ) ) @@ -169,8 +171,9 @@ class UtfNormal { * * @param string $string a valid UTF-8 string. Input is not validated. * @return string a UTF-8 string in normal form D + * @static */ - function toNFD( $string ) { + static function toNFD( $string ) { if( NORMALIZE_ICU ) return utf8_normalize( $string, UNORM_NFD ); elseif( preg_match( '/[\x80-\xff]/', $string ) ) @@ -186,8 +189,9 @@ class UtfNormal { * * @param string $string a valid UTF-8 string. Input is not validated. * @return string a UTF-8 string in normal form KC + * @static */ - function toNFKC( $string ) { + static function toNFKC( $string ) { if( NORMALIZE_ICU ) return utf8_normalize( $string, UNORM_NFKC ); elseif( preg_match( '/[\x80-\xff]/', $string ) ) @@ -203,8 +207,9 @@ class UtfNormal { * * @param string $string a valid UTF-8 string. Input is not validated. * @return string a UTF-8 string in normal form KD + * @static */ - function toNFKD( $string ) { + static function toNFKD( $string ) { if( NORMALIZE_ICU ) return utf8_normalize( $string, UNORM_NFKD ); elseif( preg_match( '/[\x80-\xff]/', $string ) ) @@ -216,10 +221,10 @@ class UtfNormal { /** * Load the basic composition data if necessary * @private + * @static */ - function loadData() { - # fixme : are $utfCanonicalComp, $utfCanonicalDecomp really used? - global $utfCombiningClass, $utfCanonicalComp, $utfCanonicalDecomp; + static function loadData() { + global $utfCombiningClass; if( !isset( $utfCombiningClass ) ) { require_once( 'UtfNormalData.inc' ); } @@ -230,8 +235,9 @@ class UtfNormal { * Returns false if not or uncertain. * @param string $string a valid UTF-8 string. Input is not validated. * @return bool + * @static */ - function quickIsNFC( $string ) { + static function quickIsNFC( $string ) { # ASCII is always valid NFC! # If it's pure ASCII, let it through. if( !preg_match( '/[\x80-\xff]/', $string ) ) return true; @@ -270,8 +276,9 @@ class UtfNormal { * Returns true if the string is _definitely_ in NFC. * Returns false if not or uncertain. * @param string $string a UTF-8 string, altered on output to be valid UTF-8 safe for XML. + * @static */ - function quickIsNFCVerify( &$string ) { + static function quickIsNFCVerify( &$string ) { # Screen out some characters that eg won't be allowed in XML $string = preg_replace( '/[\x00-\x08\x0b\x0c\x0e-\x1f]/', UTF8_REPLACEMENT, $string ); @@ -321,6 +328,7 @@ class UtfNormal { # large ASCII parts can be handled much more quickly. # Don't chop up Unicode areas for punctuation, though, # that wastes energy. + $matches = array(); preg_match_all( '/([\x00-\x7f]+|[\x80-\xff][\x00-\x40\x5b-\x5f\x7b-\xff]*)/', $string, $matches ); @@ -488,8 +496,9 @@ class UtfNormal { * @param string $string * @return string * @private + * @static */ - function NFC( $string ) { + static function NFC( $string ) { return UtfNormal::fastCompose( UtfNormal::NFD( $string ) ); } @@ -497,8 +506,9 @@ class UtfNormal { * @param string $string * @return string * @private + * @static */ - function NFD( $string ) { + static function NFD( $string ) { UtfNormal::loadData(); global $utfCanonicalDecomp; return UtfNormal::fastCombiningSort( @@ -509,8 +519,9 @@ class UtfNormal { * @param string $string * @return string * @private + * @static */ - function NFKC( $string ) { + static function NFKC( $string ) { return UtfNormal::fastCompose( UtfNormal::NFKD( $string ) ); } @@ -518,8 +529,9 @@ class UtfNormal { * @param string $string * @return string * @private + * @static */ - function NFKD( $string ) { + static function NFKD( $string ) { global $utfCompatibilityDecomp; if( !isset( $utfCompatibilityDecomp ) ) { require_once( 'UtfNormalDataK.inc' ); @@ -537,8 +549,9 @@ class UtfNormal { * @param string $string Valid UTF-8 string * @param array $map hash of expanded decomposition map * @return string a UTF-8 string decomposed, not yet normalized (needs sorting) + * @static */ - function fastDecompose( $string, &$map ) { + static function fastDecompose( $string, $map ) { UtfNormal::loadData(); $len = strlen( $string ); $out = ''; @@ -597,8 +610,9 @@ class UtfNormal { * @private * @param string $string a valid, decomposed UTF-8 string. Input is not validated. * @return string a UTF-8 string with combining characters sorted in canonical order + * @static */ - function fastCombiningSort( $string ) { + static function fastCombiningSort( $string ) { UtfNormal::loadData(); global $utfCombiningClass; $len = strlen( $string ); @@ -646,8 +660,9 @@ class UtfNormal { * @private * @param string $string a valid UTF-8 string in sorted normal form D or KD. Input is not validated. * @return string a UTF-8 string with canonical precomposed characters used where possible + * @static */ - function fastCompose( $string ) { + static function fastCompose( $string ) { UtfNormal::loadData(); global $utfCanonicalComp, $utfCombiningClass; $len = strlen( $string ); @@ -778,8 +793,9 @@ class UtfNormal { * interate through a string without really doing anything of substance. * @param string $string * @return string + * @static */ - function placebo( $string ) { + static function placebo( $string ) { $len = strlen( $string ); $out = ''; for( $i = 0; $i < $len; $i++ ) { @@ -789,4 +805,4 @@ class UtfNormal { } } -?> +?> \ No newline at end of file diff --git a/includes/normal/UtfNormalGenerate.php b/includes/normal/UtfNormalGenerate.php index 688a80f1..f0eb5330 100644 --- a/includes/normal/UtfNormalGenerate.php +++ b/includes/normal/UtfNormalGenerate.php @@ -43,6 +43,7 @@ if( !$in ) { print "Initializing normalization quick check tables...\n"; $checkNFC = array(); while( false !== ($line = fgets( $in ) ) ) { + $matches = array(); if( preg_match( '/^([0-9A-F]+)(?:..([0-9A-F]+))?\s*;\s*(NFC_QC)\s*;\s*([MN])/', $line, $matches ) ) { list( $junk, $first, $last, $prop, $value ) = $matches; #print "$first $last $prop $value\n"; diff --git a/includes/normal/UtfNormalTest.php b/includes/normal/UtfNormalTest.php index 6d95bf85..1181b633 100644 --- a/includes/normal/UtfNormalTest.php +++ b/includes/normal/UtfNormalTest.php @@ -73,6 +73,7 @@ $testedChars = array(); while( false !== ( $line = fgets( $in ) ) ) { list( $data, $comment ) = explode( '#', $line ); if( $data === '' ) continue; + $matches = array(); if( preg_match( '/@Part([\d])/', $data, $matches ) ) { if( $matches[1] > 0 ) { $ok = reportResults( $total, $success, $failure ) && $ok; @@ -236,7 +237,6 @@ function testInvariant( &$u, $char, $desc, $reportFailure = false ) { $result = verbosify( $char, $u->toNFD( $char ), 1, 'NFD', $reportFailure ) && $result; $result = verbosify( $char, $u->toNFKC( $char ), 1, 'NFKC', $reportFailure ) && $result; $result = verbosify( $char, $u->toNFKD( $char ), 1, 'NFKD', $reportFailure ) && $result; - $c = $char; $result = verbosify( $char, $u->cleanUp( $char ), 1, 'cleanUp', $reportFailure ) && $result; global $verbose; if( $verbose && !$result && !$reportFailure ) { -- cgit v1.2.2