1
0
mirror of https://github.com/lua/lua.git synced 2025-01-14 05:43:00 +08:00

correction to allow lua_Unsigned larger than usigned int

This commit is contained in:
Roberto Ierusalimschy 2010-11-08 14:31:22 -02:00
parent f1629217f1
commit c7d4da8746

View File

@ -1,5 +1,5 @@
/* /*
** $Id: lbitlib.c,v 1.9 2010/10/27 16:50:32 roberto Exp roberto $ ** $Id: lbitlib.c,v 1.10 2010/10/28 15:17:29 roberto Exp roberto $
** Standard library for bitwise operations ** Standard library for bitwise operations
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -108,7 +108,7 @@ static int b_rshift (lua_State *L) {
static int b_arshift (lua_State *L) { static int b_arshift (lua_State *L) {
b_uint r = getuintarg(L, 1); b_uint r = getuintarg(L, 1);
int i = luaL_checkint(L, 2); int i = luaL_checkint(L, 2);
if (i < 0 || !(r & (1 << (NBITS - 1)))) if (i < 0 || !(r & ((b_uint)1 << (NBITS - 1))))
return b_shift(L, r, -i); return b_shift(L, r, -i);
else { /* arithmetic shift for 'negative' number */ else { /* arithmetic shift for 'negative' number */
if (i >= NBITS) r = ALLONES; if (i >= NBITS) r = ALLONES;