History

Lua 5.1-rc1

Lua Team committed 20 years ago

Commit 53d3c321 parent 27f2ec746 files · +1822 −1531Browse files

Showing the changes to src/lua.c (1 of 46 files). Show all

Unified · Split

src/lua.c+9−5
@@ -1,5 +1,5 @@
11 /*
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 $
33 ** Lua stand-alone interpreter
44 ** See Copyright Notice in lua.h
55 */
@@ -120,7 +120,7 @@ static int getargs (lua_State *L, char **argv, int n) { · 114 unmodified lines
120120 luaL_checkstack(L, narg + 3, "too many arguments to script");
121121 for (i=n+1; i < argc; i++)
122122 lua_pushstring(L, argv[i]);
123− lua_newtable(L);
123+ lua_createtable(L, narg, n + 1);
124124 for (i=0; i < argc; i++) {
125125 lua_pushstring(L, argv[i]);
126126 lua_rawseti(L, -2, i - n);
@@ -215,7 +215,6 @@ static void dotty (lua_State *L) { · 88 unmodified lines
215215 int status;
216216 const char *oldprogname = progname;
217217 progname = NULL;
218− print_version();
219218 while ((status = loadline(L)) != -1) {
220219 if (status == 0) status = docall(L, 0, 0);
221220 report(L, status);
@@ -261,7 +260,7 @@ static int collectargs (char **argv, int *pi, int *pv, int *pe) { · 39 unmodified lines
261260 switch (argv[i][1]) { /* option */
262261 case '-': return (argv[i+1] != NULL ? i+1 : 0);
263262 case '\0': return i;
264− case 'i': *pi = 1; break;
263+ case 'i': *pi = 1; /* go through */
265264 case 'v': *pv = 1; break;
266265 case 'e': *pe = 1; /* go through */
267266 case 'l':
@@ -330,7 +329,9 @@ static int pmain (lua_State *L) { · 62 unmodified lines
330329 int has_i = 0, has_v = 0, has_e = 0;
331330 globalL = L;
332331 if (argv[0] && argv[0][0]) progname = argv[0];
332+ lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */
333333 luaL_openlibs(L); /* open libraries */
334+ lua_gc(L, LUA_GCRESTART, 0);
334335 s->status = handle_luainit(L);
335336 if (s->status != 0) return 0;
336337 script = collectargs(argv, &has_i, &has_v, &has_e);
@@ -348,7 +349,10 @@ static int pmain (lua_State *L) { · 11 unmodified lines
348349 if (has_i)
349350 dotty(L);
350351 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+ }
352356 else dofile(L, NULL); /* executes stdin as a file */
353357 }
354358 return 0;