** 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. */
| 359 | ** Returns 0 if some code raises an error. |
| 360 | */ |
| 361 | static int runargs (lua_State *L, char **argv, int n) { |
| 362 | int i; |
| 363 | for (i = 1; i < n; i++) { |
| 364 | int option = argv[i][1]; |
| 365 | lua_assert(argv[i][0] == '-'); /* already checked */ |
| 366 | switch (option) { |
| 367 | case 'e': case 'l': { |
| 368 | int status; |
| 369 | char *extra = argv[i] + 2; /* both options need an argument */ |
| 370 | if (*extra == '\0') extra = argv[++i]; |
| 371 | lua_assert(extra != NULL); |
| 372 | status = (option == 'e') |
| 373 | ? dostring(L, extra, "=(command line)") |
| 374 | : dolibrary(L, extra); |
| 375 | if (status != LUA_OK) return 0; |
| 376 | break; |
| 377 | } |
| 378 | case 'W': |
| 379 | lua_warning(L, "@off", 0); /* warnings off */ |
| 380 | break; |
| 381 | } |
| 382 | } |
| 383 | return 1; |
| 384 | } |
| 385 | |
| 386 | |
| 387 | static int handle_luainit (lua_State *L) { |
no test coverage detected