diff options
author | Stephan Mühlstrasser <stm@pdflib.com> | 2018-04-13 14:28:55 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2018-04-24 14:36:06 +0200 |
commit | dd7521bcc1b7a6fcb53c31f9bd1192fcc884bd56 (patch) | |
tree | f2b955ee5e5da25225901d8ed58379a7dfe65ca9 /lib/curl_ctype.h | |
parent | e6c22368c6e5426ec2b1cb8a3041ebc98d0ad402 (diff) | |
download | curl-dd7521bcc1b7a6fcb53c31f9bd1192fcc884bd56.tar.gz |
ctype: restore character classification for non-ASCII platforms
With commit 4272a0b0fc49a1ac0ceab5c4a365c9f6ab8bf8e2 curl-speficic
character classification macros and functions were introduced in
curl_ctype.[ch] to avoid dependencies on the locale. This broke curl on
non-ASCII, e.g. EBCDIC platforms. This change restores the previous set
of character classification macros when CURL_DOES_CONVERSIONS is
defined.
Closes #2494
Diffstat (limited to 'lib/curl_ctype.h')
-rw-r--r-- | lib/curl_ctype.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/curl_ctype.h b/lib/curl_ctype.h index da3bd95a6..1ffecb99a 100644 --- a/lib/curl_ctype.h +++ b/lib/curl_ctype.h @@ -22,6 +22,33 @@ * ***************************************************************************/ +#include "curl_setup.h" + +#ifdef CURL_DOES_CONVERSIONS + +/* + * Uppercase macro versions of ANSI/ISO is*() functions/macros which + * avoid negative number inputs with argument byte codes > 127. + * + * For non-ASCII platforms the C library character classification routines + * are used despite being locale-dependent, because this is better than + * not to work at all. + */ +#include <ctype.h> + +#define ISSPACE(x) (isspace((int) ((unsigned char)x))) +#define ISDIGIT(x) (isdigit((int) ((unsigned char)x))) +#define ISALNUM(x) (isalnum((int) ((unsigned char)x))) +#define ISXDIGIT(x) (isxdigit((int) ((unsigned char)x))) +#define ISGRAPH(x) (isgraph((int) ((unsigned char)x))) +#define ISALPHA(x) (isalpha((int) ((unsigned char)x))) +#define ISPRINT(x) (isprint((int) ((unsigned char)x))) +#define ISUPPER(x) (isupper((int) ((unsigned char)x))) +#define ISLOWER(x) (islower((int) ((unsigned char)x))) +#define ISASCII(x) (isascii((int) ((unsigned char)x))) + +#else + int Curl_isspace(int c); int Curl_isdigit(int c); int Curl_isalnum(int c); @@ -42,6 +69,9 @@ int Curl_islower(int c); #define ISUPPER(x) (Curl_isupper((int) ((unsigned char)x))) #define ISLOWER(x) (Curl_islower((int) ((unsigned char)x))) #define ISASCII(x) (((x) >= 0) && ((x) <= 0x80)) + +#endif + #define ISBLANK(x) (int)((((unsigned char)x) == ' ') || \ (((unsigned char)x) == '\t')) |