]> git.kaiwu.me - quickjs.git/commitdiff
removed some warnings - fixed win32 compilation
authorFabrice Bellard <fabrice@bellard.org>
Sat, 10 Oct 2026 16:47:01 +0000 (18:47 +0200)
committerFabrice Bellard <fabrice@bellard.org>
Sat, 10 Oct 2026 16:47:01 +0000 (18:47 +0200)
intl/collator.c
intl/datetimeformat.c
intl/intl.c
intl/numberformat.c
temporal/temporal.c

index 818ab8a81b51b1d13781d334328818b7e64c7fb0..bf1a9fc3051a13618a4468e3b8b783642cc8f735 100644 (file)
@@ -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))))
index 6006f0e9be9e146918ad17064bd76d047010a992..fc3e8876233efe6f7e7efd280fa2241b7dbbb27b 100644 (file)
@@ -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))))
index 8682142438095f217ac4aac6bd1ea971ee109691..2ce1e14e3a6973414101c77c1c2c1431ef2aeca3 100644 (file)
@@ -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;
index 4512e9bc3c57532411230bc5f6137f10554e6b3c..f1ace1a68fffeb74c2606a472aca56a177b4ab5d 100644 (file)
@@ -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))))
index f0666143edcec0a32722a14c046b566aa3bae3e8..ac84b9cb011a89daa148536c504197ae8ba6546c 100644 (file)
@@ -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);