Module Name: src
Committed By: sjg
Date: Fri Jun 3 21:10:42 UTC 2011
Modified Files:
src/usr.bin/make: var.c
src/usr.bin/make/unit-tests: sysv test.exp
Log Message:
ApplyModifiers: if we parse a variable in the modifier list,
do not consider it a nested modifier set, unless it is followed by
endc, a ':' or end of string.
To generate a diff of this commit:
cvs rdiff -u -r1.166 -r1.167 src/usr.bin/make/var.c
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/sysv
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/make/unit-tests/test.exp
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/var.c
diff -u src/usr.bin/make/var.c:1.166 src/usr.bin/make/var.c:1.167
--- src/usr.bin/make/var.c:1.166 Sat May 21 07:30:42 2011
+++ src/usr.bin/make/var.c Fri Jun 3 21:10:42 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.166 2011/05/21 07:30:42 tsutsui Exp $ */
+/* $NetBSD: var.c,v 1.167 2011/06/03 21:10:42 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.166 2011/05/21 07:30:42 tsutsui Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.167 2011/06/03 21:10:42 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.166 2011/05/21 07:30:42 tsutsui Exp $");
+__RCSID("$NetBSD: var.c,v 1.167 2011/06/03 21:10:42 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -2498,14 +2498,28 @@
if (*tstr == '$') {
/*
- * We have some complex modifiers in a variable.
+ * We may have some complex modifiers in a variable.
*/
void *freeIt;
char *rval;
int rlen;
+ int c;
rval = Var_Parse(tstr, ctxt, errnum, &rlen, &freeIt);
+ /*
+ * If we have not parsed up to endc or ':',
+ * we are not interested.
+ */
+ if (rval != NULL && *rval &&
+ (c = tstr[rlen]) != '\0' &&
+ c != ':' &&
+ c != endc) {
+ if (freeIt)
+ free(freeIt);
+ goto apply_mods;
+ }
+
if (DEBUG(VAR)) {
fprintf(debug_file, "Got '%s' from '%.*s'%.*s\n",
rval, rlen, tstr, rlen, tstr + rlen);
@@ -2537,6 +2551,7 @@
}
continue;
}
+ apply_mods:
if (DEBUG(VAR)) {
fprintf(debug_file, "Applying :%c to \"%s\"\n", *tstr, nstr);
}
Index: src/usr.bin/make/unit-tests/sysv
diff -u src/usr.bin/make/unit-tests/sysv:1.1 src/usr.bin/make/unit-tests/sysv:1.2
--- src/usr.bin/make/unit-tests/sysv:1.1 Sun Mar 6 00:02:14 2011
+++ src/usr.bin/make/unit-tests/sysv Fri Jun 3 21:10:42 2011
@@ -1,13 +1,26 @@
-# $Id: sysv,v 1.1 2011/03/06 00:02:14 sjg Exp $
+# $Id: sysv,v 1.2 2011/06/03 21:10:42 sjg Exp $
FOO ?=
FOOBAR = $(FOO:=bar)
_this := ${.PARSEDIR}/${.PARSEFILE}
+B = /b
+S = /
+FUN = ${B}${S}fun
+SUN = the Sun
+
# we expect nothing when FOO is empty
-all:
+all: foo fun
+
+foo:
@echo FOOBAR = $(FOOBAR)
.if empty(FOO)
- @FOO="foo fu" ${.MAKE} -f ${_this}
+ @FOO="foo fu" ${.MAKE} -f ${_this} foo
.endif
+
+fun:
+ @echo ${FUN:T}
+ @echo ${FUN:${B}${S}fun=fun}
+ @echo ${FUN:${B}${S}%=%}
+ @echo ${In:L:%=% ${SUN}}
Index: src/usr.bin/make/unit-tests/test.exp
diff -u src/usr.bin/make/unit-tests/test.exp:1.37 src/usr.bin/make/unit-tests/test.exp:1.38
--- src/usr.bin/make/unit-tests/test.exp:1.37 Mon Apr 11 15:10:15 2011
+++ src/usr.bin/make/unit-tests/test.exp Fri Jun 3 21:10:42 2011
@@ -317,6 +317,10 @@
V.i386 ?= OK
FOOBAR =
FOOBAR = foobar fubar
+fun
+fun
+fun
+In the Sun
The answer is unknown
The answer is unknown
The answer is empty