From 77420b94d0e49469b20df43d7913150f9668e6ac Mon Sep 17 00:00:00 2001 From: Geoff McLane Date: Mon, 8 May 2017 18:37:04 +0200 Subject: [PATCH] Fix for 'isalnum' in Windows According to the MSN documentation 'isalnum(c)' is only valid when c equals EOF, or is in the range 0 to 255 inclusive. It states the behavior is undefined outside this range, and in Debug mode triggers an assert dialog. --- src/attrs.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/attrs.c b/src/attrs.c index cbcb6a9..4f1c449 100644 --- a/src/attrs.c +++ b/src/attrs.c @@ -1475,13 +1475,21 @@ static void CheckLowerCaseAttrValue( TidyDocImpl* doc, Node *node, AttVal *attva } /* methods for checking value of a specific attribute */ +#ifdef _WIN32 +#define ISUPPER(a) ((a >= 'A') && (a <= 'Z')) +#define ISLOWER(a) ((a >= 'a') && (a <= 'z')) +#define ISNUMERIC(a) ((a >= '0') && (a <= '9')) +#define ISALNUM(a) (ISUPPER(a) || ISLOWER(a) || ISNUMERIC(a)) +#else +#define ISALNUM(a) isalnum(a) +#endif static Bool IsURLCodePoint( ctmbstr p, uint *increment ) { uint c; *increment = TY_(GetUTF8)( p, &c ) + 1; - return isalnum( c ) || + return ISALNUM( c ) || c == '%' || /* not a valid codepoint, but an escape sequence */ c == '#' || /* not a valid codepoint, but a delimiter */ c == '!' ||