From d5ee385b4b5f19934a00408a2addc70f965ea4a9 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Tue, 29 Mar 2022 11:03:54 +0200 Subject: compatibility: reduce the assumption the builtin libc locale is ASCII-compatible This is not clearly defined by the C99 standard. Define ctype-like macros to force it to be ASCII / UTF-8 (not extended ASCII or something like noticed on OpenBSD 3.8). (In practise modern libc libraries are all ASCII and UTF-8-compatible. Otherwise this would break many programs) --- util.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'util.c') diff --git a/util.c b/util.c index ed0b5c9..0b7da06 100644 --- a/util.c +++ b/util.c @@ -1,4 +1,3 @@ -#include #include #include #include @@ -66,8 +65,8 @@ strcasestr(const char *h, const char *n) return (char *)h; for (; *h; ++h) { - for (i = 0; n[i] && tolower((unsigned char)n[i]) == - tolower((unsigned char)h[i]); ++i) + for (i = 0; n[i] && TOLOWER((unsigned char)n[i]) == + TOLOWER((unsigned char)h[i]); ++i) ; if (n[i] == '\0') return (char *)h; @@ -82,7 +81,7 @@ uri_hasscheme(const char *s) { const char *p = s; - for (; isalpha((unsigned char)*p) || isdigit((unsigned char)*p) || + for (; ISALPHA((unsigned char)*p) || ISDIGIT((unsigned char)*p) || *p == '+' || *p == '-' || *p == '.'; p++) ; /* scheme, except if empty and starts with ":" then it is a path */ @@ -109,7 +108,7 @@ uri_parse(const char *s, struct uri *u) } /* scheme / protocol part */ - for (; isalpha((unsigned char)*p) || isdigit((unsigned char)*p) || + for (; ISALPHA((unsigned char)*p) || ISDIGIT((unsigned char)*p) || *p == '+' || *p == '-' || *p == '.'; p++) ; /* scheme, except if empty and starts with ":" then it is a path */ -- cgit v1.2.3