From 346250862dc549180a7516d7d007e51ed8e60813 Mon Sep 17 00:00:00 2001 From: "jband%netscape.com" Date: Sat, 19 Aug 2000 03:28:01 +0000 Subject: [PATCH] Add support for -w and -s for reporting warnings and doing strict JS checking (as supported by the engine). Also update the usage info. ra=brendan@mozilla.org git-svn-id: svn://10.0.0.236/trunk@76683 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/js/src/xpconnect/shell/xpcshell.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/mozilla/js/src/xpconnect/shell/xpcshell.cpp b/mozilla/js/src/xpconnect/shell/xpcshell.cpp index ebb9699d79e..ecbb3b8d2ee 100644 --- a/mozilla/js/src/xpconnect/shell/xpcshell.cpp +++ b/mozilla/js/src/xpconnect/shell/xpcshell.cpp @@ -98,6 +98,7 @@ FILE *gErrFile = NULL; int gExitCode = 0; JSBool gQuitting = JS_FALSE; +static int reportWarnings = 0; static void PR_CALLBACK my_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report) @@ -111,6 +112,10 @@ my_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report) return; } + /* Conditionally ignore reported warnings. */ + if (JSREPORT_IS_WARNING(report->flags) && !reportWarnings) + return; + if (report->filename) prefix = JS_smprintf("%s:", report->filename); if (report->lineno) { @@ -120,7 +125,9 @@ my_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report) } if (JSREPORT_IS_WARNING(report->flags)) { tmp = prefix; - prefix = JS_smprintf("%swarning: ", tmp ? tmp : ""); + prefix = JS_smprintf("%s%swarning: ", + tmp ? tmp : "", + JSREPORT_IS_STRICT(report->flags) ? "strict " : ""); JS_free(cx, tmp); } @@ -540,12 +547,10 @@ static int usage(void) { fprintf(gErrFile, "%s\n", JS_GetImplementationVersion()); - fprintf(gErrFile, "usage: js [-w] [-v version] [-f scriptfile] [scriptfile] [scriptarg...]\n"); + fprintf(gErrFile, "usage: xpcshell [-s] [-w] [-v version] [-f scriptfile] [scriptfile] [scriptarg...]\n"); return 2; } -static int reportWarnings; - static int ProcessArgs(JSContext *cx, JSObject *obj, char **argv, int argc) { @@ -570,7 +575,9 @@ ProcessArgs(JSContext *cx, JSObject *obj, char **argv, int argc) case 'w': reportWarnings++; break; - + case 's': + JS_ToggleOptions(cx, JSOPTION_STRICT); + break; case 'f': if (i+1 == argc) { return usage();