diff options
Diffstat (limited to 'src/lj_lib.c')
-rw-r--r-- | src/lj_lib.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/lj_lib.c b/src/lj_lib.c index a6681f2b..930e59a0 100644 --- a/src/lj_lib.c +++ b/src/lj_lib.c | |||
@@ -135,8 +135,8 @@ GCstr *lj_lib_checkstr(lua_State *L, int narg) | |||
135 | if (o < L->top) { | 135 | if (o < L->top) { |
136 | if (LJ_LIKELY(tvisstr(o))) { | 136 | if (LJ_LIKELY(tvisstr(o))) { |
137 | return strV(o); | 137 | return strV(o); |
138 | } else if (tvisnum(o)) { | 138 | } else if (tvisnumber(o)) { |
139 | GCstr *s = lj_str_fromnum(L, &o->n); | 139 | GCstr *s = lj_str_fromnumber(L, o); |
140 | setstrV(L, o, s); | 140 | setstrV(L, o, s); |
141 | return s; | 141 | return s; |
142 | } | 142 | } |
@@ -155,14 +155,18 @@ lua_Number lj_lib_checknum(lua_State *L, int narg) | |||
155 | { | 155 | { |
156 | TValue *o = L->base + narg-1; | 156 | TValue *o = L->base + narg-1; |
157 | if (!(o < L->top && | 157 | if (!(o < L->top && |
158 | (tvisnum(o) || (tvisstr(o) && lj_str_tonum(strV(o), o))))) | 158 | (tvisnumber(o) || (tvisstr(o) && lj_str_tonumber(strV(o), o))))) |
159 | lj_err_argt(L, narg, LUA_TNUMBER); | 159 | lj_err_argt(L, narg, LUA_TNUMBER); |
160 | return numV(o); | 160 | return numberVnum(o); |
161 | } | 161 | } |
162 | 162 | ||
163 | int32_t lj_lib_checkint(lua_State *L, int narg) | 163 | int32_t lj_lib_checkint(lua_State *L, int narg) |
164 | { | 164 | { |
165 | return lj_num2int(lj_lib_checknum(L, narg)); | 165 | TValue *o = L->base + narg-1; |
166 | if (!(o < L->top && | ||
167 | (tvisnumber(o) || (tvisstr(o) && lj_str_tonumber(strV(o), o))))) | ||
168 | lj_err_argt(L, narg, LUA_TNUMBER); | ||
169 | return numberVint(o); | ||
166 | } | 170 | } |
167 | 171 | ||
168 | int32_t lj_lib_optint(lua_State *L, int narg, int32_t def) | 172 | int32_t lj_lib_optint(lua_State *L, int narg, int32_t def) |