@@ -3197,7 +3197,6 @@ JSValue JS_NewSymbol(JSContext *ctx, const char *description, bool is_global)
31973197
31983198#define ATOM_GET_STR_BUF_SIZE 64
31993199
3200- /* Should only be used for debug. */
32013200static const char *JS_AtomGetStrRT(JSRuntime *rt, char *buf, int buf_size,
32023201 JSAtom atom)
32033202{
@@ -3220,13 +3219,6 @@ static const char *JS_AtomGetStrRT(JSRuntime *rt, char *buf, int buf_size,
32203219 /* encode surrogates correctly */
32213220 utf8_encode_buf16(buf, buf_size, str->u.str16, str->len);
32223221 } else {
3223- /* special case ASCII strings */
3224- int i, c = 0;
3225- for(i = 0; i < str->len; i++) {
3226- c |= str->u.str8[i];
3227- }
3228- if (c < 0x80)
3229- return (const char *)str->u.str8;
32303222 utf8_encode_buf8(buf, buf_size, str->u.str8, str->len);
32313223 }
32323224 }
@@ -6856,8 +6848,9 @@ static JSValue JS_MakeError(JSContext *ctx, JSErrorEnum error_num,
68566848}
68576849
68586850/* fmt and arguments may be pure ASCII or UTF-8 encoded contents */
6859- static JSValue JS_ThrowError2(JSContext *ctx, JSErrorEnum error_num,
6860- const char *fmt, va_list ap, bool add_backtrace)
6851+ static JSValue JS_PRINTF_FORMAT_ATTR(4, 0)
6852+ JS_ThrowError2(JSContext *ctx, JSErrorEnum error_num,
6853+ bool add_backtrace, JS_PRINTF_FORMAT const char *fmt, va_list ap)
68616854{
68626855 char buf[256];
68636856 JSValue obj;
@@ -6871,8 +6864,9 @@ static JSValue JS_ThrowError2(JSContext *ctx, JSErrorEnum error_num,
68716864 return JS_Throw(ctx, obj);
68726865}
68736866
6874- static JSValue JS_ThrowError(JSContext *ctx, JSErrorEnum error_num,
6875- const char *fmt, va_list ap)
6867+ static JSValue JS_PRINTF_FORMAT_ATTR(3, 0)
6868+ JS_ThrowError(JSContext *ctx, JSErrorEnum error_num,
6869+ JS_PRINTF_FORMAT const char *fmt, va_list ap)
68766870{
68776871 JSRuntime *rt = ctx->rt;
68786872 JSStackFrame *sf;
@@ -6882,7 +6876,7 @@ static JSValue JS_ThrowError(JSContext *ctx, JSErrorEnum error_num,
68826876 sf = rt->current_stack_frame;
68836877 add_backtrace = !rt->in_out_of_memory &&
68846878 (!sf || (JS_GetFunctionBytecode(sf->cur_func) == NULL));
6885- return JS_ThrowError2(ctx, error_num, fmt, ap, add_backtrace );
6879+ return JS_ThrowError2(ctx, error_num, add_backtrace, fmt, ap );
68866880}
68876881
68886882JSValue JS_PRINTF_FORMAT_ATTR(2, 3) JS_ThrowPlainError(JSContext *ctx, JS_PRINTF_FORMAT const char *fmt, ...)
@@ -6933,26 +6927,22 @@ static int JS_PRINTF_FORMAT_ATTR(3, 4) JS_ThrowTypeErrorOrFalse(JSContext *ctx,
69336927 }
69346928}
69356929
6936- /* never use it directly */
6937- static JSValue JS_PRINTF_FORMAT_ATTR(3, 4) __JS_ThrowTypeErrorAtom(JSContext *ctx, JSAtom atom, JS_PRINTF_FORMAT const char *fmt, ...)
6930+ #pragma GCC diagnostic push
6931+ #pragma GCC diagnostic ignored "-Wformat-nonliteral"
6932+ static JSValue JS_ThrowTypeErrorAtom(JSContext *ctx, const char *fmt, JSAtom atom)
69386933{
69396934 char buf[ATOM_GET_STR_BUF_SIZE];
6940- return JS_ThrowTypeError (ctx, fmt,
6941- JS_AtomGetStr (ctx, buf, sizeof( buf), atom) );
6935+ JS_AtomGetStr (ctx, buf, sizeof(buf), atom);
6936+ return JS_ThrowTypeError (ctx, fmt, buf);
69426937}
69436938
6944- /* never use it directly */
6945- static JSValue JS_PRINTF_FORMAT_ATTR(3, 4) __JS_ThrowSyntaxErrorAtom(JSContext *ctx, JSAtom atom, JS_PRINTF_FORMAT const char *fmt, ...)
6939+ static JSValue JS_ThrowSyntaxErrorAtom(JSContext *ctx, const char *fmt, JSAtom atom)
69466940{
69476941 char buf[ATOM_GET_STR_BUF_SIZE];
6948- return JS_ThrowSyntaxError (ctx, fmt,
6949- JS_AtomGetStr (ctx, buf, sizeof( buf), atom) );
6942+ JS_AtomGetStr (ctx, buf, sizeof(buf), atom);
6943+ return JS_ThrowSyntaxError (ctx, fmt, buf);
69506944}
6951-
6952- /* %s is replaced by 'atom'. The macro is used so that gcc can check
6953- the format string. */
6954- #define JS_ThrowTypeErrorAtom(ctx, fmt, atom) __JS_ThrowTypeErrorAtom(ctx, atom, fmt, "")
6955- #define JS_ThrowSyntaxErrorAtom(ctx, fmt, atom) __JS_ThrowSyntaxErrorAtom(ctx, atom, fmt, "")
6945+ #pragma GCC diagnostic pop // ignored "-Wformat-nonliteral"
69566946
69576947static int JS_ThrowTypeErrorReadOnly(JSContext *ctx, int flags, JSAtom atom)
69586948{
@@ -19038,7 +19028,7 @@ int JS_PRINTF_FORMAT_ATTR(2, 3) js_parse_error(JSParseState *s, JS_PRINTF_FORMAT
1903819028 int backtrace_flags;
1903919029
1904019030 va_start(ap, fmt);
19041- JS_ThrowError2(ctx, JS_SYNTAX_ERROR, fmt, ap, false );
19031+ JS_ThrowError2(ctx, JS_SYNTAX_ERROR, false, fmt, ap );
1904219032 va_end(ap);
1904319033 backtrace_flags = 0;
1904419034 if (s->cur_func && s->cur_func->backtrace_barrier)
0 commit comments