| 268 | } |
| 269 | |
| 270 | static int handle_script(lua_State *L, char **argx) |
| 271 | { |
| 272 | int status; |
| 273 | const char *fname = argx[0]; |
| 274 | if (strcmp(fname, "-") == 0 && strcmp(argx[-1], "--") != 0) |
| 275 | fname = NULL; /* stdin */ |
| 276 | status = luaL_loadfile(L, fname); |
| 277 | if (status == LUA_OK) { |
| 278 | /* Fetch args from arg table. LUA_INIT or -e might have changed them. */ |
| 279 | int narg = 0; |
| 280 | lua_getglobal(L, "arg"); |
| 281 | if (lua_istable(L, -1)) { |
| 282 | do { |
| 283 | narg++; |
| 284 | lua_rawgeti(L, -narg, narg); |
| 285 | } while (!lua_isnil(L, -1)); |
| 286 | lua_pop(L, 1); |
| 287 | lua_remove(L, -narg); |
| 288 | narg--; |
| 289 | } else { |
| 290 | lua_pop(L, 1); |
| 291 | } |
| 292 | status = docall(L, narg, 0); |
| 293 | } |
| 294 | return report(L, status); |
| 295 | } |
| 296 | |
| 297 | /* Load add-on module. */ |
| 298 | static int loadjitmodule(lua_State *L) |
no test coverage detected