mirror of
https://github.com/lua/lua.git
synced 2025-01-14 05:43:00 +08:00
Removed some wrong comments
Both 'tonumber' and 'tointeger' cannot change the out parameter when the conversion fails.
This commit is contained in:
parent
6f1c033d72
commit
508a705c1c
14
lapi.c
14
lapi.c
@ -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_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);
|
const TValue *o = index2value(L, idx);
|
||||||
int isnum = tonumber(o, &n);
|
int isnum = tonumber(o, &n);
|
||||||
if (!isnum)
|
if (pisnum)
|
||||||
n = 0; /* call to 'tonumber' may change 'n' even if it fails */
|
*pisnum = isnum;
|
||||||
if (pisnum) *pisnum = isnum;
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API lua_Integer lua_tointegerx (lua_State *L, int idx, int *pisnum) {
|
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);
|
const TValue *o = index2value(L, idx);
|
||||||
int isnum = tointeger(o, &res);
|
int isnum = tointeger(o, &res);
|
||||||
if (!isnum)
|
if (pisnum)
|
||||||
res = 0; /* call to 'tointeger' may change 'n' even if it fails */
|
*pisnum = isnum;
|
||||||
if (pisnum) *pisnum = isnum;
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user