handy.h: Add debugging assertion
authorKarl Williamson <public@khwilliamson.com>
Wed, 1 Jan 2014 05:19:45 +0000 (22:19 -0700)
committerKarl Williamson <public@khwilliamson.com>
Wed, 1 Jan 2014 20:49:24 +0000 (13:49 -0700)
This macro requires the input to be a hex digit, without testing.  It is
prudent to assert that under DEBUGGING.

handy.h

diff --git a/handy.h b/handy.h
index fb84cb9..c4a162d 100644 (file)
--- a/handy.h
+++ b/handy.h
@@ -1568,7 +1568,9 @@ typedef U32 line_t;
  * pointer.  The input must be known to be 0-9, A-F, or a-f.  In both ASCII and
  * EBCDIC the last 4 bits of the digits are 0-9; and the last 4 bits of A-F and
  * a-f are 1-6, so adding 9 yields 10-15 */
-#define READ_XDIGIT(s)  (0xf & (isDIGIT(*(s)) ? (*(s)++) : (*(s)++ + 9)))
+#define READ_XDIGIT(s)  (__ASSERT_(isXDIGIT(*s)) (0xf & (isDIGIT(*(s))     \
+                                                        ? (*(s)++)         \
+                                                        : (*(s)++ + 9))))
 
 /*
 =head1 Memory Management