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

Function io_lines

depends/lua/src/liolib.c:358–375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

356
357
358static int io_lines (lua_State *L) {
359 int toclose;
360 if (lua_isnone(L, 1)) lua_pushnil(L); /* at least one argument */
361 if (lua_isnil(L, 1)) { /* no file name? */
362 lua_getfield(L, LUA_REGISTRYINDEX, IO_INPUT); /* get default input */
363 lua_replace(L, 1); /* put it at index 1 */
364 tofile(L); /* check that it's a valid file handle */
365 toclose = 0; /* do not close it after iteration */
366 }
367 else { /* open a new file */
368 const char *filename = luaL_checkstring(L, 1);
369 opencheck(L, filename, "r");
370 lua_replace(L, 1); /* put file at index 1 */
371 toclose = 1; /* close it after iteration */
372 }
373 aux_lines(L, toclose);
374 return 1;
375}
376
377
378/*

Callers

nothing calls this directly

Calls 5

lua_pushnilFunction · 0.85
lua_getfieldFunction · 0.85
tofileFunction · 0.85
opencheckFunction · 0.85
aux_linesFunction · 0.85

Tested by

no test coverage detected