Module Name: src
Committed By: rillig
Date: Thu Jul 2 15:47:39 UTC 2020
Modified Files:
src/usr.bin/make: arch.c compat.c job.c main.c make.c meta.c nonints.h
parse.c suff.c var.c
Log Message:
make(1): remove useless parameter from Var_Set
The enum corresponding to this int parameter is only defined in var.c,
which makes it impractical for the outside to set this parameter to
anything but 0.
On x86_64, this reduces the size of the resulting executable by 5 kB.
To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/usr.bin/make/arch.c
cvs rdiff -u -r1.110 -r1.111 src/usr.bin/make/compat.c
cvs rdiff -u -r1.198 -r1.199 src/usr.bin/make/job.c
cvs rdiff -u -r1.276 -r1.277 src/usr.bin/make/main.c
cvs rdiff -u -r1.96 -r1.97 src/usr.bin/make/make.c
cvs rdiff -u -r1.82 -r1.83 src/usr.bin/make/meta.c
cvs rdiff -u -r1.76 -r1.77 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.233 -r1.234 src/usr.bin/make/parse.c
cvs rdiff -u -r1.86 -r1.87 src/usr.bin/make/suff.c
cvs rdiff -u -r1.229 -r1.230 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.71 src/usr.bin/make/arch.c:1.72
--- src/usr.bin/make/arch.c:1.71 Sat Oct 5 23:35:57 2019
+++ src/usr.bin/make/arch.c Thu Jul 2 15:47:38 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: arch.c,v 1.71 2019/10/05 23:35:57 mrg Exp $ */
+/* $NetBSD: arch.c,v 1.72 2020/07/02 15:47:38 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: arch.c,v 1.71 2019/10/05 23:35:57 mrg Exp $";
+static char rcsid[] = "$NetBSD: arch.c,v 1.72 2020/07/02 15:47:38 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.71 2019/10/05 23:35:57 mrg Exp $");
+__RCSID("$NetBSD: arch.c,v 1.72 2020/07/02 15:47:38 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -1205,9 +1205,9 @@ Arch_FindLib(GNode *gn, Lst path)
free(libName);
#ifdef LIBRARIES
- Var_Set(TARGET, gn->name, gn, 0);
+ Var_Set(TARGET, gn->name, gn);
#else
- Var_Set(TARGET, gn->path == NULL ? gn->name : gn->path, gn, 0);
+ Var_Set(TARGET, gn->path == NULL ? gn->name : gn->path, gn);
#endif /* LIBRARIES */
}
Index: src/usr.bin/make/compat.c
diff -u src/usr.bin/make/compat.c:1.110 src/usr.bin/make/compat.c:1.111
--- src/usr.bin/make/compat.c:1.110 Sun Jan 19 19:42:32 2020
+++ src/usr.bin/make/compat.c Thu Jul 2 15:47:38 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: compat.c,v 1.110 2020/01/19 19:42:32 riastradh Exp $ */
+/* $NetBSD: compat.c,v 1.111 2020/07/02 15:47:38 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.110 2020/01/19 19:42:32 riastradh Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.111 2020/07/02 15:47:38 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.110 2020/01/19 19:42:32 riastradh Exp $");
+__RCSID("$NetBSD: compat.c,v 1.111 2020/07/02 15:47:38 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -547,7 +547,7 @@ Compat_Make(void *gnp, void *pgnp)
if (Lst_Member(gn->iParents, pgn) != NULL) {
char *p1;
- Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn, 0);
+ Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn);
free(p1);
}
@@ -651,7 +651,7 @@ Compat_Make(void *gnp, void *pgnp)
} else {
if (Lst_Member(gn->iParents, pgn) != NULL) {
char *p1;
- Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn, 0);
+ Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn);
free(p1);
}
switch(gn->made) {
Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.198 src/usr.bin/make/job.c:1.199
--- src/usr.bin/make/job.c:1.198 Fri Jun 19 21:17:48 2020
+++ src/usr.bin/make/job.c Thu Jul 2 15:47:38 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.198 2020/06/19 21:17:48 sjg Exp $ */
+/* $NetBSD: job.c,v 1.199 2020/07/02 15:47:38 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.198 2020/06/19 21:17:48 sjg Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.199 2020/07/02 15:47:38 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.198 2020/06/19 21:17:48 sjg Exp $");
+__RCSID("$NetBSD: job.c,v 1.199 2020/07/02 15:47:38 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -1257,7 +1257,7 @@ Job_CheckCommands(GNode *gn, void (*abor
* .DEFAULT itself.
*/
Make_HandleUse(DEFAULT, gn);
- Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), gn, 0);
+ Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), gn);
free(p1);
} else if (Dir_MTime(gn, 0) == 0 && (gn->type & OP_SPECIAL) == 0) {
/*
@@ -2241,11 +2241,11 @@ Shell_GetNewline(void)
void
Job_SetPrefix(void)
{
-
+
if (targPrefix) {
free(targPrefix);
} else if (!Var_Exists(MAKE_JOB_PREFIX, VAR_GLOBAL)) {
- Var_Set(MAKE_JOB_PREFIX, "---", VAR_GLOBAL, 0);
+ Var_Set(MAKE_JOB_PREFIX, "---", VAR_GLOBAL);
}
targPrefix = Var_Subst(NULL, "${" MAKE_JOB_PREFIX "}",
@@ -3059,7 +3059,7 @@ Job_RunTarget(const char *target, const
return FALSE;
if (fname)
- Var_Set(ALLSRC, fname, gn, 0);
+ Var_Set(ALLSRC, fname, gn);
JobRun(gn);
if (gn->made == ERROR) {
Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.276 src/usr.bin/make/main.c:1.277
--- src/usr.bin/make/main.c:1.276 Mon Jun 22 20:15:25 2020
+++ src/usr.bin/make/main.c Thu Jul 2 15:47:38 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.276 2020/06/22 20:15:25 sjg Exp $ */
+/* $NetBSD: main.c,v 1.277 2020/07/02 15:47:38 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.276 2020/06/22 20:15:25 sjg Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.277 2020/07/02 15:47:38 rillig 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.276 2020/06/22 20:15:25 sjg Exp $");
+__RCSID("$NetBSD: main.c,v 1.277 2020/07/02 15:47:38 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -462,7 +462,7 @@ rearg:
case 'B':
compatMake = TRUE;
Var_Append(MAKEFLAGS, "-B", VAR_GLOBAL);
- Var_Set(MAKE_MODE, "compat", VAR_GLOBAL, 0);
+ Var_Set(MAKE_MODE, "compat", VAR_GLOBAL);
break;
case 'C':
if (chdir(argvalue) == -1) {
@@ -486,7 +486,7 @@ rearg:
break;
case 'D':
if (argvalue == NULL || argvalue[0] == 0) goto noarg;
- Var_Set(argvalue, "1", VAR_GLOBAL, 0);
+ Var_Set(argvalue, "1", VAR_GLOBAL);
Var_Append(MAKEFLAGS, "-D", VAR_GLOBAL);
Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
break;
@@ -585,7 +585,7 @@ rearg:
}
Var_Append(MAKEFLAGS, "-j", VAR_GLOBAL);
Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
- Var_Set(".MAKE.JOBS", argvalue, VAR_GLOBAL, 0);
+ Var_Set(".MAKE.JOBS", argvalue, VAR_GLOBAL);
maxJobTokens = maxJobs;
break;
case 'k':
@@ -745,7 +745,7 @@ Main_SetObjdir(const char *fmt, ...)
path, strerror(errno));
} else {
strncpy(objdir, path, MAXPATHLEN);
- Var_Set(".OBJDIR", objdir, VAR_GLOBAL, 0);
+ Var_Set(".OBJDIR", objdir, VAR_GLOBAL);
setenv("PWD", objdir, 1);
Dir_InitDot();
purge_cached_realpaths();
@@ -870,14 +870,14 @@ doPrintVars(void)
char *var = (char *)Lst_Datum(ln);
char *value;
char *p1;
-
+
if (strchr(var, '$')) {
value = p1 = Var_Subst(NULL, var, VAR_GLOBAL,
VARF_WANTRES);
} else if (expandVars) {
char tmp[128];
int len = snprintf(tmp, sizeof(tmp), "${%s}", var);
-
+
if (len >= (int)sizeof(tmp))
Fatal("%s: variable name too big: %s",
progname, var);
@@ -982,7 +982,7 @@ main(int argc, char **argv)
*/
gettimeofday(&rightnow, NULL);
srandom(rightnow.tv_sec + rightnow.tv_usec);
-
+
if ((progname = strrchr(argv[0], '/')) != NULL)
progname++;
else
@@ -1032,7 +1032,7 @@ main(int argc, char **argv)
static char machine_arch_buf[sizeof(utsname.machine)];
const int mib[2] = { CTL_HW, HW_MACHINE_ARCH };
size_t len = sizeof(machine_arch_buf);
-
+
if (sysctl(mib, __arraycount(mib), machine_arch_buf,
&len, NULL, 0) < 0) {
(void)fprintf(stderr, "%s: sysctl failed (%s).\n", progname,
@@ -1061,13 +1061,13 @@ main(int argc, char **argv)
*/
Var_Init(); /* Initialize the lists of variables for
* parsing arguments */
- Var_Set(".MAKE.OS", utsname.sysname, VAR_GLOBAL, 0);
- Var_Set("MACHINE", machine, VAR_GLOBAL, 0);
- Var_Set("MACHINE_ARCH", machine_arch, VAR_GLOBAL, 0);
+ Var_Set(".MAKE.OS", utsname.sysname, VAR_GLOBAL);
+ Var_Set("MACHINE", machine, VAR_GLOBAL);
+ Var_Set("MACHINE_ARCH", machine_arch, VAR_GLOBAL);
#ifdef MAKE_VERSION
- Var_Set("MAKE_VERSION", MAKE_VERSION, VAR_GLOBAL, 0);
+ Var_Set("MAKE_VERSION", MAKE_VERSION, VAR_GLOBAL);
#endif
- Var_Set(".newline", "\n", VAR_GLOBAL, 0); /* handy for :@ loops */
+ Var_Set(".newline", "\n", VAR_GLOBAL); /* handy for :@ loops */
/*
* This is the traditional preference for makefiles.
*/
@@ -1075,8 +1075,8 @@ main(int argc, char **argv)
# define MAKEFILE_PREFERENCE_LIST "makefile Makefile"
#endif
Var_Set(MAKEFILE_PREFERENCE, MAKEFILE_PREFERENCE_LIST,
- VAR_GLOBAL, 0);
- Var_Set(MAKE_DEPENDFILE, ".depend", VAR_GLOBAL, 0);
+ VAR_GLOBAL);
+ Var_Set(MAKE_DEPENDFILE, ".depend", VAR_GLOBAL);
create = Lst_Init(FALSE);
makefiles = Lst_Init(FALSE);
@@ -1130,14 +1130,14 @@ main(int argc, char **argv)
p1 = argv[0]; /* realpath failed */
}
}
- Var_Set("MAKE", p1, VAR_GLOBAL, 0);
- Var_Set(".MAKE", p1, VAR_GLOBAL, 0);
- Var_Set(MAKEFLAGS, "", VAR_GLOBAL, 0);
- Var_Set(MAKEOVERRIDES, "", VAR_GLOBAL, 0);
- Var_Set("MFLAGS", "", VAR_GLOBAL, 0);
- Var_Set(".ALLTARGETS", "", VAR_GLOBAL, 0);
+ Var_Set("MAKE", p1, VAR_GLOBAL);
+ Var_Set(".MAKE", p1, VAR_GLOBAL);
+ Var_Set(MAKEFLAGS, "", VAR_GLOBAL);
+ Var_Set(MAKEOVERRIDES, "", VAR_GLOBAL);
+ Var_Set("MFLAGS", "", VAR_GLOBAL);
+ Var_Set(".ALLTARGETS", "", VAR_GLOBAL);
/* some makefiles need to know this */
- Var_Set(MAKE_LEVEL ".ENV", MAKE_LEVEL_ENV, VAR_CMD, 0);
+ Var_Set(MAKE_LEVEL ".ENV", MAKE_LEVEL_ENV, VAR_CMD);
/*
* Set some other useful macros
@@ -1149,11 +1149,11 @@ main(int argc, char **argv)
if (makelevel < 0)
makelevel = 0;
snprintf(tmp, sizeof(tmp), "%d", makelevel);
- Var_Set(MAKE_LEVEL, tmp, VAR_GLOBAL, 0);
+ Var_Set(MAKE_LEVEL, tmp, VAR_GLOBAL);
snprintf(tmp, sizeof(tmp), "%u", myPid);
- Var_Set(".MAKE.PID", tmp, VAR_GLOBAL, 0);
+ Var_Set(".MAKE.PID", tmp, VAR_GLOBAL);
snprintf(tmp, sizeof(tmp), "%u", getppid());
- Var_Set(".MAKE.PPID", tmp, VAR_GLOBAL, 0);
+ Var_Set(".MAKE.PPID", tmp, VAR_GLOBAL);
}
if (makelevel > 0) {
char pn[1024];
@@ -1234,7 +1234,7 @@ main(int argc, char **argv)
free(ptmp2);
}
#endif
- Var_Set(".CURDIR", curdir, VAR_GLOBAL, 0);
+ Var_Set(".CURDIR", curdir, VAR_GLOBAL);
/*
* Find the .OBJDIR. If MAKEOBJDIRPREFIX, or failing that,
@@ -1284,7 +1284,7 @@ main(int argc, char **argv)
Var_Append(".TARGETS", name, VAR_GLOBAL);
}
} else
- Var_Set(".TARGETS", "", VAR_GLOBAL, 0);
+ Var_Set(".TARGETS", "", VAR_GLOBAL);
/*
@@ -1518,7 +1518,7 @@ ReadMakefile(const void *p, const void *
if (!strcmp(fname, "-")) {
Parse_File(NULL /*stdin*/, -1);
- Var_Set("MAKEFILE", "", VAR_INTERNAL, 0);
+ Var_Set("MAKEFILE", "", VAR_INTERNAL);
} else {
/* if we've chdir'd, rebuild the path name */
if (strcmp(curdir, objdir) && *fname != '/') {
@@ -1566,7 +1566,7 @@ ReadMakefile(const void *p, const void *
*/
found:
if (!doing_depend)
- Var_Set("MAKEFILE", fname, VAR_INTERNAL, 0);
+ Var_Set("MAKEFILE", fname, VAR_INTERNAL);
Parse_File(fname, fd);
}
free(path);
@@ -1987,7 +1987,7 @@ cached_realpath(const char *pathname, ch
strncpy(resolved, rp, MAXPATHLEN);
resolved[MAXPATHLEN - 1] = '\0';
} else if ((rp = realpath(pathname, resolved)) != NULL) {
- Var_Set(pathname, rp, cache, 0);
+ Var_Set(pathname, rp, cache);
} /* else should we negative-cache? */
free(cp);
@@ -2054,7 +2054,7 @@ PrintOnError(GNode *gn, const char *s)
/*
* We can print this even if there is no .ERROR target.
*/
- Var_Set(".ERROR_TARGET", gn->name, VAR_GLOBAL, 0);
+ Var_Set(".ERROR_TARGET", gn->name, VAR_GLOBAL);
Var_Delete(".ERROR_CMD", VAR_GLOBAL);
Lst_ForEach(gn->commands, addErrorCMD, gn);
}
Index: src/usr.bin/make/make.c
diff -u src/usr.bin/make/make.c:1.96 src/usr.bin/make/make.c:1.97
--- src/usr.bin/make/make.c:1.96 Thu Nov 10 23:41:58 2016
+++ src/usr.bin/make/make.c Thu Jul 2 15:47:38 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: make.c,v 1.96 2016/11/10 23:41:58 sjg Exp $ */
+/* $NetBSD: make.c,v 1.97 2020/07/02 15:47:38 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: make.c,v 1.96 2016/11/10 23:41:58 sjg Exp $";
+static char rcsid[] = "$NetBSD: make.c,v 1.97 2020/07/02 15:47:38 rillig 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.96 2016/11/10 23:41:58 sjg Exp $");
+__RCSID("$NetBSD: make.c,v 1.97 2020/07/02 15:47:38 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -831,9 +831,9 @@ Make_Update(GNode *cgn)
while ((ln = Lst_Next(cgn->iParents)) != NULL) {
pgn = (GNode *)Lst_Datum(ln);
if (pgn->flags & REMAKE) {
- Var_Set(IMPSRC, cname, pgn, 0);
+ Var_Set(IMPSRC, cname, pgn);
if (cpref != NULL)
- Var_Set(PREFIX, cpref, pgn, 0);
+ Var_Set(PREFIX, cpref, pgn);
}
}
free(p1);
@@ -967,15 +967,15 @@ Make_DoAllVar(GNode *gn)
Lst_ForEach(gn->children, MakeAddAllSrc, gn);
if (!Var_Exists (OODATE, gn)) {
- Var_Set(OODATE, "", gn, 0);
+ Var_Set(OODATE, "", gn);
}
if (!Var_Exists (ALLSRC, gn)) {
- Var_Set(ALLSRC, "", gn, 0);
+ Var_Set(ALLSRC, "", gn);
}
if (gn->type & OP_JOIN) {
char *p1;
- Var_Set(TARGET, Var_Value(ALLSRC, gn, &p1), gn, 0);
+ Var_Set(TARGET, Var_Value(ALLSRC, gn, &p1), gn);
free(p1);
}
gn->flags |= DONE_ALLSRC;
@@ -1324,14 +1324,14 @@ Make_ExpandUse(Lst targs)
continue;
*eoa = '\0';
*eon = '\0';
- Var_Set(MEMBER, eoa + 1, gn, 0);
- Var_Set(ARCHIVE, gn->name, gn, 0);
+ Var_Set(MEMBER, eoa + 1, gn);
+ Var_Set(ARCHIVE, gn->name, gn);
*eoa = '(';
*eon = ')';
}
(void)Dir_MTime(gn, 0);
- Var_Set(TARGET, gn->path ? gn->path : gn->name, gn, 0);
+ Var_Set(TARGET, gn->path ? gn->path : gn->name, gn);
Lst_ForEach(gn->children, MakeUnmark, gn);
Lst_ForEach(gn->children, MakeHandleUse, gn);
Index: src/usr.bin/make/meta.c
diff -u src/usr.bin/make/meta.c:1.82 src/usr.bin/make/meta.c:1.83
--- src/usr.bin/make/meta.c:1.82 Thu Jun 25 15:45:37 2020
+++ src/usr.bin/make/meta.c Thu Jul 2 15:47:38 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: meta.c,v 1.82 2020/06/25 15:45:37 sjg Exp $ */
+/* $NetBSD: meta.c,v 1.83 2020/07/02 15:47:38 rillig Exp $ */
/*
* Implement 'meta' mode.
@@ -570,7 +570,7 @@ meta_init(void)
{
#ifdef USE_FILEMON
/* this allows makefiles to test if we have filemon support */
- Var_Set(".MAKE.PATH_FILEMON", filemon_path(), VAR_GLOBAL, 0);
+ Var_Set(".MAKE.PATH_FILEMON", filemon_path(), VAR_GLOBAL);
#endif
}
@@ -616,7 +616,7 @@ meta_mode_init(const char *make_mode)
* This works be cause :H will generate '.' if there is no /
* and :tA will resolve that to cwd.
*/
- Var_Set(MAKE_META_PREFIX, "Building ${.TARGET:H:tA}/${.TARGET:T}", VAR_GLOBAL, 0);
+ Var_Set(MAKE_META_PREFIX, "Building ${.TARGET:H:tA}/${.TARGET:T}", VAR_GLOBAL);
}
if (once)
return;
@@ -790,12 +790,12 @@ meta_job_error(Job *job, GNode *gn, int
"(ignored)" : "");
}
if (gn) {
- Var_Set(".ERROR_TARGET", gn->path ? gn->path : gn->name, VAR_GLOBAL, 0);
+ Var_Set(".ERROR_TARGET", gn->path ? gn->path : gn->name, VAR_GLOBAL);
}
getcwd(cwd, sizeof(cwd));
- Var_Set(".ERROR_CWD", cwd, VAR_GLOBAL, 0);
+ Var_Set(".ERROR_CWD", cwd, VAR_GLOBAL);
if (pbm->meta_fname[0]) {
- Var_Set(".ERROR_META_FILE", pbm->meta_fname, VAR_GLOBAL, 0);
+ Var_Set(".ERROR_META_FILE", pbm->meta_fname, VAR_GLOBAL);
}
meta_job_finish(job);
}
@@ -1013,7 +1013,7 @@ meta_ignore(GNode *gn, const char *p)
if (metaIgnorePatterns) {
char *pm;
- Var_Set(".p.", p, gn, 0);
+ Var_Set(".p.", p, gn);
pm = Var_Subst(NULL,
"${" MAKE_META_IGNORE_PATTERNS ":@m@${.p.:M$m}@}",
gn, VARF_WANTRES);
@@ -1238,11 +1238,11 @@ meta_oodate(GNode *gn, Boolean oodate)
if (pid > 0 && pid != lastpid) {
char *ldir;
char *tp;
-
+
if (lastpid > 0) {
/* We need to remember these. */
- Var_Set(lcwd_vname, lcwd, VAR_GLOBAL, 0);
- Var_Set(ldir_vname, latestdir, VAR_GLOBAL, 0);
+ Var_Set(lcwd_vname, lcwd, VAR_GLOBAL);
+ Var_Set(ldir_vname, latestdir, VAR_GLOBAL);
}
snprintf(lcwd_vname, sizeof(lcwd_vname), LCWD_VNAME_FMT, pid);
snprintf(ldir_vname, sizeof(ldir_vname), LDIR_VNAME_FMT, pid);
@@ -1288,9 +1288,9 @@ meta_oodate(GNode *gn, Boolean oodate)
child = atoi(p);
if (child > 0) {
snprintf(cldir, sizeof(cldir), LCWD_VNAME_FMT, child);
- Var_Set(cldir, lcwd, VAR_GLOBAL, 0);
+ Var_Set(cldir, lcwd, VAR_GLOBAL);
snprintf(cldir, sizeof(cldir), LDIR_VNAME_FMT, child);
- Var_Set(cldir, latestdir, VAR_GLOBAL, 0);
+ Var_Set(cldir, latestdir, VAR_GLOBAL);
#ifdef DEBUG_META_MODE
if (DEBUG(META))
fprintf(debug_file, "%s: %d: %d: cwd=%s lcwd=%s ldir=%s\n",
@@ -1305,8 +1305,8 @@ meta_oodate(GNode *gn, Boolean oodate)
/* Update lcwd and latest directory. */
strlcpy(latestdir, p, sizeof(latestdir));
strlcpy(lcwd, p, sizeof(lcwd));
- Var_Set(lcwd_vname, lcwd, VAR_GLOBAL, 0);
- Var_Set(ldir_vname, lcwd, VAR_GLOBAL, 0);
+ Var_Set(lcwd_vname, lcwd, VAR_GLOBAL);
+ Var_Set(ldir_vname, lcwd, VAR_GLOBAL);
#ifdef DEBUG_META_MODE
if (DEBUG(META))
fprintf(debug_file, "%s: %d: cwd=%s ldir=%s\n", fname, lineno, cwd, lcwd);
@@ -1633,7 +1633,7 @@ meta_oodate(GNode *gn, Boolean oodate)
* All we can sanely do is set it to .ALLSRC.
*/
Var_Delete(OODATE, gn);
- Var_Set(OODATE, Var_Value(ALLSRC, gn, &cp), gn, 0);
+ Var_Set(OODATE, Var_Value(ALLSRC, gn, &cp), gn);
free(cp);
}
Index: src/usr.bin/make/nonints.h
diff -u src/usr.bin/make/nonints.h:1.76 src/usr.bin/make/nonints.h:1.77
--- src/usr.bin/make/nonints.h:1.76 Thu Jul 2 15:14:38 2020
+++ src/usr.bin/make/nonints.h Thu Jul 2 15:47:38 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: nonints.h,v 1.76 2020/07/02 15:14:38 rillig Exp $ */
+/* $NetBSD: nonints.h,v 1.77 2020/07/02 15:47:38 rillig Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@@ -186,7 +186,7 @@ typedef enum {
} Varf_Flags;
void Var_Delete(const char *, GNode *);
-void Var_Set(const char *, const char *, GNode *, int);
+void Var_Set(const char *, const char *, GNode *);
void Var_Append(const char *, const char *, GNode *);
Boolean Var_Exists(const char *, GNode *);
char *Var_Value(const char *, GNode *, char **);
Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.233 src/usr.bin/make/parse.c:1.234
--- src/usr.bin/make/parse.c:1.233 Thu Sep 26 21:09:55 2019
+++ src/usr.bin/make/parse.c Thu Jul 2 15:47:38 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.233 2019/09/26 21:09:55 sjg Exp $ */
+/* $NetBSD: parse.c,v 1.234 2020/07/02 15:47:38 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.233 2019/09/26 21:09:55 sjg Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.234 2020/07/02 15:47:38 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.233 2019/09/26 21:09:55 sjg Exp $");
+__RCSID("$NetBSD: parse.c,v 1.234 2020/07/02 15:47:38 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -1590,7 +1590,7 @@ ParseDoDependency(char *line)
break;
#ifdef POSIX
case Posix:
- Var_Set("%POSIX", "1003.2", VAR_GLOBAL, 0);
+ Var_Set("%POSIX", "1003.2", VAR_GLOBAL);
break;
#endif
default:
@@ -1965,13 +1965,13 @@ Parse_DoVar(char *line, GNode *ctxt)
* so that it gets substituted!
*/
if (!Var_Exists(line, ctxt))
- Var_Set(line, "", ctxt, 0);
+ Var_Set(line, "", ctxt);
cp = Var_Subst(NULL, cp, ctxt, VARF_WANTRES|VARF_ASSIGN);
oldVars = oldOldVars;
freeCp = TRUE;
- Var_Set(line, cp, ctxt, 0);
+ Var_Set(line, cp, ctxt);
} else if (type == VAR_SHELL) {
char *res;
const char *error;
@@ -1987,7 +1987,7 @@ Parse_DoVar(char *line, GNode *ctxt)
}
res = Cmd_Exec(cp, &error);
- Var_Set(line, res, ctxt, 0);
+ Var_Set(line, res, ctxt);
free(res);
if (error)
@@ -1996,7 +1996,7 @@ Parse_DoVar(char *line, GNode *ctxt)
/*
* Normal assignment -- just do it.
*/
- Var_Set(line, cp, ctxt, 0);
+ Var_Set(line, cp, ctxt);
}
if (strcmp(line, MAKEOVERRIDES) == 0)
Main_ExportMAKEFLAGS(FALSE); /* re-export MAKEFLAGS */
@@ -2352,9 +2352,9 @@ ParseSetIncludedFile(void)
char *pd, *dp = NULL;
pf = Var_Value(".PARSEFILE", VAR_GLOBAL, &fp);
- Var_Set(".INCLUDEDFROMFILE", pf, VAR_GLOBAL, 0);
+ Var_Set(".INCLUDEDFROMFILE", pf, VAR_GLOBAL);
pd = Var_Value(".PARSEDIR", VAR_GLOBAL, &dp);
- Var_Set(".INCLUDEDFROMDIR", pd, VAR_GLOBAL, 0);
+ Var_Set(".INCLUDEDFROMDIR", pd, VAR_GLOBAL);
if (DEBUG(PARSE))
fprintf(debug_file, "%s: ${.INCLUDEDFROMDIR} = `%s' "
@@ -2386,16 +2386,16 @@ ParseSetParseFile(const char *filename)
slash = strrchr(filename, '/');
if (slash == NULL) {
- Var_Set(".PARSEDIR", pd = curdir, VAR_GLOBAL, 0);
- Var_Set(".PARSEFILE", pf = filename, VAR_GLOBAL, 0);
+ Var_Set(".PARSEDIR", pd = curdir, VAR_GLOBAL);
+ Var_Set(".PARSEFILE", pf = filename, VAR_GLOBAL);
dirname= NULL;
} else {
len = slash - filename;
dirname = bmake_malloc(len + 1);
memcpy(dirname, filename, len);
dirname[len] = '\0';
- Var_Set(".PARSEDIR", pd = dirname, VAR_GLOBAL, 0);
- Var_Set(".PARSEFILE", pf = slash + 1, VAR_GLOBAL, 0);
+ Var_Set(".PARSEDIR", pd = dirname, VAR_GLOBAL);
+ Var_Set(".PARSEFILE", pf = slash + 1, VAR_GLOBAL);
}
if (DEBUG(PARSE))
fprintf(debug_file, "%s: ${.PARSEDIR} = `%s' ${.PARSEFILE} = `%s'\n",
Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.86 src/usr.bin/make/suff.c:1.87
--- src/usr.bin/make/suff.c:1.86 Sun Apr 16 20:38:18 2017
+++ src/usr.bin/make/suff.c Thu Jul 2 15:47:38 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: suff.c,v 1.86 2017/04/16 20:38:18 riastradh Exp $ */
+/* $NetBSD: suff.c,v 1.87 2020/07/02 15:47:38 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: suff.c,v 1.86 2017/04/16 20:38:18 riastradh Exp $";
+static char rcsid[] = "$NetBSD: suff.c,v 1.87 2020/07/02 15:47:38 rillig 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.86 2017/04/16 20:38:18 riastradh Exp $");
+__RCSID("$NetBSD: suff.c,v 1.87 2020/07/02 15:47:38 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -1093,9 +1093,9 @@ Suff_DoPaths(void)
}
}
- Var_Set(".INCLUDES", ptr = Dir_MakeFlags("-I", inIncludes), VAR_GLOBAL, 0);
+ Var_Set(".INCLUDES", ptr = Dir_MakeFlags("-I", inIncludes), VAR_GLOBAL);
free(ptr);
- Var_Set(".LIBS", ptr = Dir_MakeFlags("-L", inLibs), VAR_GLOBAL, 0);
+ Var_Set(".LIBS", ptr = Dir_MakeFlags("-L", inLibs), VAR_GLOBAL);
free(ptr);
Lst_Destroy(inIncludes, Dir_Destroy);
@@ -1941,7 +1941,7 @@ SuffFindArchiveDeps(GNode *gn, Lst slst)
*/
for (i = (sizeof(copy)/sizeof(copy[0]))-1; i >= 0; i--) {
char *p1;
- Var_Set(copy[i], Var_Value(copy[i], mem, &p1), gn, 0);
+ Var_Set(copy[i], Var_Value(copy[i], mem, &p1), gn);
free(p1);
}
@@ -1961,13 +1961,13 @@ SuffFindArchiveDeps(GNode *gn, Lst slst)
/*
* Set the other two local variables required for this target.
*/
- Var_Set(MEMBER, name, gn, 0);
- Var_Set(ARCHIVE, gn->name, gn, 0);
+ Var_Set(MEMBER, name, gn);
+ Var_Set(ARCHIVE, gn->name, gn);
/*
* Set $@ for compatibility with other makes
*/
- Var_Set(TARGET, gn->name, gn, 0);
+ Var_Set(TARGET, gn->name, gn);
/*
* Now we've got the important local variables set, expand any sources
@@ -2213,10 +2213,10 @@ SuffFindNormalDeps(GNode *gn, Lst slst)
}
}
- Var_Set(TARGET, gn->path ? gn->path : gn->name, gn, 0);
+ Var_Set(TARGET, gn->path ? gn->path : gn->name, gn);
pref = (targ != NULL) ? targ->pref : gn->name;
- Var_Set(PREFIX, pref, gn, 0);
+ Var_Set(PREFIX, pref, gn);
/*
* Now we've got the important local variables set, expand any sources
@@ -2246,7 +2246,7 @@ sfnd_abort:
targ->suff->searchPath));
if (gn->path != NULL) {
char *ptr;
- Var_Set(TARGET, gn->path, gn, 0);
+ Var_Set(TARGET, gn->path, gn);
if (targ != NULL) {
/*
@@ -2269,7 +2269,7 @@ sfnd_abort:
else
ptr = gn->path;
- Var_Set(PREFIX, ptr, gn, 0);
+ Var_Set(PREFIX, ptr, gn);
gn->path[savep] = savec;
} else {
@@ -2286,7 +2286,7 @@ sfnd_abort:
else
ptr = gn->path;
- Var_Set(PREFIX, ptr, gn, 0);
+ Var_Set(PREFIX, ptr, gn);
}
}
}
@@ -2373,9 +2373,9 @@ sfnd_abort:
*/
targ->node->type |= OP_DEPS_FOUND;
- Var_Set(PREFIX, targ->pref, targ->node, 0);
+ Var_Set(PREFIX, targ->pref, targ->node);
- Var_Set(TARGET, targ->node->name, targ->node, 0);
+ Var_Set(TARGET, targ->node->name, targ->node);
}
}
@@ -2458,8 +2458,8 @@ SuffFindDeps(GNode *gn, Lst slst)
/*
* Make sure we have these set, may get revised below.
*/
- Var_Set(TARGET, gn->path ? gn->path : gn->name, gn, 0);
- Var_Set(PREFIX, gn->name, gn, 0);
+ Var_Set(TARGET, gn->path ? gn->path : gn->name, gn);
+ Var_Set(PREFIX, gn->name, gn);
if (DEBUG(SUFF)) {
fprintf(debug_file, "SuffFindDeps (%s)\n", gn->name);
@@ -2488,14 +2488,14 @@ SuffFindDeps(GNode *gn, Lst slst)
Arch_FindLib(gn, s->searchPath);
} else {
gn->suffix = NULL;
- Var_Set(TARGET, gn->name, gn, 0);
+ Var_Set(TARGET, gn->name, gn);
}
/*
* Because a library (-lfoo) target doesn't follow the standard
* filesystem conventions, we don't set the regular variables for
* the thing. .PREFIX is simply made empty...
*/
- Var_Set(PREFIX, "", gn, 0);
+ Var_Set(PREFIX, "", gn);
} else {
SuffFindNormalDeps(gn, slst);
}
Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.229 src/usr.bin/make/var.c:1.230
--- src/usr.bin/make/var.c:1.229 Thu Jul 2 15:26:21 2020
+++ src/usr.bin/make/var.c Thu Jul 2 15:47:38 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.229 2020/07/02 15:26:21 rillig Exp $ */
+/* $NetBSD: var.c,v 1.230 2020/07/02 15:47:38 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.229 2020/07/02 15:26:21 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.230 2020/07/02 15:47:38 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.229 2020/07/02 15:26:21 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.230 2020/07/02 15:47:38 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -244,8 +244,9 @@ typedef enum {
VAR_NOSUBST = 0x20 /* don't expand vars in VarGetPattern */
} VarPattern_Flags;
-/* Var_Set flags */
-#define VAR_NO_EXPORT 0x01 /* do not export */
+typedef enum {
+ VAR_NO_EXPORT = 0x01 /* do not export */
+} VarSet_Flags;
typedef struct {
/*
@@ -884,7 +885,7 @@ Var_UnExport(char *str)
"${" MAKE_EXPORTED ":N%s}", v->name);
if (n < (int)sizeof(tmp)) {
cp = Var_Subst(NULL, tmp, VAR_GLOBAL, VARF_WANTRES);
- Var_Set(MAKE_EXPORTED, cp, VAR_GLOBAL, 0);
+ Var_Set(MAKE_EXPORTED, cp, VAR_GLOBAL);
free(cp);
}
}
@@ -898,36 +899,8 @@ Var_UnExport(char *str)
}
}
-/*-
- *-----------------------------------------------------------------------
- * Var_Set --
- * Set the variable name to the value val in the given context.
- *
- * Input:
- * name name of variable to set
- * val value to give to the variable
- * ctxt context in which to set it
- *
- * Results:
- * None.
- *
- * Side Effects:
- * If the variable doesn't yet exist, a new record is created for it.
- * Else the old value is freed and the new one stuck in its place
- *
- * Notes:
- * The variable is searched for only in its context before being
- * created in that context. I.e. if the context is VAR_GLOBAL,
- * only VAR_GLOBAL->context is searched. Likewise if it is VAR_CMD, only
- * VAR_CMD->context is searched. This is done to avoid the literally
- * thousands of unnecessary strcmp's that used to be done to
- * set, say, $(@) or $(<).
- * If the context is VAR_GLOBAL though, we check if the variable
- * was set in VAR_CMD from the command line and skip it if so.
- *-----------------------------------------------------------------------
- */
-void
-Var_Set(const char *name, const char *val, GNode *ctxt, int flags)
+static void
+Var_Set_Flags(const char *name, const char *val, GNode *ctxt, VarSet_Flags flags)
{
Var *v;
char *expanded_name = NULL;
@@ -1020,6 +993,40 @@ Var_Set(const char *name, const char *va
/*-
*-----------------------------------------------------------------------
+ * Var_Set --
+ * Set the variable name to the value val in the given context.
+ *
+ * Input:
+ * name name of variable to set
+ * val value to give to the variable
+ * ctxt context in which to set it
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * If the variable doesn't yet exist, a new record is created for it.
+ * Else the old value is freed and the new one stuck in its place
+ *
+ * Notes:
+ * The variable is searched for only in its context before being
+ * created in that context. I.e. if the context is VAR_GLOBAL,
+ * only VAR_GLOBAL->context is searched. Likewise if it is VAR_CMD, only
+ * VAR_CMD->context is searched. This is done to avoid the literally
+ * thousands of unnecessary strcmp's that used to be done to
+ * set, say, $(@) or $(<).
+ * If the context is VAR_GLOBAL though, we check if the variable
+ * was set in VAR_CMD from the command line and skip it if so.
+ *-----------------------------------------------------------------------
+ */
+void
+Var_Set(const char *name, const char *val, GNode *ctxt)
+{
+ Var_Set_Flags(name, val, ctxt, 0);
+}
+
+/*-
+ *-----------------------------------------------------------------------
* Var_Append --
* The variable of the given name has the given value appended to it in
* the given context.
@@ -1069,7 +1076,7 @@ Var_Append(const char *name, const char
v = VarFind(name, ctxt, (ctxt == VAR_GLOBAL) ? (FIND_CMD|FIND_ENV) : 0);
if (v == NULL) {
- Var_Set(name, val, ctxt, 0);
+ Var_Set(name, val, ctxt);
} else if (ctxt == VAR_CMD || !(v->flags & VAR_FROM_CMD)) {
Buf_AddByte(&v->val, ' ');
Buf_AddBytes(&v->val, strlen(val), val);
@@ -1836,7 +1843,7 @@ VarLoopExpand(GNode *ctx MAKE_ATTR_UNUSE
int slen;
if (word && *word) {
- Var_Set(loop->tvar, word, loop->ctxt, VAR_NO_EXPORT);
+ Var_Set_Flags(loop->tvar, word, loop->ctxt, VAR_NO_EXPORT);
s = Var_Subst(NULL, loop->str, loop->ctxt, loop->errnum | VARF_WANTRES);
if (s != NULL && *s != '\0') {
if (addSpace && *s != '\n')
@@ -2713,7 +2720,7 @@ ApplyModifiers(char *nstr, const char *t
if (emsg)
Error(emsg, nstr);
else
- Var_Set(v->name, newStr, v_ctxt, 0);
+ Var_Set(v->name, newStr, v_ctxt);
free(newStr);
break;
case '?':
@@ -2721,7 +2728,7 @@ ApplyModifiers(char *nstr, const char *t
break;
/* FALLTHROUGH */
default:
- Var_Set(v->name, pattern.rhs, v_ctxt, 0);
+ Var_Set(v->name, pattern.rhs, v_ctxt);
break;
}
}
@@ -2774,10 +2781,10 @@ ApplyModifiers(char *nstr, const char *t
np = bmake_strndup(cp, n+1);
np[n] = '\0';
cp = tstr + 2 + n;
- Var_Set(np, nstr, ctxt, 0);
+ Var_Set(np, nstr, ctxt);
free(np);
} else {
- Var_Set("_", nstr, ctxt, 0);
+ Var_Set("_", nstr, ctxt);
}
newStr = nstr;
termc = *cp;