skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

commit cb8cab7b0304b72393ea3a8db755077b1286a686
parent 86e231a8dfcd1e032bda5f927214bf385222ff02
Author: Olivier Brunel <jjk@jjacky.com>
Date:   Mon,  1 Jan 2024 20:34:05 +0100

Fix bitarray_not when within a single byte

Notably when a=0 (i.e. start on the first bit) it would affect the
entire byte (all 8 bits).

Signed-off-by: Olivier Brunel <jjk@jjacky.com>

Diffstat:
Msrc/libstddjb/bitarray_not.c | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/libstddjb/bitarray_not.c b/src/libstddjb/bitarray_not.c @@ -7,7 +7,7 @@ void bitarray_not (unsigned char *s, size_t a, size_t b) if (!b) return ; b += a ; if ((a >> 3) == ((b-1) >> 3)) - s[a>>3] ^= ((1 << (a & 7)) - 1) ^ ((a << (b & 7)) - 1) ; + s[a>>3] ^= ((1 << (a & 7)) - 1) ^ ((1 << (1 + (b-1 & 7))) - 1) ; else { size_t i = (a>>3) + 1 ;