** Processes options 'e' and 'l', which involve running Lua code, and ** 'W', which also affects the state. ** Returns 0 if some code raises an error. */
| 327 | ** Returns 0 if some code raises an error. |
| 328 | */ |
| 329 | static int runargs (lua_State *L, char **argv, int n) { |
| 330 | int i; |
| 331 | for (i = 1; i < n; i++) { |
| 332 | int option = argv[i][1]; |
| 333 | lua_assert(argv[i][0] == '-'); /* already checked */ |
| 334 | switch (option) { |
| 335 | case 'e': case 'l': { |
| 336 | int status; |
| 337 | char *extra = argv[i] + 2; /* both options need an argument */ |
| 338 | if (*extra == '\0') extra = argv[++i]; |
| 339 | lua_assert(extra != NULL); |
| 340 | status = (option == 'e') |
| 341 | ? dostring(L, extra, "=(command line)") |
| 342 | : dolibrary(L, extra); |
| 343 | if (status != LUA_OK) return 0; |
| 344 | break; |
| 345 | } |
| 346 | case 'W': |
| 347 | lua_warning(L, "@on", 0); /* warnings on */ |
| 348 | break; |
| 349 | } |
| 350 | } |
| 351 | return 1; |
| 352 | } |
| 353 | |
| 354 | |
| 355 | static int handle_luainit (lua_State *L) { |
no test coverage detected