diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-11-28 18:10:26 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-11-28 18:10:26 -0300 |
commit | 508a705c1c08d883473199d6ba019d186c28b9df (patch) | |
tree | ac1c5f17ee4356754158701cdf9c691922115df5 | |
parent | 6f1c033d72af8fe65bb67e17a242314b6aeb182f (diff) | |
download | lua-508a705c1c08d883473199d6ba019d186c28b9df.tar.gz lua-508a705c1c08d883473199d6ba019d186c28b9df.tar.bz2 lua-508a705c1c08d883473199d6ba019d186c28b9df.zip |
Removed some wrong comments
Both 'tonumber' and 'tointeger' cannot change the out parameter when
the conversion fails.
-rw-r--r-- | lapi.c | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -350,23 +350,21 @@ LUA_API size_t lua_stringtonumber (lua_State *L, const char *s) { | |||
350 | 350 | ||
351 | 351 | ||
352 | LUA_API lua_Number lua_tonumberx (lua_State *L, int idx, int *pisnum) { | 352 | LUA_API lua_Number lua_tonumberx (lua_State *L, int idx, int *pisnum) { |
353 | lua_Number n; | 353 | lua_Number n = 0; |
354 | const TValue *o = index2value(L, idx); | 354 | const TValue *o = index2value(L, idx); |
355 | int isnum = tonumber(o, &n); | 355 | int isnum = tonumber(o, &n); |
356 | if (!isnum) | 356 | if (pisnum) |
357 | n = 0; /* call to 'tonumber' may change 'n' even if it fails */ | 357 | *pisnum = isnum; |
358 | if (pisnum) *pisnum = isnum; | ||
359 | return n; | 358 | return n; |
360 | } | 359 | } |
361 | 360 | ||
362 | 361 | ||
363 | LUA_API lua_Integer lua_tointegerx (lua_State *L, int idx, int *pisnum) { | 362 | LUA_API lua_Integer lua_tointegerx (lua_State *L, int idx, int *pisnum) { |
364 | lua_Integer res; | 363 | lua_Integer res = 0; |
365 | const TValue *o = index2value(L, idx); | 364 | const TValue *o = index2value(L, idx); |
366 | int isnum = tointeger(o, &res); | 365 | int isnum = tointeger(o, &res); |
367 | if (!isnum) | 366 | if (pisnum) |
368 | res = 0; /* call to 'tointeger' may change 'n' even if it fails */ | 367 | *pisnum = isnum; |
369 | if (pisnum) *pisnum = isnum; | ||
370 | return res; | 368 | return res; |
371 | } | 369 | } |
372 | 370 | ||