diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2014-12-27 15:41:37 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2014-12-31 11:43:28 +0100 |
commit | c1f9b1f7b1b77776192048005dcc66dcf3df2bfb (patch) | |
tree | 2b38796e738dd74cb42ecd9bfd151803108386bc /includes/normal/Utf8Test.php | |
parent | b88ab0086858470dd1f644e64cb4e4f62bb2be9b (diff) |
Update to MediaWiki 1.24.1
Diffstat (limited to 'includes/normal/Utf8Test.php')
-rw-r--r-- | includes/normal/Utf8Test.php | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/includes/normal/Utf8Test.php b/includes/normal/Utf8Test.php index c5c1be59..f4acc1eb 100644 --- a/includes/normal/Utf8Test.php +++ b/includes/normal/Utf8Test.php @@ -4,7 +4,7 @@ * http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt * * Copyright © 2004 Brion Vibber <brion@pobox.com> - * 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 @@ -40,27 +40,27 @@ $verbose = false; #$verbose = true; $in = fopen( "UTF-8-test.txt", "rt" ); -if( !$in ) { +if ( !$in ) { print "Couldn't open UTF-8-test.txt -- can't run tests.\n"; print "If necessary, manually download this file. It can be obtained at\n"; print "http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt\n"; - exit(-1); + exit( -1 ); } $columns = 0; -while( false !== ( $line = fgets( $in ) ) ) { +while ( false !== ( $line = fgets( $in ) ) ) { $matches = array(); - if( preg_match( '/^(Here come the tests:\s*)\|$/', $line, $matches ) ) { + if ( preg_match( '/^(Here come the tests:\s*)\|$/', $line, $matches ) ) { $columns = strpos( $line, '|' ); break; } } -if( !$columns ) { +if ( !$columns ) { print "Something seems to be wrong; couldn't extract line length.\n"; print "Check that UTF-8-test.txt was downloaded correctly from\n"; print "http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt\n"; - exit(-1); + exit( -1 ); } # print "$columns\n"; @@ -90,22 +90,26 @@ $test = ''; $failed = 0; $success = 0; $total = 0; -while( false !== ( $line = fgets( $in ) ) ) { +while ( false !== ( $line = fgets( $in ) ) ) { $matches = array(); - if( preg_match( '/^(\d+)\s+(.*?)\s*\|/', $line, $matches ) ) { + if ( preg_match( '/^(\d+)\s+(.*?)\s*\|/', $line, $matches ) ) { $section = $matches[1]; print $line; continue; } - if( preg_match( '/^(\d+\.\d+\.\d+)\s*/', $line, $matches ) ) { + if ( preg_match( '/^(\d+\.\d+\.\d+)\s*/', $line, $matches ) ) { $test = $matches[1]; - if( in_array( $test, $ignore ) ) { + if ( in_array( $test, $ignore ) ) { continue; } - if( in_array( $test, $longTests ) ) { + if ( in_array( $test, $longTests ) ) { $line = fgets( $in ); - for( $line = fgets( $in ); !preg_match( '/^\s+\|/', $line ); $line = fgets( $in ) ) { + + // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed + for ( $line = fgets( $in ); !preg_match( '/^\s+\|/', $line ); $line = fgets( $in ) ) { + // @codingStandardsIgnoreEnd + testLine( $test, $line, $total, $success, $failed, $columns, $exceptions, $verbose ); } } else { @@ -114,15 +118,14 @@ while( false !== ( $line = fgets( $in ) ) ) { } } -if( $failed ) { +if ( $failed ) { echo "\nFailed $failed tests.\n"; echo "UTF-8 DECODER TEST FAILED\n"; - exit (-1); + exit ( -1 ); } echo "UTF-8 DECODER TEST SUCCESS!\n"; -exit (0); - +exit ( 0 ); function testLine( $test, $line, &$total, &$success, &$failed, $columns, $exceptions, $verbose ) { $stripped = $line; @@ -130,24 +133,24 @@ function testLine( $test, $line, &$total, &$success, &$failed, $columns, $except $same = ( $line == $stripped ); $len = mb_strlen( substr( $stripped, 0, strpos( $stripped, '|' ) ) ); - if( $len == 0 ) { + if ( $len == 0 ) { $len = strlen( substr( $stripped, 0, strpos( $stripped, '|' ) ) ); } - $ok = $same ^ ($test >= 3 ); + $ok = $same ^ ( $test >= 3 ); $ok ^= in_array( $test, $exceptions ); - $ok &= ($columns == $len); + $ok &= ( $columns == $len ); $total++; - if( $ok ) { + if ( $ok ) { $success++; } else { $failed++; } - if( $verbose || !$ok ) { + if ( $verbose || !$ok ) { print str_replace( "\n", "$len\n", $stripped ); } } |