diff options
Diffstat (limited to 'src/lj_meta.c')
-rw-r--r-- | src/lj_meta.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/lj_meta.c b/src/lj_meta.c index ab8099e8..b33cb88d 100644 --- a/src/lj_meta.c +++ b/src/lj_meta.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include "lj_frame.h" | 18 | #include "lj_frame.h" |
19 | #include "lj_bc.h" | 19 | #include "lj_bc.h" |
20 | #include "lj_vm.h" | 20 | #include "lj_vm.h" |
21 | #include "lj_strscan.h" | ||
21 | 22 | ||
22 | /* -- Metamethod handling ------------------------------------------------- */ | 23 | /* -- Metamethod handling ------------------------------------------------- */ |
23 | 24 | ||
@@ -193,7 +194,7 @@ static cTValue *str2num(cTValue *o, TValue *n) | |||
193 | return o; | 194 | return o; |
194 | else if (tvisint(o)) | 195 | else if (tvisint(o)) |
195 | return (setnumV(n, (lua_Number)intV(o)), n); | 196 | return (setnumV(n, (lua_Number)intV(o)), n); |
196 | else if (tvisstr(o) && lj_str_tonum(strV(o), n)) | 197 | else if (tvisstr(o) && lj_strscan_num(strV(o), n)) |
197 | return n; | 198 | return n; |
198 | else | 199 | else |
199 | return NULL; | 200 | return NULL; |
@@ -436,12 +437,9 @@ void lj_meta_call(lua_State *L, TValue *func, TValue *top) | |||
436 | /* Helper for FORI. Coercion. */ | 437 | /* Helper for FORI. Coercion. */ |
437 | void LJ_FASTCALL lj_meta_for(lua_State *L, TValue *o) | 438 | void LJ_FASTCALL lj_meta_for(lua_State *L, TValue *o) |
438 | { | 439 | { |
439 | if (!(tvisnumber(o) || (tvisstr(o) && lj_str_tonumber(strV(o), o)))) | 440 | if (!lj_strscan_numberobj(o)) lj_err_msg(L, LJ_ERR_FORINIT); |
440 | lj_err_msg(L, LJ_ERR_FORINIT); | 441 | if (!lj_strscan_numberobj(o+1)) lj_err_msg(L, LJ_ERR_FORLIM); |
441 | if (!(tvisnumber(o+1) || (tvisstr(o+1) && lj_str_tonumber(strV(o+1), o+1)))) | 442 | if (!lj_strscan_numberobj(o+2)) lj_err_msg(L, LJ_ERR_FORSTEP); |
442 | lj_err_msg(L, LJ_ERR_FORLIM); | ||
443 | if (!(tvisnumber(o+2) || (tvisstr(o+2) && lj_str_tonumber(strV(o+2), o+2)))) | ||
444 | lj_err_msg(L, LJ_ERR_FORSTEP); | ||
445 | if (LJ_DUALNUM) { | 443 | if (LJ_DUALNUM) { |
446 | /* Ensure all slots are integers or all slots are numbers. */ | 444 | /* Ensure all slots are integers or all slots are numbers. */ |
447 | int32_t k[3]; | 445 | int32_t k[3]; |