** Read a line and try to load (compile) it first as an expression (by ** adding "return " in front of it) and second as a statement. Return ** the final status of load/call with the resulting function (if any) ** in the top of the stack. */
| 638 | ** in the top of the stack. |
| 639 | */ |
| 640 | static int loadline (lua_State *L) { |
| 641 | const char *line; |
| 642 | int status; |
| 643 | lua_settop(L, 0); |
| 644 | if (!pushline(L, 1)) |
| 645 | return -1; /* no input */ |
| 646 | if ((status = addreturn(L)) != LUA_OK) /* 'return ...' did not work? */ |
| 647 | status = multiline(L); /* try as command, maybe with continuation lines */ |
| 648 | line = lua_tostring(L, 1); |
| 649 | if (line[0] != '\0') /* non empty? */ |
| 650 | lua_saveline(line); /* keep history */ |
| 651 | lua_remove(L, 1); /* remove line from the stack */ |
| 652 | lua_assert(lua_gettop(L) == 1); |
| 653 | return status; |
| 654 | } |
| 655 | |
| 656 | |
| 657 | /* |
no test coverage detected