diff options
Diffstat (limited to 'src/lj_lib.c')
-rw-r--r-- | src/lj_lib.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/lj_lib.c b/src/lj_lib.c index ae9b9301..4ab27f66 100644 --- a/src/lj_lib.c +++ b/src/lj_lib.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include "lj_bc.h" | 17 | #include "lj_bc.h" |
18 | #include "lj_dispatch.h" | 18 | #include "lj_dispatch.h" |
19 | #include "lj_vm.h" | 19 | #include "lj_vm.h" |
20 | #include "lj_strscan.h" | ||
20 | #include "lj_lib.h" | 21 | #include "lj_lib.h" |
21 | 22 | ||
22 | /* -- Library initialization ---------------------------------------------- */ | 23 | /* -- Library initialization ---------------------------------------------- */ |
@@ -155,8 +156,7 @@ GCstr *lj_lib_optstr(lua_State *L, int narg) | |||
155 | void lj_lib_checknumber(lua_State *L, int narg) | 156 | void lj_lib_checknumber(lua_State *L, int narg) |
156 | { | 157 | { |
157 | TValue *o = L->base + narg-1; | 158 | TValue *o = L->base + narg-1; |
158 | if (!(o < L->top && | 159 | if (!(o < L->top && lj_strscan_numberobj(o))) |
159 | (tvisnumber(o) || (tvisstr(o) && lj_str_tonumber(strV(o), o))))) | ||
160 | lj_err_argt(L, narg, LUA_TNUMBER); | 160 | lj_err_argt(L, narg, LUA_TNUMBER); |
161 | } | 161 | } |
162 | #endif | 162 | #endif |
@@ -165,7 +165,7 @@ lua_Number lj_lib_checknum(lua_State *L, int narg) | |||
165 | { | 165 | { |
166 | TValue *o = L->base + narg-1; | 166 | TValue *o = L->base + narg-1; |
167 | if (!(o < L->top && | 167 | if (!(o < L->top && |
168 | (tvisnumber(o) || (tvisstr(o) && lj_str_tonumber(strV(o), o))))) | 168 | (tvisnumber(o) || (tvisstr(o) && lj_strscan_num(strV(o), o))))) |
169 | lj_err_argt(L, narg, LUA_TNUMBER); | 169 | lj_err_argt(L, narg, LUA_TNUMBER); |
170 | if (LJ_UNLIKELY(tvisint(o))) { | 170 | if (LJ_UNLIKELY(tvisint(o))) { |
171 | lua_Number n = (lua_Number)intV(o); | 171 | lua_Number n = (lua_Number)intV(o); |
@@ -179,8 +179,7 @@ lua_Number lj_lib_checknum(lua_State *L, int narg) | |||
179 | int32_t lj_lib_checkint(lua_State *L, int narg) | 179 | int32_t lj_lib_checkint(lua_State *L, int narg) |
180 | { | 180 | { |
181 | TValue *o = L->base + narg-1; | 181 | TValue *o = L->base + narg-1; |
182 | if (!(o < L->top && | 182 | if (!(o < L->top && lj_strscan_numberobj(o))) |
183 | (tvisnumber(o) || (tvisstr(o) && lj_str_tonumber(strV(o), o))))) | ||
184 | lj_err_argt(L, narg, LUA_TNUMBER); | 183 | lj_err_argt(L, narg, LUA_TNUMBER); |
185 | if (LJ_LIKELY(tvisint(o))) { | 184 | if (LJ_LIKELY(tvisint(o))) { |
186 | return intV(o); | 185 | return intV(o); |
@@ -200,8 +199,7 @@ int32_t lj_lib_optint(lua_State *L, int narg, int32_t def) | |||
200 | int32_t lj_lib_checkbit(lua_State *L, int narg) | 199 | int32_t lj_lib_checkbit(lua_State *L, int narg) |
201 | { | 200 | { |
202 | TValue *o = L->base + narg-1; | 201 | TValue *o = L->base + narg-1; |
203 | if (!(o < L->top && | 202 | if (!(o < L->top && lj_strscan_numberobj(o))) |
204 | (tvisnumber(o) || (tvisstr(o) && lj_str_tonumber(strV(o), o))))) | ||
205 | lj_err_argt(L, narg, LUA_TNUMBER); | 203 | lj_err_argt(L, narg, LUA_TNUMBER); |
206 | if (LJ_LIKELY(tvisint(o))) { | 204 | if (LJ_LIKELY(tvisint(o))) { |
207 | return intV(o); | 205 | return intV(o); |