Module Name: src
Committed By: rillig
Date: Thu Feb 4 21:33:14 UTC 2021
Modified Files:
src/usr.bin/make: cond.c dir.c for.c job.c main.c make.h meta.c parse.c
targ.c trace.c var.c
src/usr.bin/make/unit-tests: varname-make_print_var_on_error-jobs.mk
varname-make_print_var_on_error.mk
Log Message:
make: rename some VAR constants to SCOPE
The word "context" does not fit perfectly to the variables that are
associate with a GNode, as the context is usually something from the
outside and the variables are more like properties inherent to the
GNode.
The term "global context" fits even less. Since the thing where
variables are looked up is commonly named a scope, use that term
instead.
This commit only renames the global variables VAR_GLOBAL, VAR_INTERNAL
and VAR_CMDLINE, plus a few very closely related comments. These are:
GNode.vars (because of line breaks)
GNode_Free (dito)
varname-make_print_var_on_error.mk
varname-make_print_var_on_error-jobs.mk
The debug message in Var_Stats is left as-is since there is no unit test
for it yet.
The other renamings (variable names "context", "ctxt", as well as
further comments) will be done in a follow-up commit.
To generate a diff of this commit:
cvs rdiff -u -r1.254 -r1.255 src/usr.bin/make/cond.c
cvs rdiff -u -r1.267 -r1.268 src/usr.bin/make/dir.c
cvs rdiff -u -r1.140 -r1.141 src/usr.bin/make/for.c
cvs rdiff -u -r1.415 -r1.416 src/usr.bin/make/job.c
cvs rdiff -u -r1.529 -r1.530 src/usr.bin/make/main.c
cvs rdiff -u -r1.251 -r1.252 src/usr.bin/make/make.h
cvs rdiff -u -r1.174 -r1.175 src/usr.bin/make/meta.c
cvs rdiff -u -r1.544 -r1.545 src/usr.bin/make/parse.c
cvs rdiff -u -r1.163 -r1.164 src/usr.bin/make/targ.c
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/make/trace.c
cvs rdiff -u -r1.800 -r1.801 src/usr.bin/make/var.c
cvs rdiff -u -r1.2 -r1.3 \
src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.mk
cvs rdiff -u -r1.5 -r1.6 \
src/usr.bin/make/unit-tests/varname-make_print_var_on_error.mk
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/cond.c
diff -u src/usr.bin/make/cond.c:1.254 src/usr.bin/make/cond.c:1.255
--- src/usr.bin/make/cond.c:1.254 Sat Jan 30 20:53:29 2021
+++ src/usr.bin/make/cond.c Thu Feb 4 21:33:13 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cond.c,v 1.254 2021/01/30 20:53:29 rillig Exp $ */
+/* $NetBSD: cond.c,v 1.255 2021/02/04 21:33:13 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
#include "dir.h"
/* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: cond.c,v 1.254 2021/01/30 20:53:29 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.255 2021/02/04 21:33:13 rillig Exp $");
/*
* The parsing of conditional expressions is based on this grammar:
@@ -268,7 +268,7 @@ ParseFuncArg(CondParser *par, const char
? VARE_WANTRES | VARE_UNDEFERR
: VARE_NONE;
FStr nestedVal;
- (void)Var_Parse(&p, VAR_CMDLINE, eflags, &nestedVal);
+ (void)Var_Parse(&p, SCOPE_CMDLINE, eflags, &nestedVal);
/* TODO: handle errors */
Buf_AddStr(&argBuf, nestedVal.str);
FStr_Done(&nestedVal);
@@ -303,7 +303,7 @@ ParseFuncArg(CondParser *par, const char
static Boolean
FuncDefined(size_t argLen MAKE_ATTR_UNUSED, const char *arg)
{
- FStr value = Var_Value(arg, VAR_CMDLINE);
+ FStr value = Var_Value(arg, SCOPE_CMDLINE);
Boolean result = value.str != NULL;
FStr_Done(&value);
return result;
@@ -426,7 +426,7 @@ CondParser_StringExpr(CondParser *par, c
nested_p = par->p;
atStart = nested_p == start;
- parseResult = Var_Parse(&nested_p, VAR_CMDLINE, eflags, inout_str);
+ parseResult = Var_Parse(&nested_p, SCOPE_CMDLINE, eflags, inout_str);
/* TODO: handle errors */
if (inout_str->str == var_Error) {
if (parseResult == VPR_ERR) {
@@ -741,7 +741,7 @@ ParseEmptyArg(CondParser *par MAKE_ATTR_
*out_arg = NULL;
(*pp)--; /* Make (*pp)[1] point to the '('. */
- (void)Var_Parse(pp, VAR_CMDLINE, doEval ? VARE_WANTRES : VARE_NONE,
+ (void)Var_Parse(pp, SCOPE_CMDLINE, doEval ? VARE_WANTRES : VARE_NONE,
&val);
/* TODO: handle errors */
/* If successful, *pp points beyond the closing ')' now. */
Index: src/usr.bin/make/dir.c
diff -u src/usr.bin/make/dir.c:1.267 src/usr.bin/make/dir.c:1.268
--- src/usr.bin/make/dir.c:1.267 Wed Feb 3 13:53:12 2021
+++ src/usr.bin/make/dir.c Thu Feb 4 21:33:13 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.267 2021/02/03 13:53:12 rillig Exp $ */
+/* $NetBSD: dir.c,v 1.268 2021/02/04 21:33:13 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -138,7 +138,7 @@
#include "job.h"
/* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: dir.c,v 1.267 2021/02/03 13:53:12 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.268 2021/02/04 21:33:13 rillig Exp $");
/*
* A search path is a list of CachedDir structures. A CachedDir has in it the
@@ -549,7 +549,7 @@ Dir_SetPATH(void)
CachedDirListNode *ln;
Boolean seenDotLast = FALSE; /* true if we should search '.' last */
- Var_Delete(".PATH", VAR_GLOBAL);
+ Var_Delete(".PATH", SCOPE_GLOBAL);
if ((ln = dirSearchPath.dirs.first) != NULL) {
CachedDir *dir = ln->datum;
Index: src/usr.bin/make/for.c
diff -u src/usr.bin/make/for.c:1.140 src/usr.bin/make/for.c:1.141
--- src/usr.bin/make/for.c:1.140 Mon Feb 1 17:26:03 2021
+++ src/usr.bin/make/for.c Thu Feb 4 21:33:13 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: for.c,v 1.140 2021/02/01 17:26:03 rillig Exp $ */
+/* $NetBSD: for.c,v 1.141 2021/02/04 21:33:13 rillig Exp $ */
/*
* Copyright (c) 1992, The Regents of the University of California.
@@ -58,7 +58,7 @@
#include "make.h"
/* "@(#)for.c 8.1 (Berkeley) 6/6/93" */
-MAKE_RCSID("$NetBSD: for.c,v 1.140 2021/02/01 17:26:03 rillig Exp $");
+MAKE_RCSID("$NetBSD: for.c,v 1.141 2021/02/04 21:33:13 rillig Exp $");
/* One of the variables to the left of the "in" in a .for loop. */
@@ -173,7 +173,7 @@ ForLoop_ParseItems(ForLoop *f, const cha
cpp_skip_whitespace(&p);
- if (Var_Subst(p, VAR_GLOBAL, VARE_WANTRES, &items) != VPR_OK) {
+ if (Var_Subst(p, SCOPE_GLOBAL, VARE_WANTRES, &items) != VPR_OK) {
Parse_Error(PARSE_FATAL, "Error in .for loop items");
return FALSE;
}
Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.415 src/usr.bin/make/job.c:1.416
--- src/usr.bin/make/job.c:1.415 Wed Feb 3 13:53:12 2021
+++ src/usr.bin/make/job.c Thu Feb 4 21:33:13 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.415 2021/02/03 13:53:12 rillig Exp $ */
+/* $NetBSD: job.c,v 1.416 2021/02/04 21:33:13 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -142,7 +142,7 @@
#include "trace.h"
/* "@(#)job.c 8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: job.c,v 1.415 2021/02/03 13:53:12 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.416 2021/02/04 21:33:13 rillig Exp $");
/*
* A shell defines how the commands are run. All commands for a target are
@@ -2136,7 +2136,7 @@ Shell_Init(void)
if (shellPath == NULL)
InitShellNameAndPath();
- Var_SetWithFlags(".SHELL", shellPath, VAR_CMDLINE, VAR_SET_READONLY);
+ Var_SetWithFlags(".SHELL", shellPath, SCOPE_CMDLINE, VAR_SET_READONLY);
if (shell->errFlag == NULL)
shell->errFlag = "";
if (shell->echoFlag == NULL)
@@ -2176,12 +2176,12 @@ Job_SetPrefix(void)
{
if (targPrefix != NULL) {
free(targPrefix);
- } else if (!Var_Exists(MAKE_JOB_PREFIX, VAR_GLOBAL)) {
+ } else if (!Var_Exists(MAKE_JOB_PREFIX, SCOPE_GLOBAL)) {
Global_Set(MAKE_JOB_PREFIX, "---");
}
(void)Var_Subst("${" MAKE_JOB_PREFIX "}",
- VAR_GLOBAL, VARE_WANTRES, &targPrefix);
+ SCOPE_GLOBAL, VARE_WANTRES, &targPrefix);
/* TODO: handle errors */
}
Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.529 src/usr.bin/make/main.c:1.530
--- src/usr.bin/make/main.c:1.529 Wed Feb 3 13:53:12 2021
+++ src/usr.bin/make/main.c Thu Feb 4 21:33:13 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.529 2021/02/03 13:53:12 rillig Exp $ */
+/* $NetBSD: main.c,v 1.530 2021/02/04 21:33:13 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -111,7 +111,7 @@
#include "trace.h"
/* "@(#)main.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.529 2021/02/03 13:53:12 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.530 2021/02/04 21:33:13 rillig Exp $");
#if defined(MAKE_NATIVE) && !defined(lint)
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
"The Regents of the University of California. "
@@ -655,7 +655,7 @@ rearg:
for (; argc > 1; argv++, argc--) {
VarAssign var;
if (Parse_IsVar(argv[1], &var)) {
- Parse_DoVar(&var, VAR_CMDLINE);
+ Parse_DoVar(&var, SCOPE_CMDLINE);
} else {
if (argv[1][0] == '\0')
Punt("illegal (null) argument.");
@@ -693,7 +693,7 @@ Main_ParseArgLine(const char *line)
return;
{
- FStr argv0 = Var_Value(".MAKE", VAR_GLOBAL);
+ FStr argv0 = Var_Value(".MAKE", SCOPE_GLOBAL);
buf = str_concat3(argv0.str, " ", line);
FStr_Done(&argv0);
}
@@ -753,7 +753,7 @@ Main_SetObjdir(Boolean writable, const c
static Boolean
SetVarObjdir(Boolean writable, const char *var, const char *suffix)
{
- FStr path = Var_Value(var, VAR_CMDLINE);
+ FStr path = Var_Value(var, SCOPE_CMDLINE);
FStr xpath;
if (path.str == NULL || path.str[0] == '\0') {
@@ -765,7 +765,7 @@ SetVarObjdir(Boolean writable, const cha
xpath = FStr_InitRefer(path.str);
if (strchr(path.str, '$') != 0) {
char *expanded;
- (void)Var_Subst(path.str, VAR_GLOBAL, VARE_WANTRES, &expanded);
+ (void)Var_Subst(path.str, SCOPE_GLOBAL, VARE_WANTRES, &expanded);
/* TODO: handle errors */
xpath = FStr_InitOwn(expanded);
}
@@ -818,7 +818,7 @@ MakeMode(void)
{
char *mode;
- (void)Var_Subst("${" MAKE_MODE ":tl}", VAR_GLOBAL, VARE_WANTRES, &mode);
+ (void)Var_Subst("${" MAKE_MODE ":tl}", SCOPE_GLOBAL, VARE_WANTRES, &mode);
/* TODO: handle errors */
if (mode[0] != '\0') {
@@ -840,7 +840,7 @@ PrintVar(const char *varname, Boolean ex
{
if (strchr(varname, '$') != NULL) {
char *evalue;
- (void)Var_Subst(varname, VAR_GLOBAL, VARE_WANTRES, &evalue);
+ (void)Var_Subst(varname, SCOPE_GLOBAL, VARE_WANTRES, &evalue);
/* TODO: handle errors */
printf("%s\n", evalue);
bmake_free(evalue);
@@ -848,14 +848,14 @@ PrintVar(const char *varname, Boolean ex
} else if (expandVars) {
char *expr = str_concat3("${", varname, "}");
char *evalue;
- (void)Var_Subst(expr, VAR_GLOBAL, VARE_WANTRES, &evalue);
+ (void)Var_Subst(expr, SCOPE_GLOBAL, VARE_WANTRES, &evalue);
/* TODO: handle errors */
free(expr);
printf("%s\n", evalue);
bmake_free(evalue);
} else {
- FStr value = Var_Value(varname, VAR_GLOBAL);
+ FStr value = Var_Value(varname, SCOPE_GLOBAL);
printf("%s\n", value.str != NULL ? value.str : "");
FStr_Done(&value);
}
@@ -875,7 +875,7 @@ GetBooleanVar(const char *varname, Boole
char *value;
Boolean res;
- (void)Var_Subst(expr, VAR_GLOBAL, VARE_WANTRES, &value);
+ (void)Var_Subst(expr, SCOPE_GLOBAL, VARE_WANTRES, &value);
/* TODO: handle errors */
res = ParseBoolean(value, fallback);
free(value);
@@ -1051,13 +1051,13 @@ HandlePWD(const struct stat *curdir_st)
if (ignorePWD || (pwd = getenv("PWD")) == NULL)
return;
- prefix = Var_Value("MAKEOBJDIRPREFIX", VAR_CMDLINE);
+ prefix = Var_Value("MAKEOBJDIRPREFIX", SCOPE_CMDLINE);
if (prefix.str != NULL) {
FStr_Done(&prefix);
return;
}
- makeobjdir = Var_Value("MAKEOBJDIR", VAR_CMDLINE);
+ makeobjdir = Var_Value("MAKEOBJDIR", SCOPE_CMDLINE);
if (makeobjdir.str != NULL && strchr(makeobjdir.str, '$') != NULL)
goto ignore_pwd;
@@ -1238,10 +1238,10 @@ InitMaxJobs(void)
int n;
if (forceJobs || opts.compatMake ||
- !Var_Exists(".MAKE.JOBS", VAR_GLOBAL))
+ !Var_Exists(".MAKE.JOBS", SCOPE_GLOBAL))
return;
- (void)Var_Subst("${.MAKE.JOBS}", VAR_GLOBAL, VARE_WANTRES, &value);
+ (void)Var_Subst("${.MAKE.JOBS}", SCOPE_GLOBAL, VARE_WANTRES, &value);
/* TODO: handle errors */
n = (int)strtol(value, NULL, 0);
if (n < 1) {
@@ -1273,10 +1273,10 @@ static void
InitVpath(void)
{
char *vpath, savec, *path;
- if (!Var_Exists("VPATH", VAR_CMDLINE))
+ if (!Var_Exists("VPATH", SCOPE_CMDLINE))
return;
- (void)Var_Subst("${VPATH}", VAR_CMDLINE, VARE_WANTRES, &vpath);
+ (void)Var_Subst("${VPATH}", SCOPE_CMDLINE, VARE_WANTRES, &vpath);
/* TODO: handle errors */
path = vpath;
do {
@@ -1314,7 +1314,7 @@ ReadFirstDefaultMakefile(void)
char *prefs;
(void)Var_Subst("${" MAKE_MAKEFILE_PREFERENCE "}",
- VAR_CMDLINE, VARE_WANTRES, &prefs);
+ SCOPE_CMDLINE, VARE_WANTRES, &prefs);
/* TODO: handle errors */
/* XXX: This should use a local list instead of opts.makefiles
@@ -1426,7 +1426,7 @@ main_Init(int argc, char **argv)
Global_Set("MFLAGS", "");
Global_Set(".ALLTARGETS", "");
/* some makefiles need to know this */
- Var_Set(MAKE_LEVEL ".ENV", MAKE_LEVEL_ENV, VAR_CMDLINE);
+ Var_Set(MAKE_LEVEL ".ENV", MAKE_LEVEL_ENV, SCOPE_CMDLINE);
/* Set some other useful variables. */
{
@@ -1545,7 +1545,7 @@ main_PrepareMaking(void)
/* In particular suppress .depend for '-r -V .OBJDIR -f /dev/null' */
if (!opts.noBuiltins || opts.printVars == PVM_NONE) {
(void)Var_Subst("${.MAKE.DEPENDFILE}",
- VAR_CMDLINE, VARE_WANTRES, &makeDependfile);
+ SCOPE_CMDLINE, VARE_WANTRES, &makeDependfile);
if (makeDependfile[0] != '\0') {
/* TODO: handle errors */
doing_depend = TRUE;
@@ -1560,7 +1560,7 @@ main_PrepareMaking(void)
MakeMode();
{
- FStr makeflags = Var_Value(MAKEFLAGS, VAR_GLOBAL);
+ FStr makeflags = Var_Value(MAKEFLAGS, SCOPE_GLOBAL);
Global_Append("MFLAGS", makeflags.str);
FStr_Done(&makeflags);
}
@@ -1691,7 +1691,7 @@ ReadMakefile(const char *fname)
if (strcmp(fname, "-") == 0) {
Parse_File(NULL /*stdin*/, -1);
- Var_Set("MAKEFILE", "", VAR_INTERNAL);
+ Var_Set("MAKEFILE", "", SCOPE_INTERNAL);
} else {
/* if we've chdir'd, rebuild the path name */
if (strcmp(curdir, objdir) != 0 && *fname != '/') {
@@ -1735,7 +1735,7 @@ ReadMakefile(const char *fname)
*/
found:
if (!doing_depend)
- Var_Set("MAKEFILE", fname, VAR_INTERNAL);
+ Var_Set("MAKEFILE", fname, SCOPE_INTERNAL);
Parse_File(fname, fd);
}
free(path);
@@ -2105,7 +2105,7 @@ SetErrorVars(GNode *gn)
* We can print this even if there is no .ERROR target.
*/
Global_Set(".ERROR_TARGET", gn->name);
- Var_Delete(".ERROR_CMD", VAR_GLOBAL);
+ Var_Delete(".ERROR_CMD", SCOPE_GLOBAL);
for (ln = gn->commands.first; ln != NULL; ln = ln->next) {
const char *cmd = ln->datum;
@@ -2147,7 +2147,7 @@ PrintOnError(GNode *gn, const char *msg)
{
char *errorVarsValues;
(void)Var_Subst("${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'\n@}",
- VAR_GLOBAL, VARE_WANTRES, &errorVarsValues);
+ SCOPE_GLOBAL, VARE_WANTRES, &errorVarsValues);
/* TODO: handle errors */
printf("%s", errorVarsValues);
free(errorVarsValues);
@@ -2177,7 +2177,7 @@ Main_ExportMAKEFLAGS(Boolean first)
once = FALSE;
expr = "${.MAKEFLAGS} ${.MAKEOVERRIDES:O:u:@v@$v=${$v:Q}@}";
- (void)Var_Subst(expr, VAR_CMDLINE, VARE_WANTRES, &s);
+ (void)Var_Subst(expr, SCOPE_CMDLINE, VARE_WANTRES, &s);
/* TODO: handle errors */
if (s[0] != '\0') {
#ifdef POSIX
@@ -2199,7 +2199,7 @@ getTmpdir(void)
/* Honor $TMPDIR but only if it is valid. Ensure it ends with '/'. */
(void)Var_Subst("${TMPDIR:tA:U" _PATH_TMP "}/",
- VAR_GLOBAL, VARE_WANTRES, &tmpdir);
+ SCOPE_GLOBAL, VARE_WANTRES, &tmpdir);
/* TODO: handle errors */
if (stat(tmpdir, &st) < 0 || !S_ISDIR(st.st_mode)) {
Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.251 src/usr.bin/make/make.h:1.252
--- src/usr.bin/make/make.h:1.251 Tue Feb 2 21:26:51 2021
+++ src/usr.bin/make/make.h Thu Feb 4 21:33:13 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: make.h,v 1.251 2021/02/02 21:26:51 rillig Exp $ */
+/* $NetBSD: make.h,v 1.252 2021/02/04 21:33:13 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -429,11 +429,14 @@ typedef struct GNode {
/* Last time (sequence number) we tried to make this node */
unsigned int checked_seqno;
- /* The "local" variables that are specific to this target and this
+ /*
+ * The "local" variables that are specific to this target and this
* target only, such as $@, $<, $?.
*
- * Also used for the global variable scopes VAR_GLOBAL, VAR_CMDLINE,
- * VAR_INTERNAL, which contain variables with arbitrary names. */
+ * Also used for the global variable scopes SCOPE_GLOBAL,
+ * SCOPE_CMDLINE, SCOPE_INTERNAL, which contain variables with
+ * arbitrary names.
+ */
HashTable /* of Var pointer */ vars;
/* The commands to be given to a shell to create this target. */
@@ -496,11 +499,11 @@ extern GNode *defaultNode;
* Variables defined internally by make which should not override those set
* by makefiles.
*/
-extern GNode *VAR_INTERNAL;
+extern GNode *SCOPE_INTERNAL;
/* Variables defined in a global context, e.g in the Makefile itself. */
-extern GNode *VAR_GLOBAL;
+extern GNode *SCOPE_GLOBAL;
/* Variables defined on the command line. */
-extern GNode *VAR_CMDLINE;
+extern GNode *SCOPE_CMDLINE;
/*
* Value returned by Var_Parse when an error is encountered. It actually
Index: src/usr.bin/make/meta.c
diff -u src/usr.bin/make/meta.c:1.174 src/usr.bin/make/meta.c:1.175
--- src/usr.bin/make/meta.c:1.174 Wed Feb 3 15:08:17 2021
+++ src/usr.bin/make/meta.c Thu Feb 4 21:33:14 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: meta.c,v 1.174 2021/02/03 15:08:17 rillig Exp $ */
+/* $NetBSD: meta.c,v 1.175 2021/02/04 21:33:14 rillig Exp $ */
/*
* Implement 'meta' mode.
@@ -609,7 +609,7 @@ meta_mode_init(const char *make_mode)
get_mode_bf(metaMissing, "missing-meta=");
get_mode_bf(metaSilent, "silent=");
}
- if (metaVerbose && !Var_Exists(MAKE_META_PREFIX, VAR_GLOBAL)) {
+ if (metaVerbose && !Var_Exists(MAKE_META_PREFIX, SCOPE_GLOBAL)) {
/*
* The default value for MAKE_META_PREFIX
* prints the absolute path of the target.
@@ -627,7 +627,7 @@ meta_mode_init(const char *make_mode)
* We consider ourselves master of all within ${.MAKE.META.BAILIWICK}
*/
(void)Var_Subst("${.MAKE.META.BAILIWICK:O:u:tA}",
- VAR_GLOBAL, VARE_WANTRES, &metaBailiwickStr);
+ SCOPE_GLOBAL, VARE_WANTRES, &metaBailiwickStr);
/* TODO: handle errors */
str2Lst_Append(&metaBailiwick, metaBailiwickStr);
/*
@@ -636,19 +636,19 @@ meta_mode_init(const char *make_mode)
Global_Append(MAKE_META_IGNORE_PATHS,
"/dev /etc /proc /tmp /var/run /var/tmp ${TMPDIR}");
(void)Var_Subst("${" MAKE_META_IGNORE_PATHS ":O:u:tA}",
- VAR_GLOBAL, VARE_WANTRES, &metaIgnorePathsStr);
+ SCOPE_GLOBAL, VARE_WANTRES, &metaIgnorePathsStr);
/* TODO: handle errors */
str2Lst_Append(&metaIgnorePaths, metaIgnorePathsStr);
/*
* We ignore any paths that match ${.MAKE.META.IGNORE_PATTERNS}
*/
- value = Var_Value(MAKE_META_IGNORE_PATTERNS, VAR_GLOBAL);
+ value = Var_Value(MAKE_META_IGNORE_PATTERNS, SCOPE_GLOBAL);
if (value.str != NULL) {
metaIgnorePatterns = TRUE;
FStr_Done(&value);
}
- value = Var_Value(MAKE_META_IGNORE_FILTER, VAR_GLOBAL);
+ value = Var_Value(MAKE_META_IGNORE_FILTER, SCOPE_GLOBAL);
if (value.str != NULL) {
metaIgnoreFilter = TRUE;
FStr_Done(&value);
@@ -812,7 +812,7 @@ meta_job_output(Job *job, char *cp, cons
char *cp2;
(void)Var_Subst("${" MAKE_META_PREFIX "}",
- VAR_GLOBAL, VARE_WANTRES, &meta_prefix);
+ SCOPE_GLOBAL, VARE_WANTRES, &meta_prefix);
/* TODO: handle errors */
if ((cp2 = strchr(meta_prefix, '$')) != NULL)
meta_prefix_len = (size_t)(cp2 - meta_prefix);
@@ -1223,12 +1223,12 @@ meta_oodate(GNode *gn, Boolean oodate)
snprintf(lcwd_vname, sizeof lcwd_vname, LCWD_VNAME_FMT, pid);
snprintf(ldir_vname, sizeof ldir_vname, LDIR_VNAME_FMT, pid);
lastpid = pid;
- ldir = Var_Value(ldir_vname, VAR_GLOBAL);
+ ldir = Var_Value(ldir_vname, SCOPE_GLOBAL);
if (ldir.str != NULL) {
strlcpy(latestdir, ldir.str, sizeof latestdir);
FStr_Done(&ldir);
}
- ldir = Var_Value(lcwd_vname, VAR_GLOBAL);
+ ldir = Var_Value(lcwd_vname, SCOPE_GLOBAL);
if (ldir.str != NULL) {
strlcpy(lcwd, ldir.str, sizeof lcwd);
FStr_Done(&ldir);
@@ -1251,8 +1251,8 @@ meta_oodate(GNode *gn, Boolean oodate)
/* Process according to record type. */
switch (buf[0]) {
case 'X': /* eXit */
- Var_DeleteExpand(lcwd_vname, VAR_GLOBAL);
- Var_DeleteExpand(ldir_vname, VAR_GLOBAL);
+ Var_DeleteExpand(lcwd_vname, SCOPE_GLOBAL);
+ Var_DeleteExpand(ldir_vname, SCOPE_GLOBAL);
lastpid = 0; /* no need to save ldir_vname */
break;
Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.544 src/usr.bin/make/parse.c:1.545
--- src/usr.bin/make/parse.c:1.544 Thu Feb 4 19:00:45 2021
+++ src/usr.bin/make/parse.c Thu Feb 4 21:33:14 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.544 2021/02/04 19:00:45 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.545 2021/02/04 21:33:14 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.544 2021/02/04 19:00:45 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.545 2021/02/04 21:33:14 rillig Exp $");
/* types and constants */
@@ -576,13 +576,13 @@ PrintLocation(FILE *f, const char *fname
/* Find out which makefile is the culprit.
* We try ${.PARSEDIR} and apply realpath(3) if not absolute. */
- dir = Var_Value(".PARSEDIR", VAR_GLOBAL);
+ dir = Var_Value(".PARSEDIR", SCOPE_GLOBAL);
if (dir.str == NULL)
dir.str = ".";
if (dir.str[0] != '/')
dir.str = realpath(dir.str, dirbuf);
- base = Var_Value(".PARSEFILE", VAR_GLOBAL);
+ base = Var_Value(".PARSEFILE", SCOPE_GLOBAL);
if (base.str == NULL)
base.str = str_basename(fname);
@@ -695,7 +695,7 @@ ParseMessage(ParseErrorLevel level, cons
return;
}
- (void)Var_Subst(umsg, VAR_CMDLINE, VARE_WANTRES, &xmsg);
+ (void)Var_Subst(umsg, SCOPE_CMDLINE, VARE_WANTRES, &xmsg);
/* TODO: handle errors */
Parse_Error(level, "%s", xmsg);
@@ -1045,7 +1045,7 @@ ParseDependencyTargetWord(const char **p
const char *nested_p = cp;
FStr nested_val;
- (void)Var_Parse(&nested_p, VAR_CMDLINE, VARE_NONE,
+ (void)Var_Parse(&nested_p, SCOPE_CMDLINE, VARE_NONE,
&nested_val);
/* TODO: handle errors */
FStr_Done(&nested_val);
@@ -1444,7 +1444,7 @@ ParseDoDependencyTargets(char **inout_cp
* there was an error in the specification. On error,
* line should remain untouched.
*/
- if (!Arch_ParseArchive(&tgt, targets, VAR_CMDLINE)) {
+ if (!Arch_ParseArchive(&tgt, targets, SCOPE_CMDLINE)) {
Parse_Error(PARSE_FATAL,
"Error in archive specification: \"%s\"",
tgt);
@@ -1549,7 +1549,8 @@ ParseDoDependencySourcesMundane(char *st
if (*end == '(') {
GNodeList sources = LST_INIT;
- if (!Arch_ParseArchive(&start, &sources, VAR_CMDLINE)) {
+ if (!Arch_ParseArchive(&start, &sources,
+ SCOPE_CMDLINE)) {
Parse_Error(PARSE_FATAL,
"Error in source archive spec \"%s\"",
start);
@@ -1920,7 +1921,7 @@ VarAssign_EvalShell(const char *name, co
cmd = FStr_InitRefer(uvalue);
if (strchr(cmd.str, '$') != NULL) {
char *expanded;
- (void)Var_Subst(cmd.str, VAR_CMDLINE,
+ (void)Var_Subst(cmd.str, SCOPE_CMDLINE,
VARE_WANTRES | VARE_UNDEFERR, &expanded);
/* TODO: handle errors */
cmd = FStr_InitOwn(expanded);
@@ -2254,7 +2255,7 @@ ParseDoInclude(char *directive)
* Substitute for any variables in the filename before trying to
* find the file.
*/
- (void)Var_Subst(file, VAR_CMDLINE, VARE_WANTRES, &file);
+ (void)Var_Subst(file, SCOPE_CMDLINE, VARE_WANTRES, &file);
/* TODO: handle errors */
IncludeFile(file, endc == '>', directive[0] == 'd', silent);
@@ -2320,8 +2321,8 @@ ParseSetParseFile(const char *filename)
SetFilenameVars(including,
".INCLUDEDFROMDIR", ".INCLUDEDFROMFILE");
} else {
- Var_Delete(".INCLUDEDFROMDIR", VAR_GLOBAL);
- Var_Delete(".INCLUDEDFROMFILE", VAR_GLOBAL);
+ Var_Delete(".INCLUDEDFROMDIR", SCOPE_GLOBAL);
+ Var_Delete(".INCLUDEDFROMFILE", SCOPE_GLOBAL);
}
}
@@ -2358,7 +2359,7 @@ StrContainsWord(const char *str, const c
static Boolean
VarContainsWord(const char *varname, const char *word)
{
- FStr val = Var_Value(varname, VAR_GLOBAL);
+ FStr val = Var_Value(varname, SCOPE_GLOBAL);
Boolean found = val.str != NULL && StrContainsWord(val.str, word);
FStr_Done(&val);
return found;
@@ -2492,7 +2493,7 @@ ParseTraditionalInclude(char *line)
* Substitute for any variables in the file name before trying to
* find the thing.
*/
- (void)Var_Subst(file, VAR_CMDLINE, VARE_WANTRES, &all_files);
+ (void)Var_Subst(file, SCOPE_CMDLINE, VARE_WANTRES, &all_files);
/* TODO: handle errors */
if (*file == '\0') {
@@ -2542,7 +2543,7 @@ ParseGmakeExport(char *line)
/*
* Expand the value before putting it in the environment.
*/
- (void)Var_Subst(value, VAR_CMDLINE, VARE_WANTRES, &value);
+ (void)Var_Subst(value, SCOPE_CMDLINE, VARE_WANTRES, &value);
/* TODO: handle errors */
setenv(variable, value, 1);
@@ -2593,10 +2594,10 @@ ParseEOF(void)
if (includes.len == 0) {
/* We've run out of input */
- Var_Delete(".PARSEDIR", VAR_GLOBAL);
- Var_Delete(".PARSEFILE", VAR_GLOBAL);
- Var_Delete(".INCLUDEDFROMDIR", VAR_GLOBAL);
- Var_Delete(".INCLUDEDFROMFILE", VAR_GLOBAL);
+ Var_Delete(".PARSEDIR", SCOPE_GLOBAL);
+ Var_Delete(".PARSEFILE", SCOPE_GLOBAL);
+ Var_Delete(".INCLUDEDFROMDIR", SCOPE_GLOBAL);
+ Var_Delete(".INCLUDEDFROMFILE", SCOPE_GLOBAL);
return FALSE;
}
@@ -3053,7 +3054,7 @@ ParseVarassign(const char *line)
return FALSE;
FinishDependencyGroup();
- Parse_DoVar(&var, VAR_GLOBAL);
+ Parse_DoVar(&var, SCOPE_GLOBAL);
return TRUE;
}
@@ -3135,7 +3136,7 @@ ParseDependency(char *line)
* It simply returns the special empty string var_Error,
* which cannot be detected in the result of Var_Subst. */
eflags = opts.strict ? VARE_WANTRES : VARE_WANTRES | VARE_UNDEFERR;
- (void)Var_Subst(line, VAR_CMDLINE, eflags, &expanded_line);
+ (void)Var_Subst(line, SCOPE_CMDLINE, eflags, &expanded_line);
/* TODO: handle errors */
/* Need a fresh list for the target nodes */
Index: src/usr.bin/make/targ.c
diff -u src/usr.bin/make/targ.c:1.163 src/usr.bin/make/targ.c:1.164
--- src/usr.bin/make/targ.c:1.163 Wed Feb 3 13:53:12 2021
+++ src/usr.bin/make/targ.c Thu Feb 4 21:33:14 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: targ.c,v 1.163 2021/02/03 13:53:12 rillig Exp $ */
+/* $NetBSD: targ.c,v 1.164 2021/02/04 21:33:14 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -113,7 +113,7 @@
#include "dir.h"
/* "@(#)targ.c 8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: targ.c,v 1.163 2021/02/03 13:53:12 rillig Exp $");
+MAKE_RCSID("$NetBSD: targ.c,v 1.164 2021/02/04 21:33:14 rillig Exp $");
/*
* All target nodes that appeared on the left-hand side of one of the
@@ -243,14 +243,14 @@ GNode_Free(void *gnp)
* by this node.
*
* XXX: For the nodes that represent targets or sources (and not
- * VAR_GLOBAL), it should be safe to free the variables as well,
+ * SCOPE_GLOBAL), it should be safe to free the variables as well,
* since each node manages the memory for all its variables itself.
*
* XXX: The GNodes that are only used as variable contexts (VAR_CMD,
- * VAR_GLOBAL, VAR_INTERNAL) are not freed at all (see Var_End, where
- * they are not mentioned). These might be freed at all, if their
- * variable values are indeed not used anywhere else (see Trace_Init
- * for the only suspicious use).
+ * SCOPE_GLOBAL, SCOPE_INTERNAL) are not freed at all (see Var_End,
+ * where they are not mentioned). These might be freed at all, if
+ * their variable values are indeed not used anywhere else (see
+ * Trace_Init for the only suspicious use).
*/
HashTable_Done(&gn->vars);
@@ -577,10 +577,10 @@ Targ_PrintGraph(int pass)
PrintOnlySources();
debug_printf("#*** Global Variables:\n");
- Var_Dump(VAR_GLOBAL);
+ Var_Dump(SCOPE_GLOBAL);
debug_printf("#*** Command-line Variables:\n");
- Var_Dump(VAR_CMDLINE);
+ Var_Dump(SCOPE_CMDLINE);
debug_printf("\n");
Dir_PrintDirectories();
Index: src/usr.bin/make/trace.c
diff -u src/usr.bin/make/trace.c:1.26 src/usr.bin/make/trace.c:1.27
--- src/usr.bin/make/trace.c:1.26 Tue Jan 19 20:51:46 2021
+++ src/usr.bin/make/trace.c Thu Feb 4 21:33:14 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: trace.c,v 1.26 2021/01/19 20:51:46 rillig Exp $ */
+/* $NetBSD: trace.c,v 1.27 2021/02/04 21:33:14 rillig Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -48,7 +48,7 @@
#include "job.h"
#include "trace.h"
-MAKE_RCSID("$NetBSD: trace.c,v 1.26 2021/01/19 20:51:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: trace.c,v 1.27 2021/02/04 21:33:14 rillig Exp $");
static FILE *trfile;
static pid_t trpid;
@@ -71,7 +71,7 @@ Trace_Init(const char *pathname)
trpid = getpid();
/* XXX: This variable may get overwritten later, which
* would make trwd point to undefined behavior. */
- curDir = Var_Value(".CURDIR", VAR_GLOBAL);
+ curDir = Var_Value(".CURDIR", SCOPE_GLOBAL);
trwd = curDir.str;
trfile = fopen(pathname, "a");
Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.800 src/usr.bin/make/var.c:1.801
--- src/usr.bin/make/var.c:1.800 Thu Feb 4 19:43:00 2021
+++ src/usr.bin/make/var.c Thu Feb 4 21:33:14 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.800 2021/02/04 19:43:00 rillig Exp $ */
+/* $NetBSD: var.c,v 1.801 2021/02/04 21:33:14 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -139,7 +139,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.800 2021/02/04 19:43:00 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.801 2021/02/04 21:33:14 rillig Exp $");
typedef enum VarFlags {
VAR_NONE = 0,
@@ -303,9 +303,9 @@ static Boolean save_dollars = TRUE;
* The four contexts are searched in the reverse order from which they are
* listed (but see opts.checkEnvFirst).
*/
-GNode *VAR_INTERNAL; /* variables from make itself */
-GNode *VAR_GLOBAL; /* variables from the makefile */
-GNode *VAR_CMDLINE; /* variables defined on the command-line */
+GNode *SCOPE_INTERNAL; /* variables from make itself */
+GNode *SCOPE_GLOBAL; /* variables from the makefile */
+GNode *SCOPE_CMDLINE; /* variables defined on the command-line */
ENUM_FLAGS_RTTI_6(VarFlags,
VAR_IN_USE, VAR_FROM_ENV,
@@ -414,14 +414,14 @@ VarFind(const char *name, GNode *ctxt, B
* The variable was not found in the given context.
* Now look for it in the other contexts as well.
*/
- if (var == NULL && ctxt != VAR_CMDLINE)
- var = GNode_FindVar(VAR_CMDLINE, name, nameHash);
+ if (var == NULL && ctxt != SCOPE_CMDLINE)
+ var = GNode_FindVar(SCOPE_CMDLINE, name, nameHash);
- if (!opts.checkEnvFirst && var == NULL && ctxt != VAR_GLOBAL) {
- var = GNode_FindVar(VAR_GLOBAL, name, nameHash);
- if (var == NULL && ctxt != VAR_INTERNAL) {
- /* VAR_INTERNAL is subordinate to VAR_GLOBAL */
- var = GNode_FindVar(VAR_INTERNAL, name, nameHash);
+ if (!opts.checkEnvFirst && var == NULL && ctxt != SCOPE_GLOBAL) {
+ var = GNode_FindVar(SCOPE_GLOBAL, name, nameHash);
+ if (var == NULL && ctxt != SCOPE_INTERNAL) {
+ /* SCOPE_INTERNAL is subordinate to SCOPE_GLOBAL */
+ var = GNode_FindVar(SCOPE_INTERNAL, name, nameHash);
}
}
@@ -433,10 +433,10 @@ VarFind(const char *name, GNode *ctxt, B
return VarNew(FStr_InitOwn(varname), env, VAR_FROM_ENV);
}
- if (opts.checkEnvFirst && ctxt != VAR_GLOBAL) {
- var = GNode_FindVar(VAR_GLOBAL, name, nameHash);
- if (var == NULL && ctxt != VAR_INTERNAL)
- var = GNode_FindVar(VAR_INTERNAL, name,
+ if (opts.checkEnvFirst && ctxt != SCOPE_GLOBAL) {
+ var = GNode_FindVar(SCOPE_GLOBAL, name, nameHash);
+ if (var == NULL && ctxt != SCOPE_INTERNAL)
+ var = GNode_FindVar(SCOPE_INTERNAL, name,
nameHash);
return var;
}
@@ -524,7 +524,7 @@ Var_DeleteExpand(const char *name, GNode
if (strchr(varname.str, '$') != NULL) {
char *expanded;
- (void)Var_Subst(varname.str, VAR_GLOBAL, VARE_WANTRES,
+ (void)Var_Subst(varname.str, SCOPE_GLOBAL, VARE_WANTRES,
&expanded);
/* TODO: handle errors */
varname = FStr_InitOwn(expanded);
@@ -552,7 +552,7 @@ Var_Undef(const char *arg)
return;
}
- vpr = Var_Subst(arg, VAR_GLOBAL, VARE_WANTRES, &expanded);
+ vpr = Var_Subst(arg, SCOPE_GLOBAL, VARE_WANTRES, &expanded);
if (vpr != VPR_OK) {
Parse_Error(PARSE_FATAL,
"Error in variable names to be undefined");
@@ -565,7 +565,7 @@ Var_Undef(const char *arg)
for (i = 0; i < varnames.len; i++) {
const char *varname = varnames.words[i];
- Var_Delete(varname, VAR_GLOBAL);
+ Var_Delete(varname, SCOPE_GLOBAL);
}
Words_Free(varnames);
@@ -623,7 +623,7 @@ ExportVarEnv(Var *v)
/* XXX: name is injected without escaping it */
expr = str_concat3("${", name, "}");
- (void)Var_Subst(expr, VAR_GLOBAL, VARE_WANTRES, &val);
+ (void)Var_Subst(expr, SCOPE_GLOBAL, VARE_WANTRES, &val);
/* TODO: handle errors */
setenv(name, val, 1);
free(val);
@@ -678,7 +678,7 @@ ExportVar(const char *name, VarExportMod
if (!MayExport(name))
return FALSE;
- v = VarFind(name, VAR_GLOBAL, FALSE);
+ v = VarFind(name, SCOPE_GLOBAL, FALSE);
if (v == NULL)
return FALSE;
@@ -716,7 +716,7 @@ Var_ReexportVars(void)
HashIter hi;
/* Ouch! Exporting all variables at once is crazy... */
- HashIter_Init(&hi, &VAR_GLOBAL->vars);
+ HashIter_Init(&hi, &SCOPE_GLOBAL->vars);
while (HashIter_Next(&hi) != NULL) {
Var *var = hi.entry->value;
ExportVar(var->name.str, VEM_ENV);
@@ -724,7 +724,7 @@ Var_ReexportVars(void)
return;
}
- (void)Var_Subst("${" MAKE_EXPORTED ":O:u}", VAR_GLOBAL, VARE_WANTRES,
+ (void)Var_Subst("${" MAKE_EXPORTED ":O:u}", SCOPE_GLOBAL, VARE_WANTRES,
&xvarnames);
/* TODO: handle errors */
if (xvarnames[0] != '\0') {
@@ -766,7 +766,7 @@ ExportVarsExpand(const char *uvarnames,
{
char *xvarnames;
- (void)Var_Subst(uvarnames, VAR_GLOBAL, VARE_WANTRES, &xvarnames);
+ (void)Var_Subst(uvarnames, SCOPE_GLOBAL, VARE_WANTRES, &xvarnames);
/* TODO: handle errors */
ExportVars(xvarnames, isExport, mode);
free(xvarnames);
@@ -843,7 +843,7 @@ GetVarnamesToUnexport(Boolean isEnv, con
if (what != UNEXPORT_NAMED) {
char *expanded;
/* Using .MAKE.EXPORTED */
- (void)Var_Subst("${" MAKE_EXPORTED ":O:u}", VAR_GLOBAL,
+ (void)Var_Subst("${" MAKE_EXPORTED ":O:u}", SCOPE_GLOBAL,
VARE_WANTRES, &expanded);
/* TODO: handle errors */
varnames = FStr_InitOwn(expanded);
@@ -856,7 +856,7 @@ GetVarnamesToUnexport(Boolean isEnv, con
static void
UnexportVar(const char *varname, UnexportWhat what)
{
- Var *v = VarFind(varname, VAR_GLOBAL, FALSE);
+ Var *v = VarFind(varname, SCOPE_GLOBAL, FALSE);
if (v == NULL) {
DEBUG1(VAR, "Not unexporting \"%s\" (not found)\n", varname);
return;
@@ -874,7 +874,7 @@ UnexportVar(const char *varname, Unexpor
char *expr = str_concat3("${" MAKE_EXPORTED ":N",
v->name.str, "}");
char *cp;
- (void)Var_Subst(expr, VAR_GLOBAL, VARE_WANTRES, &cp);
+ (void)Var_Subst(expr, SCOPE_GLOBAL, VARE_WANTRES, &cp);
/* TODO: handle errors */
Global_Set(MAKE_EXPORTED, cp);
free(cp);
@@ -899,7 +899,7 @@ UnexportVars(FStr *varnames, UnexportWha
Words_Free(words);
if (what != UNEXPORT_NAMED)
- Var_Delete(MAKE_EXPORTED, VAR_GLOBAL);
+ Var_Delete(MAKE_EXPORTED, SCOPE_GLOBAL);
}
/*
@@ -931,8 +931,8 @@ Var_SetWithFlags(const char *name, const
return;
}
- if (ctxt == VAR_GLOBAL) {
- v = VarFind(name, VAR_CMDLINE, FALSE);
+ if (ctxt == SCOPE_GLOBAL) {
+ v = VarFind(name, SCOPE_CMDLINE, FALSE);
if (v != NULL) {
if (v->flags & VAR_FROM_CMD) {
DEBUG3(VAR, "%s:%s = %s ignored!\n",
@@ -950,14 +950,14 @@ Var_SetWithFlags(const char *name, const
*/
v = VarFind(name, ctxt, FALSE);
if (v == NULL) {
- if (ctxt == VAR_CMDLINE && !(flags & VAR_SET_NO_EXPORT)) {
+ if (ctxt == SCOPE_CMDLINE && !(flags & VAR_SET_NO_EXPORT)) {
/*
* This var would normally prevent the same name being
- * added to VAR_GLOBAL, so delete it from there if
+ * added to SCOPE_GLOBAL, so delete it from there if
* needed. Otherwise -V name may show the wrong value.
*/
/* XXX: name is expanded for the second time */
- Var_DeleteExpand(name, VAR_GLOBAL);
+ Var_DeleteExpand(name, SCOPE_GLOBAL);
}
VarAdd(name, val, ctxt, flags);
} else {
@@ -978,7 +978,7 @@ Var_SetWithFlags(const char *name, const
* to the environment (as per POSIX standard)
* Other than internals.
*/
- if (ctxt == VAR_CMDLINE && !(flags & VAR_SET_NO_EXPORT) &&
+ if (ctxt == SCOPE_CMDLINE && !(flags & VAR_SET_NO_EXPORT) &&
name[0] != '.') {
if (v == NULL)
v = VarFind(name, ctxt, FALSE); /* we just added it */
@@ -1055,13 +1055,13 @@ Var_SetExpand(const char *name, const ch
void
Global_Set(const char *name, const char *value)
{
- Var_Set(name, value, VAR_GLOBAL);
+ Var_Set(name, value, SCOPE_GLOBAL);
}
void
Global_SetExpand(const char *name, const char *value)
{
- Var_SetExpand(name, value, VAR_GLOBAL);
+ Var_SetExpand(name, value, SCOPE_GLOBAL);
}
/*
@@ -1075,14 +1075,14 @@ Var_Append(const char *name, const char
{
Var *v;
- v = VarFind(name, ctxt, ctxt == VAR_GLOBAL);
+ v = VarFind(name, ctxt, ctxt == SCOPE_GLOBAL);
if (v == NULL) {
Var_SetWithFlags(name, val, ctxt, VAR_SET_NONE);
} else if (v->flags & VAR_READONLY) {
DEBUG1(VAR, "Ignoring append to %s since it is read-only\n",
name);
- } else if (ctxt == VAR_CMDLINE || !(v->flags & VAR_FROM_CMD)) {
+ } else if (ctxt == SCOPE_CMDLINE || !(v->flags & VAR_FROM_CMD)) {
Buf_AddByte(&v->val, ' ');
Buf_AddStr(&v->val, val);
@@ -1156,7 +1156,7 @@ Var_AppendExpand(const char *name, const
void
Global_Append(const char *name, const char *value)
{
- Var_Append(name, value, VAR_GLOBAL);
+ Var_Append(name, value, SCOPE_GLOBAL);
}
Boolean
@@ -3266,10 +3266,10 @@ ok:
}
ctxt = st->ctxt; /* context where v belongs */
- if (st->exprStatus == VES_NONE && st->ctxt != VAR_GLOBAL) {
+ if (st->exprStatus == VES_NONE && st->ctxt != SCOPE_GLOBAL) {
Var *gv = VarFind(st->var->name.str, st->ctxt, FALSE);
if (gv == NULL)
- ctxt = VAR_GLOBAL;
+ ctxt = SCOPE_GLOBAL;
else
VarFreeEnv(gv, TRUE);
}
@@ -3804,7 +3804,7 @@ VarnameIsDynamic(const char *name, size_
static const char *
UndefinedShortVarValue(char varname, const GNode *ctxt)
{
- if (ctxt == VAR_CMDLINE || ctxt == VAR_GLOBAL) {
+ if (ctxt == SCOPE_CMDLINE || ctxt == SCOPE_GLOBAL) {
/*
* If substituting a local variable in a non-local context,
* assume it's for dynamic source stuff. We have to handle
@@ -3972,7 +3972,7 @@ FindLocalLegacyVar(const char *varname,
const char **out_extraModifiers)
{
/* Only resolve these variables if ctxt is a "real" target. */
- if (ctxt == VAR_CMDLINE || ctxt == VAR_GLOBAL)
+ if (ctxt == SCOPE_CMDLINE || ctxt == SCOPE_GLOBAL)
return NULL;
if (namelen != 2)
@@ -4094,7 +4094,7 @@ ParseVarnameLong(
* non-local context since they are not defined there.
*/
dynamic = VarnameIsDynamic(varname, namelen) &&
- (ctxt == VAR_CMDLINE || ctxt == VAR_GLOBAL);
+ (ctxt == SCOPE_CMDLINE || ctxt == SCOPE_GLOBAL);
if (!haveModifier) {
p++; /* skip endc */
@@ -4438,9 +4438,9 @@ Var_Subst(const char *str, GNode *ctxt,
void
Var_Init(void)
{
- VAR_INTERNAL = GNode_New("Internal");
- VAR_GLOBAL = GNode_New("Global");
- VAR_CMDLINE = GNode_New("Command");
+ SCOPE_INTERNAL = GNode_New("Internal");
+ SCOPE_GLOBAL = GNode_New("Global");
+ SCOPE_CMDLINE = GNode_New("Command");
}
/* Clean up the variables module. */
@@ -4453,7 +4453,7 @@ Var_End(void)
void
Var_Stats(void)
{
- HashTable_DebugStats(&VAR_GLOBAL->vars, "VAR_GLOBAL");
+ HashTable_DebugStats(&SCOPE_GLOBAL->vars, "VAR_GLOBAL");
}
/* Print all variables in a context, sorted by name. */
Index: src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.mk
diff -u src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.mk:1.2 src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.mk:1.3
--- src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.mk:1.2 Sun Dec 13 19:08:20 2020
+++ src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.mk Thu Feb 4 21:33:14 2021
@@ -1,4 +1,4 @@
-# $NetBSD: varname-make_print_var_on_error-jobs.mk,v 1.2 2020/12/13 19:08:20 rillig Exp $
+# $NetBSD: varname-make_print_var_on_error-jobs.mk,v 1.3 2021/02/04 21:33:14 rillig Exp $
#
# Tests for the special MAKE_PRINT_VAR_ON_ERROR variable, which prints the
# values of selected variables on error.
@@ -13,7 +13,7 @@
# See also:
# compat-error.mk
-# XXX: As of 2020-12-13, PrintOnError calls Var_Subst with VAR_GLOBAL, which
+# XXX: As of 2021-02-04, PrintOnError calls Var_Subst with SCOPE_GLOBAL, which
# does not expand the node-local variables like .TARGET. This results in the
# double '${.TARGET}' in the output.
Index: src/usr.bin/make/unit-tests/varname-make_print_var_on_error.mk
diff -u src/usr.bin/make/unit-tests/varname-make_print_var_on_error.mk:1.5 src/usr.bin/make/unit-tests/varname-make_print_var_on_error.mk:1.6
--- src/usr.bin/make/unit-tests/varname-make_print_var_on_error.mk:1.5 Sun Dec 13 19:08:20 2020
+++ src/usr.bin/make/unit-tests/varname-make_print_var_on_error.mk Thu Feb 4 21:33:14 2021
@@ -1,4 +1,4 @@
-# $NetBSD: varname-make_print_var_on_error.mk,v 1.5 2020/12/13 19:08:20 rillig Exp $
+# $NetBSD: varname-make_print_var_on_error.mk,v 1.6 2021/02/04 21:33:14 rillig Exp $
#
# Tests for the special MAKE_PRINT_VAR_ON_ERROR variable, which prints the
# values of selected variables on error.
@@ -11,7 +11,7 @@
# See also:
# compat-error.mk
-# XXX: As of 2020-12-13, PrintOnError calls Var_Subst with VAR_GLOBAL, which
+# XXX: As of 2021-02-04, PrintOnError calls Var_Subst with SCOPE_GLOBAL, which
# does not expand the node-local variables like .TARGET. This results in the
# double '${.TARGET}' in the output.