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(1): rename VARE_ASSIGN to VARE_KEEP_DOLLAR
details: https://anonhg.NetBSD.org/src/rev/06502927dc80
branches: trunk
changeset: 956859:06502927dc80
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Nov 08 16:58:33 2020 +0000
description:
make(1): rename VARE_ASSIGN to VARE_KEEP_DOLLAR
The other flags in VarEvalFlags already describe their effects, not the
place where they are used. It's more important to know the effect.
Only a single unit test had to be adjusted. This probably means that
there are too few tests where the special effects of VARE_KEEP_DOLLAR
come into play. It could also mean that the effects are so simple and
obvious that they don't need any debug log, but that's not the case.
diffstat:
usr.bin/make/nonints.h | 32 ++++++++++++++++++--------
usr.bin/make/parse.c | 6 ++--
usr.bin/make/unit-tests/varname-dot-shell.exp | 2 +-
usr.bin/make/var.c | 17 ++++++-------
4 files changed, 34 insertions(+), 23 deletions(-)
diffs (151 lines):
diff -r 52ec3b4647d0 -r 06502927dc80 usr.bin/make/nonints.h
--- a/usr.bin/make/nonints.h Sun Nov 08 16:47:59 2020 +0000
+++ b/usr.bin/make/nonints.h Sun Nov 08 16:58:33 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nonints.h,v 1.158 2020/11/08 09:15:19 rillig Exp $ */
+/* $NetBSD: nonints.h,v 1.159 2020/11/08 16:58:33 rillig Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@@ -215,16 +215,28 @@
typedef enum VarEvalFlags {
VARE_NONE = 0,
- /* Treat undefined variables as errors. */
- VARE_UNDEFERR = 1 << 0,
- /* Expand and evaluate variables during parsing. */
- VARE_WANTRES = 1 << 1,
- /* In an assignment using the ':=' operator, keep '$$' as '$$' instead
- * of reducing it to a single '$'.
+
+ /* Expand and evaluate variables during parsing.
*
- * See also preserveUndefined, which preserves subexpressions based on
- * undefined variables; maybe that can be converted to a flag as well. */
- VARE_ASSIGN = 1 << 2
+ * TODO: Document what Var_Parse and Var_Subst return when this flag
+ * is not set. */
+ VARE_WANTRES = 1 << 0,
+
+ /* Treat undefined variables as errors.
+ * Must only be used in combination with VARE_WANTRES. */
+ VARE_UNDEFERR = 1 << 1,
+
+ /* Keep '$$' as '$$' instead of reducing it to a single '$'.
+ *
+ * Used in variable assignments using the ':=' operator. It allows
+ * multiple such assignments to be chained without accidentally expanding
+ * '$$file' to '$file' in the first assignment and interpreting it as
+ * '${f}' followed by 'ile' in the next assignment.
+ *
+ * See also preserveUndefined, which preserves subexpressions that are
+ * based on undefined variables; maybe that can be converted to a flag
+ * as well. */
+ VARE_KEEP_DOLLAR = 1 << 2
} VarEvalFlags;
typedef enum VarSetFlags {
diff -r 52ec3b4647d0 -r 06502927dc80 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c Sun Nov 08 16:47:59 2020 +0000
+++ b/usr.bin/make/parse.c Sun Nov 08 16:58:33 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.434 2020/11/08 15:07:37 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.435 2020/11/08 16:58:33 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.434 2020/11/08 15:07:37 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.435 2020/11/08 16:58:33 rillig Exp $");
/* types and constants */
@@ -1923,7 +1923,7 @@
if (!Var_Exists(name, ctxt))
Var_Set(name, "", ctxt);
- (void)Var_Subst(uvalue, ctxt, VARE_WANTRES|VARE_ASSIGN, &evalue);
+ (void)Var_Subst(uvalue, ctxt, VARE_WANTRES|VARE_KEEP_DOLLAR, &evalue);
/* TODO: handle errors */
preserveUndefined = savedPreserveUndefined;
avalue = evalue;
diff -r 52ec3b4647d0 -r 06502927dc80 usr.bin/make/unit-tests/varname-dot-shell.exp
--- a/usr.bin/make/unit-tests/varname-dot-shell.exp Sun Nov 08 16:47:59 2020 +0000
+++ b/usr.bin/make/unit-tests/varname-dot-shell.exp Sun Nov 08 16:58:33 2020 +0000
@@ -1,6 +1,6 @@
ParseReadLine (10): 'ORIG_SHELL:= ${.SHELL}'
Global:ORIG_SHELL =
-Var_Parse: ${.SHELL} with VARE_WANTRES|VARE_ASSIGN
+Var_Parse: ${.SHELL} with VARE_WANTRES|VARE_KEEP_DOLLAR
Global:delete .SHELL (not found)
Command:.SHELL = (details omitted)
Global:ORIG_SHELL = (details omitted)
diff -r 52ec3b4647d0 -r 06502927dc80 usr.bin/make/var.c
--- a/usr.bin/make/var.c Sun Nov 08 16:47:59 2020 +0000
+++ b/usr.bin/make/var.c Sun Nov 08 16:58:33 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.676 2020/11/08 15:07:37 rillig Exp $ */
+/* $NetBSD: var.c,v 1.677 2020/11/08 16:58:33 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.676 2020/11/08 15:07:37 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.677 2020/11/08 16:58:33 rillig Exp $");
#define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
#define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -138,7 +138,7 @@
#define VAR_DEBUG4(fmt, arg1, arg2, arg3, arg4) DEBUG4(VAR, fmt, arg1, arg2, arg3, arg4)
ENUM_FLAGS_RTTI_3(VarEvalFlags,
- VARE_UNDEFERR, VARE_WANTRES, VARE_ASSIGN);
+ VARE_UNDEFERR, VARE_WANTRES, VARE_KEEP_DOLLAR);
/*
* This lets us tell if we have replaced the original environ
@@ -1922,7 +1922,7 @@
const char *nested_p = p;
const char *nested_val;
void *nested_val_freeIt;
- VarEvalFlags nested_eflags = eflags & ~(unsigned)VARE_ASSIGN;
+ VarEvalFlags nested_eflags = eflags & ~(unsigned)VARE_KEEP_DOLLAR;
(void)Var_Parse(&nested_p, st->ctxt, nested_eflags,
&nested_val, &nested_val_freeIt);
@@ -2980,7 +2980,8 @@
delim = st->startc == '(' ? ')' : '}';
/* TODO: Add test for using the ::= modifier in a := assignment line.
- * Probably st->eflags should be passed down without VARE_ASSIGN here. */
+ * Probably st->eflags should be passed down without VARE_KEEP_DOLLAR
+ * here. */
res = ParseModifierPart(pp, delim, st->eflags, st, &val, NULL, NULL, NULL);
if (res != VPR_OK)
return AMR_CLEANUP;
@@ -3946,9 +3947,7 @@
* expanded.
* ctxt The context in which to start searching for
* variables. The other contexts are searched as well.
- * eflags VARE_UNDEFERR if undefineds are an error
- * VARE_WANTRES if we actually want the result
- * VARE_ASSIGN if we are in a := assignment
+ * eflags Special effects during expansion.
*/
VarParseResult
Var_Subst(const char *str, GNode *ctxt, VarEvalFlags eflags, char **out_res)
@@ -3966,7 +3965,7 @@
while (*p != '\0') {
if (p[0] == '$' && p[1] == '$') {
/* A dollar sign may be escaped with another dollar sign. */
- if (save_dollars && (eflags & VARE_ASSIGN))
+ if (save_dollars && (eflags & VARE_KEEP_DOLLAR))
Buf_AddByte(&buf, '$');
Buf_AddByte(&buf, '$');
p += 2;
Home |
Main Index |
Thread Index |
Old Index