MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / f_seek

Function f_seek

third-party/lua-5.5.0/src/liolib.c:702–719  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

700
701
702static int f_seek (lua_State *L) {
703 static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END};
704 static const char *const modenames[] = {"set", "cur", "end", NULL};
705 FILE *f = tofile(L);
706 int op = luaL_checkoption(L, 2, "cur", modenames);
707 lua_Integer p3 = luaL_optinteger(L, 3, 0);
708 l_seeknum offset = (l_seeknum)p3;
709 luaL_argcheck(L, (lua_Integer)offset == p3, 3,
710 "not an integer in proper range");
711 errno = 0;
712 op = l_fseek(f, offset, mode[op]);
713 if (l_unlikely(op))
714 return luaL_fileresult(L, 0, NULL); /* error */
715 else {
716 lua_pushinteger(L, (lua_Integer)l_ftell(f));
717 return 1;
718 }
719}
720
721
722static int f_setvbuf (lua_State *L) {

Callers

nothing calls this directly

Calls 5

tofileFunction · 0.70
luaL_checkoptionFunction · 0.70
luaL_optintegerFunction · 0.70
luaL_fileresultFunction · 0.70
lua_pushintegerFunction · 0.70

Tested by

no test coverage detected