Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make: rename some VAR constants to SCOPE
details: https://anonhg.NetBSD.org/src/rev/d3e8e6883167
branches: trunk
changeset: 959205:d3e8e6883167
user: rillig <rillig%NetBSD.org@localhost>
date: Thu Feb 04 21:33:13 2021 +0000
description:
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.
diffstat:
usr.bin/make/cond.c | 12 +-
usr.bin/make/dir.c | 6 +-
usr.bin/make/for.c | 6 +-
usr.bin/make/job.c | 10 +-
usr.bin/make/main.c | 54 ++--
usr.bin/make/make.h | 17 +-
usr.bin/make/meta.c | 22 +-
usr.bin/make/parse.c | 43 ++--
usr.bin/make/targ.c | 18 +-
usr.bin/make/trace.c | 6 +-
usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.mk | 4 +-
usr.bin/make/unit-tests/varname-make_print_var_on_error.mk | 4 +-
usr.bin/make/var.c | 98 +++++-----
13 files changed, 152 insertions(+), 148 deletions(-)
diffs (truncated from 1100 to 300 lines):
diff -r c577651f0d02 -r d3e8e6883167 usr.bin/make/cond.c
--- a/usr.bin/make/cond.c Thu Feb 04 21:07:06 2021 +0000
+++ b/usr.bin/make/cond.c Thu Feb 04 21:33:13 2021 +0000
@@ -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 @@
? 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 @@
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 @@
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 @@
*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. */
diff -r c577651f0d02 -r d3e8e6883167 usr.bin/make/dir.c
--- a/usr.bin/make/dir.c Thu Feb 04 21:07:06 2021 +0000
+++ b/usr.bin/make/dir.c Thu Feb 04 21:33:13 2021 +0000
@@ -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 @@
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;
diff -r c577651f0d02 -r d3e8e6883167 usr.bin/make/for.c
--- a/usr.bin/make/for.c Thu Feb 04 21:07:06 2021 +0000
+++ b/usr.bin/make/for.c Thu Feb 04 21:33:13 2021 +0000
@@ -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 @@
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;
}
diff -r c577651f0d02 -r d3e8e6883167 usr.bin/make/job.c
--- a/usr.bin/make/job.c Thu Feb 04 21:07:06 2021 +0000
+++ b/usr.bin/make/job.c Thu Feb 04 21:33:13 2021 +0000
@@ -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 @@
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 @@
{
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 */
}
diff -r c577651f0d02 -r d3e8e6883167 usr.bin/make/main.c
--- a/usr.bin/make/main.c Thu Feb 04 21:07:06 2021 +0000
+++ b/usr.bin/make/main.c Thu Feb 04 21:33:13 2021 +0000
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
{
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 @@
{
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 @@
} 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
Home |
Main Index |
Thread Index |
Old Index