aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lbitlib.c6
1 files 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 @@
1/* 1/*
2** $Id: lbitlib.c,v 1.18 2013/03/19 13:19:12 roberto Exp roberto $ 2** $Id: lbitlib.c,v 1.19 2013/04/16 18:39:37 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*/
@@ -120,7 +120,7 @@ static int b_arshift (lua_State *L) {
120 else { /* arithmetic shift for 'negative' number */ 120 else { /* arithmetic shift for 'negative' number */
121 if (i >= LUA_NBITS) r = ALLONES; 121 if (i >= LUA_NBITS) r = ALLONES;
122 else 122 else
123 r = trim((r >> i) | ~(~(b_uint)0 >> i)); /* add signal bit */ 123 r = trim((r >> i) | ~(trim(~(b_uint)0) >> i)); /* add signal bit */
124 lua_pushunsigned(L, r); 124 lua_pushunsigned(L, r);
125 return 1; 125 return 1;
126 } 126 }
@@ -177,7 +177,7 @@ static int b_extract (lua_State *L) {
177 177
178static int b_replace (lua_State *L) { 178static int b_replace (lua_State *L) {
179 int w; 179 int w;
180 b_uint r = luaL_checkunsigned(L, 1); 180 b_uint r = trim(luaL_checkunsigned(L, 1));
181 b_uint v = luaL_checkunsigned(L, 2); 181 b_uint v = luaL_checkunsigned(L, 2);
182 int f = fieldargs(L, 3, &w); 182 int f = fieldargs(L, 3, &w);
183 int m = mask(w); 183 int m = mask(w);