diff options
Diffstat (limited to 'src/lib_io.c')
-rw-r--r-- | src/lib_io.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/lib_io.c b/src/lib_io.c index d3dac7a0..f4888c1c 100644 --- a/src/lib_io.c +++ b/src/lib_io.c | |||
@@ -137,6 +137,13 @@ static int io_file_readnum(lua_State *L, FILE *fp) | |||
137 | { | 137 | { |
138 | lua_Number d; | 138 | lua_Number d; |
139 | if (fscanf(fp, LUA_NUMBER_SCAN, &d) == 1) { | 139 | if (fscanf(fp, LUA_NUMBER_SCAN, &d) == 1) { |
140 | if (LJ_DUALNUM) { | ||
141 | int32_t i = lj_num2int(d); | ||
142 | if (d == (lua_Number)i && !tvismzero((cTValue *)&d)) { | ||
143 | setintV(L->top++, i); | ||
144 | return 1; | ||
145 | } | ||
146 | } | ||
140 | setnumV(L->top++, d); | 147 | setnumV(L->top++, d); |
141 | return 1; | 148 | return 1; |
142 | } else { | 149 | } else { |
@@ -217,7 +224,7 @@ static int io_file_read(lua_State *L, FILE *fp, int start) | |||
217 | io_file_readchars(L, fp, ~((size_t)0)); | 224 | io_file_readchars(L, fp, ~((size_t)0)); |
218 | else | 225 | else |
219 | lj_err_arg(L, n+1, LJ_ERR_INVFMT); | 226 | lj_err_arg(L, n+1, LJ_ERR_INVFMT); |
220 | } else if (tvisnum(L->base+n)) { | 227 | } else if (tvisnumber(L->base+n)) { |
221 | size_t len = (size_t)lj_lib_checkint(L, n+1); | 228 | size_t len = (size_t)lj_lib_checkint(L, n+1); |
222 | ok = len ? io_file_readchars(L, fp, len) : io_file_testeof(L, fp); | 229 | ok = len ? io_file_readchars(L, fp, len) : io_file_testeof(L, fp); |
223 | } else { | 230 | } else { |