diff options
Diffstat (limited to 'lua.c')
| -rw-r--r-- | lua.c | 16 |
1 files changed, 10 insertions, 6 deletions
| @@ -416,14 +416,18 @@ static int handle_luainit (lua_State *L) { | |||
| 416 | 416 | ||
| 417 | 417 | ||
| 418 | /* | 418 | /* |
| 419 | ** Returns the string to be used as a prompt by the interpreter. | 419 | ** Return the string to be used as a prompt by the interpreter. Leave |
| 420 | ** the string (or nil, if using the default value) on the stack, to keep | ||
| 421 | ** it anchored. | ||
| 420 | */ | 422 | */ |
| 421 | static const char *get_prompt (lua_State *L, int firstline) { | 423 | static const char *get_prompt (lua_State *L, int firstline) { |
| 422 | const char *p; | 424 | if (lua_getglobal(L, firstline ? "_PROMPT" : "_PROMPT2") == LUA_TNIL) |
| 423 | lua_getglobal(L, firstline ? "_PROMPT" : "_PROMPT2"); | 425 | return (firstline ? LUA_PROMPT : LUA_PROMPT2); /* use the default */ |
| 424 | p = lua_tostring(L, -1); | 426 | else { /* apply 'tostring' over the value */ |
| 425 | if (p == NULL) p = (firstline ? LUA_PROMPT : LUA_PROMPT2); | 427 | const char *p = luaL_tolstring(L, -1, NULL); |
| 426 | return p; | 428 | lua_remove(L, -2); /* remove original value */ |
| 429 | return p; | ||
| 430 | } | ||
| 427 | } | 431 | } |
| 428 | 432 | ||
| 429 | /* mark in error messages for incomplete statements */ | 433 | /* mark in error messages for incomplete statements */ |
