Commit 2726b7cb5e848a098cef55688932806a16c98bc7

Martin Mitas 2017-01-01T17:40:02

Minor code cleanup.

diff --git a/md4c/md4c.c b/md4c/md4c.c
index 8682c89..3a8d1cf 100644
--- a/md4c/md4c.c
+++ b/md4c/md4c.c
@@ -243,34 +243,36 @@ struct MD_VERBATIMLINE_tag {
 
 /* Character classification.
  * Note we assume ASCII compatibility of code points < 128 here. */
-#define ISASCII_(ch)            ((unsigned)(ch) <= 127)
-#define ISBLANK_(ch)            ((unsigned)(ch) == _T(' ') || (unsigned)(ch) == _T('\t'))
-#define ISNEWLINE_(ch)          ((unsigned)(ch) == _T('\r') || (unsigned)(ch) == _T('\n'))
-#define ISWHITESPACE_(ch)       (ISBLANK_(ch) || ch == _T('\v') || ch == _T('\f'))
-#define ISCNTRL_(ch)            ((unsigned)(ch) <= 31 || (unsigned)(ch) == 127)
-#define ISPUNCT_(ch)            ((33 <= (unsigned)(ch) && (unsigned)(ch) <= 47) || (58 <= (unsigned)(ch) && (unsigned)(ch) <= 64) || (91 <= (unsigned)(ch) && (unsigned)(ch) <= 96) || (123 <= (unsigned)(ch) && (unsigned)(ch) <= 126))
-#define ISUPPER_(ch)            (_T('A') <= (unsigned)(ch) && (unsigned)(ch) <= _T('Z'))
-#define ISLOWER_(ch)            (_T('a') <= (unsigned)(ch) && (unsigned)(ch) <= _T('z'))
-#define ISALPHA_(ch)            (ISUPPER_(ch) || ISLOWER_(ch))
-#define ISDIGIT_(ch)            (_T('0') <= (unsigned)(ch) && (unsigned)(ch) <= _T('9'))
-#define ISXDIGIT_(ch)           (ISDIGIT_(ch) || (_T('a') <= (unsigned)(ch) && (unsigned)(ch) <= _T('f')) || (_T('A') <= (unsigned)(ch) && (unsigned)(ch) <= _T('F')))
-#define ISALNUM_(ch)            (ISALPHA_(ch) || ISDIGIT_(ch))
-#define ISANYOF_(ch, palette)   (md_strchr((palette), (ch)) != NULL)
-
-#define ISASCII(off)            ISASCII_(CH(off))
-#define ISBLANK(off)            ISBLANK_(CH(off))
-#define ISNEWLINE(off)          ISNEWLINE_(CH(off))
-#define ISWHITESPACE(off)       ISWHITESPACE_(CH(off))
-#define ISCNTRL(off)            ISCNTRL_(CH(off))
-#define ISPUNCT(off)            ISPUNCT_(CH(off))
-#define ISUPPER(off)            ISUPPER_(CH(off))
-#define ISLOWER(off)            ISLOWER_(CH(off))
-#define ISALPHA(off)            ISALPHA_(CH(off))
-#define ISDIGIT(off)            ISDIGIT_(CH(off))
-#define ISXDIGIT(off)           ISXDIGIT_(CH(off))
-#define ISALNUM(off)            ISALNUM_(CH(off))
-#define ISANYOF(off, palette)   ISANYOF_(CH(off), (palette))
-
+#define ISIN_(ch, ch_min, ch_max)   ((ch_min) <= (unsigned)(ch) && (unsigned)(ch) <= (ch_max))
+#define ISANYOF_(ch, palette)       (md_strchr((palette), (ch)) != NULL)
+#define ISANYOF2_(ch, ch1, ch2)     ((ch) == (ch1) || (ch) == (ch2))
+#define ISASCII_(ch)                ((unsigned)(ch) <= 127)
+#define ISBLANK_(ch)                (ISANYOF2_((ch), _T(' '), _T('\t')))
+#define ISNEWLINE_(ch)              (ISANYOF2_((ch), _T('\r'), _T('\n')))
+#define ISWHITESPACE_(ch)           (ISBLANK_(ch) || ISANYOF2_((ch), _T('\v'), _T('\f')))
+#define ISCNTRL_(ch)                ((unsigned)(ch) <= 31 || (unsigned)(ch) == 127)
+#define ISPUNCT_(ch)                (ISIN_(ch, 33, 47) || ISIN_(ch, 58, 64) || ISIN_(ch, 91, 96) || ISIN_(ch, 123, 126))
+#define ISUPPER_(ch)                (ISIN_(ch, _T('A'), _T('Z')))
+#define ISLOWER_(ch)                (ISIN_(ch, _T('a'), _T('z')))
+#define ISALPHA_(ch)                (ISUPPER_(ch) || ISLOWER_(ch))
+#define ISDIGIT_(ch)                (ISIN_(ch, _T('0'), _T('9')))
+#define ISXDIGIT_(ch)               (ISDIGIT_(ch) || ISIN_(ch, _T('A'), _T('F')) || ISIN_(ch, _T('a'), _T('f')))
+#define ISALNUM_(ch)                (ISALPHA_(ch) || ISDIGIT_(ch))
+
+#define ISANYOF(off, palette)       ISANYOF_(CH(off), (palette))
+#define ISANYOF2(off, ch1, ch2)     ISANYOF2_(CH(off), (ch1), (ch2))
+#define ISASCII(off)                ISASCII_(CH(off))
+#define ISBLANK(off)                ISBLANK_(CH(off))
+#define ISNEWLINE(off)              ISNEWLINE_(CH(off))
+#define ISWHITESPACE(off)           ISWHITESPACE_(CH(off))
+#define ISCNTRL(off)                ISCNTRL_(CH(off))
+#define ISPUNCT(off)                ISPUNCT_(CH(off))
+#define ISUPPER(off)                ISUPPER_(CH(off))
+#define ISLOWER(off)                ISLOWER_(CH(off))
+#define ISALPHA(off)                ISALPHA_(CH(off))
+#define ISDIGIT(off)                ISDIGIT_(CH(off))
+#define ISXDIGIT(off)               ISXDIGIT_(CH(off))
+#define ISALNUM(off)                ISALNUM_(CH(off))
 static inline const CHAR*
 md_strchr(const CHAR* str, CHAR ch)
 {