From: Fabrice Bellard Date: Sat, 10 Oct 2026 16:47:01 +0000 (+0200) Subject: removed some warnings - fixed win32 compilation X-Git-Url: https://git.kaiwu.me/$%7BISSUES%7D/static/gitweb.js?a=commitdiff_plain;h=9d01a96849dbbe653da65f231cd40bddc7457ae2;p=quickjs.git removed some warnings - fixed win32 compilation --- diff --git a/intl/collator.c b/intl/collator.c index 818ab8a..bf1a9fc 100644 --- a/intl/collator.c +++ b/intl/collator.c @@ -802,10 +802,12 @@ int js_add_collator(JSContext *ctx, JSValue intl_obj) JS_NewClassID(&js_collator_class_id); JS_NewClass(JS_GetRuntime(ctx), js_collator_class_id, &js_collator_class); + JSCFunctionType ft = { .constructor_or_func_flags = js_collator_constructor }; + if (JS_IsException(js_intl_new_constructor(ctx, intl_obj, JS_INTL_CTOR_COLLATOR, js_collator_class_id, "Collator", - (JSCFunction *)js_collator_constructor, 0, + ft.generic, 0, JS_CFUNC_constructor_or_func_flags, 0, js_collator_static_funcs, countof(js_collator_static_funcs), js_collator_proto_funcs, countof(js_collator_proto_funcs)))) diff --git a/intl/datetimeformat.c b/intl/datetimeformat.c index 6006f0e..fc3e887 100644 --- a/intl/datetimeformat.c +++ b/intl/datetimeformat.c @@ -2969,7 +2969,7 @@ static JSValue js_datetimeformat_bound_format(JSContext *ctx, JSValueConst this_ JS_GetOpaque(argv[0], js_plainyearmonth_class_id) || JS_GetOpaque(argv[0], js_plainmonthday_class_id) || JS_GetOpaque(argv[0], js_plaindatetime_class_id)) { - s_copy.timeZone = "+00:00"; + s_copy.timeZone = (char *)"+00:00"; s_copy.timeZoneName = DTF_TIMEZONE_UNSET; } dtf_resolve_style_for_temporal(&s_copy, argv[0]); @@ -3032,7 +3032,7 @@ static JSValue js_datetimeformat_formatToParts(JSContext *ctx, JSValueConst this JS_GetOpaque(argv[0], js_plainyearmonth_class_id) || JS_GetOpaque(argv[0], js_plainmonthday_class_id) || JS_GetOpaque(argv[0], js_plaindatetime_class_id)) { - s_copy.timeZone = "+00:00"; + s_copy.timeZone = (char *)"+00:00"; s_copy.timeZoneName = DTF_TIMEZONE_UNSET; } dtf_resolve_style_for_temporal(&s_copy, argv[0]); @@ -3155,7 +3155,7 @@ static JSValue js_datetimeformat_formatRange(JSContext *ctx, JSValueConst this_v JS_GetOpaque(argv[0], js_plainmonthday_class_id) || JS_GetOpaque(argv[0], js_plaindatetime_class_id)) { s_copy = *s; - s_copy.timeZone = "+00:00"; + s_copy.timeZone = (char *)"+00:00"; s_copy.timeZoneName = DTF_TIMEZONE_UNSET; s_use = &s_copy; } @@ -3394,7 +3394,7 @@ static JSValue js_datetimeformat_formatRangeToParts(JSContext *ctx, JSValueConst JSDateTimeFormatData *s = JS_GetOpaque2(ctx, unwrapped, js_datetimeformat_class_id); JSDateTimeFormatData *s_use = s; JSDateTimeFormatData s_copy; - JSValue start_arr, end_arr, ret; + JSValue start_arr, end_arr, ret = JS_UNDEFINED; double x, y; int i, start_len, end_len; uint32_t idx; @@ -3441,7 +3441,7 @@ static JSValue js_datetimeformat_formatRangeToParts(JSContext *ctx, JSValueConst JS_GetOpaque(argv[0], js_plainmonthday_class_id) || JS_GetOpaque(argv[0], js_plaindatetime_class_id)) { s_copy = *s; - s_copy.timeZone = "+00:00"; + s_copy.timeZone = (char *)"+00:00"; s_copy.timeZoneName = DTF_TIMEZONE_UNSET; s_use = &s_copy; } @@ -3552,17 +3552,17 @@ static JSValue js_datetimeformat_formatRangeToParts(JSContext *ctx, JSValueConst { JSValue len_val = JS_GetPropertyStr(ctx, start_arr, "length"); - if (!JS_IsException(len_val)) { - JS_ToInt32(ctx, &start_len, len_val); - JS_FreeValue(ctx, len_val); - } + if (JS_IsException(len_val)) + goto fail; + JS_ToInt32(ctx, &start_len, len_val); + JS_FreeValue(ctx, len_val); } { JSValue len_val = JS_GetPropertyStr(ctx, end_arr, "length"); - if (!JS_IsException(len_val)) { - JS_ToInt32(ctx, &end_len, len_val); - JS_FreeValue(ctx, len_val); - } + if (JS_IsException(len_val)) + goto fail; + JS_ToInt32(ctx, &end_len, len_val); + JS_FreeValue(ctx, len_val); } for (j = 0; j < start_len && j < end_len; j++) { @@ -3904,10 +3904,12 @@ int js_add_datetimeformat(JSContext *ctx, JSValue intl_obj) JS_NewClassID(&js_datetimeformat_class_id); JS_NewClass(JS_GetRuntime(ctx), js_datetimeformat_class_id, &js_datetimeformat_class); + JSCFunctionType ft = { .constructor_or_func_flags = js_datetimeformat_constructor }; + if (JS_IsException(js_intl_new_constructor(ctx, intl_obj, JS_INTL_CTOR_DATETIMEFORMAT, js_datetimeformat_class_id, "DateTimeFormat", - (JSCFunction *)js_datetimeformat_constructor, 0, + ft.generic, 0, JS_CFUNC_constructor_or_func_flags, 0, js_datetimeformat_static_funcs, countof(js_datetimeformat_static_funcs), js_datetimeformat_proto_funcs, countof(js_datetimeformat_proto_funcs)))) diff --git a/intl/intl.c b/intl/intl.c index 8682142..2ce1e14 100644 --- a/intl/intl.c +++ b/intl/intl.c @@ -801,11 +801,11 @@ char *canonicalize_locale(JSContext *ctx, const char *locale) break; } } - subtags[0] = "sr"; + subtags[0] = (char *)"sr"; if (!found_script) { if (n > 1) memmove(&subtags[2], &subtags[1], (size_t)(n - 1) * sizeof(char *)); - subtags[1] = "Latn"; + subtags[1] = (char *)"Latn"; n++; } } else if (!strcasecmp(subtags[0], "cnr")) { @@ -820,11 +820,11 @@ char *canonicalize_locale(JSContext *ctx, const char *locale) break; } } - subtags[0] = "sr"; + subtags[0] = (char *)"sr"; if (!found_region) { if (insert_pos < n) memmove(&subtags[insert_pos + 1], &subtags[insert_pos], (size_t)(n - insert_pos) * sizeof(char *)); - subtags[insert_pos] = "ME"; + subtags[insert_pos] = (char *)"ME"; n++; } } else if (n == 2 && !strcasecmp(subtags[0], "hy") && !strcasecmp(subtags[1], "arevela")) { @@ -994,7 +994,7 @@ char *canonicalize_locale(JSContext *ctx, const char *locale) if (has_alalc97 && has_hepburn) { for (i = 0; i < base_end; i++) { if (!strcmp(subtags[i], "hepburn")) { - subtags[i] = ""; + subtags[i] = (char *)""; } } } @@ -1038,18 +1038,18 @@ char *canonicalize_locale(JSContext *ctx, const char *locale) } if (gf_variant >= 0) { if (!strcasecmp(subtags[0], "art")) { - subtags[0] = "jbo"; + subtags[0] = (char *)"jbo"; } else if (!strcasecmp(subtags[0], "cel")) { - subtags[0] = "xtg"; + subtags[0] = (char *)"xtg"; } else if (!strcasecmp(subtags[0], "zh")) { if (!strcasecmp(subtags[gf_variant], "guoyu")) - subtags[0] = "zh"; + subtags[0] = (char *)"zh"; else if (!strcasecmp(subtags[gf_variant], "hakka")) - subtags[0] = "hak"; + subtags[0] = (char *)"hak"; else if (!strcasecmp(subtags[gf_variant], "xiang")) - subtags[0] = "hsn"; + subtags[0] = (char *)"hsn"; } - subtags[gf_variant] = ""; + subtags[gf_variant] = (char *)""; /* compact empty slots */ { int j, k = 0; @@ -1121,7 +1121,7 @@ char *canonicalize_locale(JSContext *ctx, const char *locale) if (var_start < tlang_end && tlang_end - var_start > 1) qsort(&subtags[t_start + var_start], (size_t)(tlang_end - var_start), sizeof(char *), cmp_str); if (!strcmp(subtags[t_start], "iw")) - subtags[t_start] = "he"; + subtags[t_start] = (char *)"he"; } { typedef struct { const char *key; int nvalues; const char *values[4]; } TFieldEntry; diff --git a/intl/numberformat.c b/intl/numberformat.c index 4512e9b..f1ace1a 100644 --- a/intl/numberformat.c +++ b/intl/numberformat.c @@ -3722,10 +3722,12 @@ int js_add_numberformat(JSContext *ctx, JSValue intl_obj) JS_NewClassID(&js_numberformat_class_id); JS_NewClass(JS_GetRuntime(ctx), js_numberformat_class_id, &js_numberformat_class); + JSCFunctionType ft = { .constructor_or_func_flags = js_numberformat_constructor }; + if (JS_IsException(js_intl_new_constructor(ctx, intl_obj, JS_INTL_CTOR_NUMBERFORMAT, js_numberformat_class_id, "NumberFormat", - (JSCFunction *)js_numberformat_constructor, 0, + ft.generic, 0, JS_CFUNC_constructor_or_func_flags, 0, js_numberformat_static_funcs, countof(js_numberformat_static_funcs), js_numberformat_proto_funcs, countof(js_numberformat_proto_funcs)))) diff --git a/temporal/temporal.c b/temporal/temporal.c index f066614..ac84b9c 100644 --- a/temporal/temporal.c +++ b/temporal/temporal.c @@ -260,6 +260,7 @@ void ti_get_default_timezone(char *buf, size_t buf_size) pstrcpy(buf, buf_size, tz); return; } +#if !defined(_WIN32) { char linkbuf[512]; ssize_t len = readlink("/etc/localtime", linkbuf, sizeof(linkbuf) - 1); @@ -290,6 +291,7 @@ void ti_get_default_timezone(char *buf, size_t buf_size) fclose(f); } } +#endif /* fallback: compute offset from localtime */ { time_t t = time(NULL);