MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / runargs

Function runargs

3rd/lua-5.4.3/src/lua.c:322–345  ·  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

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