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

Function io_lines

lua/liolib.c:256–271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

254
255
256static int io_lines (lua_State *L) {
257 if (lua_isnoneornil(L, 1)) { /* no arguments? */
258 /* will iterate over default input */
259 lua_rawgeti(L, LUA_ENVIRONINDEX, IO_INPUT);
260 return f_lines(L);
261 }
262 else {
263 const char *filename = luaL_checkstring(L, 1);
264 FILE **pf = newfile(L);
265 *pf = fopen(filename, "r");
266 if (*pf == NULL)
267 fileerror(L, 1, filename);
268 aux_lines(L, lua_gettop(L), 1);
269 return 1;
270 }
271}
272
273
274/*

Callers

nothing calls this directly

Calls 6

lua_rawgetiFunction · 0.85
f_linesFunction · 0.85
newfileFunction · 0.85
fileerrorFunction · 0.85
aux_linesFunction · 0.85
lua_gettopFunction · 0.85

Tested by

no test coverage detected