Default mujs shell to non-strict mode.

Pass "-s" as the first argument to start the shell in strict mode.
This commit is contained in:
Tor Andersson
2018-08-29 12:56:23 +02:00
parent 3430d9a06d
commit 643d428894

17
main.c
View File

@@ -208,9 +208,16 @@ main(int argc, char **argv)
{ {
char *input; char *input;
js_State *J; 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_newcfunction(J, jsB_gc, "gc", 0);
js_setglobal(J, "gc"); js_setglobal(J, "gc");
@@ -236,10 +243,12 @@ main(int argc, char **argv)
js_dostring(J, require_js); js_dostring(J, require_js);
js_dostring(J, stacktrace_js); js_dostring(J, stacktrace_js);
if (argc > 1) { if (i < argc) {
for (i = 1; i < argc; ++i) while (i < argc) {
if (js_dofile(J, argv[i])) if (js_dofile(J, argv[i]))
status = 1; status = 1;
++i;
}
} else { } else {
if (isatty(0)) { if (isatty(0)) {
using_history(); using_history();