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 context and ctxt to scope
details: https://anonhg.NetBSD.org/src/rev/f6e1abfd29c9
branches: trunk
changeset: 951511:f6e1abfd29c9
user: rillig <rillig%NetBSD.org@localhost>
date: Thu Feb 04 21:42:46 2021 +0000
description:
make: rename context and ctxt to scope
This continues the previous commit, in which VAR_GLOBAL, VAR_INTERNAL
and VAR_CMDLINE were renamed.
Renaming the variable 'ctxt' was trivial since that word is used nowhere
else. In the comments though, each occurrence of the word 'context' had
to be checked individually since the word 'context' was not only used
for referring to a variable scope. It is also used to distinguish
different situations where characters are escaped in a certain way
('parsing context') and in a few other expressions.
diffstat:
usr.bin/make/arch.c | 18 +-
usr.bin/make/compat.c | 6 +-
usr.bin/make/make.1 | 6 +-
usr.bin/make/make.c | 12 +-
usr.bin/make/make.h | 4 +-
usr.bin/make/parse.c | 44 +-
usr.bin/make/suff.c | 8 +-
usr.bin/make/targ.c | 6 +-
usr.bin/make/unit-tests/envfirst.mk | 4 +-
usr.bin/make/unit-tests/vardebug.mk | 4 +-
usr.bin/make/unit-tests/varmisc.mk | 8 +-
usr.bin/make/unit-tests/varmod-loop.mk | 6 +-
usr.bin/make/unit-tests/varname-dot-shell.mk | 6 +-
usr.bin/make/unit-tests/varparse-dynamic.mk | 6 +-
usr.bin/make/var.c | 313 +++++++++++++-------------
15 files changed, 225 insertions(+), 226 deletions(-)
diffs (truncated from 1506 to 300 lines):
diff -r e37a5dfbeba9 -r f6e1abfd29c9 usr.bin/make/arch.c
--- a/usr.bin/make/arch.c Thu Feb 04 21:39:00 2021 +0000
+++ b/usr.bin/make/arch.c Thu Feb 04 21:42:46 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arch.c,v 1.195 2021/02/04 19:50:29 rillig Exp $ */
+/* $NetBSD: arch.c,v 1.196 2021/02/04 21:42:46 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -126,7 +126,7 @@
#include "config.h"
/* "@(#)arch.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: arch.c,v 1.195 2021/02/04 19:50:29 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.196 2021/02/04 21:42:46 rillig Exp $");
typedef struct List ArchList;
typedef struct ListNode ArchListNode;
@@ -176,14 +176,14 @@
* Input:
* pp The start of the specification.
* gns The list on which to place the nodes.
- * ctxt The context in which to expand variables.
+ * scope The scope in which to expand variables.
*
* Output:
* return TRUE if it was a valid specification.
* *pp Points to the first non-space after the archive spec.
*/
Boolean
-Arch_ParseArchive(char **pp, GNodeList *gns, GNode *ctxt)
+Arch_ParseArchive(char **pp, GNodeList *gns, GNode *scope)
{
char *cp; /* Pointer into line */
GNode *gn; /* New node */
@@ -206,7 +206,7 @@
Boolean isError;
/* XXX: is expanded twice: once here and once below */
- (void)Var_Parse(&nested_p, ctxt,
+ (void)Var_Parse(&nested_p, scope,
VARE_WANTRES | VARE_UNDEFERR, &result);
/* TODO: handle errors */
isError = result.str == var_Error;
@@ -223,7 +223,7 @@
*cp++ = '\0';
if (expandLibName) {
char *expanded;
- (void)Var_Subst(libName.str, ctxt,
+ (void)Var_Subst(libName.str, scope,
VARE_WANTRES | VARE_UNDEFERR, &expanded);
/* TODO: handle errors */
libName = MFStr_InitOwn(expanded);
@@ -249,7 +249,7 @@
Boolean isError;
const char *nested_p = cp;
- (void)Var_Parse(&nested_p, ctxt,
+ (void)Var_Parse(&nested_p, scope,
VARE_WANTRES | VARE_UNDEFERR,
&result);
/* TODO: handle errors */
@@ -306,7 +306,7 @@
char *p;
char *unexpandedMemName = memName;
- (void)Var_Subst(memName, ctxt,
+ (void)Var_Subst(memName, scope,
VARE_WANTRES | VARE_UNDEFERR,
&memName);
/* TODO: handle errors */
@@ -330,7 +330,7 @@
gn->type |= OP_ARCHV;
Lst_Append(gns, gn);
- } else if (!Arch_ParseArchive(&p, gns, ctxt)) {
+ } else if (!Arch_ParseArchive(&p, gns, scope)) {
/* Error in nested call. */
free(fullName);
/* XXX: does unexpandedMemName leak? */
diff -r e37a5dfbeba9 -r f6e1abfd29c9 usr.bin/make/compat.c
--- a/usr.bin/make/compat.c Thu Feb 04 21:39:00 2021 +0000
+++ b/usr.bin/make/compat.c Thu Feb 04 21:42:46 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: compat.c,v 1.222 2021/02/02 17:47:56 rillig Exp $ */
+/* $NetBSD: compat.c,v 1.223 2021/02/04 21:42:46 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -96,7 +96,7 @@
#include "pathnames.h"
/* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: compat.c,v 1.222 2021/02/02 17:47:56 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.223 2021/02/04 21:42:46 rillig Exp $");
static GNode *curTarg = NULL;
static pid_t compatChild;
@@ -257,7 +257,7 @@
/*
* Append the expanded command, to prevent the
* local variables from being interpreted in the
- * context of the .END node.
+ * scope of the .END node.
*
* A probably unintended side effect of this is that
* the expanded command will be expanded again in the
diff -r e37a5dfbeba9 -r f6e1abfd29c9 usr.bin/make/make.1
--- a/usr.bin/make/make.1 Thu Feb 04 21:39:00 2021 +0000
+++ b/usr.bin/make/make.1 Thu Feb 04 21:42:46 2021 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: make.1,v 1.295 2020/12/23 13:49:12 rillig Exp $
+.\" $NetBSD: make.1,v 1.296 2021/02/04 21:42:46 rillig Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -99,7 +99,7 @@
.It Fl D Ar variable
Define
.Ar variable
-to be 1, in the global context.
+to be 1, in the global scope.
.It Fl d Ar [-]flags
Turn on debugging, and specify which portions of
.Nm
@@ -355,7 +355,7 @@
Multiple instances of this option may be specified;
the variables will be printed one per line,
with a blank line for each null or undefined variable.
-The value printed is extracted from the global context after all
+The value printed is extracted from the global scope after all
makefiles have been read.
By default, the raw variable contents (which may
include additional unexpanded variable references) are shown.
diff -r e37a5dfbeba9 -r f6e1abfd29c9 usr.bin/make/make.c
--- a/usr.bin/make/make.c Thu Feb 04 21:39:00 2021 +0000
+++ b/usr.bin/make/make.c Thu Feb 04 21:42:46 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: make.c,v 1.240 2021/02/02 21:26:51 rillig Exp $ */
+/* $NetBSD: make.c,v 1.241 2021/02/04 21:42:46 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -78,8 +78,8 @@
* Make_Update After a target is made, update all its parents.
* Perform various bookkeeping chores like the updating
* of the youngestChild field of the parent, filling
- * of the IMPSRC context variable, etc. Place the parent
- * on the toBeMade queue if it should be.
+ * of the IMPSRC variable, etc. Place the parent on the
+ * toBeMade queue if it should be.
*
* GNode_UpdateYoungestChild
* Update the node's youngestChild field based on the
@@ -103,7 +103,7 @@
#include "job.h"
/* "@(#)make.c 8.1 (Berkeley) 6/6/93" */
-MAKE_RCSID("$NetBSD: make.c,v 1.240 2021/02/02 21:26:51 rillig Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.241 2021/02/04 21:42:46 rillig Exp $");
/* Sequence # to detect recursion. */
static unsigned int checked_seqno = 1;
@@ -1032,9 +1032,9 @@
if (gn->type & OP_JOIN) {
/*
* Even for an up-to-date .JOIN node, we
- * need it to have its context variables so
+ * need it to have its local variables so
* references to it get the correct value
- * for .TARGET when building up the context
+ * for .TARGET when building up the local
* variables of its parent(s)...
*/
Make_DoAllVar(gn);
diff -r e37a5dfbeba9 -r f6e1abfd29c9 usr.bin/make/make.h
--- a/usr.bin/make/make.h Thu Feb 04 21:39:00 2021 +0000
+++ b/usr.bin/make/make.h Thu Feb 04 21:42:46 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: make.h,v 1.252 2021/02/04 21:33:13 rillig Exp $ */
+/* $NetBSD: make.h,v 1.253 2021/02/04 21:42:46 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -500,7 +500,7 @@
* by makefiles.
*/
extern GNode *SCOPE_INTERNAL;
-/* Variables defined in a global context, e.g in the Makefile itself. */
+/* Variables defined in a global scope, e.g in the Makefile itself. */
extern GNode *SCOPE_GLOBAL;
/* Variables defined on the command line. */
extern GNode *SCOPE_CMDLINE;
diff -r e37a5dfbeba9 -r f6e1abfd29c9 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c Thu Feb 04 21:39:00 2021 +0000
+++ b/usr.bin/make/parse.c Thu Feb 04 21:42:46 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.545 2021/02/04 21:33:14 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.546 2021/02/04 21:42:46 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.545 2021/02/04 21:33:14 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.546 2021/02/04 21:42:46 rillig Exp $");
/* types and constants */
@@ -1871,13 +1871,13 @@
* Check for syntax errors such as unclosed expressions or unknown modifiers.
*/
static void
-VarCheckSyntax(VarAssignOp type, const char *uvalue, GNode *ctxt)
+VarCheckSyntax(VarAssignOp type, const char *uvalue, GNode *scope)
{
if (opts.strict) {
if (type != VAR_SUBST && strchr(uvalue, '$') != NULL) {
char *expandedValue;
- (void)Var_Subst(uvalue, ctxt, VARE_NONE,
+ (void)Var_Subst(uvalue, scope, VARE_NONE,
&expandedValue);
/* TODO: handle errors */
free(expandedValue);
@@ -1886,7 +1886,7 @@
}
static void
-VarAssign_EvalSubst(const char *name, const char *uvalue, GNode *ctxt,
+VarAssign_EvalSubst(const char *name, const char *uvalue, GNode *scope,
FStr *out_avalue)
{
char *evalue;
@@ -1898,20 +1898,20 @@
* TODO: Add a test that demonstrates why this code is needed,
* apart from making the debug log longer.
*/
- if (!Var_ExistsExpand(name, ctxt))
- Var_SetExpand(name, "", ctxt);
-
- (void)Var_Subst(uvalue, ctxt,
+ if (!Var_ExistsExpand(name, scope))
+ Var_SetExpand(name, "", scope);
+
+ (void)Var_Subst(uvalue, scope,
VARE_WANTRES | VARE_KEEP_DOLLAR | VARE_KEEP_UNDEF, &evalue);
/* TODO: handle errors */
- Var_SetExpand(name, evalue, ctxt);
+ Var_SetExpand(name, evalue, scope);
*out_avalue = FStr_InitOwn(evalue);
}
static void
-VarAssign_EvalShell(const char *name, const char *uvalue, GNode *ctxt,
+VarAssign_EvalShell(const char *name, const char *uvalue, GNode *scope,
FStr *out_avalue)
{
FStr cmd;
@@ -1928,7 +1928,7 @@
}
cmdOut = Cmd_Exec(cmd.str, &errfmt);
- Var_SetExpand(name, cmdOut, ctxt);
+ Var_SetExpand(name, cmdOut, scope);
*out_avalue = FStr_InitOwn(cmdOut);
if (errfmt != NULL)
@@ -1950,22 +1950,22 @@
*/
static Boolean
VarAssign_Eval(const char *name, VarAssignOp op, const char *uvalue,
- GNode *ctxt, FStr *out_TRUE_avalue)
+ GNode *scope, FStr *out_TRUE_avalue)
{
FStr avalue = FStr_InitRefer(uvalue);
if (op == VAR_APPEND)
- Var_AppendExpand(name, uvalue, ctxt);
+ Var_AppendExpand(name, uvalue, scope);
else if (op == VAR_SUBST)
- VarAssign_EvalSubst(name, uvalue, ctxt, &avalue);
+ VarAssign_EvalSubst(name, uvalue, scope, &avalue);
else if (op == VAR_SHELL)
- VarAssign_EvalShell(name, uvalue, ctxt, &avalue);
+ VarAssign_EvalShell(name, uvalue, scope, &avalue);
else {
- if (op == VAR_DEFAULT && Var_ExistsExpand(name, ctxt))
+ if (op == VAR_DEFAULT && Var_ExistsExpand(name, scope))
return FALSE;
/* Normal assignment -- just do it. */
- Var_SetExpand(name, uvalue, ctxt);
+ Var_SetExpand(name, uvalue, scope);
}
Home |
Main Index |
Thread Index |
Old Index