shithub: libmujs

Download patch

ref: 643d4288948c1655a3dfa3b03ce783c66e82a36f
parent: 3430d9a06d6f8a3696e2bbdca7681937e60ca7a9
author: Tor Andersson <tor.andersson@artifex.com>
date: Wed Aug 29 08:56:23 EDT 2018

Default mujs shell to non-strict mode.

Pass "-s" as the first argument to start the shell in strict mode.

--- a/main.c
+++ b/main.c
@@ -208,10 +208,17 @@
 {
 	char *input;
 	js_State *J;
-	int i, status = 0;
+	int status = 0;
+	int flags = 0;
+	int i = 1;
 
-	J = js_newstate(NULL, NULL, JS_STRICT);
+	if (i < argc && !strcmp(argv[i], "-s")) {
+		flags |= JS_STRICT;
+		++i;
+	}
 
+	J = js_newstate(NULL, NULL, flags);
+
 	js_newcfunction(J, jsB_gc, "gc", 0);
 	js_setglobal(J, "gc");
 
@@ -236,10 +243,12 @@
 	js_dostring(J, require_js);
 	js_dostring(J, stacktrace_js);
 
-	if (argc > 1) {
-		for (i = 1; i < argc; ++i)
+	if (i < argc) {
+		while (i < argc) {
 			if (js_dofile(J, argv[i]))
 				status = 1;
+			++i;
+		}
 	} else {
 		if (isatty(0)) {
 			using_history();