1
0
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:
Roberto Ierusalimschy 2019-11-28 18:10:26 -03:00
parent 6f1c033d72
commit 508a705c1c

14
lapi.c
View File

@ -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;
}