Module Name: src
Committed By: christos
Date: Thu Feb 18 18:29:14 UTC 2016
Modified Files:
src/usr.bin/make: arch.c compat.c cond.c for.c job.c main.c make.c
make.h nonints.h parse.c suff.c var.c
Log Message:
Collapse the 3 boolean parameter to 1 flags parameter. No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/usr.bin/make/arch.c
cvs rdiff -u -r1.103 -r1.104 src/usr.bin/make/compat.c
cvs rdiff -u -r1.73 -r1.74 src/usr.bin/make/cond.c
cvs rdiff -u -r1.51 -r1.52 src/usr.bin/make/for.c
cvs rdiff -u -r1.185 -r1.186 src/usr.bin/make/job.c
cvs rdiff -u -r1.238 -r1.239 src/usr.bin/make/main.c
cvs rdiff -u -r1.94 -r1.95 src/usr.bin/make/make.c
cvs rdiff -u -r1.97 -r1.98 src/usr.bin/make/make.h
cvs rdiff -u -r1.70 -r1.71 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.210 -r1.211 src/usr.bin/make/parse.c
cvs rdiff -u -r1.77 -r1.78 src/usr.bin/make/suff.c
cvs rdiff -u -r1.201 -r1.202 src/usr.bin/make/var.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/arch.c
diff -u src/usr.bin/make/arch.c:1.67 src/usr.bin/make/arch.c:1.68
--- src/usr.bin/make/arch.c:1.67 Sun Jan 17 12:45:21 2016
+++ src/usr.bin/make/arch.c Thu Feb 18 13:29:14 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: arch.c,v 1.67 2016/01/17 17:45:21 christos Exp $ */
+/* $NetBSD: arch.c,v 1.68 2016/02/18 18:29:14 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: arch.c,v 1.67 2016/01/17 17:45:21 christos Exp $";
+static char rcsid[] = "$NetBSD: arch.c,v 1.68 2016/02/18 18:29:14 christos 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.67 2016/01/17 17:45:21 christos Exp $");
+__RCSID("$NetBSD: arch.c,v 1.68 2016/02/18 18:29:14 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -259,7 +259,8 @@ Arch_ParseArchive(char **linePtr, Lst no
void *freeIt;
char *result;
- result = Var_Parse(cp, ctxt, TRUE, TRUE, FALSE, &length, &freeIt);
+ result = Var_Parse(cp, ctxt, VARF_UNDEFERR|VARF_WANTRES,
+ &length, &freeIt);
free(freeIt);
if (result == var_Error) {
@@ -274,7 +275,7 @@ Arch_ParseArchive(char **linePtr, Lst no
*cp++ = '\0';
if (subLibName) {
- libName = Var_Subst(NULL, libName, ctxt, TRUE, TRUE, FALSE);
+ libName = Var_Subst(NULL, libName, ctxt, VARF_UNDEFERR|VARF_WANTRES);
}
@@ -300,7 +301,8 @@ Arch_ParseArchive(char **linePtr, Lst no
void *freeIt;
char *result;
- result = Var_Parse(cp, ctxt, TRUE, TRUE, FALSE, &length, &freeIt);
+ result = Var_Parse(cp, ctxt, VARF_UNDEFERR|VARF_WANTRES,
+ &length, &freeIt);
free(freeIt);
if (result == var_Error) {
@@ -353,7 +355,8 @@ Arch_ParseArchive(char **linePtr, Lst no
char *oldMemName = memName;
size_t sz;
- memName = Var_Subst(NULL, memName, ctxt, TRUE, TRUE, FALSE);
+ memName = Var_Subst(NULL, memName, ctxt,
+ VARF_UNDEFERR|VARF_WANTRES);
/*
* Now form an archive spec and recurse to deal with nested
Index: src/usr.bin/make/compat.c
diff -u src/usr.bin/make/compat.c:1.103 src/usr.bin/make/compat.c:1.104
--- src/usr.bin/make/compat.c:1.103 Sun Jan 17 12:45:21 2016
+++ src/usr.bin/make/compat.c Thu Feb 18 13:29:14 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: compat.c,v 1.103 2016/01/17 17:45:21 christos Exp $ */
+/* $NetBSD: compat.c,v 1.104 2016/02/18 18:29:14 christos 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.103 2016/01/17 17:45:21 christos Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.104 2016/02/18 18:29:14 christos 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.103 2016/01/17 17:45:21 christos Exp $");
+__RCSID("$NetBSD: compat.c,v 1.104 2016/02/18 18:29:14 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -210,7 +210,7 @@ CompatRunCommand(void *cmdp, void *gnp)
doIt = FALSE;
cmdNode = Lst_Member(gn->commands, cmd);
- cmdStart = Var_Subst(NULL, cmd, gn, FALSE, TRUE, FALSE);
+ cmdStart = Var_Subst(NULL, cmd, gn, VARF_WANTRES);
/*
* brk_string will return an argv with a NULL in av[0], thus causing
Index: src/usr.bin/make/cond.c
diff -u src/usr.bin/make/cond.c:1.73 src/usr.bin/make/cond.c:1.74
--- src/usr.bin/make/cond.c:1.73 Sun Jan 17 12:45:21 2016
+++ src/usr.bin/make/cond.c Thu Feb 18 13:29:14 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: cond.c,v 1.73 2016/01/17 17:45:21 christos Exp $ */
+/* $NetBSD: cond.c,v 1.74 2016/02/18 18:29:14 christos 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.73 2016/01/17 17:45:21 christos Exp $";
+static char rcsid[] = "$NetBSD: cond.c,v 1.74 2016/02/18 18:29:14 christos 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.73 2016/01/17 17:45:21 christos Exp $");
+__RCSID("$NetBSD: cond.c,v 1.74 2016/02/18 18:29:14 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -289,7 +289,8 @@ CondGetArg(char **linePtr, char **argPtr
int len;
void *freeIt;
- cp2 = Var_Parse(cp, VAR_CMD, TRUE, TRUE, FALSE, &len, &freeIt);
+ cp2 = Var_Parse(cp, VAR_CMD, VARF_UNDEFERR|VARF_WANTRES,
+ &len, &freeIt);
Buf_AddBytes(&buf, strlen(cp2), cp2);
free(freeIt);
cp += len;
@@ -573,8 +574,9 @@ CondGetString(Boolean doEval, Boolean *q
break;
case '$':
/* if we are in quotes, then an undefined variable is ok */
- str = Var_Parse(condExpr, VAR_CMD, (qt ? 0 : doEval),
- TRUE, FALSE, &len, freeIt);
+ str = Var_Parse(condExpr, VAR_CMD,
+ ((!qt && doEval) ? VARF_UNDEFERR : 0) |
+ VARF_WANTRES, &len, freeIt);
if (str == var_Error) {
if (*freeIt) {
free(*freeIt);
@@ -824,7 +826,7 @@ get_mpt_arg(char **linePtr, char **argPt
/* We do all the work here and return the result as the length */
*argPtr = NULL;
- val = Var_Parse(cp - 1, VAR_CMD, FALSE, TRUE, FALSE, &length, &freeIt);
+ val = Var_Parse(cp - 1, VAR_CMD, VARF_WANTRES, &length, &freeIt);
/*
* Advance *linePtr to beyond the closing ). Note that
* we subtract one because 'length' is calculated from 'cp - 1'.
Index: src/usr.bin/make/for.c
diff -u src/usr.bin/make/for.c:1.51 src/usr.bin/make/for.c:1.52
--- src/usr.bin/make/for.c:1.51 Fri Jan 8 19:55:17 2016
+++ src/usr.bin/make/for.c Thu Feb 18 13:29:14 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: for.c,v 1.51 2016/01/09 00:55:17 christos Exp $ */
+/* $NetBSD: for.c,v 1.52 2016/02/18 18:29:14 christos 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.51 2016/01/09 00:55:17 christos Exp $";
+static char rcsid[] = "$NetBSD: for.c,v 1.52 2016/02/18 18:29:14 christos 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.51 2016/01/09 00:55:17 christos Exp $");
+__RCSID("$NetBSD: for.c,v 1.52 2016/02/18 18:29:14 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -216,7 +216,7 @@ For_Eval(char *line)
* We can't do the escapes here - because we don't know whether
* we are substuting into ${...} or $(...).
*/
- sub = Var_Subst(NULL, ptr, VAR_GLOBAL, FALSE, TRUE, FALSE);
+ sub = Var_Subst(NULL, ptr, VAR_GLOBAL, VARF_WANTRES);
/*
* Split into words allowing for quoted strings.
Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.185 src/usr.bin/make/job.c:1.186
--- src/usr.bin/make/job.c:1.185 Sun Jan 17 12:45:21 2016
+++ src/usr.bin/make/job.c Thu Feb 18 13:29:14 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.185 2016/01/17 17:45:21 christos Exp $ */
+/* $NetBSD: job.c,v 1.186 2016/02/18 18:29:14 christos 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.185 2016/01/17 17:45:21 christos Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.186 2016/02/18 18:29:14 christos 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.185 2016/01/17 17:45:21 christos Exp $");
+__RCSID("$NetBSD: job.c,v 1.186 2016/02/18 18:29:14 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -701,7 +701,7 @@ JobPrintCommand(void *cmdp, void *jobp)
numCommands += 1;
- cmdStart = cmd = Var_Subst(NULL, cmd, job->node, FALSE, TRUE, FALSE);
+ cmdStart = cmd = Var_Subst(NULL, cmd, job->node, VARF_WANTRES);
cmdTemplate = "%s\n";
@@ -888,7 +888,7 @@ JobPrintCommand(void *cmdp, void *jobp)
static int
JobSaveCommand(void *cmd, void *gn)
{
- cmd = Var_Subst(NULL, (char *)cmd, (GNode *)gn, FALSE, TRUE, FALSE);
+ cmd = Var_Subst(NULL, (char *)cmd, (GNode *)gn, VARF_WANTRES);
(void)Lst_AtEnd(postCommands->commands, cmd);
return(0);
}
@@ -2176,7 +2176,7 @@ Job_SetPrefix(void)
}
targPrefix = Var_Subst(NULL, "${" MAKE_JOB_PREFIX "}",
- VAR_GLOBAL, FALSE, TRUE, FALSE);
+ VAR_GLOBAL, VARF_WANTRES);
}
/*-
Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.238 src/usr.bin/make/main.c:1.239
--- src/usr.bin/make/main.c:1.238 Sun Jan 17 12:45:21 2016
+++ src/usr.bin/make/main.c Thu Feb 18 13:29:14 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.238 2016/01/17 17:45:21 christos Exp $ */
+/* $NetBSD: main.c,v 1.239 2016/02/18 18:29:14 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.238 2016/01/17 17:45:21 christos Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.239 2016/02/18 18:29:14 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: main.c,v 1.238 2016/01/17 17:45:21 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.239 2016/02/18 18:29:14 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -690,7 +690,7 @@ Main_SetObjdir(const char *path)
/* expand variable substitutions */
if (strchr(path, '$') != 0) {
snprintf(buf, MAXPATHLEN, "%s", path);
- path = p = Var_Subst(NULL, buf, VAR_GLOBAL, FALSE, TRUE, FALSE);
+ path = p = Var_Subst(NULL, buf, VAR_GLOBAL, VARF_WANTRES);
}
if (path[0] != '/') {
@@ -773,7 +773,7 @@ MakeMode(const char *mode)
if (!mode)
mode = mp = Var_Subst(NULL, "${" MAKE_MODE ":tl}",
- VAR_GLOBAL, FALSE, TRUE, FALSE);
+ VAR_GLOBAL, VARF_WANTRES);
if (mode && *mode) {
if (strstr(mode, "compat")) {
@@ -1215,7 +1215,7 @@ main(int argc, char **argv)
(char *)Lst_Datum(ln));
} else {
p1 = Var_Subst(NULL, "${" MAKEFILE_PREFERENCE "}",
- VAR_CMD, FALSE, TRUE, FALSE);
+ VAR_CMD, VARF_WANTRES);
if (p1) {
(void)str2Lst_Append(makefiles, p1, NULL);
(void)Lst_Find(makefiles, NULL, ReadMakefile);
@@ -1226,7 +1226,7 @@ main(int argc, char **argv)
/* In particular suppress .depend for '-r -V .OBJDIR -f /dev/null' */
if (!noBuiltins || !printVars) {
makeDependfile = Var_Subst(NULL, "${.MAKE.DEPENDFILE:T}",
- VAR_CMD, FALSE, TRUE, FALSE);
+ VAR_CMD, VARF_WANTRES);
doing_depend = TRUE;
(void)ReadMakefile(makeDependfile, NULL);
doing_depend = FALSE;
@@ -1264,7 +1264,7 @@ main(int argc, char **argv)
*/
static char VPATH[] = "${VPATH}";
- vpath = Var_Subst(NULL, VPATH, VAR_CMD, FALSE, TRUE, FALSE);
+ vpath = Var_Subst(NULL, VPATH, VAR_CMD, VARF_WANTRES);
path = vpath;
do {
/* skip to end of directory */
@@ -1312,7 +1312,7 @@ main(int argc, char **argv)
if (strchr(var, '$')) {
value = p1 = Var_Subst(NULL, var, VAR_GLOBAL,
- FALSE, TRUE, FALSE);
+ VARF_WANTRES);
} else if (expandVars) {
char tmp[128];
@@ -1320,7 +1320,7 @@ main(int argc, char **argv)
Fatal("%s: variable name too big: %s",
progname, var);
value = p1 = Var_Subst(NULL, tmp, VAR_GLOBAL,
- FALSE, TRUE, FALSE);
+ VARF_WANTRES);
} else {
value = Var_Value(var, VAR_GLOBAL, &p1);
}
@@ -1856,7 +1856,7 @@ PrintOnError(GNode *gn, const char *s)
}
strncpy(tmp, "${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'\n@}",
sizeof(tmp) - 1);
- cp = Var_Subst(NULL, tmp, VAR_GLOBAL, FALSE, TRUE, FALSE);
+ cp = Var_Subst(NULL, tmp, VAR_GLOBAL, VARF_WANTRES);
if (cp) {
if (*cp)
printf("%s", cp);
@@ -1887,7 +1887,7 @@ Main_ExportMAKEFLAGS(Boolean first)
strncpy(tmp, "${.MAKEFLAGS} ${.MAKEOVERRIDES:O:u:@v@$v=${$v:Q}@}",
sizeof(tmp));
- s = Var_Subst(NULL, tmp, VAR_CMD, FALSE, TRUE, FALSE);
+ s = Var_Subst(NULL, tmp, VAR_CMD, VARF_WANTRES);
if (s && *s) {
#ifdef POSIX
setenv("MAKEFLAGS", s, 1);
@@ -1910,7 +1910,7 @@ getTmpdir(void)
* Ensure it ends with /.
*/
tmpdir = Var_Subst(NULL, "${TMPDIR:tA:U" _PATH_TMP "}/", VAR_GLOBAL,
- FALSE, TRUE, FALSE);
+ VARF_WANTRES);
if (stat(tmpdir, &st) < 0 || !S_ISDIR(st.st_mode)) {
free(tmpdir);
tmpdir = bmake_strdup(_PATH_TMP);
@@ -1965,7 +1965,7 @@ getBoolean(const char *name, Boolean bf)
char *cp;
if (snprintf(tmp, sizeof(tmp), "${%s:tl}", name) < (int)(sizeof(tmp))) {
- cp = Var_Subst(NULL, tmp, VAR_GLOBAL, FALSE, TRUE, FALSE);
+ cp = Var_Subst(NULL, tmp, VAR_GLOBAL, VARF_WANTRES);
if (cp) {
switch(*cp) {
Index: src/usr.bin/make/make.c
diff -u src/usr.bin/make/make.c:1.94 src/usr.bin/make/make.c:1.95
--- src/usr.bin/make/make.c:1.94 Sun Jan 17 12:45:21 2016
+++ src/usr.bin/make/make.c Thu Feb 18 13:29:14 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: make.c,v 1.94 2016/01/17 17:45:21 christos Exp $ */
+/* $NetBSD: make.c,v 1.95 2016/02/18 18:29:14 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: make.c,v 1.94 2016/01/17 17:45:21 christos Exp $";
+static char rcsid[] = "$NetBSD: make.c,v 1.95 2016/02/18 18:29:14 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93";
#else
-__RCSID("$NetBSD: make.c,v 1.94 2016/01/17 17:45:21 christos Exp $");
+__RCSID("$NetBSD: make.c,v 1.95 2016/02/18 18:29:14 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -484,7 +484,7 @@ Make_HandleUse(GNode *cgn, GNode *pgn)
} else {
free(gn->name);
}
- gn->name = Var_Subst(NULL, gn->uname, pgn, FALSE, TRUE, FALSE);
+ gn->name = Var_Subst(NULL, gn->uname, pgn, VARF_WANTRES);
if (gn->name && gn->uname && strcmp(gn->name, gn->uname) != 0) {
/* See if we have a target for this node. */
tgn = Targ_FindNode(gn->name, TARG_NOCREATE);
Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.97 src/usr.bin/make/make.h:1.98
--- src/usr.bin/make/make.h:1.97 Sun Jan 17 10:32:38 2016
+++ src/usr.bin/make/make.h Thu Feb 18 13:29:14 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: make.h,v 1.97 2016/01/17 15:32:38 christos Exp $ */
+/* $NetBSD: make.h,v 1.98 2016/02/18 18:29:14 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -490,6 +490,10 @@ Boolean Main_SetObjdir(const char *);
int mkTempFile(const char *, char **);
int str2Lst_Append(Lst, char *, const char *);
+#define VARF_UNDEFERR 1
+#define VARF_WANTRES 2
+#define VARF_ASSIGN 4
+
#ifdef __GNUC__
#define UNCONST(ptr) ({ \
union __unconst { \
Index: src/usr.bin/make/nonints.h
diff -u src/usr.bin/make/nonints.h:1.70 src/usr.bin/make/nonints.h:1.71
--- src/usr.bin/make/nonints.h:1.70 Fri Jan 8 19:55:17 2016
+++ src/usr.bin/make/nonints.h Thu Feb 18 13:29:14 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: nonints.h,v 1.70 2016/01/09 00:55:17 christos Exp $ */
+/* $NetBSD: nonints.h,v 1.71 2016/02/18 18:29:14 christos Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@@ -182,9 +182,8 @@ void Var_Set(const char *, const char *,
void Var_Append(const char *, const char *, GNode *);
Boolean Var_Exists(const char *, GNode *);
char *Var_Value(const char *, GNode *, char **);
-char *Var_Parse(const char *, GNode *, Boolean, Boolean, Boolean,
- int *, void **);
-char *Var_Subst(const char *, const char *, GNode *, Boolean, Boolean, Boolean);
+char *Var_Parse(const char *, GNode *, int, int *, void **);
+char *Var_Subst(const char *, const char *, GNode *, int);
char *Var_GetTail(const char *);
char *Var_GetHead(const char *);
void Var_Init(void);
Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.210 src/usr.bin/make/parse.c:1.211
--- src/usr.bin/make/parse.c:1.210 Thu Feb 18 00:02:49 2016
+++ src/usr.bin/make/parse.c Thu Feb 18 13:29:14 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.210 2016/02/18 05:02:49 sjg Exp $ */
+/* $NetBSD: parse.c,v 1.211 2016/02/18 18:29:14 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.210 2016/02/18 05:02:49 sjg Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.211 2016/02/18 18:29:14 christos 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.210 2016/02/18 05:02:49 sjg Exp $");
+__RCSID("$NetBSD: parse.c,v 1.211 2016/02/18 18:29:14 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -802,7 +802,7 @@ ParseMessage(char *line)
while (isspace((u_char)*line))
line++;
- line = Var_Subst(NULL, line, VAR_CMD, FALSE, TRUE, FALSE);
+ line = Var_Subst(NULL, line, VAR_CMD, VARF_WANTRES);
Parse_Error(mtype, "%s", line);
free(line);
@@ -1219,7 +1219,8 @@ ParseDoDependency(char *line)
int length;
void *freeIt;
- (void)Var_Parse(cp, VAR_CMD, TRUE, TRUE, FALSE, &length, &freeIt);
+ (void)Var_Parse(cp, VAR_CMD, VARF_UNDEFERR|VARF_WANTRES,
+ &length, &freeIt);
free(freeIt);
cp += length-1;
}
@@ -1933,7 +1934,7 @@ Parse_DoVar(char *line, GNode *ctxt)
if (!Var_Exists(line, ctxt))
Var_Set(line, "", ctxt, 0);
- cp = Var_Subst(NULL, cp, ctxt, FALSE, TRUE, TRUE);
+ cp = Var_Subst(NULL, cp, ctxt, VARF_WANTRES|VARF_ASSIGN);
oldVars = oldOldVars;
freeCp = TRUE;
@@ -1948,7 +1949,7 @@ Parse_DoVar(char *line, GNode *ctxt)
* expansion on the whole thing. The resulting string will need
* freeing when we're done, so set freeCmd to TRUE.
*/
- cp = Var_Subst(NULL, cp, VAR_CMD, TRUE, TRUE, FALSE);
+ cp = Var_Subst(NULL, cp, VAR_CMD, VARF_UNDEFERR|VARF_WANTRES);
freeCp = TRUE;
}
@@ -2290,7 +2291,7 @@ ParseDoInclude(char *line)
* Substitute for any variables in the file name before trying to
* find the thing.
*/
- file = Var_Subst(NULL, file, VAR_CMD, FALSE, TRUE, FALSE);
+ file = Var_Subst(NULL, file, VAR_CMD, VARF_WANTRES);
Parse_include_file(file, endc == '>', (*line == 'd'), silent);
free(file);
@@ -2518,7 +2519,7 @@ ParseTraditionalInclude(char *line)
* Substitute for any variables in the file name before trying to
* find the thing.
*/
- all_files = Var_Subst(NULL, file, VAR_CMD, FALSE, TRUE, FALSE);
+ all_files = Var_Subst(NULL, file, VAR_CMD, VARF_WANTRES);
if (*file == '\0') {
Parse_Error(PARSE_FATAL,
@@ -2586,7 +2587,7 @@ ParseGmakeExport(char *line)
/*
* Expand the value before putting it in the environment.
*/
- value = Var_Subst(NULL, value, VAR_CMD, FALSE, TRUE, FALSE);
+ value = Var_Subst(NULL, value, VAR_CMD, VARF_WANTRES);
setenv(variable, value, 1);
}
#endif
@@ -3136,7 +3137,7 @@ Parse_File(const char *name, int fd)
* variables expanded before being parsed. Tell the variable
* module to complain if some variable is undefined...
*/
- line = Var_Subst(NULL, line, VAR_CMD, TRUE, TRUE, FALSE);
+ line = Var_Subst(NULL, line, VAR_CMD, VARF_UNDEFERR|VARF_WANTRES);
/*
* Need a non-circular list for the target nodes
Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.77 src/usr.bin/make/suff.c:1.78
--- src/usr.bin/make/suff.c:1.77 Sun Jan 17 12:45:21 2016
+++ src/usr.bin/make/suff.c Thu Feb 18 13:29:14 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: suff.c,v 1.77 2016/01/17 17:45:21 christos Exp $ */
+/* $NetBSD: suff.c,v 1.78 2016/02/18 18:29:14 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: suff.c,v 1.77 2016/01/17 17:45:21 christos Exp $";
+static char rcsid[] = "$NetBSD: suff.c,v 1.78 2016/02/18 18:29:14 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94";
#else
-__RCSID("$NetBSD: suff.c,v 1.77 2016/01/17 17:45:21 christos Exp $");
+__RCSID("$NetBSD: suff.c,v 1.78 2016/02/18 18:29:14 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -1556,7 +1556,7 @@ SuffExpandChildren(LstNode cln, GNode *p
if (DEBUG(SUFF)) {
fprintf(debug_file, "Expanding \"%s\"...", cgn->name);
}
- cp = Var_Subst(NULL, cgn->name, pgn, TRUE, TRUE, FALSE);
+ cp = Var_Subst(NULL, cgn->name, pgn, VARF_UNDEFERR|VARF_WANTRES);
if (cp != NULL) {
Lst members = Lst_Init(FALSE);
@@ -1609,7 +1609,8 @@ SuffExpandChildren(LstNode cln, GNode *p
int len;
void *freeIt;
- junk = Var_Parse(cp, pgn, TRUE, TRUE, FALSE, &len, &freeIt);
+ junk = Var_Parse(cp, pgn, VARF_UNDEFERR|VARF_WANTRES,
+ &len, &freeIt);
if (junk != var_Error) {
cp += len - 1;
}
Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.201 src/usr.bin/make/var.c:1.202
--- src/usr.bin/make/var.c:1.201 Fri Jan 8 19:55:17 2016
+++ src/usr.bin/make/var.c Thu Feb 18 13:29:14 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.201 2016/01/09 00:55:17 christos Exp $ */
+/* $NetBSD: var.c,v 1.202 2016/02/18 18:29:14 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.201 2016/01/09 00:55:17 christos Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.202 2016/02/18 18:29:14 christos 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.201 2016/01/09 00:55:17 christos Exp $");
+__RCSID("$NetBSD: var.c,v 1.202 2016/02/18 18:29:14 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -155,9 +155,9 @@ char **savedEnv = NULL;
char var_Error[] = "";
/*
- * Similar to var_Error, but returned when the 'errnum' flag for Var_Parse is
- * set false. Why not just use a constant? Well, gcc likes to condense
- * identical string instances...
+ * Similar to var_Error, but returned when the 'VARF_UNDEFERR' flag for
+ * Var_Parse is not set. Why not just use a constant? Well, gcc likes
+ * to condense identical string instances...
*/
static char varNoError[] = "";
@@ -542,7 +542,7 @@ Var_Delete(const char *name, GNode *ctxt
char *cp;
if (strchr(name, '$')) {
- cp = Var_Subst(NULL, name, VAR_GLOBAL, FALSE, TRUE, FALSE);
+ cp = Var_Subst(NULL, name, VAR_GLOBAL, VARF_WANTRES);
} else {
cp = (char *)name;
}
@@ -633,7 +633,7 @@ Var_Export1(const char *name, int parent
}
n = snprintf(tmp, sizeof(tmp), "${%s}", name);
if (n < (int)sizeof(tmp)) {
- val = Var_Subst(NULL, tmp, VAR_GLOBAL, FALSE, TRUE, FALSE);
+ val = Var_Subst(NULL, tmp, VAR_GLOBAL, VARF_WANTRES);
setenv(name, val, 1);
free(val);
}
@@ -701,7 +701,7 @@ Var_ExportVars(void)
int ac;
int i;
- val = Var_Subst(NULL, tmp, VAR_GLOBAL, FALSE, TRUE, FALSE);
+ val = Var_Subst(NULL, tmp, VAR_GLOBAL, VARF_WANTRES);
if (*val) {
av = brk_string(val, &ac, FALSE, &as);
for (i = 0; i < ac; i++) {
@@ -741,7 +741,7 @@ Var_Export(char *str, int isExport)
} else {
track = VAR_EXPORT_PARENT;
}
- val = Var_Subst(NULL, str, VAR_GLOBAL, FALSE, TRUE, FALSE);
+ val = Var_Subst(NULL, str, VAR_GLOBAL, VARF_WANTRES);
if (*val) {
av = brk_string(val, &ac, FALSE, &as);
for (i = 0; i < ac; i++) {
@@ -831,7 +831,7 @@ Var_UnExport(char *str)
/* Using .MAKE.EXPORTED */
n = snprintf(tmp, sizeof(tmp), "${" MAKE_EXPORTED ":O:u}");
if (n < (int)sizeof(tmp)) {
- vlist = Var_Subst(NULL, tmp, VAR_GLOBAL, FALSE, TRUE, FALSE);
+ vlist = Var_Subst(NULL, tmp, VAR_GLOBAL, VARF_WANTRES);
}
}
if (vlist) {
@@ -861,7 +861,7 @@ Var_UnExport(char *str)
n = snprintf(tmp, sizeof(tmp),
"${" MAKE_EXPORTED ":N%s}", v->name);
if (n < (int)sizeof(tmp)) {
- cp = Var_Subst(NULL, tmp, VAR_GLOBAL, FALSE, TRUE, FALSE);
+ cp = Var_Subst(NULL, tmp, VAR_GLOBAL, VARF_WANTRES);
Var_Set(MAKE_EXPORTED, cp, VAR_GLOBAL, 0);
free(cp);
}
@@ -916,7 +916,7 @@ Var_Set(const char *name, const char *va
* point in searching them all just to save a bit of memory...
*/
if (strchr(name, '$') != NULL) {
- expanded_name = Var_Subst(NULL, name, ctxt, FALSE, TRUE, FALSE);
+ expanded_name = Var_Subst(NULL, name, ctxt, VARF_WANTRES);
if (expanded_name[0] == 0) {
if (DEBUG(VAR)) {
fprintf(debug_file, "Var_Set(\"%s\", \"%s\", ...) "
@@ -1026,7 +1026,7 @@ Var_Append(const char *name, const char
char *expanded_name = NULL;
if (strchr(name, '$') != NULL) {
- expanded_name = Var_Subst(NULL, name, ctxt, FALSE, TRUE, FALSE);
+ expanded_name = Var_Subst(NULL, name, ctxt, VARF_WANTRES);
if (expanded_name[0] == 0) {
if (DEBUG(VAR)) {
fprintf(debug_file, "Var_Append(\"%s\", \"%s\", ...) "
@@ -1091,7 +1091,7 @@ Var_Exists(const char *name, GNode *ctxt
char *cp;
if ((cp = strchr(name, '$')) != NULL) {
- cp = Var_Subst(NULL, name, ctxt, FALSE, TRUE, FALSE);
+ cp = Var_Subst(NULL, name, ctxt, VARF_WANTRES);
}
v = VarFind(cp ? cp : name, ctxt, FIND_CMD|FIND_GLOBAL|FIND_ENV);
free(cp);
@@ -1389,7 +1389,7 @@ VarSYSVMatch(GNode *ctx, Var_Parse_State
addSpace = TRUE;
if ((ptr = Str_SYSVMatch(word, pat->lhs, &len)) != NULL) {
- varexp = Var_Subst(NULL, pat->rhs, ctx, FALSE, TRUE, FALSE);
+ varexp = Var_Subst(NULL, pat->rhs, ctx, VARF_WANTRES);
Str_SYSVSubst(buf, varexp, ptr, len);
free(varexp);
} else {
@@ -1629,14 +1629,14 @@ VarSubstitute(GNode *ctx MAKE_ATTR_UNUSE
*-----------------------------------------------------------------------
*/
static void
-VarREError(int errnum, regex_t *pat, const char *str)
+VarREError(int reerr, regex_t *pat, const char *str)
{
char *errbuf;
int errlen;
- errlen = regerror(errnum, pat, 0, 0);
+ errlen = regerror(reerr, pat, 0, 0);
errbuf = bmake_malloc(errlen);
- regerror(errnum, pat, errbuf, errlen);
+ regerror(reerr, pat, errbuf, errlen);
Error("%s: %s", str, errbuf);
free(errbuf);
}
@@ -1809,7 +1809,7 @@ VarLoopExpand(GNode *ctx MAKE_ATTR_UNUSE
if (word && *word) {
Var_Set(loop->tvar, word, loop->ctxt, VAR_NO_EXPORT);
- s = Var_Subst(NULL, loop->str, loop->ctxt, loop->errnum, TRUE, FALSE);
+ s = Var_Subst(NULL, loop->str, loop->ctxt, loop->errnum | VARF_WANTRES);
if (s != NULL && *s != '\0') {
if (addSpace && *s != '\n')
Buf_AddByte(buf, ' ');
@@ -2143,13 +2143,14 @@ VarUniq(const char *str)
*/
static char *
VarGetPattern(GNode *ctxt, Var_Parse_State *vpstate MAKE_ATTR_UNUSED,
- int errnum, const char **tstr, int delim, int *flags,
+ int flags, const char **tstr, int delim, int *vflags,
int *length, VarPattern *pattern)
{
const char *cp;
char *rstr;
Buffer buf;
int junk;
+ int errnum = flags & VARF_UNDEFERR;
Buf_Init(&buf, 0);
if (length == NULL)
@@ -2171,16 +2172,16 @@ VarGetPattern(GNode *ctxt, Var_Parse_Sta
cp++;
} else if (*cp == '$') {
if (cp[1] == delim) {
- if (flags == NULL)
+ if (vflags == NULL)
Buf_AddByte(&buf, *cp);
else
/*
* Unescaped $ at end of pattern => anchor
* pattern at end.
*/
- *flags |= VAR_MATCH_END;
+ *vflags |= VAR_MATCH_END;
} else {
- if (flags == NULL || (*flags & VAR_NOSUBST) == 0) {
+ if (vflags == NULL || (*vflags & VAR_NOSUBST) == 0) {
char *cp2;
int len;
void *freeIt;
@@ -2190,7 +2191,8 @@ VarGetPattern(GNode *ctxt, Var_Parse_Sta
* delimiter, assume it's a variable
* substitution and recurse.
*/
- cp2 = Var_Parse(cp, ctxt, errnum, TRUE, FALSE, &len, &freeIt);
+ cp2 = Var_Parse(cp, ctxt, errnum | VARF_WANTRES, &len,
+ &freeIt);
Buf_AddBytes(&buf, strlen(cp2), cp2);
free(freeIt);
cp += len - 1;
@@ -2463,8 +2465,7 @@ VarStrftime(const char *fmt, int zulu)
static char *
ApplyModifiers(char *nstr, const char *tstr,
int startc, int endc,
- Var *v, GNode *ctxt, Boolean errnum, Boolean wantit,
- Boolean assign,
+ Var *v, GNode *ctxt, int flags,
int *lengthPtr, void **freePtr)
{
const char *start;
@@ -2495,7 +2496,7 @@ ApplyModifiers(char *nstr, const char *t
int rlen;
int c;
- rval = Var_Parse(tstr, ctxt, errnum, wantit, assign, &rlen, &freeIt);
+ rval = Var_Parse(tstr, ctxt, flags, &rlen, &freeIt);
/*
* If we have not parsed up to endc or ':',
@@ -2520,10 +2521,9 @@ ApplyModifiers(char *nstr, const char *t
int used;
nstr = ApplyModifiers(nstr, rval,
- 0, 0, v, ctxt,
- errnum, wantit, assign, &used, freePtr);
+ 0, 0, v, ctxt, flags, &used, freePtr);
if (nstr == var_Error
- || (nstr == varNoError && errnum == 0)
+ || (nstr == varNoError && (flags & VARF_UNDEFERR) == 0)
|| strlen(rval) != (size_t) used) {
free(freeIt);
goto out; /* error already reported */
@@ -2558,7 +2558,7 @@ ApplyModifiers(char *nstr, const char *t
char *sv_name;
VarPattern pattern;
int how;
- int flags;
+ int vflags;
if (v->name[0] == 0)
goto bad_modifier;
@@ -2594,9 +2594,9 @@ ApplyModifiers(char *nstr, const char *t
delim = startc == PROPEN ? PRCLOSE : BRCLOSE;
pattern.flags = 0;
- flags = (wantit) ? 0 : VAR_NOSUBST;
- pattern.rhs = VarGetPattern(ctxt, &parsestate, errnum,
- &cp, delim, &flags,
+ vflags = (flags & VARF_WANTRES) ? 0 : VAR_NOSUBST;
+ pattern.rhs = VarGetPattern(ctxt, &parsestate, flags,
+ &cp, delim, &vflags,
&pattern.rightLen,
NULL);
if (v->flags & VAR_JUNK) {
@@ -2610,7 +2610,7 @@ ApplyModifiers(char *nstr, const char *t
termc = *--cp;
delim = '\0';
- if (wantit) {
+ if (flags & VARF_WANTRES) {
switch (how) {
case '+':
Var_Append(v->name, pattern.rhs, v_ctxt);
@@ -2641,26 +2641,26 @@ ApplyModifiers(char *nstr, const char *t
case '@':
{
VarLoop_t loop;
- int flags = VAR_NOSUBST;
+ int vflags = VAR_NOSUBST;
cp = ++tstr;
delim = '@';
- if ((loop.tvar = VarGetPattern(ctxt, &parsestate, errnum,
+ if ((loop.tvar = VarGetPattern(ctxt, &parsestate, flags,
&cp, delim,
- &flags, &loop.tvarLen,
+ &vflags, &loop.tvarLen,
NULL)) == NULL)
goto cleanup;
- if ((loop.str = VarGetPattern(ctxt, &parsestate, errnum,
+ if ((loop.str = VarGetPattern(ctxt, &parsestate, flags,
&cp, delim,
- &flags, &loop.strLen,
+ &vflags, &loop.strLen,
NULL)) == NULL)
goto cleanup;
termc = *cp;
delim = '\0';
- loop.errnum = errnum;
+ loop.errnum = flags & VARF_UNDEFERR;
loop.ctxt = ctxt;
newStr = VarModify(ctxt, &parsestate, nstr, VarLoopExpand,
&loop);
@@ -2672,15 +2672,19 @@ ApplyModifiers(char *nstr, const char *t
case 'U':
{
Buffer buf; /* Buffer for patterns */
- int wantit_; /* want data in buffer */
+ int nflags;
- if (wantit) {
+ if (flags & VARF_WANTRES) {
+ int wantres;
if (*tstr == 'U')
- wantit_ = ((v->flags & VAR_JUNK) != 0);
+ wantres = ((v->flags & VAR_JUNK) != 0);
else
- wantit_ = ((v->flags & VAR_JUNK) == 0);
+ wantres = ((v->flags & VAR_JUNK) == 0);
+ nflags = flags & ~VARF_WANTRES;
+ if (wantres)
+ nflags |= VARF_WANTRES;
} else
- wantit_ = wantit;
+ nflags = flags;
/*
* Pass through tstr looking for 1) escaped delimiters,
* '$'s and backslashes (place the escaped character in
@@ -2709,8 +2713,7 @@ ApplyModifiers(char *nstr, const char *t
int len;
void *freeIt;
- cp2 = Var_Parse(cp, ctxt, errnum, wantit_,
- assign, &len, &freeIt);
+ cp2 = Var_Parse(cp, ctxt, nflags, &len, &freeIt);
Buf_AddBytes(&buf, strlen(cp2), cp2);
free(freeIt);
cp += len - 1;
@@ -2723,7 +2726,7 @@ ApplyModifiers(char *nstr, const char *t
if ((v->flags & VAR_JUNK) != 0)
v->flags |= VAR_KEEP;
- if (wantit_) {
+ if (nflags & VARF_WANTRES) {
newStr = Buf_Destroy(&buf, FALSE);
} else {
newStr = nstr;
@@ -2770,12 +2773,12 @@ ApplyModifiers(char *nstr, const char *t
delim = '!';
emsg = NULL;
cp = ++tstr;
- if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, errnum,
+ if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, flags,
&cp, delim,
NULL, &pattern.rightLen,
NULL)) == NULL)
goto cleanup;
- if (wantit)
+ if (flags & VARF_WANTRES)
newStr = Cmd_Exec(pattern.rhs, &emsg);
else
newStr = varNoError;
@@ -2803,7 +2806,7 @@ ApplyModifiers(char *nstr, const char *t
cp = tstr+1; /* point to char after '[' */
delim = ']'; /* look for closing ']' */
estr = VarGetPattern(ctxt, &parsestate,
- errnum, &cp, delim,
+ flags, &cp, delim,
NULL, NULL, NULL);
if (estr == NULL)
goto cleanup; /* report missing ']' */
@@ -3154,7 +3157,7 @@ ApplyModifiers(char *nstr, const char *t
* expand it.
*/
cp2 = pattern;
- pattern = Var_Subst(NULL, cp2, ctxt, errnum, TRUE, assign);
+ pattern = Var_Subst(NULL, cp2, ctxt, flags | VARF_WANTRES);
free(cp2);
}
if (DEBUG(VAR))
@@ -3190,14 +3193,14 @@ ApplyModifiers(char *nstr, const char *t
}
cp = tstr;
- if ((pattern.lhs = VarGetPattern(ctxt, &parsestate, errnum,
+ if ((pattern.lhs = VarGetPattern(ctxt, &parsestate, flags,
&cp, delim,
&pattern.flags,
&pattern.leftLen,
NULL)) == NULL)
goto cleanup;
- if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, errnum,
+ if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, flags,
&cp, delim, NULL,
&pattern.rightLen,
&pattern)) == NULL)
@@ -3244,7 +3247,7 @@ ApplyModifiers(char *nstr, const char *t
int lhs_flags, rhs_flags;
/* find ':', and then substitute accordingly */
- if (wantit) {
+ if (flags & VARF_WANTRES) {
cond_rc = Cond_EvalExpression(NULL, v->name, &value, 0, FALSE);
if (cond_rc == COND_INVALID) {
lhs_flags = rhs_flags = VAR_NOSUBST;
@@ -3264,7 +3267,7 @@ ApplyModifiers(char *nstr, const char *t
cp = ++tstr;
delim = ':';
- if ((pattern.lhs = VarGetPattern(ctxt, &parsestate, errnum,
+ if ((pattern.lhs = VarGetPattern(ctxt, &parsestate, flags,
&cp, delim, &lhs_flags,
&pattern.leftLen,
NULL)) == NULL)
@@ -3272,7 +3275,7 @@ ApplyModifiers(char *nstr, const char *t
/* BROPEN or PROPEN */
delim = endc;
- if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, errnum,
+ if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, flags,
&cp, delim, &rhs_flags,
&pattern.rightLen,
NULL)) == NULL)
@@ -3313,12 +3316,12 @@ ApplyModifiers(char *nstr, const char *t
cp = tstr;
- if ((re = VarGetPattern(ctxt, &parsestate, errnum, &cp, delim,
+ if ((re = VarGetPattern(ctxt, &parsestate, flags, &cp, delim,
NULL, NULL, NULL)) == NULL)
goto cleanup;
if ((pattern.replace = VarGetPattern(ctxt, &parsestate,
- errnum, &cp, delim, NULL,
+ flags, &cp, delim, NULL,
NULL, NULL)) == NULL){
free(re);
goto cleanup;
@@ -3442,7 +3445,7 @@ ApplyModifiers(char *nstr, const char *t
case 's':
if (tstr[1] == 'h' && (tstr[2] == endc || tstr[2] == ':')) {
const char *emsg;
- if (wantit) {
+ if (flags & VARF_WANTRES) {
newStr = Cmd_Exec(nstr, &emsg);
if (emsg)
Error(emsg, nstr);
@@ -3495,12 +3498,12 @@ ApplyModifiers(char *nstr, const char *t
delim='=';
cp = tstr;
if ((pattern.lhs = VarGetPattern(ctxt, &parsestate,
- errnum, &cp, delim, &pattern.flags,
+ flags, &cp, delim, &pattern.flags,
&pattern.leftLen, NULL)) == NULL)
goto cleanup;
delim = endc;
if ((pattern.rhs = VarGetPattern(ctxt, &parsestate,
- errnum, &cp, delim, NULL, &pattern.rightLen,
+ flags, &cp, delim, NULL, &pattern.rightLen,
&pattern)) == NULL)
goto cleanup;
@@ -3583,8 +3586,9 @@ ApplyModifiers(char *nstr, const char *t
* Input:
* str The string to parse
* ctxt The context for the variable
- * errnum TRUE if undefined variables are an error
- * wantit TRUE if we actually want the result
+ * flags VARF_UNDEFERR if undefineds are an error
+ * VARF_WANTRES if we actually want the result
+ * VARF_ASSIGN if we are in a := assignment
* lengthPtr OUT: The length of the specification
* freePtr OUT: Non-NULL if caller should free *freePtr
*
@@ -3603,9 +3607,8 @@ ApplyModifiers(char *nstr, const char *t
*/
/* coverity[+alloc : arg-*4] */
char *
-Var_Parse(const char *str, GNode *ctxt,
- Boolean errnum, Boolean wantit, Boolean assign,
- int *lengthPtr, void **freePtr)
+Var_Parse(const char *str, GNode *ctxt, int flags,
+ int *lengthPtr, void **freePtr)
{
const char *tstr; /* Pointer into str */
Var *v; /* Variable in invocation */
@@ -3673,7 +3676,7 @@ Var_Parse(const char *str, GNode *ctxt,
/*
* Error
*/
- return (errnum ? var_Error : varNoError);
+ return (flags & VARF_UNDEFERR) ? var_Error : varNoError;
} else {
haveModifier = FALSE;
tstr = &str[1];
@@ -3710,8 +3713,7 @@ Var_Parse(const char *str, GNode *ctxt,
if (*tstr == '$') {
int rlen;
void *freeIt;
- char *rval = Var_Parse(tstr, ctxt, errnum, wantit,
- assign, &rlen, &freeIt);
+ char *rval = Var_Parse(tstr, ctxt, flags, &rlen, &freeIt);
if (rval != NULL) {
Buf_AddBytes(&buf, strlen(rval), rval);
}
@@ -3824,7 +3826,7 @@ Var_Parse(const char *str, GNode *ctxt,
return(pstr);
} else {
Buf_Destroy(&buf, TRUE);
- return (errnum ? var_Error : varNoError);
+ return (flags & VARF_UNDEFERR) ? var_Error : varNoError;
}
} else {
/*
@@ -3858,7 +3860,7 @@ Var_Parse(const char *str, GNode *ctxt,
*/
nstr = Buf_GetAll(&v->val, NULL);
if (strchr(nstr, '$') != NULL) {
- nstr = Var_Subst(NULL, nstr, ctxt, errnum, wantit, assign);
+ nstr = Var_Subst(NULL, nstr, ctxt, flags);
*freePtr = nstr;
}
@@ -3871,8 +3873,7 @@ Var_Parse(const char *str, GNode *ctxt,
extraFree = NULL;
if (extramodifiers != NULL) {
nstr = ApplyModifiers(nstr, extramodifiers, '(', ')',
- v, ctxt, errnum, wantit, assign,
- &used, &extraFree);
+ v, ctxt, flags, &used, &extraFree);
}
if (haveModifier) {
@@ -3880,8 +3881,7 @@ Var_Parse(const char *str, GNode *ctxt,
tstr++;
nstr = ApplyModifiers(nstr, tstr, startc, endc,
- v, ctxt, errnum, wantit, assign,
- &used, freePtr);
+ v, ctxt, flags, &used, freePtr);
tstr += used;
free(extraFree);
} else {
@@ -3922,7 +3922,7 @@ Var_Parse(const char *str, GNode *ctxt,
nstr = bmake_strndup(start, *lengthPtr);
*freePtr = nstr;
} else {
- nstr = errnum ? var_Error : varNoError;
+ nstr = (flags & VARF_UNDEFERR) ? var_Error : varNoError;
}
}
if (nstr != Buf_GetAll(&v->val, NULL))
@@ -3937,16 +3937,16 @@ Var_Parse(const char *str, GNode *ctxt,
*-----------------------------------------------------------------------
* Var_Subst --
* Substitute for all variables in the given string in the given context
- * If undefErr is TRUE, Parse_Error will be called when an undefined
+ * If flags & VARF_UNDEFERR, Parse_Error will be called when an undefined
* variable is encountered.
*
* Input:
* var Named variable || NULL for all
* str the string which to substitute
* ctxt the context wherein to find variables
- * undefErr TRUE if undefineds are an error
- * wantit TRUE if we actually want the result
- * assign TRUE if we actually want the result
+ * flags VARF_UNDEFERR if undefineds are an error
+ * VARF_WANTRES if we actually want the result
+ * VARF_ASSIGN if we are in a := assignment
*
* Results:
* The resulting string.
@@ -3956,8 +3956,7 @@ Var_Parse(const char *str, GNode *ctxt,
*-----------------------------------------------------------------------
*/
char *
-Var_Subst(const char *var, const char *str, GNode *ctxt,
- Boolean undefErr, Boolean wantit, Boolean assign)
+Var_Subst(const char *var, const char *str, GNode *ctxt, int flags)
{
Buffer buf; /* Buffer for forming things */
char *val; /* Value to substitute for a variable */
@@ -3981,7 +3980,7 @@ Var_Subst(const char *var, const char *s
* In such a case, we skip over the escape character and store the
* dollar sign into the buffer directly.
*/
- if (assign)
+ if (flags & VARF_ASSIGN)
Buf_AddByte(&buf, *str);
str++;
Buf_AddByte(&buf, *str);
@@ -4057,7 +4056,7 @@ Var_Subst(const char *var, const char *s
continue;
}
- val = Var_Parse(str, ctxt, undefErr, wantit, assign, &length, &freeIt);
+ val = Var_Parse(str, ctxt, flags, &length, &freeIt);
/*
* When we come down here, val should either point to the
@@ -4074,7 +4073,7 @@ Var_Subst(const char *var, const char *s
*/
if (oldVars) {
str += length;
- } else if (undefErr || val == var_Error) {
+ } else if ((flags & VARF_UNDEFERR) || val == var_Error) {
/*
* If variable is undefined, complain and skip the
* variable. The complaint will stop us from doing anything