diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-06-21 14:27:24 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-06-21 14:27:24 -0300 |
commit | de6e5a5919a948965ab39de92fa53ec48792bff7 (patch) | |
tree | 23473dc0bef25f0b74c792cdc4c07e7ce92d2ced | |
parent | 81102d368907bb5c0006d8630a7af683d6a353c5 (diff) | |
download | lua-de6e5a5919a948965ab39de92fa53ec48792bff7.tar.gz lua-de6e5a5919a948965ab39de92fa53ec48792bff7.tar.bz2 lua-de6e5a5919a948965ab39de92fa53ec48792bff7.zip |
small bugs uncovered in a 64-bit machine (where 'long' has 64 bits)
-rw-r--r-- | lbitlib.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -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 | ||
178 | static int b_replace (lua_State *L) { | 178 | static 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); |