Merge "Convert -{}- markups in title="" and alt=""."
[lhc/web/wiklou.git] / includes / normal / UtfNormalTest2.php
index 960f346..691bfaa 100644 (file)
@@ -1,7 +1,22 @@
 #!/usr/bin/php
 <?php
 /**
- * Other tests for the unicode normalization module
+ * Other tests for the unicode normalization module.
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
  *
  * @file
  * @ingroup UtfNormal
@@ -13,8 +28,13 @@ if( php_sapi_name() != 'cli' ) {
 
 // From http://unicode.org/Public/UNIDATA/NormalizationTest.txt
 $file = "NormalizationTest.txt";
-$sep = ';';
-$comment = "#";
+
+// Anything after this character is a comment
+define ( 'COMMENT', '#' );
+
+// Semicolons are used to separate the columns
+define ( 'SEPARATOR', ';' );
+
 $f = fopen($file, "r");
 
 /**
@@ -56,6 +76,7 @@ function normalize_form_kd($c)     { return UtfNormal::toNFKD($c); }
  * following functions to force pure PHP usage.  I decided not to
  * commit that code since might produce a slowdown in the UTF
  * normalization code just for the sake of these tests. -- hexmode
+ * @return string
  */
 function normalize_form_c_php($c)  { return UtfNormal::toNFC($c, "php");  }
 function normalize_form_d_php($c)  { return UtfNormal::toNFD($c, "php");  }
@@ -189,12 +210,12 @@ echo "done.\n";
 function unichr($c) {
        if ($c <= 0x7F) {
                return chr($c);
-       } else if ($c <= 0x7FF) {
+       } elseif ($c <= 0x7FF) {
                return chr(0xC0 | $c >> 6) . chr(0x80 | $c & 0x3F);
-       } else if ($c <= 0xFFFF) {
+       } elseif ($c <= 0xFFFF) {
                return chr(0xE0 | $c >> 12) . chr(0x80 | $c >> 6 & 0x3F)
                        . chr(0x80 | $c & 0x3F);
-       } else if ($c <= 0x10FFFF) {
+       } elseif ($c <= 0x10FFFF) {
                return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F)
                        . chr(0x80 | $c >> 6 & 0x3F)
                        . chr(0x80 | $c & 0x3F);
@@ -208,12 +229,10 @@ function unistr($c) {
 }
 
 function getRow( $f ) {
-       global $comment, $sep;
-
        $row = fgets( $f );
        if( $row === false ) return false;
        $row = rtrim($row);
-       $pos = strpos( $row, $comment );
+       $pos = strpos( $row, COMMENT );
        $pos2 = strpos( $row, ")" );
        if( $pos === 0 ) return array($row);
        $c = "";
@@ -225,8 +244,8 @@ function getRow( $f ) {
        }
 
        $ret = array();
-       foreach(explode( $sep, $row ) as $ent) {
-               if(trim($ent) !== "") {
+       foreach( explode( SEPARATOR, $row ) as $ent ) {
+               if( trim( $ent ) !== "" ) {
                        $ret[] = unistr($ent);
                }
        }