MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / pmain

Function pmain

lua/lua.c:338–372  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected