diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-04-11 16:02:16 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-04-11 16:02:16 -0300 |
commit | 2771050dfa0fe6b2b679a9f91749a1ab19cfe7dd (patch) | |
tree | e2d9eedaada92e98af023d2b6d97bdadb0310107 | |
parent | e1daf10e4cb4276725db1bda8cdf0e3c893f1094 (diff) | |
download | lua-2771050dfa0fe6b2b679a9f91749a1ab19cfe7dd.tar.gz lua-2771050dfa0fe6b2b679a9f91749a1ab19cfe7dd.tar.bz2 lua-2771050dfa0fe6b2b679a9f91749a1ab19cfe7dd.zip |
'MIN/MAX_INTEGER' replaced by 'LUA_MIN/MAXINTEGER'
-rw-r--r-- | llimits.h | 7 | ||||
-rw-r--r-- | lvm.c | 8 |
2 files changed, 6 insertions, 9 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: llimits.h,v 1.110 2014/02/26 12:38:43 roberto Exp roberto $ | 2 | ** $Id: llimits.h,v 1.111 2014/03/07 16:19:00 roberto Exp roberto $ |
3 | ** Limits, basic types, and some other `installation-dependent' definitions | 3 | ** Limits, basic types, and some other `installation-dependent' definitions |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -44,11 +44,8 @@ typedef unsigned char lu_byte; | |||
44 | 44 | ||
45 | 45 | ||
46 | /* maximum value for a lua_Unsigned */ | 46 | /* maximum value for a lua_Unsigned */ |
47 | #define MAX_UINTEGER (~(lua_Unsigned)0) | 47 | #define MAX_UINTEGER (((lua_Unsigned)LUA_MAXINTEGER << 1) + 1u) |
48 | 48 | ||
49 | /* minimum and maximum values for lua_Integer */ | ||
50 | #define MAX_INTEGER ((lua_Integer)(MAX_UINTEGER >> 1)) | ||
51 | #define MIN_INTEGER (~MAX_INTEGER) | ||
52 | 49 | ||
53 | /* | 50 | /* |
54 | ** conversion of pointer to integer | 51 | ** conversion of pointer to integer |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 2.194 2014/04/08 14:28:04 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.195 2014/04/09 17:05:11 roberto Exp roberto $ |
3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -87,7 +87,7 @@ int luaV_tostring (lua_State *L, StkId obj) { | |||
87 | ** This function should be called only when 'n' has an integral value. | 87 | ** This function should be called only when 'n' has an integral value. |
88 | */ | 88 | */ |
89 | int luaV_numtointeger (lua_Number n, lua_Integer *p) { | 89 | int luaV_numtointeger (lua_Number n, lua_Integer *p) { |
90 | if (cast_num(MIN_INTEGER) <= n && n < (MAX_INTEGER + cast_num(1))) { | 90 | if (cast_num(LUA_MININTEGER) <= n && n < (LUA_MAXINTEGER + cast_num(1))) { |
91 | *p = cast_integer(n); | 91 | *p = cast_integer(n); |
92 | lua_assert(cast_num(*p) == n); | 92 | lua_assert(cast_num(*p) == n); |
93 | return 1; | 93 | return 1; |
@@ -343,7 +343,7 @@ void luaV_objlen (lua_State *L, StkId ra, const TValue *rb) { | |||
343 | 343 | ||
344 | 344 | ||
345 | lua_Integer luaV_div (lua_State *L, lua_Integer x, lua_Integer y) { | 345 | lua_Integer luaV_div (lua_State *L, lua_Integer x, lua_Integer y) { |
346 | if (cast_unsigned(y) + 1 <= 1u) { /* special cases: -1 or 0 */ | 346 | if (cast_unsigned(y) + 1u <= 1u) { /* special cases: -1 or 0 */ |
347 | if (y == 0) | 347 | if (y == 0) |
348 | luaG_runerror(L, "attempt to divide by zero"); | 348 | luaG_runerror(L, "attempt to divide by zero"); |
349 | return intop(-, 0, x); /* y==-1; avoid overflow with 0x80000...//-1 */ | 349 | return intop(-, 0, x); /* y==-1; avoid overflow with 0x80000...//-1 */ |
@@ -359,7 +359,7 @@ lua_Integer luaV_div (lua_State *L, lua_Integer x, lua_Integer y) { | |||
359 | 359 | ||
360 | 360 | ||
361 | lua_Integer luaV_mod (lua_State *L, lua_Integer x, lua_Integer y) { | 361 | lua_Integer luaV_mod (lua_State *L, lua_Integer x, lua_Integer y) { |
362 | if (cast_unsigned(y) + 1 <= 1u) { /* special cases: -1 or 0 */ | 362 | if (cast_unsigned(y) + 1u <= 1u) { /* special cases: -1 or 0 */ |
363 | if (y == 0) | 363 | if (y == 0) |
364 | luaG_runerror(L, "attempt to perform 'n%%0'"); | 364 | luaG_runerror(L, "attempt to perform 'n%%0'"); |
365 | return 0; /* y==-1; avoid overflow with 0x80000...%-1 */ | 365 | return 0; /* y==-1; avoid overflow with 0x80000...%-1 */ |