MCPcopy Create free account
hub / github.com/DFHack/dfhack / runargs

Function runargs

depends/lua/src/lua.c:514–531  ·  view source on GitHub ↗

** Processes options 'e' and 'l', which involve running Lua code. ** Returns 0 if some code raises an error. */

Source from the content-addressed store, hash-verified

512** Returns 0 if some code raises an error.
513*/
514static int runargs (lua_State *L, char **argv, int n) {
515 int i;
516 for (i = 1; i < n; i++) {
517 int option = argv[i][1];
518 lua_assert(argv[i][0] == '-'); /* already checked */
519 if (option == 'e' || option == 'l') {
520 int status;
521 const char *extra = argv[i] + 2; /* both options need an argument */
522 if (*extra == '\0') extra = argv[++i];
523 lua_assert(extra != NULL);
524 status = (option == 'e')
525 ? dostring(L, extra, "=(command line)")
526 : dolibrary(L, extra);
527 if (status != LUA_OK) return 0;
528 }
529 }
530 return 1;
531}
532
533
534

Callers 1

pmainFunction · 0.85

Calls 2

dostringFunction · 0.85
dolibraryFunction · 0.85

Tested by

no test coverage detected