** 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. */
| 348 | ** Returns 0 if some code raises an error. |
| 349 | */ |
| 350 | static int runargs (lua_State *L, char **argv, int n) { |
| 351 | int i; |
| 352 | lua_warning(L, "@off", 0); /* by default, Lua stand-alone has warnings off */ |
| 353 | for (i = 1; i < n; i++) { |
| 354 | int option = argv[i][1]; |
| 355 | lua_assert(argv[i][0] == '-'); /* already checked */ |
| 356 | switch (option) { |
| 357 | case 'e': case 'l': { |
| 358 | int status; |
| 359 | char *extra = argv[i] + 2; /* both options need an argument */ |
| 360 | if (*extra == '\0') extra = argv[++i]; |
| 361 | lua_assert(extra != NULL); |
| 362 | status = (option == 'e') |
| 363 | ? dostring(L, extra, "=(command line)") |
| 364 | : dolibrary(L, extra); |
| 365 | if (status != LUA_OK) return 0; |
| 366 | break; |
| 367 | } |
| 368 | case 'W': |
| 369 | lua_warning(L, "@on", 0); /* warnings on */ |
| 370 | break; |
| 371 | } |
| 372 | } |
| 373 | return 1; |
| 374 | } |
| 375 | |
| 376 | |
| 377 | static int handle_luainit (lua_State *L) { |
no test coverage detected