diff options
Diffstat (limited to 'lua.c')
-rw-r--r-- | lua.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.c,v 1.109 2002/11/19 13:49:43 roberto Exp roberto $ | 2 | ** $Id: lua.c,v 1.110 2002/11/25 17:47:13 roberto Exp roberto $ |
3 | ** Lua stand-alone interpreter | 3 | ** Lua stand-alone interpreter |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -121,7 +121,8 @@ static int report (int status) { | |||
121 | static int lcall (int narg, int clear) { | 121 | static int lcall (int narg, int clear) { |
122 | int status; | 122 | int status; |
123 | int base = lua_gettop(L) - narg; /* function index */ | 123 | int base = lua_gettop(L) - narg; /* function index */ |
124 | lua_getglobal(L, "_TRACEBACK"); /* get traceback function */ | 124 | lua_pushliteral(L, "_TRACEBACK"); |
125 | lua_rawget(L, LUA_GLOBALSINDEX); /* get traceback function */ | ||
125 | lua_insert(L, base); /* put it under chunk and args */ | 126 | lua_insert(L, base); /* put it under chunk and args */ |
126 | signal(SIGINT, laction); | 127 | signal(SIGINT, laction); |
127 | status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base); | 128 | status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base); |
@@ -175,7 +176,8 @@ static int dostring (const char *s, const char *name) { | |||
175 | 176 | ||
176 | 177 | ||
177 | static int load_file (const char *name) { | 178 | static int load_file (const char *name) { |
178 | lua_getglobal(L, "require"); | 179 | lua_pushliteral(L, "require"); |
180 | lua_rawget(L, LUA_GLOBALSINDEX); | ||
179 | if (!lua_isfunction(L, -1)) { /* no `require' defined? */ | 181 | if (!lua_isfunction(L, -1)) { /* no `require' defined? */ |
180 | lua_pop(L, 1); | 182 | lua_pop(L, 1); |
181 | return file_input(name); | 183 | return file_input(name); |
@@ -228,7 +230,8 @@ static int readline (lua_State *l, const char *prompt) { | |||
228 | 230 | ||
229 | static const char *get_prompt (int firstline) { | 231 | static const char *get_prompt (int firstline) { |
230 | const char *p = NULL; | 232 | const char *p = NULL; |
231 | lua_getglobal(L, firstline ? "_PROMPT" : "_PROMPT2"); | 233 | lua_pushstring(L, firstline ? "_PROMPT" : "_PROMPT2"); |
234 | lua_rawget(L, LUA_GLOBALSINDEX); | ||
232 | p = lua_tostring(L, -1); | 235 | p = lua_tostring(L, -1); |
233 | if (p == NULL) p = (firstline ? PROMPT : PROMPT2); | 236 | if (p == NULL) p = (firstline ? PROMPT : PROMPT2); |
234 | lua_pop(L, 1); /* remove global */ | 237 | lua_pop(L, 1); /* remove global */ |