Index: trunk/phase3/includes/normal/Utf8Test.php |
— | — | @@ -30,6 +30,7 @@ |
31 | 31 | require_once 'UtfNormal.php'; |
32 | 32 | mb_internal_encoding( "utf-8" ); |
33 | 33 | |
| 34 | +$verbose = false; |
34 | 35 | #$verbose = true; |
35 | 36 | if( php_sapi_name() != 'cli' ) { |
36 | 37 | die( "Run me from the command line please.\n" ); |
— | — | @@ -39,7 +40,7 @@ |
40 | 41 | if( !$in ) { |
41 | 42 | print "Couldn't open UTF-8-test.txt -- can't run tests.\n"; |
42 | 43 | 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"; |
44 | 45 | exit(-1); |
45 | 46 | } |
46 | 47 | |
— | — | @@ -55,7 +56,7 @@ |
56 | 57 | if( !$columns ) { |
57 | 58 | print "Something seems to be wrong; couldn't extract line length.\n"; |
58 | 59 | 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"; |
60 | 61 | exit(-1); |
61 | 62 | } |
62 | 63 | |
— | — | @@ -102,10 +103,10 @@ |
103 | 104 | if( in_array( $test, $longTests ) ) { |
104 | 105 | $line = fgets( $in ); |
105 | 106 | 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 ); |
107 | 108 | } |
108 | 109 | } else { |
109 | | - testLine( $test, $line, $total, $success, $failed ); |
| 110 | + testLine( $test, $line, $total, $success, $failed, $columns, $exceptions, $verbose ); |
110 | 111 | } |
111 | 112 | } |
112 | 113 | } |
— | — | @@ -120,7 +121,7 @@ |
121 | 122 | exit (0); |
122 | 123 | |
123 | 124 | |
124 | | -function testLine( $test, $line, &$total, &$success, &$failed ) { |
| 125 | +function testLine( $test, $line, &$total, &$success, &$failed, $columns, $exceptions, $verbose ) { |
125 | 126 | $stripped = $line; |
126 | 127 | UtfNormal::quickisNFCVerify( $stripped ); |
127 | 128 | |
— | — | @@ -130,10 +131,8 @@ |
131 | 132 | $len = strlen( substr( $stripped, 0, strpos( $stripped, '|' ) ) ); |
132 | 133 | } |
133 | 134 | |
134 | | - global $columns; |
135 | 135 | $ok = $same ^ ($test >= 3 ); |
136 | 136 | |
137 | | - global $exceptions; |
138 | 137 | $ok ^= in_array( $test, $exceptions ); |
139 | 138 | |
140 | 139 | $ok &= ($columns == $len); |
— | — | @@ -144,7 +143,7 @@ |
145 | 144 | } else { |
146 | 145 | $failed++; |
147 | 146 | } |
148 | | - global $verbose; |
| 147 | + |
149 | 148 | if( $verbose || !$ok ) { |
150 | 149 | print str_replace( "\n", "$len\n", $stripped ); |
151 | 150 | } |