diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-11-08 14:31:22 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-11-08 14:31:22 -0200 |
commit | c7d4da8746bc03542501db3fc0c7fff7f8bc60ce (patch) | |
tree | 86bbc498c1640a5c306852d6c0b2ca5609e7a778 | |
parent | f1629217f136c37b58c912692b4d78f4314b4795 (diff) | |
download | lua-c7d4da8746bc03542501db3fc0c7fff7f8bc60ce.tar.gz lua-c7d4da8746bc03542501db3fc0c7fff7f8bc60ce.tar.bz2 lua-c7d4da8746bc03542501db3fc0c7fff7f8bc60ce.zip |
correction to allow lua_Unsigned larger than usigned int
-rw-r--r-- | lbitlib.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbitlib.c,v 1.9 2010/10/27 16:50:32 roberto Exp roberto $ | 2 | ** $Id: lbitlib.c,v 1.10 2010/10/28 15:17:29 roberto Exp roberto $ |
3 | ** Standard library for bitwise operations | 3 | ** Standard library for bitwise operations |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -108,7 +108,7 @@ static int b_rshift (lua_State *L) { | |||
108 | static int b_arshift (lua_State *L) { | 108 | static int b_arshift (lua_State *L) { |
109 | b_uint r = getuintarg(L, 1); | 109 | b_uint r = getuintarg(L, 1); |
110 | int i = luaL_checkint(L, 2); | 110 | int i = luaL_checkint(L, 2); |
111 | if (i < 0 || !(r & (1 << (NBITS - 1)))) | 111 | if (i < 0 || !(r & ((b_uint)1 << (NBITS - 1)))) |
112 | return b_shift(L, r, -i); | 112 | return b_shift(L, r, -i); |
113 | else { /* arithmetic shift for 'negative' number */ | 113 | else { /* arithmetic shift for 'negative' number */ |
114 | if (i >= NBITS) r = ALLONES; | 114 | if (i >= NBITS) r = ALLONES; |