summaryrefslogtreecommitdiff
path: root/usr.bin/make
diff options
context:
space:
mode:
authorsjg <sjg@NetBSD.org>2000-06-01 02:29:21 +0000
committersjg <sjg@NetBSD.org>2000-06-01 02:29:21 +0000
commitcd8908a299eb0fc6a37c79d5f6d07cb84ecff9f8 (patch)
tree7856acf5f8dcb20c319575787827fae55423fd92 /usr.bin/make
parente488ca043b6a52dbfb8a1127e7a03404e1a287b0 (diff)
Rats! ${FOO:=bar} is a common usage of the SysV = modifier.
To avoid that, we now do ::[+?!]*= but the SysV = modifier can conflict with any new modifier. At there are currently no Makefiles in our tree that use ${FOO::=bar}
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/make.130
-rw-r--r--usr.bin/make/var.c36
2 files changed, 35 insertions, 31 deletions
diff --git a/usr.bin/make/make.1 b/usr.bin/make/make.1
index 9acd8e450e1..d1aee5d56e2 100644
--- a/usr.bin/make/make.1
+++ b/usr.bin/make/make.1
@@ -1,4 +1,4 @@
-.\" $NetBSD: make.1,v 1.41 2000/05/30 02:32:21 sjg Exp $
+.\" $NetBSD: make.1,v 1.42 2000/06/01 02:29:21 sjg Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -664,7 +664,7 @@ is the value.
.It Cm sh
If the variable is non-empty it is run as a command and the output
becomes the new value.
-.It Cm = Ar str
+.It Cm \&:= Ar str
The variable is assigned the value
.Ar str
after substitution. This modifier and its variations are useful in
@@ -680,27 +680,29 @@ happy. As in:
.Bd -literal
use_foo: \&.USE
\&.for i in ${\&.TARGET} ${\&.TARGET:R}\&.gz
- @: ${t:=$i}
+ @: ${t::=$i}
@echo t:R:T=${t:R:T}
\&.endfor
.Ed
-While [?+!]= might look better than =[?+!], given that substitution is
-always done before the assignment they are more like variations on
-.Cm :=
-rather than
-.Cm =
-in normal variable assignments. Coupled with the obscurity of their
-use, the extra complexity in implementing [?+!]= is unwarranted.
-.It Cm =? Ar str
+The double
+.Cm \&:
+helps avoid false matches with the
+.At V
+style
+.Cm \&=
+modifier and since substitution always occurs the
+.Cm \&:=
+form is vaguely appropriate.
+.It Cm \&:?= Ar str
As for
-.Cm =
+.Cm \&:=
but only if the variable does not already have a value.
-.It Cm =+ Ar str
+.It Cm \&:+= Ar str
Append
.Ar str
to the variable.
-.It Cm =! Ar cmd
+.It Cm \&:!= Ar cmd
Assign the output of
.Ar cmd
to the variable.
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c
index 4e89a6316e3..6710a843336 100644
--- a/usr.bin/make/var.c
+++ b/usr.bin/make/var.c
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.44 2000/05/30 02:32:21 sjg Exp $ */
+/* $NetBSD: var.c,v 1.45 2000/06/01 02:29:21 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -39,14 +39,14 @@
*/
#ifdef MAKE_BOOTSTRAP
-static char rcsid[] = "$NetBSD: var.c,v 1.44 2000/05/30 02:32:21 sjg Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.45 2000/06/01 02:29:21 sjg 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.44 2000/05/30 02:32:21 sjg Exp $");
+__RCSID("$NetBSD: var.c,v 1.45 2000/06/01 02:29:21 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -1856,7 +1856,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
* the form '${x:P}'.
* :!<cmd>! Run cmd much the same as :sh run's the
* current value of the variable.
- * The := modifiers, actually assign a value to the variable.
+ * The ::= modifiers, actually assign a value to the variable.
* Their main purpose is in supporting modifiers of .for loop
* iterators and other obscure uses. They always expand to
* nothing. In a target rule that would otherwise expand to an
@@ -1865,19 +1865,15 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
*
* foo: .USE
* .for i in ${.TARGET} ${.TARGET:R}.gz
- * @: ${t:=$i}
+ * @: ${t::=$i}
* @echo blah ${t:T}
* .endfor
*
- * It would be neater if :=[+?!] were :[+?!]= but that would be
- * much messier to implement given the existing ! and ? modifiers.
- * Also the fact that substitution is always done on <str> makes
- * these modifiers more like variations on the normal ':=' assignment.
- * :=<str> Assigns <str> as the new value of variable.
- * :=?<str> Assigns <str> as value of variable if
+ * ::=<str> Assigns <str> as the new value of variable.
+ * ::?=<str> Assigns <str> as value of variable if
* it was not already set.
- * :=+<str> Appends <str> to variable.
- * :=!<cmd> Assigns output of <cmd> as the new value of
+ * ::+=<str> Appends <str> to variable.
+ * ::!=<cmd> Assigns output of <cmd> as the new value of
* variable.
*/
if ((str != (char *)NULL) && haveModifier) {
@@ -1893,13 +1889,17 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
printf("Applying :%c to \"%s\"\n", *tstr, str);
}
switch (*tstr) {
- case '=':
- {
+ case ':':
+
+ if (tstr[1] == '=' ||
+ (tstr[2] == '=' &&
+ (tstr[1] == '!' || tstr[1] == '+' || tstr[1] == '?'))) {
GNode *v_ctxt; /* context where v belongs */
char *emsg;
VarPattern pattern;
int how;
-
+
+ ++tstr;
if (v->flags & VAR_JUNK) {
/*
* JUNK vars get name = &str[1]
@@ -1919,7 +1919,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
v_ctxt = ctxt;
}
- switch ((how = tstr[1])) {
+ switch ((how = *tstr)) {
case '+':
case '?':
case '!':
@@ -1972,6 +1972,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
newStr = var_Error;
break;
}
+ goto default_case;
case '@':
{
VarLoop_t loop;
@@ -2374,6 +2375,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
/*FALLTHRU*/
#endif
default:
+ default_case:
{
#ifdef SYSVVARSUB
/*