Minor code cleanup.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
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)
{