From: Fabrice Bellard Date: Sat, 10 Oct 2026 14:13:11 +0000 (+0200) Subject: libunicode: added lre_is_soft_dotted() and exported unicode_get_cc() X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=7693ca910722f45049a99a9f7a9db392a7e5f80b;p=quickjs.git libunicode: added lre_is_soft_dotted() and exported unicode_get_cc() --- diff --git a/libunicode-table.h b/libunicode-table.h index 85956ed..bda11f5 100644 --- a/libunicode-table.h +++ b/libunicode-table.h @@ -632,6 +632,25 @@ static const uint8_t unicode_prop_ID_Continue1_index[66] = { 0xf0, 0x01, 0x0e, // E01F0 at 704 (upper bound) }; +static const uint8_t unicode_prop_Soft_Dotted_table[79] = { + 0xe8, 0x81, 0x40, 0xc3, 0x80, 0x41, 0x18, 0x80, + 0x9d, 0x80, 0xb3, 0x80, 0x93, 0x80, 0x41, 0x3f, + 0x80, 0xe1, 0x00, 0x80, 0x59, 0x08, 0x80, 0xb2, + 0x80, 0x8c, 0x02, 0x80, 0x40, 0x83, 0x80, 0x40, + 0x9c, 0x80, 0x41, 0xa4, 0x80, 0x40, 0xd5, 0x81, + 0x4b, 0x31, 0x80, 0x61, 0xa7, 0xa4, 0x81, 0xb1, + 0x81, 0xb1, 0x81, 0xb1, 0x81, 0xb1, 0x81, 0xb1, + 0x81, 0xb1, 0x81, 0xb1, 0x81, 0xb1, 0x81, 0xb1, + 0x81, 0xb1, 0x81, 0xb1, 0x81, 0xb1, 0x81, 0x48, + 0x85, 0x80, 0x41, 0x30, 0x81, 0x99, 0x80, +}; + +static const uint8_t unicode_prop_Soft_Dotted_index[9] = { + 0xcc, 0x1e, 0x40, // 01ECC at 34 + 0xf8, 0xd5, 0x21, // 1D5F8 at 65 + 0x69, 0xe0, 0x01, // 1E069 at 96 (upper bound) +}; + #ifdef CONFIG_ALL_UNICODE static const uint8_t unicode_cc_table[937] = { @@ -4391,19 +4410,6 @@ static const uint8_t unicode_prop_Sentence_Terminal_table[213] = { 0x05, 0x80, 0x5d, 0xe7, 0x80, }; -static const uint8_t unicode_prop_Soft_Dotted_table[79] = { - 0xe8, 0x81, 0x40, 0xc3, 0x80, 0x41, 0x18, 0x80, - 0x9d, 0x80, 0xb3, 0x80, 0x93, 0x80, 0x41, 0x3f, - 0x80, 0xe1, 0x00, 0x80, 0x59, 0x08, 0x80, 0xb2, - 0x80, 0x8c, 0x02, 0x80, 0x40, 0x83, 0x80, 0x40, - 0x9c, 0x80, 0x41, 0xa4, 0x80, 0x40, 0xd5, 0x81, - 0x4b, 0x31, 0x80, 0x61, 0xa7, 0xa4, 0x81, 0xb1, - 0x81, 0xb1, 0x81, 0xb1, 0x81, 0xb1, 0x81, 0xb1, - 0x81, 0xb1, 0x81, 0xb1, 0x81, 0xb1, 0x81, 0xb1, - 0x81, 0xb1, 0x81, 0xb1, 0x81, 0xb1, 0x81, 0x48, - 0x85, 0x80, 0x41, 0x30, 0x81, 0x99, 0x80, -}; - static const uint8_t unicode_prop_Terminal_Punctuation_table[264] = { 0xa0, 0x80, 0x89, 0x00, 0x80, 0x8a, 0x0a, 0x80, 0x43, 0x3d, 0x07, 0x80, 0x42, 0x00, 0x80, 0xb8, @@ -5203,4 +5209,4 @@ static const uint8_t unicode_rgi_emoji_zwj_sequence[2392] = { }; #endif /* CONFIG_ALL_UNICODE */ -/* 71 tables / 36659 bytes, 5 index / 357 bytes */ +/* 71 tables / 36659 bytes, 6 index / 366 bytes */ diff --git a/libunicode.c b/libunicode.c index 0b7b6d0..f3f75cc 100644 --- a/libunicode.c +++ b/libunicode.c @@ -376,6 +376,13 @@ BOOL lre_is_case_ignorable(uint32_t c) sizeof(unicode_prop_Case_Ignorable_index) / 3); } +BOOL lre_is_soft_dotted(uint32_t c) +{ + return lre_is_in_table(c, unicode_prop_Soft_Dotted_table, + unicode_prop_Soft_Dotted_index, + sizeof(unicode_prop_Soft_Dotted_index) / 3); +} + /* character range */ static __maybe_unused void cr_dump(CharRange *cr) @@ -1030,7 +1037,7 @@ static int unicode_compose_pair(uint32_t c0, uint32_t c1) } /* return the combining class of character c (between 0 and 255) */ -static int unicode_get_cc(uint32_t c) +int unicode_get_cc(uint32_t c) { uint32_t code, n, type, cc, c1, b; int pos; diff --git a/libunicode.h b/libunicode.h index c2fdeac..be2f3cc 100644 --- a/libunicode.h +++ b/libunicode.h @@ -134,6 +134,8 @@ extern uint8_t const lre_ctype_bits[256]; /* zero or non-zero return value */ int lre_is_cased(uint32_t c); int lre_is_case_ignorable(uint32_t c); +int lre_is_soft_dotted(uint32_t c); +int unicode_get_cc(uint32_t c); int lre_is_id_start(uint32_t c); int lre_is_id_continue(uint32_t c); diff --git a/unicode_gen.c b/unicode_gen.c index c793ba1..f33cd05 100644 --- a/unicode_gen.c +++ b/unicode_gen.c @@ -1957,6 +1957,7 @@ void build_flags_tables(FILE *f) build_prop_table(f, "Case_Ignorable", PROP_Case_Ignorable, TRUE); build_prop_table(f, "ID_Start", PROP_ID_Start, TRUE); build_prop_table(f, "ID_Continue1", PROP_ID_Continue1, TRUE); + build_prop_table(f, "Soft_Dotted", PROP_Soft_Dotted, TRUE); } void dump_name_table(FILE *f, const char *cname, const char **tab_name, int len, @@ -2211,7 +2212,8 @@ void build_prop_list_table(FILE *f) for(i = 0; i < PROP_TABLE_COUNT; i++) { if (i == PROP_ID_Start || i == PROP_Case_Ignorable || - i == PROP_ID_Continue1) { + i == PROP_ID_Continue1 || + i == PROP_Soft_Dotted) { /* already generated */ } else { build_prop_table(f, unicode_prop_name[i], i, FALSE);