| 301 | |
| 302 | |
| 303 | static void dotty (lua_State *L) { |
| 304 | int status; |
| 305 | const char *oldprogname = progname; |
| 306 | progname = NULL; |
| 307 | while ((status = loadline(L)) != -1) { |
| 308 | if (status == LUA_OK) status = docall(L, 0, LUA_MULTRET); |
| 309 | report(L, status); |
| 310 | if (status == LUA_OK && lua_gettop(L) > 0) { /* any result to print? */ |
| 311 | luaL_checkstack(L, LUA_MINSTACK, "too many results to print"); |
| 312 | lua_getglobal(L, "print"); |
| 313 | lua_insert(L, 1); |
| 314 | if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != LUA_OK) |
| 315 | l_message(progname, lua_pushfstring(L, |
| 316 | "error calling " LUA_QL("print") " (%s)", |
| 317 | lua_tostring(L, -1))); |
| 318 | } |
| 319 | } |
| 320 | lua_settop(L, 0); /* clear stack */ |
| 321 | luai_writeline(); |
| 322 | progname = oldprogname; |
| 323 | } |
| 324 | |
| 325 | |
| 326 | static int handle_script (lua_State *L, char **argv, int n) { |
no test coverage detected