diff options
author | Olivier Brunel <jjk@jjacky.com> | 2024-01-01 20:34:05 +0100 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2024-01-02 02:05:02 +0000 |
commit | cb8cab7b0304b72393ea3a8db755077b1286a686 (patch) | |
tree | 2ac21c36b8664a20b846aae4d4890d8a57dee5d3 | |
parent | 86e231a8dfcd1e032bda5f927214bf385222ff02 (diff) | |
download | skalibs-cb8cab7b0304b72393ea3a8db755077b1286a686.tar.xz |
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>
-rw-r--r-- | src/libstddjb/bitarray_not.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libstddjb/bitarray_not.c b/src/libstddjb/bitarray_not.c index 6c4149e..1e9f5af 100644 --- 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 ; |