]> granicus.if.org Git - php/commitdiff
update the html table generator
authorAnatol Belski <ab@php.net>
Sat, 13 Sep 2014 22:42:48 +0000 (00:42 +0200)
committerAnatol Belski <ab@php.net>
Sat, 13 Sep 2014 22:42:48 +0000 (00:42 +0200)
ext/standard/html_tables/html_table_gen.php

index 2aae24475ad9ed1bb974e6df8cfd1aa75193492a..a14cf5064d6d30dff7cd45af67cfe433e78a9b56 100644 (file)
@@ -371,18 +371,17 @@ $t = <<<'CODE'
 #define ENT_STAGE3_INDEX(k) ((k) & 0x3F)
 #define ENT_CODE_POINT_FROM_STAGES(i,j,k) (((i) << 12) | ((j) << 6) | (k))
 
-/* Table should be organized with a leading row telling the size of
- * the table and the default entity (maybe NULL) and the rest being
- * normal rows ordered by code point so that we can do a binary search */
+/* The default entity may be NULL. Binary search is still possible while
+   is senseless as there are just two rows (see also find_entity_for_char()). */
 typedef union {
        struct {
-               unsigned size; /* number of remaining entries in the table */
                const char *default_entity;
+               unsigned size; /* number of remaining entries in the table */
                unsigned short default_entity_len;
        } leading_entry;
        struct {
-               unsigned second_cp; /* second code point */
                const char *entity;
+               unsigned second_cp; /* second code point */
                unsigned short entity_len;
        } normal_entry;
 } entity_multicodepoint_row;
@@ -475,16 +474,16 @@ foreach ($multicp_rows as $k => $v) {
        if (key_exists("default", $v)) {
         if ($v['default'] == 'GT') /* hack to make > translate to &gt; not GT; */
             $v['default'] = "gt";
-               echo "\t{ {", sprintf("%02d", count($v) - 1),
-                       ",\t\t", sprintf("\"%-21s", $v["default"].'",'), "\t",
+               echo "\t{ {", sprintf("\"%-21s", $v["default"].'",'),
+                       "\t", sprintf("%02d", (count($v) - 1)), ",\t\t",
             sprintf("% 2d", strlen($v["default"])), '} },', "\n"; 
        } else {
-               echo "\t{ {", sprintf("%02d", count($v)),
-                       ",\t\t", sprintf("%-22s", 'NULL'), ",\t0} },\n"; 
+               echo "\t{ {", sprintf("%-22s", 'NULL,'),
+                       "\t", sprintf("%02d", count($v)), ",\t\t0} },\n";
        }
        unset($v["default"]);
        foreach ($v as $l => $w) {
-               echo "\t{ {", sprintf("0x%05s", $l), ",\t", sprintf("\"%-21s", $w.'",'), "\t",
+               echo "\t{ {", sprintf("\"%-21s", $w.'",'), "\t", sprintf("0x%05s", $l), ",\t",
             sprintf("% 2d", strlen($w)), '} },', "\n"; 
        }
        echo "};\n";