summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2010-11-24 14:20:30 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2010-11-26 09:59:24 +1000
commit42dc91e32a02b6b21ff5c45f465f3349e5822615 (patch)
tree3d00c985dc42fbcc61bba1dc3d091480cdda6d73 /include
parent4e0f8f666e61390206c42ad2087477a912525bc7 (diff)
include: let BitIsOn() return a boolean value.
Simply returning the mask bit breaks checks like BitIsOn(mask, 0) != BitIsOn(mask, 1); as used in 048e93593e3f7a99a7d2a219e1ce2bdc9d407807. The naming of this macro suggests that it should return boolean values anyway. This patch also adds a few simple tests for these macros to make sure they don't accidentally break in the future. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Pat Kane <pekane52@gmail.com> Reviewed-by: Julien Cristau <jcristau@debian.org> Reviewed-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'include')
-rw-r--r--include/inputstr.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/inputstr.h b/include/inputstr.h
index d4c253eac..44de9c44a 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -57,7 +57,7 @@ SOFTWARE.
#include "geext.h"
#include "privates.h"
-#define BitIsOn(ptr, bit) (((BYTE *) (ptr))[(bit)>>3] & (1 << ((bit) & 7)))
+#define BitIsOn(ptr, bit) (!!(((BYTE *) (ptr))[(bit)>>3] & (1 << ((bit) & 7))))
#define SetBit(ptr, bit) (((BYTE *) (ptr))[(bit)>>3] |= (1 << ((bit) & 7)))
#define ClearBit(ptr, bit) (((BYTE *)(ptr))[(bit)>>3] &= ~(1 << ((bit) & 7)))
extern _X_EXPORT int CountBits(const uint8_t *mask, int len);