** Do the REPL: repeatedly read (load) a line, evaluate (call) it, and ** print any results. */
| 416 | ** print any results. |
| 417 | */ |
| 418 | static void doREPL(lua_State *L) { |
| 419 | int status; |
| 420 | const char *oldprogname = progname; |
| 421 | progname = NULL; /* no 'progname' on errors in interactive mode */ |
| 422 | while ((status = loadline(L)) != -1) { |
| 423 | if (status == LUA_OK) |
| 424 | { |
| 425 | status = docall(L, 0, LUA_MULTRET); |
| 426 | } |
| 427 | if (status == LUA_OK) l_print(L); |
| 428 | else report(L, status); |
| 429 | } |
| 430 | lua_settop(L, 0); /* clear stack */ |
| 431 | lua_writeline(); |
| 432 | progname = oldprogname; |
| 433 | } |
| 434 | |
| 435 | /* |
| 436 | ** Push on the stack the contents of table 'arg' from 1 to #arg |