r70080 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70079‎ | r70080 | r70081 >
Date:12:07, 28 July 2010
Author:platonides
Status:ok
Tags:
Comment:
From globals to parameters: $columns, $exceptions, $verbose
New line after the error messages.
Modified paths:
  • /trunk/phase3/includes/normal/Utf8Test.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/normal/Utf8Test.php
@@ -30,6 +30,7 @@
3131 require_once 'UtfNormal.php';
3232 mb_internal_encoding( "utf-8" );
3333
 34+$verbose = false;
3435 #$verbose = true;
3536 if( php_sapi_name() != 'cli' ) {
3637 die( "Run me from the command line please.\n" );
@@ -39,7 +40,7 @@
4041 if( !$in ) {
4142 print "Couldn't open UTF-8-test.txt -- can't run tests.\n";
4243 print "If necessary, manually download this file. It can be obtained at\n";
43 - print "http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt";
 44+ print "http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt\n";
4445 exit(-1);
4546 }
4647
@@ -55,7 +56,7 @@
5657 if( !$columns ) {
5758 print "Something seems to be wrong; couldn't extract line length.\n";
5859 print "Check that UTF-8-test.txt was downloaded correctly from\n";
59 - print "http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt";
 60+ print "http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt\n";
6061 exit(-1);
6162 }
6263
@@ -102,10 +103,10 @@
103104 if( in_array( $test, $longTests ) ) {
104105 $line = fgets( $in );
105106 for( $line = fgets( $in ); !preg_match( '/^\s+\|/', $line ); $line = fgets( $in ) ) {
106 - testLine( $test, $line, $total, $success, $failed );
 107+ testLine( $test, $line, $total, $success, $failed, $columns, $exceptions, $verbose );
107108 }
108109 } else {
109 - testLine( $test, $line, $total, $success, $failed );
 110+ testLine( $test, $line, $total, $success, $failed, $columns, $exceptions, $verbose );
110111 }
111112 }
112113 }
@@ -120,7 +121,7 @@
121122 exit (0);
122123
123124
124 -function testLine( $test, $line, &$total, &$success, &$failed ) {
 125+function testLine( $test, $line, &$total, &$success, &$failed, $columns, $exceptions, $verbose ) {
125126 $stripped = $line;
126127 UtfNormal::quickisNFCVerify( $stripped );
127128
@@ -130,10 +131,8 @@
131132 $len = strlen( substr( $stripped, 0, strpos( $stripped, '|' ) ) );
132133 }
133134
134 - global $columns;
135135 $ok = $same ^ ($test >= 3 );
136136
137 - global $exceptions;
138137 $ok ^= in_array( $test, $exceptions );
139138
140139 $ok &= ($columns == $len);
@@ -144,7 +143,7 @@
145144 } else {
146145 $failed++;
147146 }
148 - global $verbose;
 147+
149148 if( $verbose || !$ok ) {
150149 print str_replace( "\n", "$len\n", $stripped );
151150 }

Status & tagging log