mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-03-14 14:25:19 +00:00
Add compatibility string coercion for fp:seek() argument.
Reported by Magnus Wibeck. #1343
This commit is contained in:
parent
62e362afbb
commit
d508715ab6
@ -18,7 +18,7 @@ lib_ffi.o: lib_ffi.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
|
|||||||
lib_init.o: lib_init.c lua.h luaconf.h lauxlib.h lualib.h lj_arch.h
|
lib_init.o: lib_init.c lua.h luaconf.h lauxlib.h lualib.h lj_arch.h
|
||||||
lib_io.o: lib_io.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
|
lib_io.o: lib_io.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
|
||||||
lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_state.h lj_ff.h \
|
lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_str.h lj_state.h lj_ff.h \
|
||||||
lj_ffdef.h lj_lib.h lj_libdef.h
|
lj_ffdef.h lj_lib.h lj_strscan.h lj_libdef.h
|
||||||
lib_jit.o: lib_jit.c lua.h luaconf.h lauxlib.h lualib.h lj_arch.h \
|
lib_jit.o: lib_jit.c lua.h luaconf.h lauxlib.h lualib.h lj_arch.h \
|
||||||
lj_obj.h lj_def.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h \
|
lj_obj.h lj_def.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h \
|
||||||
lj_bc.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_target.h \
|
lj_bc.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h lj_target.h \
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "lj_state.h"
|
#include "lj_state.h"
|
||||||
#include "lj_ff.h"
|
#include "lj_ff.h"
|
||||||
#include "lj_lib.h"
|
#include "lj_lib.h"
|
||||||
|
#include "lj_strscan.h"
|
||||||
|
|
||||||
/* Userdata payload for I/O file. */
|
/* Userdata payload for I/O file. */
|
||||||
typedef struct IOFileUD {
|
typedef struct IOFileUD {
|
||||||
@ -324,13 +325,14 @@ LJLIB_CF(io_method_seek)
|
|||||||
FILE *fp = io_tofile(L)->fp;
|
FILE *fp = io_tofile(L)->fp;
|
||||||
int opt = lj_lib_checkopt(L, 2, 1, "\3set\3cur\3end");
|
int opt = lj_lib_checkopt(L, 2, 1, "\3set\3cur\3end");
|
||||||
int64_t ofs = 0;
|
int64_t ofs = 0;
|
||||||
cTValue *o;
|
TValue *o;
|
||||||
int res;
|
int res;
|
||||||
if (opt == 0) opt = SEEK_SET;
|
if (opt == 0) opt = SEEK_SET;
|
||||||
else if (opt == 1) opt = SEEK_CUR;
|
else if (opt == 1) opt = SEEK_CUR;
|
||||||
else if (opt == 2) opt = SEEK_END;
|
else if (opt == 2) opt = SEEK_END;
|
||||||
o = L->base+2;
|
o = L->base+2;
|
||||||
if (o < L->top) {
|
if (o < L->top) {
|
||||||
|
if (tvisstr(o)) lj_strscan_num(strV(o), o);
|
||||||
if (tvisint(o))
|
if (tvisint(o))
|
||||||
ofs = (int64_t)intV(o);
|
ofs = (int64_t)intV(o);
|
||||||
else if (tvisnum(o))
|
else if (tvisnum(o))
|
||||||
|
Loading…
Reference in New Issue
Block a user