From 865b54e2acea4fdaa3f302ed225f50281b371d6e Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 17 Sep 2024 16:54:17 -0700 Subject: [PATCH] Use c-ctype.h in lib-src This fixes some unlikely bugs and removes the temptation of using ctype.h. Although some uses were correct, many weren't. * lib-src/ebrowse.c: Include c-ctype.h, not ctype.h. * lib-src/emacsclient.c: Include c-ctype.h, not ctype.h. * lib-src/update-game-score.c: Include c-ctype.h, not ctype.h. All uses changed. --- lib-src/ebrowse.c | 10 +++++----- lib-src/emacsclient.c | 6 +++--- lib-src/update-game-score.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib-src/ebrowse.c b/lib-src/ebrowse.c index 821c29272a4..13c1befdc3e 100644 --- a/lib-src/ebrowse.c +++ b/lib-src/ebrowse.c @@ -22,11 +22,11 @@ along with GNU Emacs. If not, see . */ #include #include #include -#include #include #include #include +#include #include #include #include @@ -1875,7 +1875,7 @@ yylex (void) int_suffixes: /* Integer suffixes. */ - while (isalpha (c)) + while (c_isalpha (c)) GET (c); UNGET (); return CINT; @@ -1907,7 +1907,7 @@ yylex (void) } /* Optional type suffixes. */ - while (isalpha (c)) + while (c_isalpha (c)) GET (c); UNGET (); return CFLOAT; @@ -2158,7 +2158,7 @@ init_scanner (void) /* Set up character class vectors. */ for (i = 0; i < sizeof is_ident; ++i) { - if (i == '_' || isalnum (i)) + if (i == '_' || c_isalnum (i)) is_ident[i] = 1; if (i >= '0' && i <= '9') @@ -2946,7 +2946,7 @@ operator_name (int *sc) MATCH (); /* If this is a simple operator like `+', stop now. */ - if (!isalpha ((unsigned char) *s) && *s != '(' && *s != '[') + if (!c_isalpha (*s) && *s != '(' && *s != '[') break; ++tokens_matched; diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index 8e64f1e92d3..c1ffa1480ec 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c @@ -68,7 +68,6 @@ char *w32_getenv (const char *); #define DEFAULT_TIMEOUT (30) -#include #include #include #include @@ -83,6 +82,7 @@ char *w32_getenv (const char *); #include #include +#include #include #include #include @@ -2124,7 +2124,7 @@ main (int argc, char **argv) unsigned char c; do c = *++p; - while (isdigit (c) || c == ':'); + while (c_isdigit (c) || c == ':'); if (c == 0) { @@ -2136,7 +2136,7 @@ main (int argc, char **argv) } #ifdef WINDOWSNT else if (! IS_ABSOLUTE_FILE_NAME (argv[i]) - && (isalpha (argv[i][0]) && argv[i][1] == ':')) + && (c_isalpha (argv[i][0]) && argv[i][1] == ':')) /* Windows can have a different default directory for each drive, so the cwd passed via "-dir" is not sufficient to account for that. diff --git a/lib-src/update-game-score.c b/lib-src/update-game-score.c index e3b24ad7717..7545d0390c1 100644 --- a/lib-src/update-game-score.c +++ b/lib-src/update-game-score.c @@ -41,11 +41,11 @@ along with GNU Emacs. If not, see . */ #include #include #include -#include #include #include #include +#include #include #ifdef WINDOWSNT @@ -143,7 +143,7 @@ normalize_integer (char *num) { bool neg; char *p; - while (*num != '\n' && isspace (*num)) + while (*num != '\n' && c_isspace (*num)) num++; neg = *num == '-'; num += neg || *num == '-';