MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / pmain

Function pmain

deps/lua/src/luac.c:158–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156};
157
158static int pmain(lua_State* L)
159{
160 struct Smain* s = (struct Smain*)lua_touserdata(L, 1);
161 int argc=s->argc;
162 char** argv=s->argv;
163 const Proto* f;
164 int i;
165 if (!lua_checkstack(L,argc)) fatal("too many input files");
166 for (i=0; i<argc; i++)
167 {
168 const char* filename=IS("-") ? NULL : argv[i];
169 if (luaL_loadfile(L,filename)!=0) fatal(lua_tostring(L,-1));
170 }
171 f=combine(L,argc);
172 if (listing) luaU_print(f,listing>1);
173 if (dumping)
174 {
175 FILE* D= (output==NULL) ? stdout : fopen(output,"wb");
176 if (D==NULL) cannot("open");
177 lua_lock(L);
178 luaU_dump(L,f,writer,D,stripping);
179 lua_unlock(L);
180 if (ferror(D)) cannot("write");
181 if (fclose(D)) cannot("close");
182 }
183 return 0;
184}
185
186int main(int argc, char* argv[])
187{

Callers

nothing calls this directly

Calls 7

lua_touserdataFunction · 0.85
lua_checkstackFunction · 0.85
fatalFunction · 0.85
luaL_loadfileFunction · 0.85
combineFunction · 0.85
cannotFunction · 0.85
luaU_dumpFunction · 0.70

Tested by

no test coverage detected