cataphract Wed, 31 Aug 2011 05:45:02 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=315846
Log: - Less GCC warnings; code less readable, yay! - Fixed html_tables.h generaration in 64-bit archs. - Closes bug #55394 - Patch to suppress initialization warnings in html.c #signed/unsigned mismatches for another day #regenerated tables on another commit Bug: https://bugs.php.net/55394 (Assigned) Patch to suppress initialization warnings in html.c Changed paths: U php/php-src/branches/PHP_5_4/ext/standard/html.c U php/php-src/branches/PHP_5_4/ext/standard/html_tables/html_table_gen.php U php/php-src/trunk/ext/standard/html.c U php/php-src/trunk/ext/standard/html_tables/html_table_gen.php
Modified: php/php-src/branches/PHP_5_4/ext/standard/html.c =================================================================== --- php/php-src/branches/PHP_5_4/ext/standard/html.c 2011-08-31 04:24:48 UTC (rev 315845) +++ php/php-src/branches/PHP_5_4/ext/standard/html.c 2011-08-31 05:45:02 UTC (rev 315846) @@ -271,7 +271,7 @@ MB_FAILURE(pos, 2); } pos += 2; - } else if (c < 0x80 || c >= 0xA1 && c <= 0xDF) { + } else if (c < 0x80 || (c >= 0xA1 && c <= 0xDF)) { this_char = c; pos += 1; } else { @@ -787,8 +787,8 @@ /* strtol allows whitespace and other stuff in the beginning * we're not interested */ - if (hexadecimal && !isxdigit(**buf) || - !hexadecimal && !isdigit(**buf)) { + if ((hexadecimal && !isxdigit(**buf)) || + (!hexadecimal && !isdigit(**buf))) { return FAILURE; } @@ -821,9 +821,9 @@ * sequence of 8-bit code units. If in the ranges below, it represents * necessarily a alpha character because none of the supported encodings * has an overlap with ASCII in the leading byte (only on the second one) */ - while (**buf >= 'a' && **buf <= 'z' || - **buf >= 'A' && **buf <= 'Z' || - **buf >= '0' && **buf <= '9') { + while ((**buf >= 'a' && **buf <= 'z') || + (**buf >= 'A' && **buf <= 'Z') || + (**buf >= '0' && **buf <= '9')) { (*buf)++; } Modified: php/php-src/branches/PHP_5_4/ext/standard/html_tables/html_table_gen.php =================================================================== --- php/php-src/branches/PHP_5_4/ext/standard/html_tables/html_table_gen.php 2011-08-31 04:24:48 UTC (rev 315845) +++ php/php-src/branches/PHP_5_4/ext/standard/html_tables/html_table_gen.php 2011-08-31 05:45:02 UTC (rev 315846) @@ -25,7 +25,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-%s The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -119,7 +119,7 @@ CODE; -echo $t; +echo sprintf($t, date("Y")); $encodings = array( array( @@ -213,7 +213,7 @@ $s2tables_idents[$i] = $e["ident"]; echo "static const enc_to_uni_stage2 enc_to_uni_s2_{$e['ident']}_". - sprintf("%02X", $i << 6)." = {\n"; + sprintf("%02X", $i << 6)." = { {\n"; for ($j = 0; $j < 64; $j++) { if ($j == 0) echo "\t"; elseif ($j % 6 == 0) echo "\n\t"; @@ -223,7 +223,7 @@ else echo "0xFFFF,"; /* special value; indicates no mapping */ } - echo "\n};\n\n"; + echo "\n} };\n\n"; $prevStage2[] = $mstable[$i]; } @@ -235,11 +235,11 @@ "/* {{{ Stage 1 table for {$e['name']} */\n"; echo -"static const enc_to_uni enc_to_uni_{$e['ident']} = { +"static const enc_to_uni enc_to_uni_{$e['ident']} = { { \t&enc_to_uni_s2_{$s2tables_idents[0]}_00, \t&enc_to_uni_s2_{$s2tables_idents[1]}_40, \t&enc_to_uni_s2_{$s2tables_idents[2]}_80, -\t&enc_to_uni_s2_{$s2tables_idents[3]}_C0, +\t&enc_to_uni_s2_{$s2tables_idents[3]}_C0 } }; "; @@ -471,17 +471,17 @@ if (key_exists("default", $v)) { if ($v['default'] == 'GT') /* hack to make > translate to > not GT; */ $v['default'] = "gt"; - echo "\t{", sprintf("%02d", count($v) - 1), + echo "\t{ {", sprintf("%02d", count($v) - 1), ",\t\t", sprintf("\"%-21s", $v["default"].'",'), "\t", - sprintf("% 2d", strlen($v["default"])), '},', "\n"; + sprintf("% 2d", strlen($v["default"])), '} },', "\n"; } else { - echo "\t{", sprintf("%02d", count($v)), - ",\t\t", sprintf("%-22s", 'NULL'), ",\t0},\n"; + echo "\t{ {", sprintf("%02d", count($v)), + ",\t\t", sprintf("%-22s", 'NULL'), ",\t0} },\n"; } unset($v["default"]); foreach ($v as $l => $w) { - echo "\t{", sprintf("0x%05s", $l), ",\t", sprintf("\"%-21s", $w.'",'), "\t", - sprintf("% 2d", strlen($w)), '},', "\n"; + echo "\t{ {", sprintf("0x%05s", $l), ",\t", sprintf("\"%-21s", $w.'",'), "\t", + sprintf("% 2d", strlen($w)), '} },', "\n"; } echo "};\n"; } @@ -495,22 +495,22 @@ $t = <<<CODE static const entity_stage3_row empty_stage3_table[] = { /* 64 elements */ - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, }; CODE; @@ -550,14 +550,14 @@ elseif ($y % 4 == 0) echo "\n\t"; else echo " "; if ($z === NULL) - echo "{0, NULL, 0},"; + echo "{0, { {NULL, 0} } },"; elseif ($z === "QUOT") /* hack to translate " into "e;, not " */ - echo "{0, \"quot\", 4},"; + echo "{0, { {\"quot\", 4} } },"; elseif ($z !== "") - echo "{0, \"$z\", ", strlen($z), "},"; + echo "{0, { {\"$z\", ", strlen($z), "} } },"; else - echo "{1, (void*)", sprintf("multi_cp_{$ident}_%05X", - ($i << 12) | ($k << 6) | $y ), "},"; + echo "{1, { {(void *)", sprintf("multi_cp_{$ident}_%05X", + ($i << 12) | ($k << 6) | $y ), "} } },"; } echo "\n};\n\n"; @@ -712,7 +712,7 @@ const entity_ht_bucket *buckets; /* .num_elems elements */ } entity_ht; -static const entity_cp_map ht_bucket_empty[] = { NULL }; +static const entity_cp_map ht_bucket_empty[] = { {NULL, 0, 0, 0} }; CODE; @@ -726,9 +726,9 @@ $nKeyLength = strlen($str); $pos = 0; - /* variant with the hash unrolled eight times */ for (; $nKeyLength > 0; $nKeyLength--) { - $hash = (int)(((int)(((int)($hash << 5)) + $hash)) + ord($str[$pos++])); + $hash = (int)(((int)(((int)($hash << 5)) + $hash)) + ord($str[$pos++])) + & 0xFFFFFFFF; } return $hash; @@ -762,7 +762,7 @@ $h[0], strlen($h[0]), hexdec($h[1])); } } - echo " {NULL} };\n"; + echo " {NULL, 0, 0, 0} };\n"; } echo "\n"; Modified: php/php-src/trunk/ext/standard/html.c =================================================================== --- php/php-src/trunk/ext/standard/html.c 2011-08-31 04:24:48 UTC (rev 315845) +++ php/php-src/trunk/ext/standard/html.c 2011-08-31 05:45:02 UTC (rev 315846) @@ -271,7 +271,7 @@ MB_FAILURE(pos, 2); } pos += 2; - } else if (c < 0x80 || c >= 0xA1 && c <= 0xDF) { + } else if (c < 0x80 || (c >= 0xA1 && c <= 0xDF)) { this_char = c; pos += 1; } else { @@ -787,8 +787,8 @@ /* strtol allows whitespace and other stuff in the beginning * we're not interested */ - if (hexadecimal && !isxdigit(**buf) || - !hexadecimal && !isdigit(**buf)) { + if ((hexadecimal && !isxdigit(**buf)) || + (!hexadecimal && !isdigit(**buf))) { return FAILURE; } @@ -821,9 +821,9 @@ * sequence of 8-bit code units. If in the ranges below, it represents * necessarily a alpha character because none of the supported encodings * has an overlap with ASCII in the leading byte (only on the second one) */ - while (**buf >= 'a' && **buf <= 'z' || - **buf >= 'A' && **buf <= 'Z' || - **buf >= '0' && **buf <= '9') { + while ((**buf >= 'a' && **buf <= 'z') || + (**buf >= 'A' && **buf <= 'Z') || + (**buf >= '0' && **buf <= '9')) { (*buf)++; } Modified: php/php-src/trunk/ext/standard/html_tables/html_table_gen.php =================================================================== --- php/php-src/trunk/ext/standard/html_tables/html_table_gen.php 2011-08-31 04:24:48 UTC (rev 315845) +++ php/php-src/trunk/ext/standard/html_tables/html_table_gen.php 2011-08-31 05:45:02 UTC (rev 315846) @@ -25,7 +25,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2010 The PHP Group | + | Copyright (c) 1997-%s The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -119,7 +119,7 @@ CODE; -echo $t; +echo sprintf($t, date("Y")); $encodings = array( array( @@ -213,7 +213,7 @@ $s2tables_idents[$i] = $e["ident"]; echo "static const enc_to_uni_stage2 enc_to_uni_s2_{$e['ident']}_". - sprintf("%02X", $i << 6)." = {\n"; + sprintf("%02X", $i << 6)." = { {\n"; for ($j = 0; $j < 64; $j++) { if ($j == 0) echo "\t"; elseif ($j % 6 == 0) echo "\n\t"; @@ -223,7 +223,7 @@ else echo "0xFFFF,"; /* special value; indicates no mapping */ } - echo "\n};\n\n"; + echo "\n} };\n\n"; $prevStage2[] = $mstable[$i]; } @@ -235,11 +235,11 @@ "/* {{{ Stage 1 table for {$e['name']} */\n"; echo -"static const enc_to_uni enc_to_uni_{$e['ident']} = { +"static const enc_to_uni enc_to_uni_{$e['ident']} = { { \t&enc_to_uni_s2_{$s2tables_idents[0]}_00, \t&enc_to_uni_s2_{$s2tables_idents[1]}_40, \t&enc_to_uni_s2_{$s2tables_idents[2]}_80, -\t&enc_to_uni_s2_{$s2tables_idents[3]}_C0, +\t&enc_to_uni_s2_{$s2tables_idents[3]}_C0 } }; "; @@ -471,17 +471,17 @@ if (key_exists("default", $v)) { if ($v['default'] == 'GT') /* hack to make > translate to > not GT; */ $v['default'] = "gt"; - echo "\t{", sprintf("%02d", count($v) - 1), + echo "\t{ {", sprintf("%02d", count($v) - 1), ",\t\t", sprintf("\"%-21s", $v["default"].'",'), "\t", - sprintf("% 2d", strlen($v["default"])), '},', "\n"; + sprintf("% 2d", strlen($v["default"])), '} },', "\n"; } else { - echo "\t{", sprintf("%02d", count($v)), - ",\t\t", sprintf("%-22s", 'NULL'), ",\t0},\n"; + echo "\t{ {", sprintf("%02d", count($v)), + ",\t\t", sprintf("%-22s", 'NULL'), ",\t0} },\n"; } unset($v["default"]); foreach ($v as $l => $w) { - echo "\t{", sprintf("0x%05s", $l), ",\t", sprintf("\"%-21s", $w.'",'), "\t", - sprintf("% 2d", strlen($w)), '},', "\n"; + echo "\t{ {", sprintf("0x%05s", $l), ",\t", sprintf("\"%-21s", $w.'",'), "\t", + sprintf("% 2d", strlen($w)), '} },', "\n"; } echo "};\n"; } @@ -495,22 +495,22 @@ $t = <<<CODE static const entity_stage3_row empty_stage3_table[] = { /* 64 elements */ - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, - {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, {0, NULL, 0}, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, + {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, {0, { {NULL, 0} } }, }; CODE; @@ -550,14 +550,14 @@ elseif ($y % 4 == 0) echo "\n\t"; else echo " "; if ($z === NULL) - echo "{0, NULL, 0},"; + echo "{0, { {NULL, 0} } },"; elseif ($z === "QUOT") /* hack to translate " into "e;, not " */ - echo "{0, \"quot\", 4},"; + echo "{0, { {\"quot\", 4} } },"; elseif ($z !== "") - echo "{0, \"$z\", ", strlen($z), "},"; + echo "{0, { {\"$z\", ", strlen($z), "} } },"; else - echo "{1, (void*)", sprintf("multi_cp_{$ident}_%05X", - ($i << 12) | ($k << 6) | $y ), "},"; + echo "{1, { {(void *)", sprintf("multi_cp_{$ident}_%05X", + ($i << 12) | ($k << 6) | $y ), "} } },"; } echo "\n};\n\n"; @@ -712,7 +712,7 @@ const entity_ht_bucket *buckets; /* .num_elems elements */ } entity_ht; -static const entity_cp_map ht_bucket_empty[] = { NULL }; +static const entity_cp_map ht_bucket_empty[] = { {NULL, 0, 0, 0} }; CODE; @@ -726,9 +726,9 @@ $nKeyLength = strlen($str); $pos = 0; - /* variant with the hash unrolled eight times */ for (; $nKeyLength > 0; $nKeyLength--) { - $hash = (int)(((int)(((int)($hash << 5)) + $hash)) + ord($str[$pos++])); + $hash = (int)(((int)(((int)($hash << 5)) + $hash)) + ord($str[$pos++])) + & 0xFFFFFFFF; } return $hash; @@ -762,7 +762,7 @@ $h[0], strlen($h[0]), hexdec($h[1])); } } - echo " {NULL} };\n"; + echo " {NULL, 0, 0, 0} };\n"; } echo "\n";
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php