diff options
-rw-r--r-- | lua.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.c,v 1.204 2012/04/20 17:05:17 roberto Exp roberto $ | 2 | ** $Id: lua.c,v 1.205 2012/05/23 15:37:09 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 | */ |
@@ -237,7 +237,6 @@ static const char *get_prompt (lua_State *L, int firstline) { | |||
237 | lua_getglobal(L, firstline ? "_PROMPT" : "_PROMPT2"); | 237 | lua_getglobal(L, firstline ? "_PROMPT" : "_PROMPT2"); |
238 | p = lua_tostring(L, -1); | 238 | p = lua_tostring(L, -1); |
239 | if (p == NULL) p = (firstline ? LUA_PROMPT : LUA_PROMPT2); | 239 | if (p == NULL) p = (firstline ? LUA_PROMPT : LUA_PROMPT2); |
240 | lua_pop(L, 1); /* remove global */ | ||
241 | return p; | 240 | return p; |
242 | } | 241 | } |
243 | 242 | ||
@@ -263,7 +262,9 @@ static int pushline (lua_State *L, int firstline) { | |||
263 | char *b = buffer; | 262 | char *b = buffer; |
264 | size_t l; | 263 | size_t l; |
265 | const char *prmt = get_prompt(L, firstline); | 264 | const char *prmt = get_prompt(L, firstline); |
266 | if (lua_readline(L, b, prmt) == 0) | 265 | int readstatus = lua_readline(L, b, prmt); |
266 | lua_pop(L, 1); /* remove result from 'get_prompt' */ | ||
267 | if (readstatus == 0) | ||
267 | return 0; /* no input */ | 268 | return 0; /* no input */ |
268 | l = strlen(b); | 269 | l = strlen(b); |
269 | if (l > 0 && b[l-1] == '\n') /* line ends with newline? */ | 270 | if (l > 0 && b[l-1] == '\n') /* line ends with newline? */ |