Module Name: src
Committed By: sjg
Date: Mon Sep 7 17:56:24 UTC 2009
Modified Files:
src/usr.bin/make: var.c
src/usr.bin/make/unit-tests: modmatch test.exp
Log Message:
PR: 41998
:Ufu\:goo
should expand to fu:goo even when it appears in :M${:Ufu\:goo}
When scanning for :M do not compress \: if we know we have
to call Var_Subst.
To generate a diff of this commit:
cvs rdiff -u -r1.152 -r1.153 src/usr.bin/make/var.c
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/modmatch
cvs rdiff -u -r1.27 -r1.28 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.152 src/usr.bin/make/var.c:1.153
--- src/usr.bin/make/var.c:1.152 Tue Jun 16 05:44:06 2009
+++ src/usr.bin/make/var.c Mon Sep 7 17:56:24 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.152 2009/06/16 05:44:06 sjg Exp $ */
+/* $NetBSD: var.c,v 1.153 2009/09/07 17:56:24 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.152 2009/06/16 05:44:06 sjg Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.153 2009/09/07 17:56:24 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.152 2009/06/16 05:44:06 sjg Exp $");
+__RCSID("$NetBSD: var.c,v 1.153 2009/09/07 17:56:24 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -2763,9 +2763,11 @@
const char *endpat; /* points just after end of pattern */
char *cp2;
Boolean copy; /* pattern should be, or has been, copied */
+ Boolean needSubst;
int nest;
copy = FALSE;
+ needSubst = FALSE;
nest = 1;
/*
* In the loop below, ignore ':' unless we are at
@@ -2780,10 +2782,15 @@
if (*cp == '\\' &&
(cp[1] == ':' ||
cp[1] == endc || cp[1] == startc)) {
- copy = TRUE;
+ if (!needSubst) {
+ copy = TRUE;
+ }
cp++;
continue;
}
+ if (*cp == '$') {
+ needSubst = TRUE;
+ }
if (*cp == '(' || *cp == '{')
++nest;
if (*cp == ')' || *cp == '}') {
@@ -2822,7 +2829,7 @@
*/
pattern = bmake_strndup(tstr+1, endpat - (tstr + 1));
}
- if (strchr(pattern, '$') != NULL) {
+ if (needSubst) {
/*
* pattern contains embedded '$', so use Var_Subst to
* expand it.
Index: src/usr.bin/make/unit-tests/modmatch
diff -u src/usr.bin/make/unit-tests/modmatch:1.1 src/usr.bin/make/unit-tests/modmatch:1.2
--- src/usr.bin/make/unit-tests/modmatch:1.1 Fri Feb 20 09:03:26 2004
+++ src/usr.bin/make/unit-tests/modmatch Mon Sep 7 17:56:23 2009
@@ -9,8 +9,15 @@
LIB?=a
+var = head
+res = no
+.if !empty(var:M${:Uhead\:tail:C/:.*//})
+res = OK
+.endif
+
all:
@for x in $X; do ${.MAKE} -f ${MAKEFILE} show LIB=$$x; done
+ @echo "Mscanner=${res}"
show:
@echo 'LIB=${LIB} X_LIBS:M$${LIB$${LIB:tu}} is "${X_LIBS:M${LIB${LIB:tu}}}"'
Index: src/usr.bin/make/unit-tests/test.exp
diff -u src/usr.bin/make/unit-tests/test.exp:1.27 src/usr.bin/make/unit-tests/test.exp:1.28
--- src/usr.bin/make/unit-tests/test.exp:1.27 Tue Feb 3 23:11:12 2009
+++ src/usr.bin/make/unit-tests/test.exp Mon Sep 7 17:56:23 2009
@@ -97,6 +97,7 @@
LIB=e X_LIBS:M${LIB${LIB:tu}} is "/tmp/libe.a"
LIB=e X_LIBS:M*/lib${LIB}.a is "/tmp/libe.a"
LIB=e X_LIBS:M*/lib${LIB}.a:tu is "/TMP/LIBE.A"
+Mscanner=OK
path=':/bin:/usr/bin::/sbin:/usr/sbin:.:/home/user/bin:.'
path='/bin:/usr/bin:/sbin:/usr/sbin:/home/user/bin'
path='/bin:/usr/bin:/sbin:/usr/sbin:/homes/user/bin'