From de6e5a5919a948965ab39de92fa53ec48792bff7 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 21 Jun 2013 14:27:24 -0300 Subject: small bugs uncovered in a 64-bit machine (where 'long' has 64 bits) --- lbitlib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lbitlib.c b/lbitlib.c index faba3c6d..764d1d71 100644 --- a/lbitlib.c +++ b/lbitlib.c @@ -1,5 +1,5 @@ /* -** $Id: lbitlib.c,v 1.18 2013/03/19 13:19:12 roberto Exp roberto $ +** $Id: lbitlib.c,v 1.19 2013/04/16 18:39:37 roberto Exp roberto $ ** Standard library for bitwise operations ** See Copyright Notice in lua.h */ @@ -120,7 +120,7 @@ static int b_arshift (lua_State *L) { else { /* arithmetic shift for 'negative' number */ if (i >= LUA_NBITS) r = ALLONES; else - r = trim((r >> i) | ~(~(b_uint)0 >> i)); /* add signal bit */ + r = trim((r >> i) | ~(trim(~(b_uint)0) >> i)); /* add signal bit */ lua_pushunsigned(L, r); return 1; } @@ -177,7 +177,7 @@ static int b_extract (lua_State *L) { static int b_replace (lua_State *L) { int w; - b_uint r = luaL_checkunsigned(L, 1); + b_uint r = trim(luaL_checkunsigned(L, 1)); b_uint v = luaL_checkunsigned(L, 2); int f = fieldargs(L, 3, &w); int m = mask(w); -- cgit v1.2.3-55-g6feb