From c1f9b1f7b1b77776192048005dcc66dcf3df2bfb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 27 Dec 2014 15:41:37 +0100 Subject: Update to MediaWiki 1.24.1 --- includes/normal/UtfNormalGenerate.php | 103 ++++++++++++++++++++-------------- 1 file changed, 60 insertions(+), 43 deletions(-) (limited to 'includes/normal/UtfNormalGenerate.php') diff --git a/includes/normal/UtfNormalGenerate.php b/includes/normal/UtfNormalGenerate.php index f392df52..f57aa6cc 100644 --- a/includes/normal/UtfNormalGenerate.php +++ b/includes/normal/UtfNormalGenerate.php @@ -4,7 +4,7 @@ * and supplementary files. * * Copyright (C) 2004 Brion Vibber - * http://www.mediawiki.org/ + * https://www.mediawiki.org/ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,29 +25,37 @@ * @ingroup UtfNormal */ -if( PHP_SAPI != 'cli' ) { +if ( PHP_SAPI != 'cli' ) { die( "Run me from the command line please.\n" ); } require_once 'UtfNormalDefines.php'; require_once 'UtfNormalUtil.php'; -$in = fopen("DerivedNormalizationProps.txt", "rt" ); -if( !$in ) { +$in = fopen( "DerivedNormalizationProps.txt", "rt" ); +if ( !$in ) { print "Can't open DerivedNormalizationProps.txt for reading.\n"; print "If necessary, fetch this file from the internet:\n"; print "http://www.unicode.org/Public/UNIDATA/DerivedNormalizationProps.txt\n"; - exit(-1); + exit( -1 ); } print "Initializing normalization quick check tables...\n"; $checkNFC = array(); -while( false !== ($line = fgets( $in ) ) ) { +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 ) ) { + 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"; - if( !$last ) $last = $first; - for( $i = hexdec( $first ); $i <= hexdec( $last ); $i++) { + if ( !$last ) { + $last = $first; + } + + $lastInDecimal = hexdec( $last ); + for ( $i = hexdec( $first ); $i <= $lastInDecimal; $i++ ) { $char = codepointToUtf8( $i ); $checkNFC[$char] = $value; } @@ -55,29 +63,29 @@ while( false !== ($line = fgets( $in ) ) ) { } fclose( $in ); -$in = fopen("CompositionExclusions.txt", "rt" ); -if( !$in ) { +$in = fopen( "CompositionExclusions.txt", "rt" ); +if ( !$in ) { print "Can't open CompositionExclusions.txt for reading.\n"; print "If necessary, fetch this file from the internet:\n"; print "http://www.unicode.org/Public/UNIDATA/CompositionExclusions.txt\n"; - exit(-1); + exit( -1 ); } $exclude = array(); -while( false !== ($line = fgets( $in ) ) ) { - if( preg_match( '/^([0-9A-F]+)/i', $line, $matches ) ) { +while ( false !== ( $line = fgets( $in ) ) ) { + if ( preg_match( '/^([0-9A-F]+)/i', $line, $matches ) ) { $codepoint = $matches[1]; $source = codepointToUtf8( hexdec( $codepoint ) ); $exclude[$source] = true; } } -fclose($in); +fclose( $in ); -$in = fopen("UnicodeData.txt", "rt" ); -if( !$in ) { +$in = fopen( "UnicodeData.txt", "rt" ); +if ( !$in ) { print "Can't open UnicodeData.txt for reading.\n"; print "If necessary, fetch this file from the internet:\n"; print "http://www.unicode.org/Public/UNIDATA/UnicodeData.txt\n"; - exit(-1); + exit( -1 ); } $compatibilityDecomp = array(); @@ -89,8 +97,8 @@ $compat = 0; $canon = 0; print "Reading character definitions...\n"; -while( false !== ($line = fgets( $in ) ) ) { - $columns = explode(';', $line); +while ( false !== ( $line = fgets( $in ) ) ) { + $columns = explode( ';', $line ); $codepoint = $columns[0]; $name = $columns[1]; $canonicalCombiningClass = $columns[3]; @@ -98,12 +106,12 @@ while( false !== ($line = fgets( $in ) ) ) { $source = codepointToUtf8( hexdec( $codepoint ) ); - if( $canonicalCombiningClass != 0 ) { + if ( $canonicalCombiningClass != 0 ) { $combiningClass[$source] = intval( $canonicalCombiningClass ); } - if( $decompositionMapping === '' ) continue; - if( preg_match( '/^<(.+)> (.*)$/', $decompositionMapping, $matches ) ) { + if ( $decompositionMapping === '' ) continue; + if ( preg_match( '/^<(.+)> (.*)$/', $decompositionMapping, $matches ) ) { # Compatibility decomposition $canonical = false; $decompositionMapping = $matches[2]; @@ -116,9 +124,9 @@ while( false !== ($line = fgets( $in ) ) ) { $dest = hexSequenceToUtf8( $decompositionMapping ); $compatibilityDecomp[$source] = $dest; - if( $canonical ) { + if ( $canonical ) { $canonicalDecomp[$source] = $dest; - if( empty( $exclude[$source] ) ) { + if ( empty( $exclude[$source] ) ) { $canonicalComp[$dest] = $source; } } @@ -129,15 +137,15 @@ fclose( $in ); print "Recursively expanding canonical mappings...\n"; $changed = 42; $pass = 1; -while( $changed > 0 ) { +while ( $changed > 0 ) { print "pass $pass\n"; $changed = 0; - foreach( $canonicalDecomp as $source => $dest ) { + foreach ( $canonicalDecomp as $source => $dest ) { $newDest = preg_replace_callback( '/([\xc0-\xff][\x80-\xbf]+)/', 'callbackCanonical', - $dest); - if( $newDest === $dest ) continue; + $dest ); + if ( $newDest === $dest ) continue; $changed++; $canonicalDecomp[$source] = $newDest; } @@ -147,15 +155,15 @@ while( $changed > 0 ) { print "Recursively expanding compatibility mappings...\n"; $changed = 42; $pass = 1; -while( $changed > 0 ) { +while ( $changed > 0 ) { print "pass $pass\n"; $changed = 0; - foreach( $compatibilityDecomp as $source => $dest ) { + foreach ( $compatibilityDecomp as $source => $dest ) { $newDest = preg_replace_callback( '/([\xc0-\xff][\x80-\xbf]+)/', 'callbackCompat', - $dest); - if( $newDest === $dest ) continue; + $dest ); + if ( $newDest === $dest ) continue; $changed++; $compatibilityDecomp[$source] = $newDest; } @@ -164,8 +172,8 @@ while( $changed > 0 ) { print "$total decomposition mappings ($canon canonical, $compat compatibility)\n"; -$out = fopen("UtfNormalData.inc", "wt"); -if( $out ) { +$out = fopen( "UtfNormalData.inc", "wt" ); +if ( $out ) { $serCombining = escapeSingleString( serialize( $combiningClass ) ); $serComp = escapeSingleString( serialize( $canonicalComp ) ); $serCanon = escapeSingleString( serialize( $canonicalDecomp ) ); @@ -177,6 +185,7 @@ if( $out ) { * * @file */ +// @codingStandardsIgnoreFile UtfNormal::\$utfCombiningClass = unserialize( '$serCombining' ); UtfNormal::\$utfCanonicalComp = unserialize( '$serComp' ); @@ -188,12 +197,11 @@ UtfNormal::\$utfCheckNFC = unserialize( '$serCheckNFC' ); print "Wrote out UtfNormalData.inc\n"; } else { print "Can't create file UtfNormalData.inc\n"; - exit(-1); + exit( -1 ); } - -$out = fopen("UtfNormalDataK.inc", "wt"); -if( $out ) { +$out = fopen( "UtfNormalDataK.inc", "wt" ); +if ( $out ) { $serCompat = escapeSingleString( serialize( $compatibilityDecomp ) ); $outdata = "<" . "?php /** @@ -202,32 +210,41 @@ if( $out ) { * * @file */ +// @codingStandardsIgnoreFile UtfNormal::\$utfCompatibilityDecomp = unserialize( '$serCompat' ); \n"; fputs( $out, $outdata ); fclose( $out ); print "Wrote out UtfNormalDataK.inc\n"; - exit(0); + exit( 0 ); } else { print "Can't create file UtfNormalDataK.inc\n"; - exit(-1); + exit( -1 ); } # --------------- function callbackCanonical( $matches ) { + // @codingStandardsIgnoreStart MediaWiki.NamingConventions.ValidGlobalName.wgPrefix global $canonicalDecomp; - if( isset( $canonicalDecomp[$matches[1]] ) ) { + // @codingStandardsIgnoreEnd + + if ( isset( $canonicalDecomp[$matches[1]] ) ) { return $canonicalDecomp[$matches[1]]; } + return $matches[1]; } function callbackCompat( $matches ) { + // @codingStandardsIgnoreStart MediaWiki.NamingConventions.ValidGlobalName.wgPrefix global $compatibilityDecomp; - if( isset( $compatibilityDecomp[$matches[1]] ) ) { + // @codingStandardsIgnoreEnd + + if ( isset( $compatibilityDecomp[$matches[1]] ) ) { return $compatibilityDecomp[$matches[1]]; } + return $matches[1]; } -- cgit v1.2.3-54-g00ecf