Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make ApplyModifiers: if we parse a variable in the m...
details: https://anonhg.NetBSD.org/src/rev/3746653d35e4
branches: trunk
changeset: 765722:3746653d35e4
user: sjg <sjg%NetBSD.org@localhost>
date: Fri Jun 03 21:10:42 2011 +0000
description:
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.
diffstat:
usr.bin/make/unit-tests/sysv | 19 ++++++++++++++++---
usr.bin/make/unit-tests/test.exp | 4 ++++
usr.bin/make/var.c | 23 +++++++++++++++++++----
3 files changed, 39 insertions(+), 7 deletions(-)
diffs (111 lines):
diff -r 1d47e19b7550 -r 3746653d35e4 usr.bin/make/unit-tests/sysv
--- a/usr.bin/make/unit-tests/sysv Fri Jun 03 20:01:00 2011 +0000
+++ b/usr.bin/make/unit-tests/sysv Fri Jun 03 21:10:42 2011 +0000
@@ -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}}
diff -r 1d47e19b7550 -r 3746653d35e4 usr.bin/make/unit-tests/test.exp
--- a/usr.bin/make/unit-tests/test.exp Fri Jun 03 20:01:00 2011 +0000
+++ b/usr.bin/make/unit-tests/test.exp Fri Jun 03 21:10:42 2011 +0000
@@ -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
diff -r 1d47e19b7550 -r 3746653d35e4 usr.bin/make/var.c
--- a/usr.bin/make/var.c Fri Jun 03 20:01:00 2011 +0000
+++ b/usr.bin/make/var.c Fri Jun 03 21:10:42 2011 +0000
@@ -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);
}
Home |
Main Index |
Thread Index |
Old Index