diff options
Diffstat (limited to '')
-rw-r--r-- | src/luajit.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/luajit.c b/src/luajit.c index b7d9d0c1..22628aaf 100644 --- a/src/luajit.c +++ b/src/luajit.c | |||
@@ -71,6 +71,7 @@ static void print_usage(void) | |||
71 | " -O[opt] Control LuaJIT optimizations.\n" | 71 | " -O[opt] Control LuaJIT optimizations.\n" |
72 | " -i Enter interactive mode after executing " LUA_QL("script") ".\n" | 72 | " -i Enter interactive mode after executing " LUA_QL("script") ".\n" |
73 | " -v Show version information.\n" | 73 | " -v Show version information.\n" |
74 | " -E Ignore environment variables.\n" | ||
74 | " -- Stop handling options.\n" | 75 | " -- Stop handling options.\n" |
75 | " - Execute stdin and stop handling options.\n" | 76 | " - Execute stdin and stop handling options.\n" |
76 | , | 77 | , |
@@ -406,6 +407,7 @@ static int dobytecode(lua_State *L, char **argv) | |||
406 | #define FLAGS_VERSION 2 | 407 | #define FLAGS_VERSION 2 |
407 | #define FLAGS_EXEC 4 | 408 | #define FLAGS_EXEC 4 |
408 | #define FLAGS_OPTION 8 | 409 | #define FLAGS_OPTION 8 |
410 | #define FLAGS_NOENV 16 | ||
409 | 411 | ||
410 | static int collectargs(char **argv, int *flags) | 412 | static int collectargs(char **argv, int *flags) |
411 | { | 413 | { |
@@ -442,6 +444,9 @@ static int collectargs(char **argv, int *flags) | |||
442 | if (*flags) return -1; | 444 | if (*flags) return -1; |
443 | *flags |= FLAGS_EXEC; | 445 | *flags |= FLAGS_EXEC; |
444 | return 0; | 446 | return 0; |
447 | case 'E': | ||
448 | *flags |= FLAGS_NOENV; | ||
449 | break; | ||
445 | default: return -1; /* invalid option */ | 450 | default: return -1; /* invalid option */ |
446 | } | 451 | } |
447 | } | 452 | } |
@@ -521,23 +526,30 @@ static int pmain(lua_State *L) | |||
521 | globalL = L; | 526 | globalL = L; |
522 | if (argv[0] && argv[0][0]) progname = argv[0]; | 527 | if (argv[0] && argv[0][0]) progname = argv[0]; |
523 | LUAJIT_VERSION_SYM(); /* linker-enforced version check */ | 528 | LUAJIT_VERSION_SYM(); /* linker-enforced version check */ |
524 | lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */ | ||
525 | luaL_openlibs(L); /* open libraries */ | ||
526 | lua_gc(L, LUA_GCRESTART, -1); | ||
527 | s->status = handle_luainit(L); | ||
528 | if (s->status != 0) return 0; | ||
529 | script = collectargs(argv, &flags); | 529 | script = collectargs(argv, &flags); |
530 | if (script < 0) { /* invalid args? */ | 530 | if (script < 0) { /* invalid args? */ |
531 | print_usage(); | 531 | print_usage(); |
532 | s->status = 1; | 532 | s->status = 1; |
533 | return 0; | 533 | return 0; |
534 | } | 534 | } |
535 | if ((flags & FLAGS_NOENV)) { | ||
536 | lua_pushboolean(L, 1); | ||
537 | lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV"); | ||
538 | } | ||
539 | lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */ | ||
540 | luaL_openlibs(L); /* open libraries */ | ||
541 | lua_gc(L, LUA_GCRESTART, -1); | ||
542 | if (!(flags & FLAGS_NOENV)) { | ||
543 | s->status = handle_luainit(L); | ||
544 | if (s->status != 0) return 0; | ||
545 | } | ||
535 | if ((flags & FLAGS_VERSION)) print_version(); | 546 | if ((flags & FLAGS_VERSION)) print_version(); |
536 | s->status = runargs(L, argv, (script > 0) ? script : s->argc); | 547 | s->status = runargs(L, argv, (script > 0) ? script : s->argc); |
537 | if (s->status != 0) return 0; | 548 | if (s->status != 0) return 0; |
538 | if (script) | 549 | if (script) { |
539 | s->status = handle_script(L, argv, script); | 550 | s->status = handle_script(L, argv, script); |
540 | if (s->status != 0) return 0; | 551 | if (s->status != 0) return 0; |
552 | } | ||
541 | if ((flags & FLAGS_INTERACTIVE)) { | 553 | if ((flags & FLAGS_INTERACTIVE)) { |
542 | print_jit_status(L); | 554 | print_jit_status(L); |
543 | dotty(L); | 555 | dotty(L); |