From 3ec522429ae933a3035c854aa78d136a06dee0db Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 27 Mar 2017 14:50:36 +0100 Subject: ASCII: Split out A-F test. --- utils/ascii.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/utils/ascii.h b/utils/ascii.h index f08e756a0..55ca89ca2 100644 --- a/utils/ascii.h +++ b/utils/ascii.h @@ -122,6 +122,17 @@ static inline bool ascii_is_hex_lower(char c) (c >= 'a' && c <= 'f')); } +/** + * Test whether a character is 'A' to 'F' (uppercase). + * + * \param[in] c Character to test. + * \return true iff `c` is 'A' to 'F' (uppercase), else false. + */ +static inline bool ascii_is_af_upper(char c) +{ + return (c >= 'A' && c <= 'F'); +} + /** * Test whether a character is hexadecimal (upper case). * @@ -130,8 +141,7 @@ static inline bool ascii_is_hex_lower(char c) */ static inline bool ascii_is_hex_upper(char c) { - return (ascii_is_digit(c) || - (c >= 'A' && c <= 'F')); + return (ascii_is_digit(c) || ascii_is_af_upper(c)); } /** @@ -143,7 +153,7 @@ static inline bool ascii_is_hex_upper(char c) static inline bool ascii_is_hex(char c) { return (ascii_is_digit(c) || - (c >= 'A' && c <= 'F') || + ascii_is_af_upper(c) || (c >= 'a' && c <= 'f')); } -- cgit v1.2.3