Module Name: src
Committed By: rillig
Date: Sat Jul 4 17:10:34 UTC 2020
Modified Files:
src/usr.bin/make: var.c
src/usr.bin/make/unit-tests: modmisc.exp modmisc.mk
Log Message:
make(1): add debugging output for :@ modifier
The inner working of the :@ modifier is quite tricky. To understand what
really happens, it helps to look at each word as it is being modified.
To generate a diff of this commit:
cvs rdiff -u -r1.253 -r1.254 src/usr.bin/make/var.c
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/modmisc.exp
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/modmisc.mk
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.253 src/usr.bin/make/var.c:1.254
--- src/usr.bin/make/var.c:1.253 Sat Jul 4 16:30:47 2020
+++ src/usr.bin/make/var.c Sat Jul 4 17:10:33 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.253 2020/07/04 16:30:47 rillig Exp $ */
+/* $NetBSD: var.c,v 1.254 2020/07/04 17:10:33 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.253 2020/07/04 16:30:47 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.254 2020/07/04 17:10:33 rillig 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.253 2020/07/04 16:30:47 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.254 2020/07/04 17:10:33 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -1567,6 +1567,12 @@ VarLoopExpand(GNode *ctx MAKE_ATTR_UNUSE
if (*word) {
Var_Set_with_flags(loop->tvar, word, loop->ctxt, VAR_NO_EXPORT);
s = Var_Subst(NULL, loop->str, loop->ctxt, loop->flags);
+ if (DEBUG(VAR)) {
+ fprintf(debug_file,
+ "VarLoopExpand: in \"%s\", replace \"%s\" with \"%s\" "
+ "to \"%s\"\n",
+ word, loop->tvar, loop->str, s ? s : "(null)");
+ }
if (s != NULL && *s != '\0') {
if (addSpace && *s != '\n')
Buf_AddByte(buf, ' ');
Index: src/usr.bin/make/unit-tests/modmisc.exp
diff -u src/usr.bin/make/unit-tests/modmisc.exp:1.10 src/usr.bin/make/unit-tests/modmisc.exp:1.11
--- src/usr.bin/make/unit-tests/modmisc.exp:1.10 Sat Jul 4 16:15:21 2020
+++ src/usr.bin/make/unit-tests/modmisc.exp Sat Jul 4 17:10:33 2020
@@ -31,4 +31,5 @@ make: Unclosed substitution for (, miss
:a c:
:x__ 3 x__ 3:
:+one+ +two+ +three+:
+mod-at-resolve:w1a2w w1b2w w1a2 1b${RES2}w:
exit status 0
Index: src/usr.bin/make/unit-tests/modmisc.mk
diff -u src/usr.bin/make/unit-tests/modmisc.mk:1.9 src/usr.bin/make/unit-tests/modmisc.mk:1.10
--- src/usr.bin/make/unit-tests/modmisc.mk:1.9 Sat Jul 4 16:15:21 2020
+++ src/usr.bin/make/unit-tests/modmisc.mk Sat Jul 4 17:10:33 2020
@@ -1,4 +1,4 @@
-# $Id: modmisc.mk,v 1.9 2020/07/04 16:15:21 rillig Exp $
+# $Id: modmisc.mk,v 1.10 2020/07/04 17:10:33 rillig Exp $
#
# miscellaneous modifier tests
@@ -16,7 +16,7 @@ MOD_OPT=@d@$${exists($$d):?$$d:$${d:S,/u
MOD_SEP=S,:, ,g
all: modvar modvarloop modsysv mod-HTE emptyvar undefvar
-all: mod-S mod-C mod-at-varname
+all: mod-S mod-C mod-at-varname mod-at-resolve
modsysv:
@echo "The answer is ${libfoo.a:L:libfoo.a=42}"
@@ -80,3 +80,13 @@ mod-C:
# will ever depend on this, but technically it's possible.
mod-at-varname:
@echo :${:Uone two three:@${:Ubar:S,b,v,}@+${var}+@:Q}:
+
+# The :@ modifier resolves the variables a little more often than expected.
+# In particular, it resolves _all_ variables from the context, and not only
+# the loop variable (in this case v).
+RESOLVE= ${RES1} $${RES1}
+RES1= 1a${RES2} 1b$${RES2}
+RES2= 2
+
+mod-at-resolve:
+ @echo $@:${RESOLVE:@v@w${v}w@:Q}: