aboutsummaryrefslogtreecommitdiff
path: root/src/lib_io.c
diff options
context:
space:
mode:
authorMike Pall <mike>2025-11-27 17:45:17 +0100
committerMike Pall <mike>2025-11-27 17:45:17 +0100
commitf80b349d5490aa289b2925d297f3f3c618977570 (patch)
tree8d8fb0d2beb3e863592139d603ada63e5aa6ce77 /src/lib_io.c
parent3215838aa744d148e79a8ea0bd7c014e984302cb (diff)
downloadluajit-f80b349d5490aa289b2925d297f3f3c618977570.tar.gz
luajit-f80b349d5490aa289b2925d297f3f3c618977570.tar.bz2
luajit-f80b349d5490aa289b2925d297f3f3c618977570.zip
Unify Lua number to FFI integer conversions.
Phew. #1411
Diffstat (limited to 'src/lib_io.c')
-rw-r--r--src/lib_io.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/lib_io.c b/src/lib_io.c
index 5659ff51..ec7d2545 100644
--- a/src/lib_io.c
+++ b/src/lib_io.c
@@ -127,8 +127,9 @@ static int io_file_readnum(lua_State *L, FILE *fp)
127 lua_Number d; 127 lua_Number d;
128 if (fscanf(fp, LUA_NUMBER_SCAN, &d) == 1) { 128 if (fscanf(fp, LUA_NUMBER_SCAN, &d) == 1) {
129 if (LJ_DUALNUM) { 129 if (LJ_DUALNUM) {
130 int32_t i = lj_num2int(d); 130 int64_t i64;
131 if (d == (lua_Number)i && !tvismzero((cTValue *)&d)) { 131 int32_t i;
132 if (lj_num2int_check(d, i64, i) && !tvismzero((cTValue *)&d)) {
132 setintV(L->top++, i); 133 setintV(L->top++, i);
133 return 1; 134 return 1;
134 } 135 }
@@ -335,7 +336,7 @@ LJLIB_CF(io_method_seek)
335 if (tvisint(o)) 336 if (tvisint(o))
336 ofs = (int64_t)intV(o); 337 ofs = (int64_t)intV(o);
337 else if (tvisnum(o)) 338 else if (tvisnum(o))
338 ofs = (int64_t)numV(o); 339 ofs = lj_num2i64(numV(o));
339 else if (!tvisnil(o)) 340 else if (!tvisnil(o))
340 lj_err_argt(L, 3, LUA_TNUMBER); 341 lj_err_argt(L, 3, LUA_TNUMBER);
341 } 342 }