Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make(1): add debugging output for :@ modifier
details: https://anonhg.NetBSD.org/src/rev/e7c179240c47
branches: trunk
changeset: 935522:e7c179240c47
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Jul 04 17:10:33 2020 +0000
description:
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.
diffstat:
usr.bin/make/unit-tests/modmisc.exp | 1 +
usr.bin/make/unit-tests/modmisc.mk | 14 ++++++++++++--
usr.bin/make/var.c | 12 +++++++++---
3 files changed, 22 insertions(+), 5 deletions(-)
diffs (80 lines):
diff -r d30a1d46963b -r e7c179240c47 usr.bin/make/unit-tests/modmisc.exp
--- a/usr.bin/make/unit-tests/modmisc.exp Sat Jul 04 16:58:11 2020 +0000
+++ b/usr.bin/make/unit-tests/modmisc.exp Sat Jul 04 17:10:33 2020 +0000
@@ -31,4 +31,5 @@
:a c:
:x__ 3 x__ 3:
:+one+ +two+ +three+:
+mod-at-resolve:w1a2w w1b2w w1a2 1b${RES2}w:
exit status 0
diff -r d30a1d46963b -r e7c179240c47 usr.bin/make/unit-tests/modmisc.mk
--- a/usr.bin/make/unit-tests/modmisc.mk Sat Jul 04 16:58:11 2020 +0000
+++ b/usr.bin/make/unit-tests/modmisc.mk Sat Jul 04 17:10:33 2020 +0000
@@ -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_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 @@
# 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}:
diff -r d30a1d46963b -r e7c179240c47 usr.bin/make/var.c
--- a/usr.bin/make/var.c Sat Jul 04 16:58:11 2020 +0000
+++ b/usr.bin/make/var.c Sat Jul 04 17:10:33 2020 +0000
@@ -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 @@
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, ' ');
Home |
Main Index |
Thread Index |
Old Index