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

Function runargs

xrepo/packages/l/lua/port/lua/src/lua.c:329–352  ·  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

327** Returns 0 if some code raises an error.
328*/
329static int runargs (lua_State *L, char **argv, int n) {
330 int i;
331 for (i = 1; i < n; i++) {
332 int option = argv[i][1];
333 lua_assert(argv[i][0] == '-'); /* already checked */
334 switch (option) {
335 case 'e': case 'l': {
336 int status;
337 char *extra = argv[i] + 2; /* both options need an argument */
338 if (*extra == '\0') extra = argv[++i];
339 lua_assert(extra != NULL);
340 status = (option == 'e')
341 ? dostring(L, extra, "=(command line)")
342 : dolibrary(L, extra);
343 if (status != LUA_OK) return 0;
344 break;
345 }
346 case 'W':
347 lua_warning(L, "@on", 0); /* warnings on */
348 break;
349 }
350 }
351 return 1;
352}
353
354
355static 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