From fcda76f684045787d9b1af94718252ae0005aa39 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 13 Mar 2020 11:43:31 +0100 Subject: [PATCH] build: restore non-UTF8 fallbacks, to allow compiling with --disable-utf8 Commits b2c63c3d and 004af03e from yesterday mistakenly removed those calls. --- src/chars.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/chars.c b/src/chars.c index 5f268123..023ed87f 100644 --- a/src/chars.c +++ b/src/chars.c @@ -47,28 +47,37 @@ bool using_utf8(void) /* Return TRUE when the given character is some kind of letter. */ bool is_alpha_char(const char *c) { +#ifdef ENABLE_UTF8 wchar_t wc; if (mbtowc(&wc, c, MAXCHARLEN) < 0) return FALSE; return iswalpha(wc); +#else + return isalpha((unsigned char)*c); +#endif } /* Return TRUE when the given character is some kind of letter or a digit. */ bool is_alnum_char(const char *c) { +#ifdef ENABLE_UTF8 wchar_t wc; if (mbtowc(&wc, c, MAXCHARLEN) < 0) return FALSE; return iswalnum(wc); +#else + return isalnum((unsigned char)*c); +#endif } /* Return TRUE when the given character is space or tab or other whitespace. */ bool is_blank_char(const char *c) { +#ifdef ENABLE_UTF8 wchar_t wc; if ((signed char)*c >= 0) @@ -78,6 +87,9 @@ bool is_blank_char(const char *c) return FALSE; return iswblank(wc); +#else + return isblank((unsigned char)*c); +#endif } /* Return TRUE when the given character is a control character. */ @@ -95,12 +107,16 @@ bool is_cntrl_char(const char *c) /* Return TRUE when the given character is a punctuation character. */ bool is_punct_char(const char *c) { +#ifdef ENABLE_UTF8 wchar_t wc; if (mbtowc(&wc, c, MAXCHARLEN) < 0) return FALSE; return iswpunct(wc); +#else + return ispunct((unsigned char)*c); +#endif } /* Return TRUE when the given character is word-forming (it is alphanumeric or