LUA_MAXUNSIGNED was only used to define 2.0^intnumbits (and that
definition was not strictly portable), so it was removed and replaced by a more correct and direct definition for 2.0^intnumbits (only where it was needed)
This commit is contained in:
9
lapi.c
9
lapi.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lapi.c,v 2.218 2014/06/12 19:07:30 roberto Exp roberto $
|
** $Id: lapi.c,v 2.219 2014/06/19 18:27:20 roberto Exp roberto $
|
||||||
** Lua API
|
** Lua API
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -372,6 +372,11 @@ LUA_API lua_Integer lua_tointegerx (lua_State *L, int idx, int *pisnum) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(LUAI_FTWO2N)
|
||||||
|
/* 2.0^(numbits in an integer), computed without roundings */
|
||||||
|
#define LUAI_FTWO2N (cast_num(LUA_MININTEGER) * cast_num(-2))
|
||||||
|
#endif
|
||||||
|
|
||||||
LUA_API lua_Unsigned lua_tounsignedx (lua_State *L, int idx, int *pisnum) {
|
LUA_API lua_Unsigned lua_tounsignedx (lua_State *L, int idx, int *pisnum) {
|
||||||
lua_Unsigned res = 0;
|
lua_Unsigned res = 0;
|
||||||
const TValue *o = index2addr(L, idx);
|
const TValue *o = index2addr(L, idx);
|
||||||
@@ -383,7 +388,7 @@ LUA_API lua_Unsigned lua_tounsignedx (lua_State *L, int idx, int *pisnum) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LUA_TNUMFLT: { /* compute floor(n) % 2^(numbits in an integer) */
|
case LUA_TNUMFLT: { /* compute floor(n) % 2^(numbits in an integer) */
|
||||||
const lua_Number two2n = cast_num(LUA_MAXUNSIGNED) + cast_num(1);
|
const lua_Number two2n = LUAI_FTWO2N;
|
||||||
lua_Number n = fltvalue(o); /* get value */
|
lua_Number n = fltvalue(o); /* get value */
|
||||||
int neg = 0;
|
int neg = 0;
|
||||||
n = l_floor(n); /* get its floor */
|
n = l_floor(n); /* get its floor */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: luaconf.h,v 1.206 2014/06/02 00:03:16 roberto Exp roberto $
|
** $Id: luaconf.h,v 1.207 2014/06/10 19:21:20 roberto Exp roberto $
|
||||||
** Configuration file for Lua
|
** Configuration file for Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -569,7 +569,6 @@
|
|||||||
@@ LUA_INTEGER_FMT is the format for writing integers.
|
@@ LUA_INTEGER_FMT is the format for writing integers.
|
||||||
@@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER.
|
@@ LUA_MAXINTEGER is the maximum value for a LUA_INTEGER.
|
||||||
@@ LUA_MININTEGER is the minimum value for a LUA_INTEGER.
|
@@ LUA_MININTEGER is the minimum value for a LUA_INTEGER.
|
||||||
@@ LUA_MAXUNSIGNED is the maximum value for a LUA_UNSIGNED.
|
|
||||||
@@ lua_integer2str converts an integer to a string.
|
@@ lua_integer2str converts an integer to a string.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -595,7 +594,6 @@
|
|||||||
#define LUA_INTEGER int
|
#define LUA_INTEGER int
|
||||||
#define LUA_INTEGER_FRMLEN ""
|
#define LUA_INTEGER_FRMLEN ""
|
||||||
|
|
||||||
#define LUA_MAXUNSIGNED UINT_MAX
|
|
||||||
#define LUA_MAXINTEGER INT_MAX
|
#define LUA_MAXINTEGER INT_MAX
|
||||||
#define LUA_MININTEGER INT_MIN
|
#define LUA_MININTEGER INT_MIN
|
||||||
|
|
||||||
@@ -604,7 +602,6 @@
|
|||||||
#define LUA_INTEGER long
|
#define LUA_INTEGER long
|
||||||
#define LUA_INTEGER_FRMLEN "l"
|
#define LUA_INTEGER_FRMLEN "l"
|
||||||
|
|
||||||
#define LUA_MAXUNSIGNED ULONG_MAX
|
|
||||||
#define LUA_MAXINTEGER LONG_MAX
|
#define LUA_MAXINTEGER LONG_MAX
|
||||||
#define LUA_MININTEGER LONG_MIN
|
#define LUA_MININTEGER LONG_MIN
|
||||||
|
|
||||||
@@ -615,7 +612,6 @@
|
|||||||
#define LUA_INTEGER __int64
|
#define LUA_INTEGER __int64
|
||||||
#define LUA_INTEGER_FRMLEN "I64"
|
#define LUA_INTEGER_FRMLEN "I64"
|
||||||
|
|
||||||
#define LUA_MAXUNSIGNED _UI64_MAX
|
|
||||||
#define LUA_MAXINTEGER _I64_MAX
|
#define LUA_MAXINTEGER _I64_MAX
|
||||||
#define LUA_MININTEGER _I64_MIN
|
#define LUA_MININTEGER _I64_MIN
|
||||||
|
|
||||||
@@ -624,7 +620,6 @@
|
|||||||
#define LUA_INTEGER long long
|
#define LUA_INTEGER long long
|
||||||
#define LUA_INTEGER_FRMLEN "ll"
|
#define LUA_INTEGER_FRMLEN "ll"
|
||||||
|
|
||||||
#define LUA_MAXUNSIGNED ULLONG_MAX
|
|
||||||
#define LUA_MAXINTEGER LLONG_MAX
|
#define LUA_MAXINTEGER LLONG_MAX
|
||||||
#define LUA_MININTEGER LLONG_MIN
|
#define LUA_MININTEGER LLONG_MIN
|
||||||
|
|
||||||
@@ -639,7 +634,6 @@
|
|||||||
#define LUA_INTEGER short int
|
#define LUA_INTEGER short int
|
||||||
#define LUA_INTEGER_FRMLEN ""
|
#define LUA_INTEGER_FRMLEN ""
|
||||||
|
|
||||||
#define LUA_MAXUNSIGNED ((LUA_UNSIGNED)USHRT_MAX)
|
|
||||||
#define LUA_MAXINTEGER SHRT_MAX
|
#define LUA_MAXINTEGER SHRT_MAX
|
||||||
#define LUA_MININTEGER SHRT_MIN
|
#define LUA_MININTEGER SHRT_MIN
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user