MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / pmain

Function pmain

other_src/lua/src/lua.cpp:340–374  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

338
339
340static int pmain (lua_State *L) {
341 struct Smain *s = (struct Smain *)lua_touserdata(L, 1);
342 char **argv = s->argv;
343 int script;
344 int has_i = 0, has_v = 0, has_e = 0;
345 globalL = L;
346 if (argv[0] && argv[0][0]) progname = argv[0];
347 lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */
348 luaL_openlibs(L); /* open libraries */
349 lua_gc(L, LUA_GCRESTART, 0);
350 s->status = handle_luainit(L);
351 if (s->status != 0) return 0;
352 script = collectargs(argv, &has_i, &has_v, &has_e);
353 if (script < 0) { /* invalid args? */
354 print_usage();
355 s->status = 1;
356 return 0;
357 }
358 if (has_v) print_version();
359 s->status = runargs(L, argv, (script > 0) ? script : s->argc);
360 if (s->status != 0) return 0;
361 if (script)
362 s->status = handle_script(L, argv, script);
363 if (s->status != 0) return 0;
364 if (has_i)
365 dotty(L);
366 else if (script == 0 && !has_e && !has_v) {
367 if (lua_stdin_is_tty()) {
368 print_version();
369 dotty(L);
370 }
371 else dofile(L, NULL); /* executes stdin as a file */
372 }
373 return 0;
374}
375
376
377int main (int argc, char **argv) {

Callers

nothing calls this directly

Calls 11

lua_touserdataFunction · 0.70
lua_gcFunction · 0.70
luaL_openlibsFunction · 0.70
handle_luainitFunction · 0.70
collectargsFunction · 0.70
print_usageFunction · 0.70
print_versionFunction · 0.70
runargsFunction · 0.70
handle_scriptFunction · 0.70
dottyFunction · 0.70
dofileFunction · 0.70

Tested by

no test coverage detected