From c98f195eb930422be2829f78696fb4bf79b93677 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 26 May 2014 14:10:22 -0300 Subject: function 'luaV_numtointeger' changed to a global macro 'lua_numtointeger' (tricky, small, and useful in several places) --- lvm.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) (limited to 'lvm.c') diff --git a/lvm.c b/lvm.c index 321320b0..8dc34f75 100644 --- a/lvm.c +++ b/lvm.c @@ -1,5 +1,5 @@ /* -** $Id: lvm.c,v 2.212 2014/05/20 14:12:59 roberto Exp roberto $ +** $Id: lvm.c,v 2.213 2014/05/23 18:32:21 roberto Exp roberto $ ** Lua virtual machine ** See Copyright Notice in lua.h */ @@ -79,22 +79,6 @@ int luaV_tonumber_ (const TValue *obj, lua_Number *n) { } -/* -** Check whether a float number is within the range of a lua_Integer. -** (The comparisons are tricky because of rounding, which can or -** not occur depending on the relative sizes of floats and integers.) -** This function should be called only when 'n' has an integral value. -*/ -int luaV_numtointeger (lua_Number n, lua_Integer *p) { - if (cast_num(LUA_MININTEGER) <= n && n < (LUA_MAXINTEGER + cast_num(1))) { - *p = cast(lua_Integer, n); - lua_assert(cast_num(*p) == n); - return 1; - } - return 0; /* number is outside integer limits */ -} - - /* ** try to convert a value to an integer, rounding up if 'up' is true */ @@ -104,7 +88,7 @@ static int tointeger_aux (const TValue *obj, lua_Integer *p, int up) { if (ttisfloat(obj)) { lua_Number n = fltvalue(obj); n = (up ? -l_floor(-n) : l_floor(n)); - return luaV_numtointeger(n, p); + return lua_numtointeger(n, p); } else if (ttisinteger(obj)) { *p = ivalue(obj); -- cgit v1.2.3-55-g6feb