make(1): add wrappers around ctype.h functions

This avoids casting the argument to unsigned char, and to cast the
result of toupper/tolower back to char.
This commit is contained in:
rillig 2020-09-11 17:32:36 +00:00
parent b30dd7c747
commit 1fcb18225c
10 changed files with 110 additions and 102 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: arch.c,v 1.110 2020/09/07 06:51:05 rillig Exp $ */
/* $NetBSD: arch.c,v 1.111 2020/09/11 17:32:36 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: arch.c,v 1.110 2020/09/07 06:51:05 rillig Exp $";
static char rcsid[] = "$NetBSD: arch.c,v 1.111 2020/09/11 17:32:36 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94";
#else
__RCSID("$NetBSD: arch.c,v 1.110 2020/09/07 06:51:05 rillig Exp $");
__RCSID("$NetBSD: arch.c,v 1.111 2020/09/11 17:32:36 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -265,11 +265,11 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt)
*/
Boolean doSubst = FALSE; /* TRUE if need to substitute in memName */
while (*cp != '\0' && *cp != ')' && isspace ((unsigned char)*cp)) {
while (*cp != '\0' && *cp != ')' && ch_isspace(*cp)) {
cp++;
}
memName = cp;
while (*cp != '\0' && *cp != ')' && !isspace ((unsigned char)*cp)) {
while (*cp != '\0' && *cp != ')' && !ch_isspace(*cp)) {
if (*cp == '$') {
/*
* Variable spec, so call the Var module to parse the puppy
@ -448,7 +448,7 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt)
*/
do {
cp++;
} while (*cp != '\0' && isspace ((unsigned char)*cp));
} while (*cp != '\0' && ch_isspace(*cp));
*linePtr = cp;
return TRUE;
@ -631,7 +631,7 @@ ArchStatMember(const char *archive, const char *member, Boolean hash)
* first <namelen> bytes of the file
*/
if (strncmp(memName, AR_EFMT1, sizeof(AR_EFMT1) - 1) == 0 &&
isdigit((unsigned char)memName[sizeof(AR_EFMT1) - 1])) {
ch_isdigit(memName[sizeof(AR_EFMT1) - 1])) {
int elen = atoi(&memName[sizeof(AR_EFMT1)-1]);
@ -879,7 +879,7 @@ ArchFindMember(const char *archive, const char *member, struct ar_hdr *arhPtr,
*/
if (strncmp(arhPtr->ar_name, AR_EFMT1,
sizeof(AR_EFMT1) - 1) == 0 &&
isdigit((unsigned char)arhPtr->ar_name[sizeof(AR_EFMT1) - 1])) {
ch_isdigit(arhPtr->ar_name[sizeof(AR_EFMT1) - 1])) {
int elen = atoi(&arhPtr->ar_name[sizeof(AR_EFMT1)-1]);
char ename[MAXPATHLEN + 1];

View File

@ -1,4 +1,4 @@
/* $NetBSD: compat.c,v 1.139 2020/08/30 20:08:47 rillig Exp $ */
/* $NetBSD: compat.c,v 1.140 2020/09/11 17:32:36 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: compat.c,v 1.139 2020/08/30 20:08:47 rillig Exp $";
static char rcsid[] = "$NetBSD: compat.c,v 1.140 2020/09/11 17:32:36 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: compat.c,v 1.139 2020/08/30 20:08:47 rillig Exp $");
__RCSID("$NetBSD: compat.c,v 1.140 2020/09/11 17:32:36 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -264,7 +264,7 @@ CompatRunCommand(void *cmdp, void *gnp)
cmd++;
}
while (isspace((unsigned char)*cmd))
while (ch_isspace(*cmd))
cmd++;
/*
@ -416,9 +416,9 @@ CompatRunCommand(void *cmdp, void *gnp)
fprintf(debug_file, "\n*** Failed target: %s\n*** Failed command: ",
gn->name);
for (cp = cmd; *cp; ) {
if (isspace((unsigned char)*cp)) {
if (ch_isspace(*cp)) {
fprintf(debug_file, " ");
while (isspace((unsigned char)*cp))
while (ch_isspace(*cp))
cp++;
} else {
fprintf(debug_file, "%c", *cp);

View File

@ -1,4 +1,4 @@
/* $NetBSD: cond.c,v 1.133 2020/09/11 16:37:48 rillig Exp $ */
/* $NetBSD: cond.c,v 1.134 2020/09/11 17:32:36 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: cond.c,v 1.133 2020/09/11 16:37:48 rillig Exp $";
static char rcsid[] = "$NetBSD: cond.c,v 1.134 2020/09/11 17:32:36 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94";
#else
__RCSID("$NetBSD: cond.c,v 1.133 2020/09/11 16:37:48 rillig Exp $");
__RCSID("$NetBSD: cond.c,v 1.134 2020/09/11 17:32:36 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -175,7 +175,7 @@ static Boolean lhsStrict;
static int
is_token(const char *str, const char *tok, size_t len)
{
return strncmp(str, tok, len) == 0 && !isalpha((unsigned char)str[len]);
return strncmp(str, tok, len) == 0 && !ch_isalpha(str[len]);
}
/* Push back the most recent token read. We only need one level of this. */
@ -191,7 +191,7 @@ CondParser_PushBack(CondParser *par, Token t)
static void
CondParser_SkipWhitespace(CondParser *par)
{
while (isspace((unsigned char)par->p[0]))
while (ch_isspace(par->p[0]))
par->p++;
}
@ -472,7 +472,7 @@ CondParser_String(CondParser *par, Boolean doEval, Boolean strictLHS,
*/
if ((par->p == start + len) &&
(par->p[0] == '\0' ||
isspace((unsigned char)par->p[0]) ||
ch_isspace(par->p[0]) ||
strchr("!=><)", par->p[0]))) {
goto cleanup;
}
@ -485,8 +485,7 @@ CondParser_String(CondParser *par, Boolean doEval, Boolean strictLHS,
str = NULL; /* not finished yet */
continue;
default:
if (strictLHS && !qt && *start != '$' &&
!isdigit((unsigned char)*start)) {
if (strictLHS && !qt && *start != '$' && !ch_isdigit(*start)) {
/* lhs must be quoted, a variable reference or number */
if (*freeIt) {
free(*freeIt);
@ -700,7 +699,7 @@ ParseEmptyArg(const char **linePtr, Boolean doEval,
}
/* A variable is empty when it just contains spaces... 4/15/92, christos */
while (isspace((unsigned char)val[0]))
while (ch_isspace(val[0]))
val++;
/*
@ -748,7 +747,7 @@ CondParser_Func(CondParser *par, Boolean doEval)
continue;
cp += fn_def->fn_name_len;
/* There can only be whitespace before the '(' */
while (isspace((unsigned char)*cp))
while (ch_isspace(*cp))
cp++;
if (*cp != '(')
break;
@ -767,7 +766,7 @@ CondParser_Func(CondParser *par, Boolean doEval)
/* Push anything numeric through the compare expression */
cp = par->p;
if (isdigit((unsigned char)cp[0]) || strchr("+-", cp[0]))
if (ch_isdigit(cp[0]) || strchr("+-", cp[0]))
return CondParser_Comparison(par, doEval);
/*
@ -779,7 +778,7 @@ CondParser_Func(CondParser *par, Boolean doEval)
* expression.
*/
arglen = ParseFuncArg(&cp, doEval, NULL, &arg);
for (cp1 = cp; isspace((unsigned char)*cp1); cp1++)
for (cp1 = cp; ch_isspace(*cp1); cp1++)
continue;
if (*cp1 == '=' || *cp1 == '!')
return CondParser_Comparison(par, doEval);

View File

@ -1,4 +1,4 @@
/* $NetBSD: for.c,v 1.78 2020/09/07 06:28:22 rillig Exp $ */
/* $NetBSD: for.c,v 1.79 2020/09/11 17:32:36 rillig Exp $ */
/*
* Copyright (c) 1992, The Regents of the University of California.
@ -30,14 +30,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: for.c,v 1.78 2020/09/07 06:28:22 rillig Exp $";
static char rcsid[] = "$NetBSD: for.c,v 1.79 2020/09/11 17:32:36 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)for.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: for.c,v 1.78 2020/09/07 06:28:22 rillig Exp $");
__RCSID("$NetBSD: for.c,v 1.79 2020/09/11 17:32:36 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -129,7 +129,7 @@ For_Eval(const char *line)
Words words;
/* Skip the '.' and any following whitespace */
for (ptr = line + 1; isspace((unsigned char)*ptr); ptr++)
for (ptr = line + 1; ch_isspace(*ptr); ptr++)
continue;
/*
@ -137,7 +137,7 @@ For_Eval(const char *line)
* a for.
*/
if (ptr[0] != 'f' || ptr[1] != 'o' || ptr[2] != 'r' ||
!isspace((unsigned char)ptr[3])) {
!ch_isspace(ptr[3])) {
if (ptr[0] == 'e' && strncmp(ptr + 1, "ndfor", 5) == 0) {
Parse_Error(PARSE_FATAL, "for-less endfor");
return -1;
@ -162,7 +162,7 @@ For_Eval(const char *line)
while (TRUE) {
size_t len;
while (isspace((unsigned char)*ptr))
while (ch_isspace(*ptr))
ptr++;
if (*ptr == '\0') {
Parse_Error(PARSE_FATAL, "missing `in' in for");
@ -170,7 +170,7 @@ For_Eval(const char *line)
return -1;
}
for (len = 1; ptr[len] && !isspace((unsigned char)ptr[len]); len++)
for (len = 1; ptr[len] && !ch_isspace(ptr[len]); len++)
continue;
if (len == 2 && ptr[0] == 'i' && ptr[1] == 'n') {
ptr += 2;
@ -189,7 +189,7 @@ For_Eval(const char *line)
return -1;
}
while (isspace((unsigned char)*ptr))
while (ch_isspace(*ptr))
ptr++;
/*
@ -277,17 +277,15 @@ For_Accum(const char *line)
if (*ptr == '.') {
for (ptr++; *ptr && isspace((unsigned char)*ptr); ptr++)
for (ptr++; *ptr && ch_isspace(*ptr); ptr++)
continue;
if (strncmp(ptr, "endfor", 6) == 0 &&
(isspace((unsigned char)ptr[6]) || !ptr[6])) {
if (strncmp(ptr, "endfor", 6) == 0 && (ch_isspace(ptr[6]) || !ptr[6])) {
if (DEBUG(FOR))
(void)fprintf(debug_file, "For: end for %d\n", forLevel);
if (--forLevel <= 0)
return 0;
} else if (strncmp(ptr, "for", 3) == 0 &&
isspace((unsigned char)ptr[3])) {
} else if (strncmp(ptr, "for", 3) == 0 && ch_isspace(ptr[3])) {
forLevel++;
if (DEBUG(FOR))
(void)fprintf(debug_file, "For: new loop %d\n", forLevel);

View File

@ -1,4 +1,4 @@
/* $NetBSD: job.c,v 1.229 2020/09/11 04:32:39 rillig Exp $ */
/* $NetBSD: job.c,v 1.230 2020/09/11 17:32:36 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: job.c,v 1.229 2020/09/11 04:32:39 rillig Exp $";
static char rcsid[] = "$NetBSD: job.c,v 1.230 2020/09/11 17:32:36 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: job.c,v 1.229 2020/09/11 04:32:39 rillig Exp $");
__RCSID("$NetBSD: job.c,v 1.230 2020/09/11 17:32:36 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -751,7 +751,7 @@ JobPrintCommand(void *cmdp, void *jobp)
cmd++;
}
while (isspace((unsigned char) *cmd))
while (ch_isspace(*cmd))
cmd++;
/*
@ -2400,9 +2400,8 @@ Job_ParseShell(char *line)
Boolean fullSpec = FALSE;
Shell *sh;
while (isspace((unsigned char)*line)) {
while (ch_isspace(*line))
line++;
}
free(shellArgv);

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.331 2020/08/30 19:56:02 rillig Exp $ */
/* $NetBSD: main.c,v 1.332 2020/09/11 17:32:36 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: main.c,v 1.331 2020/08/30 19:56:02 rillig Exp $";
static char rcsid[] = "$NetBSD: main.c,v 1.332 2020/09/11 17:32:36 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: main.c,v 1.331 2020/08/30 19:56:02 rillig Exp $");
__RCSID("$NetBSD: main.c,v 1.332 2020/09/11 17:32:36 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -216,7 +216,7 @@ explode(const char *flags)
return NULL;
for (f = flags; *f; f++)
if (!isalpha((unsigned char)*f))
if (!ch_isalpha(*f))
break;
if (*f)

View File

@ -1,4 +1,4 @@
/* $NetBSD: make.h,v 1.138 2020/09/11 05:37:40 rillig Exp $ */
/* $NetBSD: make.h,v 1.139 2020/09/11 17:32:36 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -574,4 +574,19 @@ void GNode_FprintDetails(FILE *, const char *, const GNode *, const char *);
#define KILLPG(pid, sig) killpg((pid), (sig))
#endif
static inline MAKE_ATTR_UNUSED Boolean ch_isalnum(char ch)
{ return isalnum((unsigned char)ch) != 0; }
static inline MAKE_ATTR_UNUSED Boolean ch_isalpha(char ch)
{ return isalpha((unsigned char)ch) != 0; }
static inline MAKE_ATTR_UNUSED Boolean ch_isdigit(char ch)
{ return isdigit((unsigned char)ch) != 0; }
static inline MAKE_ATTR_UNUSED Boolean ch_isspace(char ch)
{ return isspace((unsigned char)ch) != 0; }
static inline MAKE_ATTR_UNUSED Boolean ch_isupper(char ch)
{ return isupper((unsigned char)ch) != 0; }
static inline MAKE_ATTR_UNUSED char ch_tolower(char ch)
{ return (char)tolower((unsigned char)ch); }
static inline MAKE_ATTR_UNUSED char ch_toupper(char ch)
{ return (char)toupper((unsigned char)ch); }
#endif /* MAKE_MAKE_H */

View File

@ -1,4 +1,4 @@
/* $NetBSD: metachar.h,v 1.7 2020/08/25 17:37:09 rillig Exp $ */
/* $NetBSD: metachar.h,v 1.8 2020/09/11 17:32:36 rillig Exp $ */
/*-
* Copyright (c) 2015 The NetBSD Foundation, Inc.
@ -41,7 +41,7 @@ static inline int MAKE_ATTR_UNUSED
needshell(const char *cmd, int white)
{
while (!ismeta(*cmd) && *cmd != ':' && *cmd != '=') {
if (white && isspace((unsigned char)*cmd))
if (white && ch_isspace(*cmd))
break;
cmd++;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: parse.c,v 1.289 2020/09/08 05:26:21 rillig Exp $ */
/* $NetBSD: parse.c,v 1.290 2020/09/11 17:32:36 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: parse.c,v 1.289 2020/09/08 05:26:21 rillig Exp $";
static char rcsid[] = "$NetBSD: parse.c,v 1.290 2020/09/11 17:32:36 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: parse.c,v 1.289 2020/09/08 05:26:21 rillig Exp $");
__RCSID("$NetBSD: parse.c,v 1.290 2020/09/11 17:32:36 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -769,11 +769,11 @@ ParseMessage(char *line)
return FALSE;
}
while (isalpha((unsigned char)*line))
while (ch_isalpha(*line))
line++;
if (!isspace((unsigned char)*line))
if (!ch_isspace(*line))
return FALSE; /* not for us */
while (isspace((unsigned char)*line))
while (ch_isspace(*line))
line++;
line = Var_Subst(line, VAR_CMD, VARE_WANTRES);
@ -937,7 +937,7 @@ ParseDoSrc(int tOp, const char *src)
static int wait_number = 0;
char wait_src[16];
if (*src == '.' && isupper ((unsigned char)src[1])) {
if (*src == '.' && ch_isupper(src[1])) {
int keywd = ParseFindKeyword(src);
if (keywd != -1) {
int op = parseKeywords[keywd].op;
@ -1182,7 +1182,7 @@ ParseDoDependency(char *line)
/* Find the end of the next word. */
for (cp = line; *cp && (ParseIsEscaped(lstart, cp) ||
!(isspace((unsigned char)*cp) ||
!(ch_isspace(*cp) ||
*cp == '!' || *cp == ':' || *cp == LPAREN));) {
if (*cp == '$') {
/*
@ -1246,10 +1246,10 @@ ParseDoDependency(char *line)
else if (lstart[0] == '.') {
const char *dirstart = lstart + 1;
const char *dirend;
while (isspace((unsigned char)*dirstart))
while (ch_isspace(*dirstart))
dirstart++;
dirend = dirstart;
while (isalnum((unsigned char)*dirend) || *dirend == '-')
while (ch_isalnum(*dirend) || *dirend == '-')
dirend++;
Parse_Error(PARSE_FATAL, "Unknown directive \"%.*s\"",
(int)(dirend - dirstart), dirstart);
@ -1266,7 +1266,7 @@ ParseDoDependency(char *line)
* Got the word. See if it's a special target and if so set
* specType to match it.
*/
if (*line == '.' && isupper ((unsigned char)line[1])) {
if (*line == '.' && ch_isupper(line[1])) {
/*
* See if the target is a special target that must have it
* or its sources handled specially.
@ -1447,7 +1447,7 @@ ParseDoDependency(char *line)
Parse_Error(PARSE_WARNING, "Extra target ignored");
}
} else {
while (*cp && isspace ((unsigned char)*cp)) {
while (*cp && ch_isspace(*cp)) {
cp++;
}
}
@ -1520,7 +1520,7 @@ ParseDoDependency(char *line)
* LINE will now point to the first source word, if any, or the
* end of the string if not.
*/
while (*cp && isspace ((unsigned char)*cp)) {
while (*cp && ch_isspace(*cp)) {
cp++;
}
line = cp;
@ -1615,7 +1615,7 @@ ParseDoDependency(char *line)
* If it was .OBJDIR, the source is a new definition for .OBJDIR,
* and will cause make to do a new chdir to that path.
*/
while (*cp && !isspace ((unsigned char)*cp)) {
while (*cp && !ch_isspace(*cp)) {
cp++;
}
savec = *cp;
@ -1647,7 +1647,7 @@ ParseDoDependency(char *line)
if (savec != '\0') {
cp++;
}
while (*cp && isspace ((unsigned char)*cp)) {
while (*cp && ch_isspace(*cp)) {
cp++;
}
line = cp;
@ -1666,7 +1666,7 @@ ParseDoDependency(char *line)
* specifications (i.e. things with left parentheses in them)
* and handle them accordingly.
*/
for (; *cp && !isspace ((unsigned char)*cp); cp++) {
for (; *cp && !ch_isspace(*cp); cp++) {
if (*cp == LPAREN && cp > line && cp[-1] != '$') {
/*
* Only stop for a left parenthesis if it isn't at the
@ -1700,7 +1700,7 @@ ParseDoDependency(char *line)
ParseDoSrc(tOp, line);
}
while (*cp && isspace ((unsigned char)*cp)) {
while (*cp && ch_isspace(*cp)) {
cp++;
}
line = cp;
@ -1850,7 +1850,7 @@ Parse_DoVar(char *line, GNode *ctxt)
depth--;
continue;
}
if (depth == 0 && isspace ((unsigned char)*cp)) {
if (depth == 0 && ch_isspace(*cp)) {
*cp = '\0';
}
}
@ -1903,7 +1903,7 @@ Parse_DoVar(char *line, GNode *ctxt)
break;
}
while (isspace((unsigned char)*cp))
while (ch_isspace(*cp))
cp++;
if (DEBUG(LINT)) {
@ -2019,8 +2019,8 @@ ParseMaybeSubMake(const char *cmd)
char *ptr;
if ((ptr = strstr(cmd, vals[i].name)) == NULL)
continue;
if ((ptr == cmd || !isalnum((unsigned char)ptr[-1]))
&& !isalnum((unsigned char)ptr[vals[i].len]))
if ((ptr == cmd || !ch_isalnum(ptr[-1]))
&& !ch_isalnum(ptr[vals[i].len]))
return TRUE;
}
return FALSE;
@ -2431,7 +2431,7 @@ IsInclude(const char *line, Boolean sysv)
return FALSE;
/* Space is not mandatory for BSD .include */
return !sysv || isspace((unsigned char)line[inclen + o]);
return !sysv || ch_isspace(line[inclen + o]);
}
@ -2451,7 +2451,7 @@ IsSysVInclude(const char *line)
/* end of line -> dependency */
return FALSE;
}
if (*p == ':' || isspace((unsigned char)*p)) {
if (*p == ':' || ch_isspace(*p)) {
/* :: operator or ': ' -> dependency */
return FALSE;
}
@ -2475,7 +2475,7 @@ ParseTraditionalInclude(char *line)
/*
* Skip over whitespace
*/
while (isspace((unsigned char)*file))
while (ch_isspace(*file))
file++;
/*
@ -2492,7 +2492,7 @@ ParseTraditionalInclude(char *line)
for (file = all_files; !done; file = cp + 1) {
/* Skip to end of line or next whitespace */
for (cp = file; *cp && !isspace((unsigned char) *cp); cp++)
for (cp = file; *cp && !ch_isspace(*cp); cp++)
continue;
if (*cp)
@ -2521,7 +2521,7 @@ ParseGmakeExport(char *line)
/*
* Skip over whitespace
*/
while (isspace((unsigned char)*variable))
while (ch_isspace(*variable))
variable++;
for (value = variable; *value && *value != '='; value++)
@ -2676,7 +2676,7 @@ ParseGetLine(int flags, int *length)
ptr++;
if (ch == '\n')
break;
if (!isspace((unsigned char)ch))
if (!ch_isspace(ch))
/* We are not interested in trailing whitespace */
line_end = ptr;
}
@ -2760,7 +2760,7 @@ ParseGetLine(int flags, int *length)
}
/* Delete any trailing spaces - eg from empty continuations */
while (tp > escaped && isspace((unsigned char)tp[-1]))
while (tp > escaped && ch_isspace(tp[-1]))
tp--;
*tp = 0;
@ -2913,7 +2913,7 @@ Parse_File(const char *name, int fd)
* On the other hand they can be suffix rules (.c.o: ...)
* or just dependencies for filenames that start '.'.
*/
for (cp = line + 1; isspace((unsigned char)*cp); cp++) {
for (cp = line + 1; ch_isspace(*cp); cp++) {
continue;
}
if (IsInclude(cp, FALSE)) {
@ -2922,16 +2922,15 @@ Parse_File(const char *name, int fd)
}
if (strncmp(cp, "undef", 5) == 0) {
char *cp2;
for (cp += 5; isspace((unsigned char) *cp); cp++)
for (cp += 5; ch_isspace(*cp); cp++)
continue;
for (cp2 = cp; !isspace((unsigned char) *cp2) &&
*cp2 != '\0'; cp2++)
for (cp2 = cp; !ch_isspace(*cp2) && *cp2 != '\0'; cp2++)
continue;
*cp2 = '\0';
Var_Delete(cp, VAR_GLOBAL);
continue;
} else if (strncmp(cp, "export", 6) == 0) {
for (cp += 6; isspace((unsigned char) *cp); cp++)
for (cp += 6; ch_isspace(*cp); cp++)
continue;
Var_Export(cp, TRUE);
continue;
@ -2953,7 +2952,7 @@ Parse_File(const char *name, int fd)
*/
cp = line + 1;
shellCommand:
for (; isspace ((unsigned char)*cp); cp++) {
for (; ch_isspace(*cp); cp++) {
continue;
}
if (*cp) {
@ -2987,8 +2986,7 @@ Parse_File(const char *name, int fd)
}
#endif
#ifdef GMAKEEXPORT
if (strncmp(line, "export", 6) == 0 &&
isspace((unsigned char) line[6]) &&
if (strncmp(line, "export", 6) == 0 && ch_isspace(line[6]) &&
strchr(line, ':') == NULL) {
/*
* It's a Gmake "export".
@ -3012,8 +3010,8 @@ Parse_File(const char *name, int fd)
* and add it to the current list of targets.
*/
cp = line;
if (isspace((unsigned char) line[0])) {
while (isspace((unsigned char) *cp))
if (ch_isspace(line[0])) {
while (ch_isspace(*cp))
cp++;
while (*cp && (ParseIsEscaped(line, cp) ||
*cp != ':' && *cp != '!')) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: var.c,v 1.492 2020/09/11 04:32:39 rillig Exp $ */
/* $NetBSD: var.c,v 1.493 2020/09/11 17:32:36 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
static char rcsid[] = "$NetBSD: var.c,v 1.492 2020/09/11 04:32:39 rillig Exp $";
static char rcsid[] = "$NetBSD: var.c,v 1.493 2020/09/11 17:32:36 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
#else
__RCSID("$NetBSD: var.c,v 1.492 2020/09/11 04:32:39 rillig Exp $");
__RCSID("$NetBSD: var.c,v 1.493 2020/09/11 17:32:36 rillig Exp $");
#endif
#endif /* not lint */
#endif
@ -306,7 +306,7 @@ VarFind(const char *name, GNode *ctxt, VarFindFlags flags)
* and substitute the short version in for 'name' if it matches one of
* them.
*/
if (*name == '.' && isupper((unsigned char)name[1])) {
if (*name == '.' && ch_isupper(name[1])) {
switch (name[1]) {
case 'A':
if (strcmp(name, ".ALLSRC") == 0)
@ -698,7 +698,7 @@ Var_UnExport(const char *str)
if (cp && *cp)
setenv(MAKE_LEVEL_ENV, cp, 1);
} else {
for (; isspace((unsigned char)*str); str++)
for (; ch_isspace(*str); str++)
continue;
if (str[0] != '\0')
varnames = str;
@ -1369,7 +1369,7 @@ tryagain:
continue;
}
if (*rp != '\\' || !isdigit((unsigned char)rp[1])) {
if (*rp != '\\' || !ch_isdigit(rp[1])) {
SepBuf_AddBytes(buf, rp, 1);
continue;
}
@ -1757,7 +1757,7 @@ VarQuote(const char *str, Boolean quoteDollar)
Buf_AddStr(&buf, newline);
continue;
}
if (isspace((unsigned char)*str) || ismeta((unsigned char)*str))
if (ch_isspace(*str) || ismeta((unsigned char)*str))
Buf_AddByte(&buf, '\\');
Buf_AddByte(&buf, *str);
if (quoteDollar && *str == '$')
@ -2480,7 +2480,7 @@ ApplyModifier_ToSep(const char **pp, ApplyModifiersState *st)
if (sep[1] == 'x') {
base = 16;
numStart++;
} else if (!isdigit((unsigned char)sep[1]))
} else if (!ch_isdigit(sep[1]))
return AMR_BAD; /* ":ts<backslash><unrecognised>". */
st->sep = (char)strtoul(numStart, &end, base);
@ -2525,7 +2525,7 @@ ApplyModifier_To(const char **pp, ApplyModifiersState *st)
size_t len = strlen(st->val);
st->newVal = bmake_malloc(len + 1);
for (i = 0; i < len + 1; i++)
st->newVal[i] = (char)toupper((unsigned char)st->val[i]);
st->newVal[i] = ch_toupper(st->val[i]);
*pp = mod + 2;
return AMR_OK;
}
@ -2535,7 +2535,7 @@ ApplyModifier_To(const char **pp, ApplyModifiersState *st)
size_t len = strlen(st->val);
st->newVal = bmake_malloc(len + 1);
for (i = 0; i < len + 1; i++)
st->newVal[i] = (char)tolower((unsigned char)st->val[i]);
st->newVal[i] = ch_tolower(st->val[i]);
*pp = mod + 2;
return AMR_OK;
}
@ -3291,8 +3291,7 @@ VarIsDynamic(GNode *ctxt, const char *varname, size_t namelen)
}
if ((namelen == 7 || namelen == 8) && varname[0] == '.' &&
isupper((unsigned char)varname[1]) &&
(ctxt == VAR_CMD || ctxt == VAR_GLOBAL))
ch_isupper(varname[1]) && (ctxt == VAR_CMD || ctxt == VAR_GLOBAL))
{
return strcmp(varname, ".TARGET") == 0 ||
strcmp(varname, ".ARCHIVE") == 0 ||