diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2022-03-29 11:03:54 +0200 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2022-03-29 11:03:54 +0200 |
commit | d5ee385b4b5f19934a00408a2addc70f965ea4a9 (patch) | |
tree | 7f023c601b9b04dbd16273e47f3286f7ae61011e /util.c | |
parent | 880256b8bfde746cd54993f3abcb4dc648895af7 (diff) |
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)
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -1,4 +1,3 @@ -#include <ctype.h> #include <errno.h> #include <stdarg.h> #include <stdio.h> @@ -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 */ |