Showing the changes to src/lua.c (1 of 46 files). Show all
Unified · Split
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 2 | −** $Id: lua.c,v 1.154 2005/10/24 17:38:47 roberto Exp $ | |
| 2 | +** $Id: lua.c,v 1.157 2005/12/29 16:23:32 roberto Exp $ | |
| 3 | 3 | ** Lua stand-alone interpreter |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -120,7 +120,7 @@ static int getargs (lua_State *L, char **argv, int n) { · 114 unmodified lines | ||
| 120 | 120 | luaL_checkstack(L, narg + 3, "too many arguments to script"); |
| 121 | 121 | for (i=n+1; i < argc; i++) |
| 122 | 122 | lua_pushstring(L, argv[i]); |
| 123 | − lua_newtable(L); | |
| 123 | + lua_createtable(L, narg, n + 1); | |
| 124 | 124 | for (i=0; i < argc; i++) { |
| 125 | 125 | lua_pushstring(L, argv[i]); |
| 126 | 126 | lua_rawseti(L, -2, i - n); |
| @@ -215,7 +215,6 @@ static void dotty (lua_State *L) { · 88 unmodified lines | ||
| 215 | 215 | int status; |
| 216 | 216 | const char *oldprogname = progname; |
| 217 | 217 | progname = NULL; |
| 218 | − print_version(); | |
| 219 | 218 | while ((status = loadline(L)) != -1) { |
| 220 | 219 | if (status == 0) status = docall(L, 0, 0); |
| 221 | 220 | report(L, status); |
| @@ -261,7 +260,7 @@ static int collectargs (char **argv, int *pi, int *pv, int *pe) { · 39 unmodified lines | ||
| 261 | 260 | switch (argv[i][1]) { /* option */ |
| 262 | 261 | case '-': return (argv[i+1] != NULL ? i+1 : 0); |
| 263 | 262 | case '\0': return i; |
| 264 | − case 'i': *pi = 1; break; | |
| 263 | + case 'i': *pi = 1; /* go through */ | |
| 265 | 264 | case 'v': *pv = 1; break; |
| 266 | 265 | case 'e': *pe = 1; /* go through */ |
| 267 | 266 | case 'l': |
| @@ -330,7 +329,9 @@ static int pmain (lua_State *L) { · 62 unmodified lines | ||
| 330 | 329 | int has_i = 0, has_v = 0, has_e = 0; |
| 331 | 330 | globalL = L; |
| 332 | 331 | if (argv[0] && argv[0][0]) progname = argv[0]; |
| 332 | + lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */ | |
| 333 | 333 | luaL_openlibs(L); /* open libraries */ |
| 334 | + lua_gc(L, LUA_GCRESTART, 0); | |
| 334 | 335 | s->status = handle_luainit(L); |
| 335 | 336 | if (s->status != 0) return 0; |
| 336 | 337 | script = collectargs(argv, &has_i, &has_v, &has_e); |
| @@ -348,7 +349,10 @@ static int pmain (lua_State *L) { · 11 unmodified lines | ||
| 348 | 349 | if (has_i) |
| 349 | 350 | dotty(L); |
| 350 | 351 | else if (script == 0 && !has_e && !has_v) { |
| 351 | − if (lua_stdin_is_tty()) dotty(L); | |
| 352 | + if (lua_stdin_is_tty()) { | |
| 353 | + print_version(); | |
| 354 | + dotty(L); | |
| 355 | + } | |
| 352 | 356 | else dofile(L, NULL); /* executes stdin as a file */ |
| 353 | 357 | } |
| 354 | 358 | return 0; |