** 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. */
| 320 | ** Returns 0 if some code raises an error. |
| 321 | */ |
| 322 | static int runargs (lua_State *L, char **argv, int n) { |
| 323 | int i; |
| 324 | for (i = 1; i < n; i++) { |
| 325 | int option = argv[i][1]; |
| 326 | lua_assert(argv[i][0] == '-'); /* already checked */ |
| 327 | switch (option) { |
| 328 | case 'e': case 'l': { |
| 329 | int status; |
| 330 | const char *extra = argv[i] + 2; /* both options need an argument */ |
| 331 | if (*extra == '\0') extra = argv[++i]; |
| 332 | lua_assert(extra != NULL); |
| 333 | status = (option == 'e') |
| 334 | ? dostring(L, extra, "=(command line)") |
| 335 | : dolibrary(L, extra); |
| 336 | if (status != LUA_OK) return 0; |
| 337 | break; |
| 338 | } |
| 339 | case 'W': |
| 340 | lua_warning(L, "@on", 0); /* warnings on */ |
| 341 | break; |
| 342 | } |
| 343 | } |
| 344 | return 1; |
| 345 | } |
| 346 | |
| 347 | |
| 348 | static int handle_luainit (lua_State *L) { |
no test coverage detected