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