MCPcopy Create free account
hub / github.com/DFHack/dfhack / pmain

Function pmain

depends/lua/src/luac.c:165–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected