MCPcopy Create free account
hub / github.com/PlutoLang/Pluto / runargs

Function runargs

src/lua.cpp:361–384  ·  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

359** Returns 0 if some code raises an error.
360*/
361static int runargs (lua_State *L, char **argv, int n) {
362 int i;
363 for (i = 1; i < n; i++) {
364 int option = argv[i][1];
365 lua_assert(argv[i][0] == '-'); /* already checked */
366 switch (option) {
367 case 'e': case 'l': {
368 int status;
369 char *extra = argv[i] + 2; /* both options need an argument */
370 if (*extra == '\0') extra = argv[++i];
371 lua_assert(extra != NULL);
372 status = (option == 'e')
373 ? dostring(L, extra, "=(command line)")
374 : dolibrary(L, extra);
375 if (status != LUA_OK) return 0;
376 break;
377 }
378 case 'W':
379 lua_warning(L, "@off", 0); /* warnings off */
380 break;
381 }
382 }
383 return 1;
384}
385
386
387static 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