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

Function io_readline

deps/lua/src/liolib.c:391–408  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

389
390
391static int io_readline (lua_State *L) {
392 FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(1));
393 int sucess;
394 if (f == NULL) /* file is already closed? */
395 luaL_error(L, "file is already closed");
396 sucess = read_line(L, f);
397 if (ferror(f))
398 return luaL_error(L, "%s", strerror(errno));
399 if (sucess) return 1;
400 else { /* EOF */
401 if (lua_toboolean(L, lua_upvalueindex(2))) { /* generator created file? */
402 lua_settop(L, 0);
403 lua_pushvalue(L, lua_upvalueindex(1));
404 aux_close(L); /* close it */
405 }
406 return 0;
407 }
408}
409
410/* }====================================================== */
411

Callers

nothing calls this directly

Calls 7

lua_touserdataFunction · 0.85
luaL_errorFunction · 0.85
read_lineFunction · 0.85
lua_tobooleanFunction · 0.85
lua_settopFunction · 0.85
lua_pushvalueFunction · 0.85
aux_closeFunction · 0.85

Tested by

no test coverage detected