浏览代码

correction to allow lua_Unsigned larger than usigned int

Roberto Ierusalimschy 14 年之前
父节点
当前提交
c7d4da8746
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      lbitlib.c

+ 2 - 2
lbitlib.c

@@ -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
 ** See Copyright Notice in lua.h
 */
@@ -108,7 +108,7 @@ static int b_rshift (lua_State *L) {
 static int b_arshift (lua_State *L) {
   b_uint r = getuintarg(L, 1);
   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);
   else {  /* arithmetic shift for 'negative' number */
     if (i >= NBITS) r = ALLONES;