@@ -2554,16 +2554,18 @@ typedef U32 line_t;
25542554/* Converts a character KNOWN to represent a hexadecimal digit (0-9, A-F, or
25552555 * a-f) to its numeric value without using any branches. The input is
25562556 * validated only by an assert() in DEBUGGING builds.
2557- *
25582557 * It works by right shifting and isolating the bit that is 0 for the digits,
25592558 * and 1 for at least the alphas A-F, a-f. The bit is shifted to the ones
25602559 * position, and then to the eights position. Both are added together to form
25612560 * 0 if the input is '0'-'9' and to form 9 if alpha. This is added to the
25622561 * final four bits of the input to form the correct value. */
2563- #define XDIGIT_VALUE (c ) (assert(isXDIGIT(c)), \
2564- ((NATIVE_TO_LATIN1(c) >> 6) & 1) /* 1 if alpha; 0 if not */ \
2565- + ((NATIVE_TO_LATIN1 (c ) >> 3 ) & 8 ) /* 8 if alpha; 0 if not */ \
2566- + ((c ) & 0xF )) /* 0-9 if input valid hex digit */
2562+
2563+ #define XDIGIT_VALUE (c ) \
2564+ (assert(isXDIGIT(c)), \
2565+ ( ( (NATIVE_TO_LATIN1(c) & 0x40) >> 3) /* 8 if alpha; 0 if not */ \
2566+ | (NATIVE_TO_LATIN1 (c ) & 0x40) >> 6) /* 1 if alpha; 0 if not */ \
2567+ /* After OR: 9 if alpha, 0 if not */ \
2568+ + ((c ) & 0xF )) /* 0-9 if input valid hex digit */
25672569
25682570/* The argument is a string pointer, which is advanced. */
25692571#define READ_XDIGIT (s ) ((s)++, XDIGIT_VALUE(*((s) - 1)))
0 commit comments