#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;
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),
- ",\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";