From 4887683ab00cfed3fc43cbec46b2bfb5aef129ff Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 23 Aug 2024 10:00:26 -0700 Subject: [PATCH] maint: assume STDC_HEADERS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don’t need to worry about pre-C89 any more. * src/common.h (CTYPE_DOMAIN, ISSPACE): Remove. All uses of ISSPACE replaced by isspace. (errno): Remove decl. --- src/common.h | 14 -------------- src/inp.c | 8 ++++---- src/pch.c | 12 ++++++------ src/util.c | 10 +++++----- src/util.h | 2 +- 5 files changed, 16 insertions(+), 30 deletions(-) diff --git a/src/common.h b/src/common.h index 53c5e32..32f6046 100644 --- a/src/common.h +++ b/src/common.h @@ -42,16 +42,6 @@ #include #include -/* CTYPE_DOMAIN (C) is nonzero if the unsigned char C can safely be given - as an argument to macros like 'isspace'. */ -#if STDC_HEADERS -#define CTYPE_DOMAIN(c) 1 -#else -#define CTYPE_DOMAIN(c) ((unsigned) (c) <= 0177) -#endif -#ifndef ISSPACE -#define ISSPACE(c) (CTYPE_DOMAIN (c) && isspace (c)) -#endif #ifndef ISDIGIT #define ISDIGIT(c) ((unsigned) (c) - '0' <= 9) @@ -149,10 +139,6 @@ XTERN char *revision; /* prerequisite revision, if any */ void fatal_exit (int) __attribute__ ((noreturn)); #include -#if !STDC_HEADERS && !defined errno -extern int errno; -#endif - #include #include #include diff --git a/src/inp.c b/src/inp.c index 22d7473..28f526c 100644 --- a/src/inp.c +++ b/src/inp.c @@ -323,8 +323,8 @@ plan_a (char const *filename) for (s = buffer; (s = (char *) memchr (s, rev0, limrev - s)); s++) if (memcmp (s, rev, revlen) == 0 - && (s == buffer || ISSPACE ((unsigned char) s[-1])) - && (s + 1 == limrev || ISSPACE ((unsigned char) s[revlen]))) + && (s == buffer || isspace ((unsigned char) s[-1])) + && (s + 1 == limrev || isspace ((unsigned char) s[revlen]))) { found_revision = true; break; @@ -402,13 +402,13 @@ plan_b (char const *filename) { if (i == revlen) { - found_revision = ISSPACE ((unsigned char) c); + found_revision = isspace ((unsigned char) c); i = (size_t) -1; } else if (i != (size_t) -1) i = rev[i]==c ? i + 1 : (size_t) -1; - if (i == (size_t) -1 && ISSPACE ((unsigned char) c)) + if (i == (size_t) -1 && isspace ((unsigned char) c)) i = 0; } } diff --git a/src/pch.c b/src/pch.c index fd9c480..1884595 100644 --- a/src/pch.c +++ b/src/pch.c @@ -328,7 +328,7 @@ fetchmode (char const *str) const char *s; mode_t mode; - while (ISSPACE ((unsigned char) *str)) + while (isspace ((unsigned char) *str)) str++; for (s = str, mode = 0; s < str + 6; s++) @@ -570,14 +570,14 @@ intuit_diff_type (bool need_header, mode_t *p_file_type) } else if (strnEQ(s, "Prereq:", 7)) { - for (t = s + 7; ISSPACE ((unsigned char) *t); t++) + for (t = s + 7; isspace ((unsigned char) *t); t++) /* do nothing */ ; revision = t; for (t = revision; *t; t++) - if (ISSPACE ((unsigned char) *t)) + if (isspace ((unsigned char) *t)) { char const *u; - for (u = t + 1; ISSPACE ((unsigned char) *u); u++) + for (u = t + 1; isspace ((unsigned char) *u); u++) /* do nothing */ ; if (*u) { @@ -615,7 +615,7 @@ intuit_diff_type (bool need_header, mode_t *p_file_type) p_name[i] = 0; } if (! ((p_name[OLD] = parse_name (s + 11, strippath, &u)) - && ISSPACE ((unsigned char) *u) + && isspace ((unsigned char) *u) && (p_name[NEW] = parse_name (u, strippath, &u)) && (u = skip_spaces (u), ! *u))) for (i = OLD; i <= NEW; i++) @@ -632,7 +632,7 @@ intuit_diff_type (bool need_header, mode_t *p_file_type) if ((u = skip_hex_digits (s + 6)) && u[0] == '.' && u[1] == '.' && (v = skip_hex_digits (u + 2)) - && (! *v || ISSPACE ((unsigned char) *v))) + && (! *v || isspace ((unsigned char) *v))) { get_sha1(&p_sha1[OLD], s + 6, u); get_sha1(&p_sha1[NEW], u + 2, v); diff --git a/src/util.c b/src/util.c index c3ff5dd..dd2cf84 100644 --- a/src/util.c +++ b/src/util.c @@ -1464,7 +1464,7 @@ fetchname (char const *at, int strip_leading, char **pname, stamp.tv_sec = -1; stamp.tv_nsec = 0; - while (ISSPACE ((unsigned char) *at)) + while (isspace ((unsigned char) *at)) at++; if (debug & 128) say ("fetchname %s %d\n", at, strip_leading); @@ -1483,12 +1483,12 @@ fetchname (char const *at, int strip_leading, char **pname, { for (t = at; *t; t++) { - if (ISSPACE ((unsigned char) *t)) + if (isspace ((unsigned char) *t)) { /* Allow file names with internal spaces, but only if a tab separates the file name from the date. */ char const *u = t; - while (*u != '\t' && ISSPACE ((unsigned char) u[1])) + while (*u != '\t' && isspace ((unsigned char) u[1])) u++; if (*u != '\t' && (strchr (u + 1, pstamp ? '\t' : '\n'))) continue; @@ -1575,7 +1575,7 @@ parse_name (char const *s, int strip_leading, char const **endp) { char *ret; - while (ISSPACE ((unsigned char) *s)) + while (isspace ((unsigned char) *s)) s++; if (*s == '"') { @@ -1587,7 +1587,7 @@ parse_name (char const *s, int strip_leading, char const **endp) { char const *t; - for (t = s; *t && ! ISSPACE ((unsigned char) *t); t++) + for (t = s; *t && ! isspace ((unsigned char) *t); t++) /* do nothing*/ ; ret = xmemdup0 (s, t - s); if (endp) diff --git a/src/util.h b/src/util.h index f4936ec..9eb6902 100644 --- a/src/util.h +++ b/src/util.h @@ -84,7 +84,7 @@ void set_file_attributes (char const *, enum file_attributes, char const *, static inline char const * _GL_ATTRIBUTE_PURE skip_spaces (char const *str) { - while (ISSPACE ((unsigned char) *str)) + while (isspace ((unsigned char) *str)) str++; return str; }