MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / runargs

Function runargs

extlibs/lua/src/lua.c:301–324  ·  view source on GitHub ↗

** 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. */

Source from the content-addressed store, hash-verified

299** Returns 0 if some code raises an error.
300*/
301static 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
327static int handle_luainit (lua_State *L) {

Callers 1

pmainFunction · 0.85

Calls 3

dostringFunction · 0.85
dolibraryFunction · 0.85
lua_warningFunction · 0.85

Tested by

no test coverage detected