| 214 | |
| 215 | |
| 216 | static void dotty (lua_State *L) { |
| 217 | int status; |
| 218 | const char *oldprogname = progname; |
| 219 | progname = NULL; |
| 220 | while ((status = loadline(L)) != -1) { |
| 221 | if (status == 0) status = docall(L, 0, 0); |
| 222 | report(L, status); |
| 223 | if (status == 0 && lua_gettop(L) > 0) { /* any result to print? */ |
| 224 | lua_getglobal(L, "print"); |
| 225 | lua_insert(L, 1); |
| 226 | if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0) |
| 227 | l_message(progname, lua_pushfstring(L, |
| 228 | "error calling " LUA_QL("print") " (%s)", |
| 229 | lua_tostring(L, -1))); |
| 230 | } |
| 231 | } |
| 232 | lua_settop(L, 0); /* clear stack */ |
| 233 | fputs("\n", stdout); |
| 234 | fflush(stdout); |
| 235 | progname = oldprogname; |
| 236 | } |
| 237 | |
| 238 | |
| 239 | static int handle_script (lua_State *L, char **argv, int n) { |
no test coverage detected