diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-03-19 15:57:42 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-03-19 15:57:42 -0300 |
commit | 16f8e449244f313e4e8b185948b363fd38a2f795 (patch) | |
tree | 6f9ba2371ff6672dd853c17c68e5a86ac07df9a3 | |
parent | 2f5f77788fc96b4f729d4d1e1f1a37e8d9458456 (diff) | |
download | lua-16f8e449244f313e4e8b185948b363fd38a2f795.tar.gz lua-16f8e449244f313e4e8b185948b363fd38a2f795.tar.bz2 lua-16f8e449244f313e4e8b185948b363fd38a2f795.zip |
with 64-bit integers, file offsets do not need to be floats
-rw-r--r-- | liolib.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: liolib.c,v 2.118 2014/03/06 17:12:02 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 2.119 2014/03/13 20:07:18 roberto Exp roberto $ |
3 | ** Standard I/O (and system) library | 3 | ** Standard I/O (and system) library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -569,15 +569,15 @@ static int f_seek (lua_State *L) { | |||
569 | static const char *const modenames[] = {"set", "cur", "end", NULL}; | 569 | static const char *const modenames[] = {"set", "cur", "end", NULL}; |
570 | FILE *f = tofile(L); | 570 | FILE *f = tofile(L); |
571 | int op = luaL_checkoption(L, 2, "cur", modenames); | 571 | int op = luaL_checkoption(L, 2, "cur", modenames); |
572 | lua_Number p3 = luaL_optnumber(L, 3, 0); | 572 | lua_Integer p3 = luaL_optinteger(L, 3, 0); |
573 | l_seeknum offset = (l_seeknum)p3; | 573 | l_seeknum offset = (l_seeknum)p3; |
574 | luaL_argcheck(L, (lua_Number)offset == p3, 3, | 574 | luaL_argcheck(L, (lua_Integer)offset == p3, 3, |
575 | "not an integer in proper range"); | 575 | "not an integer in proper range"); |
576 | op = l_fseek(f, offset, mode[op]); | 576 | op = l_fseek(f, offset, mode[op]); |
577 | if (op) | 577 | if (op) |
578 | return luaL_fileresult(L, 0, NULL); /* error */ | 578 | return luaL_fileresult(L, 0, NULL); /* error */ |
579 | else { | 579 | else { |
580 | lua_pushnumber(L, (lua_Number)l_ftell(f)); | 580 | lua_pushinteger(L, (lua_Integer)l_ftell(f)); |
581 | return 1; | 581 | return 1; |
582 | } | 582 | } |
583 | } | 583 | } |