From 8caae83d356c80536ac58a84801c861f0e6f0745 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 27 Mar 2017 14:57:11 +0100 Subject: ASCII: Split out a-f test. --- utils/ascii.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'utils/ascii.h') diff --git a/utils/ascii.h b/utils/ascii.h index 55ca89ca2..6f7bf6d9a 100644 --- a/utils/ascii.h +++ b/utils/ascii.h @@ -110,6 +110,17 @@ static inline bool ascii_is_alphanumerical(char c) return (ascii_is_alpha(c) || ascii_is_digit(c)); } +/** + * Test whether a character is 'a' to 'f' (lowercase). + * + * \param[in] c Character to test. + * \return true iff `c` is 'a' to 'f' (lowercase), else false. + */ +static inline bool ascii_is_af_lower(char c) +{ + return (c >= 'a' && c <= 'f'); +} + /** * Test whether a character is hexadecimal (lower case). * @@ -118,8 +129,7 @@ static inline bool ascii_is_alphanumerical(char c) */ static inline bool ascii_is_hex_lower(char c) { - return (ascii_is_digit(c) || - (c >= 'a' && c <= 'f')); + return (ascii_is_digit(c) || ascii_is_af_lower(c)); } /** @@ -154,7 +164,7 @@ static inline bool ascii_is_hex(char c) { return (ascii_is_digit(c) || ascii_is_af_upper(c) || - (c >= 'a' && c <= 'f')); + ascii_is_af_lower(c)); } /** -- cgit v1.2.3