From 4ce8b611808485a0bd1a18878fdb9cf926ed7e9f Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Fri, 14 Apr 2017 20:12:02 +0100 Subject: [PATCH] Extend ucd_property to 64-bits to allow all properties to be specified. --- src/include/ucd/ucd.h | 50 ++++++++++++++++++++------------------ tests/printcdata.c | 2 +- tests/printucddata.c | 2 +- tests/printucddata_cpp.cpp | 2 +- tools/printdata.py | 2 +- 5 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/include/ucd/ucd.h b/src/include/ucd/ucd.h index 883ae809..4fb26ee7 100644 --- a/src/include/ucd/ucd.h +++ b/src/include/ucd/ucd.h @@ -327,30 +327,31 @@ ucd_script ucd_lookup_script(codepoint_t c); /** @brief Properties */ -typedef enum ucd_property_ +typedef uint64_t ucd_property; +enum { - UCD_PROPERTY_WHITE_SPACE = 0x00000001, /**< @brief White_Space */ - UCD_PROPERTY_BIDI_CONTROL = 0x00000002, /**< @brief Bidi_Control */ - UCD_PROPERTY_JOIN_CONTROL = 0x00000004, /**< @brief Join_Control */ - UCD_PROPERTY_DASH = 0x00000008, /**< @brief Dash */ - UCD_PROPERTY_HYPHEN = 0x00000010, /**< @brief Hyphen */ - UCD_PROPERTY_QUOTATION_MARK = 0x00000020, /**< @brief Quotation_Mark */ - UCD_PROPERTY_TERMINAL_PUNCTUATION = 0x00000040, /**< @brief Terminal_Punctuation */ - UCD_PROPERTY_OTHER_MATH = 0x00000080, /**< @brief Other_Math */ - UCD_PROPERTY_HEX_DIGIT = 0x00000100, /**< @brief Hex_Digit */ - UCD_PROPERTY_ASCII_HEX_DIGIT = 0x00000200, /**< @brief ASCII_Hex_Digit */ - UCD_PROPERTY_OTHER_ALPHABETIC = 0x00000400, /**< @brief Other_Alphabetic */ - UCD_PROPERTY_IDEOGRAPHIC = 0x00000800, /**< @brief Ideographic */ - UCD_PROPERTY_DIACRITIC = 0x00001000, /**< @brief Diacritic */ - UCD_PROPERTY_EXTENDER = 0x00002000, /**< @brief Extender */ - UCD_PROPERTY_OTHER_LOWERCASE = 0x00004000, /**< @brief Other_Lowercase */ - UCD_PROPERTY_OTHER_UPPERCASE = 0x00008000, /**< @brief Other_Uppercase */ - UCD_PROPERTY_NONCHARACTER_CODE_POINT = 0x00010000, /**< @brief Noncharacter_Code_Point */ - UCD_PROPERTY_OTHER_GRAPHEME_EXTEND = 0x00020000, /**< @brief Other_Grapheme_Extend */ - UCD_PROPERTY_IDS_BINARY_OPERATOR = 0x00040000, /**< @brief IDS_Binary_Operator */ - UCD_PROPERTY_IDS_TRINARY_OPERATOR = 0x00080000, /**< @brief IDS_Trinary_Operator */ - UCD_PROPERTY_RADICAL = 0x00100000, /**< @brief Radical */ -} ucd_property; + UCD_PROPERTY_WHITE_SPACE = 0x0000000000000001ull, /**< @brief White_Space */ + UCD_PROPERTY_BIDI_CONTROL = 0x0000000000000002ull, /**< @brief Bidi_Control */ + UCD_PROPERTY_JOIN_CONTROL = 0x0000000000000004ull, /**< @brief Join_Control */ + UCD_PROPERTY_DASH = 0x0000000000000008ull, /**< @brief Dash */ + UCD_PROPERTY_HYPHEN = 0x0000000000000010ull, /**< @brief Hyphen */ + UCD_PROPERTY_QUOTATION_MARK = 0x0000000000000020ull, /**< @brief Quotation_Mark */ + UCD_PROPERTY_TERMINAL_PUNCTUATION = 0x0000000000000040ull, /**< @brief Terminal_Punctuation */ + UCD_PROPERTY_OTHER_MATH = 0x0000000000000080ull, /**< @brief Other_Math */ + UCD_PROPERTY_HEX_DIGIT = 0x0000000000000100ull, /**< @brief Hex_Digit */ + UCD_PROPERTY_ASCII_HEX_DIGIT = 0x0000000000000200ull, /**< @brief ASCII_Hex_Digit */ + UCD_PROPERTY_OTHER_ALPHABETIC = 0x0000000000000400ull, /**< @brief Other_Alphabetic */ + UCD_PROPERTY_IDEOGRAPHIC = 0x0000000000000800ull, /**< @brief Ideographic */ + UCD_PROPERTY_DIACRITIC = 0x0000000000001000ull, /**< @brief Diacritic */ + UCD_PROPERTY_EXTENDER = 0x0000000000002000ull, /**< @brief Extender */ + UCD_PROPERTY_OTHER_LOWERCASE = 0x0000000000004000ull, /**< @brief Other_Lowercase */ + UCD_PROPERTY_OTHER_UPPERCASE = 0x0000000000008000ull, /**< @brief Other_Uppercase */ + UCD_PROPERTY_NONCHARACTER_CODE_POINT = 0x0000000000010000ull, /**< @brief Noncharacter_Code_Point */ + UCD_PROPERTY_OTHER_GRAPHEME_EXTEND = 0x0000000000020000ull, /**< @brief Other_Grapheme_Extend */ + UCD_PROPERTY_IDS_BINARY_OPERATOR = 0x0000000000040000ull, /**< @brief IDS_Binary_Operator */ + UCD_PROPERTY_IDS_TRINARY_OPERATOR = 0x0000000000080000ull, /**< @brief IDS_Trinary_Operator */ + UCD_PROPERTY_RADICAL = 0x0000000000100000ull, /**< @brief Radical */ +}; /** @brief Return the properties of the specified codepoint. * @@ -807,7 +808,8 @@ namespace ucd /** @brief Properties */ - enum property + typedef ucd_property property; + enum { White_Space = UCD_PROPERTY_WHITE_SPACE, /**< @brief White_Space */ Bidi_Control = UCD_PROPERTY_BIDI_CONTROL, /**< @brief Bidi_Control */ diff --git a/tests/printcdata.c b/tests/printcdata.c index 49e29a42..d3e9190c 100644 --- a/tests/printcdata.c +++ b/tests/printcdata.c @@ -164,7 +164,7 @@ void uprintf(FILE *out, codepoint_t c, const char *format) uprintf_codepoint(out, c, *++format); break; case 'P': // properties - fprintf(out, "%08x", ucd_properties(c, ucd_lookup_category(c))); + fprintf(out, "%016x", ucd_properties(c, ucd_lookup_category(c))); break; case 'i': // is* uprintf_is(out, c, *++format); diff --git a/tests/printucddata.c b/tests/printucddata.c index 2fb87ed8..c023141f 100644 --- a/tests/printucddata.c +++ b/tests/printucddata.c @@ -161,7 +161,7 @@ void uprintf(FILE *out, codepoint_t c, const char *format) uprintf_codepoint(out, c, *++format); break; case 'P': // properties - fprintf(out, "%08x", ucd_properties(c, ucd_lookup_category(c))); + fprintf(out, "%016x", ucd_properties(c, ucd_lookup_category(c))); break; case 'i': // is* uprintf_is(out, c, *++format); diff --git a/tests/printucddata_cpp.cpp b/tests/printucddata_cpp.cpp index 59128c22..c5e89479 100644 --- a/tests/printucddata_cpp.cpp +++ b/tests/printucddata_cpp.cpp @@ -161,7 +161,7 @@ void uprintf(FILE *out, ucd::codepoint_t c, const char *format) uprintf_codepoint(out, c, *++format); break; case 'P': // properties - fprintf(out, "%08x", ucd::properties(c, ucd::lookup_category(c))); + fprintf(out, "%016x", ucd::properties(c, ucd::lookup_category(c))); break; case 'i': // is* uprintf_is(out, c, *++format); diff --git a/tools/printdata.py b/tools/printdata.py index 903c1020..2c2c9ad0 100755 --- a/tools/printdata.py +++ b/tools/printdata.py @@ -157,7 +157,7 @@ if __name__ == '__main__': if title == null: title = codepoint if upper == null: upper = codepoint if lower == null: lower = codepoint - print('%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %08x' % ( + print('%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %016x' % ( codepoint, script, data.get('GeneralCategory', 'Cn')[0], data.get('GeneralCategory', 'Cn'), upper, lower, title,