summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@apple.com>2010-12-02 15:50:28 -0800
committerJeremy Huddleston <jeremyhu@apple.com>2010-12-02 15:50:28 -0800
commit1f1c1ae85600c058f1971e981da9a31eadb71dec (patch)
tree18277a41f868d840cd832d69773b55a2d7c6f489
parent444e180ad12baf9d84ff96f68ec9c16b39fac322 (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> (cherry picked from commit 42dc91e32a02b6b21ff5c45f465f3349e5822615)
-rw-r--r--include/inputstr.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/inputstr.h b/include/inputstr.h
index 1b504e939..df6721093 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)))