|
@@ -350,23 +350,21 @@ LUA_API size_t lua_stringtonumber (lua_State *L, const char *s) {
|
|
|
|
|
|
|
|
|
LUA_API lua_Number lua_tonumberx (lua_State *L, int idx, int *pisnum) {
|
|
|
- lua_Number n;
|
|
|
+ lua_Number n = 0;
|
|
|
const TValue *o = index2value(L, idx);
|
|
|
int isnum = tonumber(o, &n);
|
|
|
- if (!isnum)
|
|
|
- n = 0; /* call to 'tonumber' may change 'n' even if it fails */
|
|
|
- if (pisnum) *pisnum = isnum;
|
|
|
+ if (pisnum)
|
|
|
+ *pisnum = isnum;
|
|
|
return n;
|
|
|
}
|
|
|
|
|
|
|
|
|
LUA_API lua_Integer lua_tointegerx (lua_State *L, int idx, int *pisnum) {
|
|
|
- lua_Integer res;
|
|
|
+ lua_Integer res = 0;
|
|
|
const TValue *o = index2value(L, idx);
|
|
|
int isnum = tointeger(o, &res);
|
|
|
- if (!isnum)
|
|
|
- res = 0; /* call to 'tointeger' may change 'n' even if it fails */
|
|
|
- if (pisnum) *pisnum = isnum;
|
|
|
+ if (pisnum)
|
|
|
+ *pisnum = isnum;
|
|
|
return res;
|
|
|
}
|
|
|
|