| 695 | |
| 696 | |
| 697 | static int f_seek (lua_State *L) { |
| 698 | static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END}; |
| 699 | static const char *const modenames[] = {"set", "cur", "end", NULL}; |
| 700 | FILE *f = tofile(L); |
| 701 | int op = luaL_checkoption(L, 2, "cur", modenames); |
| 702 | lua_Integer p3 = luaL_optinteger(L, 3, 0); |
| 703 | l_seeknum offset = (l_seeknum)p3; |
| 704 | luaL_argcheck(L, (lua_Integer)offset == p3, 3, |
| 705 | "not an integer in proper range"); |
| 706 | op = l_fseek(f, offset, mode[op]); |
| 707 | if (l_unlikely(op)) |
| 708 | return luaL_fileresult(L, 0, NULL); /* error */ |
| 709 | else { |
| 710 | lua_pushinteger(L, (lua_Integer)l_ftell(f)); |
| 711 | return 1; |
| 712 | } |
| 713 | } |
| 714 | |
| 715 | |
| 716 | static int f_setvbuf (lua_State *L) { |
nothing calls this directly
no test coverage detected