| 656 | |
| 657 | |
| 658 | static int f_seek (lua_State *L) { |
| 659 | static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END}; |
| 660 | static const char *const modenames[] = {"set", "cur", "end", NULL}; |
| 661 | FILE *f = tofile(L); |
| 662 | int op = luaL_checkoption(L, 2, "cur", modenames); |
| 663 | lua_Integer p3 = luaL_optinteger(L, 3, 0); |
| 664 | l_seeknum offset = (l_seeknum)p3; |
| 665 | luaL_argcheck(L, (lua_Integer)offset == p3, 3, |
| 666 | "not an integer in proper range"); |
| 667 | op = l_fseek(f, offset, mode[op]); |
| 668 | if (op) |
| 669 | return luaL_fileresult(L, 0, NULL); /* error */ |
| 670 | else { |
| 671 | lua_pushinteger(L, (lua_Integer)l_ftell(f)); |
| 672 | return 1; |
| 673 | } |
| 674 | } |
| 675 | |
| 676 | |
| 677 | static int f_setvbuf (lua_State *L) { |
nothing calls this directly
no test coverage detected