From 5860237d2f05f6ae45a98569b0d567c2227904c6 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 5 Mar 2016 20:16:14 +0100 Subject: Fix bugs and add a randomised testing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/znot.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/znot.c') diff --git a/src/znot.c b/src/znot.c index bcb17e2..d0e52c0 100644 --- a/src/znot.c +++ b/src/znot.c @@ -18,12 +18,12 @@ znot(z_t a, z_t b) for (n = a->used; n--;) a->chars[n] = ~(a->chars[n]); - bits &= BITS_PER_CHAR - 1; - a->chars[a->used - 1] &= ((zahl_char_t)1 << bits) - 1; + bits = BITS_IN_LAST_CHAR(bits); + if (bits) + a->chars[a->used - 1] &= ((zahl_char_t)1 << bits) - 1; - for (; a->used; a->used--) - if (a->chars[a->used - 1]) - break; + while (a->used && !a->chars[a->used - 1]) + a->used--; if (!a->used) SET_SIGNUM(a, 0); } -- cgit v1.2.3-70-g09d2