diff options
author | Philip Chimento <philip.chimento@gmail.com> | 2017-05-02 22:02:51 -0700 |
---|---|---|
committer | Philip Chimento <philip.chimento@gmail.com> | 2017-07-09 12:55:47 -0700 |
commit | 39f4a7a64b8f964edc2e3dd81d05a6b221f9b42f (patch) | |
tree | b592c1b0ebfcff90c59b93b71d48937a091f22ac | |
parent | 3199806e73acb424fef911838edb380e10a17b60 (diff) | |
download | gjs-39f4a7a64b8f964edc2e3dd81d05a6b221f9b42f.tar.gz |
js: Report warnings and errors with encoding
JS_ReportWarning() and JS_ReportError() are changed in SpiderMonkey 52 to
specify their character encodings. Therefore, we use JS_ReportWarningUTF8()
and JS_ReportErrorUTF8(), except in a few cases where we use the ASCII
version because the argument is a string literal with only ASCII characters
and no format codes.
https://bugzilla.gnome.org/show_bug.cgi?id=784196
-rw-r--r-- | gi/function.cpp | 6 | ||||
-rw-r--r-- | gi/repo.cpp | 2 | ||||
-rw-r--r-- | gjs/jsapi-util-error.cpp | 8 |
3 files changed, 7 insertions, 9 deletions
diff --git a/gi/function.cpp b/gi/function.cpp index 70306cd0..1a89821e 100644 --- a/gi/function.cpp +++ b/gi/function.cpp @@ -769,9 +769,9 @@ gjs_invoke_c_function(JSContext *context, */ if (args.length() > function->expected_js_argc) { GjsAutoChar name = format_function_name(function, is_method); - JS_ReportWarning(context, "Too many arguments to %s: expected %d, " - "got %" G_GSIZE_FORMAT, name.get(), - function->expected_js_argc, args.length()); + JS_ReportWarningUTF8(context, "Too many arguments to %s: expected %d, " + "got %" G_GSIZE_FORMAT, name.get(), + function->expected_js_argc, args.length()); } else if (args.length() < function->expected_js_argc) { GjsAutoChar name = format_function_name(function, is_method); gjs_throw(context, "Too few arguments to %s: " diff --git a/gi/repo.cpp b/gi/repo.cpp index 1836b588..e13cf82e 100644 --- a/gi/repo.cpp +++ b/gi/repo.cpp @@ -105,7 +105,7 @@ resolve_namespace_object(JSContext *context, "versions available; use " "imports.gi.versions to pick one", ns_name, nversions); - JS_ReportWarning(context, warn_text); + JS_ReportWarningUTF8(context, "%s", warn_text.get()); } g_list_free_full(versions, g_free); diff --git a/gjs/jsapi-util-error.cpp b/gjs/jsapi-util-error.cpp index 56d3ec78..ce1bbd59 100644 --- a/gjs/jsapi-util-error.cpp +++ b/gjs/jsapi-util-error.cpp @@ -83,13 +83,13 @@ gjs_throw_valist(JSContext *context, result = false; if (!gjs_string_from_utf8(context, s, -1, error_args[0])) { - JS_ReportError(context, "Failed to copy exception string"); + JS_ReportErrorUTF8(context, "Failed to copy exception string"); goto out; } if (!JS_GetProperty(context, global, error_class, &v_constructor) || !v_constructor.isObject()) { - JS_ReportError(context, "??? Missing Error constructor in global object?"); + JS_ReportErrorUTF8(context, "??? Missing Error constructor in global object?"); goto out; } @@ -119,9 +119,7 @@ gjs_throw_valist(JSContext *context, /* try just reporting it to error handler? should not * happen though pretty much */ - JS_ReportError(context, - "Failed to throw exception '%s'", - s); + JS_ReportErrorUTF8(context, "Failed to throw exception '%s'", s); } g_free(s); |