** Do the REPL: repeatedly read (load) a line, evaluate (call) it, and ** print any results. */
| 401 | ** print any results. |
| 402 | */ |
| 403 | static void doREPL(lua_State *L) { |
| 404 | int status; |
| 405 | const char *oldprogname = progname; |
| 406 | progname = nullptr; /* no 'progname' on errors in interactive mode */ |
| 407 | while ((status = loadline(L)) != -1) { |
| 408 | if (status == LUA_OK) |
| 409 | status = docall(L, 0, LUA_MULTRET); |
| 410 | if (status == LUA_OK) l_print(L); |
| 411 | else report(L, status); |
| 412 | } |
| 413 | lua_settop(L, 0); /* clear stack */ |
| 414 | lua_writeline(); |
| 415 | progname = oldprogname; |
| 416 | } |
| 417 | |
| 418 | |
| 419 | /* |