** 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. */
| 299 | ** Returns 0 if some code raises an error. |
| 300 | */ |
| 301 | static int runargs (lua_State *L, char **argv, int n) { |
| 302 | int i; |
| 303 | for (i = 1; i < n; i++) { |
| 304 | int option = argv[i][1]; |
| 305 | lua_assert(argv[i][0] == '-'); /* already checked */ |
| 306 | switch (option) { |
| 307 | case 'e': case 'l': { |
| 308 | int status; |
| 309 | const char *extra = argv[i] + 2; /* both options need an argument */ |
| 310 | if (*extra == '\0') extra = argv[++i]; |
| 311 | lua_assert(extra != NULL); |
| 312 | status = (option == 'e') |
| 313 | ? dostring(L, extra, "=(command line)") |
| 314 | : dolibrary(L, extra); |
| 315 | if (status != LUA_OK) return 0; |
| 316 | break; |
| 317 | } |
| 318 | case 'W': |
| 319 | lua_warning(L, "@on", 0); /* warnings on */ |
| 320 | break; |
| 321 | } |
| 322 | } |
| 323 | return 1; |
| 324 | } |
| 325 | |
| 326 | |
| 327 | static int handle_luainit (lua_State *L) { |
no test coverage detected