From a721bda7b593ed71a9e0b1da6922c78766b6ed68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Mon, 20 Nov 2023 10:25:54 +0100 Subject: [PATCH] Drop CONFIG_ALL_UNICODE and enable it by default --- libregexp.c | 4 ---- libregexp.h | 8 -------- libunicode-table.h | 4 ---- libunicode.c | 4 ---- libunicode.h | 7 ------- quickjs.c | 18 +----------------- quickjs.h | 1 - unicode_gen.c | 2 -- 8 files changed, 1 insertion(+), 47 deletions(-) diff --git a/libregexp.c b/libregexp.c index d2fb427..20b8139 100644 --- a/libregexp.c +++ b/libregexp.c @@ -600,7 +600,6 @@ int lre_parse_escape(const uint8_t **pp, int allow_utf16) return c; } -#ifdef CONFIG_ALL_UNICODE /* XXX: we use the same chars for name and value */ static BOOL is_unicode_char(int c) { @@ -703,7 +702,6 @@ static int parse_unicode_property(REParseState *s, CharRange *cr, out_of_memory: return re_parse_out_of_memory(s); } -#endif /* CONFIG_ALL_UNICODE */ /* return -1 if error otherwise the character or a class range (CLASS_RANGE_BASE). In case of class range, 'cr' is @@ -763,7 +761,6 @@ static int get_class_atom(REParseState *s, CharRange *cr, c = '\\'; } break; -#ifdef CONFIG_ALL_UNICODE case 'p': case 'P': if (s->is_utf16) { @@ -773,7 +770,6 @@ static int get_class_atom(REParseState *s, CharRange *cr, break; } /* fall thru */ -#endif default: p--; ret = lre_parse_escape(&p, s->is_utf16 * 2); diff --git a/libregexp.h b/libregexp.h index 7c03b1a..97eac5c 100644 --- a/libregexp.h +++ b/libregexp.h @@ -66,11 +66,7 @@ static inline int lre_js_is_ident_first(int c) if ((uint32_t)c < 128) { return (lre_id_start_table_ascii[c >> 5] >> (c & 31)) & 1; } else { -#ifdef CONFIG_ALL_UNICODE return lre_is_id_start(c); -#else - return !lre_is_space(c); -#endif } } @@ -80,11 +76,7 @@ static inline int lre_js_is_ident_next(int c) return (lre_id_continue_table_ascii[c >> 5] >> (c & 31)) & 1; } else { /* ZWNJ and ZWJ are accepted in identifiers */ -#ifdef CONFIG_ALL_UNICODE return lre_is_id_continue(c) || c == 0x200C || c == 0x200D; -#else - return !lre_is_space(c) || c == 0x200C || c == 0x200D; -#endif } } diff --git a/libunicode-table.h b/libunicode-table.h index b64178b..a7b1e9d 100644 --- a/libunicode-table.h +++ b/libunicode-table.h @@ -557,8 +557,6 @@ static const uint8_t unicode_prop_ID_Continue1_index[63] = { 0x41, 0xaf, 0xe2, 0x21, 0xf0, 0x01, 0x0e, }; -#ifdef CONFIG_ALL_UNICODE - static const uint8_t unicode_cc_table[899] = { 0xb2, 0xcf, 0xd4, 0x00, 0xe8, 0x03, 0xdc, 0x00, 0xe8, 0x00, 0xd8, 0x04, 0xdc, 0x01, 0xca, 0x03, @@ -4484,5 +4482,3 @@ static const uint16_t unicode_prop_len_table[] = { countof(unicode_prop_ID_Start_table), countof(unicode_prop_Case_Ignorable_table), }; - -#endif /* CONFIG_ALL_UNICODE */ diff --git a/libunicode.c b/libunicode.c index 0361089..825a12b 100644 --- a/libunicode.c +++ b/libunicode.c @@ -426,8 +426,6 @@ int cr_invert(CharRange *cr) return 0; } -#ifdef CONFIG_ALL_UNICODE - BOOL lre_is_id_start(uint32_t c) { return lre_is_in_table(c, unicode_prop_ID_Start_table, @@ -1504,5 +1502,3 @@ int unicode_prop(CharRange *cr, const char *prop_name) } return ret; } - -#endif /* CONFIG_ALL_UNICODE */ diff --git a/libunicode.h b/libunicode.h index 0acc209..d815b4b 100644 --- a/libunicode.h +++ b/libunicode.h @@ -28,9 +28,6 @@ #define LRE_BOOL int /* for documentation purposes */ -/* define it to include all the unicode tables (40KB larger) */ -#define CONFIG_ALL_UNICODE - #define LRE_CC_RES_LEN_MAX 3 typedef enum { @@ -101,8 +98,6 @@ int cr_op(CharRange *cr, const uint32_t *a_pt, int a_len, int cr_invert(CharRange *cr); -#ifdef CONFIG_ALL_UNICODE - LRE_BOOL lre_is_id_start(uint32_t c); LRE_BOOL lre_is_id_continue(uint32_t c); @@ -117,8 +112,6 @@ int unicode_script(CharRange *cr, int unicode_general_category(CharRange *cr, const char *gc_name); int unicode_prop(CharRange *cr, const char *prop_name); -#endif /* CONFIG_ALL_UNICODE */ - #undef LRE_BOOL #endif /* LIBUNICODE_H */ diff --git a/quickjs.c b/quickjs.c index a1af736..52d4375 100644 --- a/quickjs.c +++ b/quickjs.c @@ -1978,7 +1978,6 @@ JSContext *JS_NewContext(JSRuntime *rt) JS_AddIntrinsicBaseObjects(ctx); JS_AddIntrinsicDate(ctx); JS_AddIntrinsicEval(ctx); - JS_AddIntrinsicStringNormalize(ctx); JS_AddIntrinsicRegExp(ctx); JS_AddIntrinsicJSON(ctx); JS_AddIntrinsicProxy(ctx); @@ -39197,8 +39196,6 @@ static JSValue js_string_toLowerCase(JSContext *ctx, JSValueConst this_val, return JS_EXCEPTION; } -#ifdef CONFIG_ALL_UNICODE - /* return (-1, NULL) if exception, otherwise (len, buf) */ static int JS_ToUTF32String(JSContext *ctx, uint32_t **pbuf, JSValueConst val1) { @@ -39301,7 +39298,6 @@ static JSValue js_string_normalize(JSContext *ctx, JSValueConst this_val, js_free(ctx, out_buf); return val; } -#endif /* CONFIG_ALL_UNICODE */ /* also used for String.prototype.valueOf */ static JSValue js_string_toString(JSContext *ctx, JSValueConst this_val, @@ -39460,6 +39456,7 @@ static const JSCFunctionListEntry js_string_proto_funcs[] = { JS_CFUNC_DEF("valueOf", 0, js_string_toString ), JS_CFUNC_DEF("__quote", 1, js_string___quote ), JS_CFUNC_DEF("localeCompare", 1, js_string_localeCompare ), + JS_CFUNC_DEF("normalize", 0, js_string_normalize ), JS_CFUNC_MAGIC_DEF("toLowerCase", 0, js_string_toLowerCase, 1 ), JS_CFUNC_MAGIC_DEF("toUpperCase", 0, js_string_toLowerCase, 0 ), JS_CFUNC_MAGIC_DEF("toLocaleLowerCase", 0, js_string_toLowerCase, 1 ), @@ -39486,19 +39483,6 @@ static const JSCFunctionListEntry js_string_iterator_proto_funcs[] = { JS_PROP_STRING_DEF("[Symbol.toStringTag]", "String Iterator", JS_PROP_CONFIGURABLE ), }; -#ifdef CONFIG_ALL_UNICODE -static const JSCFunctionListEntry js_string_proto_normalize[] = { - JS_CFUNC_DEF("normalize", 0, js_string_normalize ), -}; -#endif - -void JS_AddIntrinsicStringNormalize(JSContext *ctx) -{ -#ifdef CONFIG_ALL_UNICODE - JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_STRING], js_string_proto_normalize, - countof(js_string_proto_normalize)); -#endif -} /* Math */ diff --git a/quickjs.h b/quickjs.h index 488295e..aad0f18 100644 --- a/quickjs.h +++ b/quickjs.h @@ -356,7 +356,6 @@ JSContext *JS_NewContextRaw(JSRuntime *rt); void JS_AddIntrinsicBaseObjects(JSContext *ctx); void JS_AddIntrinsicDate(JSContext *ctx); void JS_AddIntrinsicEval(JSContext *ctx); -void JS_AddIntrinsicStringNormalize(JSContext *ctx); void JS_AddIntrinsicRegExpCompiler(JSContext *ctx); void JS_AddIntrinsicRegExp(JSContext *ctx); void JS_AddIntrinsicJSON(JSContext *ctx); diff --git a/unicode_gen.c b/unicode_gen.c index 1ae0d96..6814977 100644 --- a/unicode_gen.c +++ b/unicode_gen.c @@ -2987,14 +2987,12 @@ int main(int argc, char **argv) dump_case_conv_table(fo); compute_internal_props(); build_flags_tables(fo); - fprintf(fo, "#ifdef CONFIG_ALL_UNICODE\n\n"); build_cc_table(fo); build_decompose_table(fo); build_general_category_table(fo); build_script_table(fo); build_script_ext_table(fo); build_prop_list_table(fo); - fprintf(fo, "#endif /* CONFIG_ALL_UNICODE */\n"); fclose(fo); } return 0;