Module Name:    src
Committed By:   rillig
Date:           Mon Apr  5 12:51:35 UTC 2021

Modified Files:
        src/usr.bin/make: var.c
        src/usr.bin/make/unit-tests: directive-export-impl.exp vardebug.exp
            varmod-match-escape.exp

Log Message:
make: clean up debug logging for ':M' and ':N'

Using square brackets as quotes was confusing since patterns can contain
square brackets themselves.

The debug logging for VarMatch was a bit too detailed.  Having the
"before" and "after" states is enough for all practically relevant
cases.


To generate a diff of this commit:
cvs rdiff -u -r1.907 -r1.908 src/usr.bin/make/var.c
cvs rdiff -u -r1.8 -r1.9 \
    src/usr.bin/make/unit-tests/directive-export-impl.exp
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/vardebug.exp
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/varmod-match-escape.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.907 src/usr.bin/make/var.c:1.908
--- src/usr.bin/make/var.c:1.907	Sun Apr  4 13:35:25 2021
+++ src/usr.bin/make/var.c	Mon Apr  5 12:51:35 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.907 2021/04/04 13:35:25 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.908 2021/04/05 12:51:35 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.907 2021/04/04 13:35:25 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.908 2021/04/05 12:51:35 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -1412,7 +1412,7 @@ static void
 ModifyWord_Match(const char *word, SepBuf *buf, void *data)
 {
 	const char *pattern = data;
-	DEBUG2(VAR, "VarMatch [%s] [%s]\n", word, pattern);
+
 	if (Str_Match(word, pattern))
 		SepBuf_AddStr(buf, word);
 }
@@ -1425,6 +1425,7 @@ static void
 ModifyWord_NoMatch(const char *word, SepBuf *buf, void *data)
 {
 	const char *pattern = data;
+
 	if (!Str_Match(word, pattern))
 		SepBuf_AddStr(buf, word);
 }
@@ -2853,8 +2854,7 @@ ParseModifier_Match(const char **pp, con
 		free(old_pattern);
 	}
 
-	DEBUG3(VAR, "Pattern[%s] for [%s] is [%s]\n",
-	       expr->name, expr->value.str, pattern);
+	DEBUG2(VAR, "Pattern for ':%c' is \"%s\"\n", mod[0], pattern);
 
 	*out_pattern = pattern;
 }

Index: src/usr.bin/make/unit-tests/directive-export-impl.exp
diff -u src/usr.bin/make/unit-tests/directive-export-impl.exp:1.8 src/usr.bin/make/unit-tests/directive-export-impl.exp:1.9
--- src/usr.bin/make/unit-tests/directive-export-impl.exp:1.8	Sun Apr  4 10:13:09 2021
+++ src/usr.bin/make/unit-tests/directive-export-impl.exp	Mon Apr  5 12:51:35 2021
@@ -6,7 +6,7 @@ ParseReadLine (32): ': ${UT_VAR:N*}'
 Var_Parse: ${UT_VAR:N*} (eval-defined)
 Var_Parse: ${REF}> (eval-defined)
 Applying ${UT_VAR:N...} to "<>" (eval-defined, regular)
-Pattern[UT_VAR] for [<>] is [*]
+Pattern for ':N' is "*"
 ModifyWords: split "<>" into 1 words
 Result of ${UT_VAR:N*} is "" (eval-defined, regular)
 ParseDependency(: )
@@ -27,7 +27,7 @@ ParseReadLine (50): ': ${UT_VAR:N*}'
 Var_Parse: ${UT_VAR:N*} (eval-defined)
 Var_Parse: ${REF}> (eval-defined)
 Applying ${UT_VAR:N...} to "<>" (eval-defined, regular)
-Pattern[UT_VAR] for [<>] is [*]
+Pattern for ':N' is "*"
 ModifyWords: split "<>" into 1 words
 Result of ${UT_VAR:N*} is "" (eval-defined, regular)
 ParseDependency(: )

Index: src/usr.bin/make/unit-tests/vardebug.exp
diff -u src/usr.bin/make/unit-tests/vardebug.exp:1.19 src/usr.bin/make/unit-tests/vardebug.exp:1.20
--- src/usr.bin/make/unit-tests/vardebug.exp:1.19	Sat Apr  3 22:02:59 2021
+++ src/usr.bin/make/unit-tests/vardebug.exp	Mon Apr  5 12:51:35 2021
@@ -19,15 +19,12 @@ Global:VAR = 1 2
 Global:VAR = 1 2 3
 Var_Parse: ${VAR:M[2]} (eval-defined)
 Applying ${VAR:M...} to "1 2 3" (eval-defined, regular)
-Pattern[VAR] for [1 2 3] is [[2]]
+Pattern for ':M' is "[2]"
 ModifyWords: split "1 2 3" into 3 words
-VarMatch [1] [[2]]
-VarMatch [2] [[2]]
-VarMatch [3] [[2]]
 Result of ${VAR:M[2]} is "2" (eval-defined, regular)
 Var_Parse: ${VAR:N[2]} (eval-defined)
 Applying ${VAR:N...} to "1 2 3" (eval-defined, regular)
-Pattern[VAR] for [1 2 3] is [[2]]
+Pattern for ':N' is "[2]"
 ModifyWords: split "1 2 3" into 3 words
 Result of ${VAR:N[2]} is "1 3" (eval-defined, regular)
 Var_Parse: ${VAR:S,2,two,} (eval-defined)
@@ -54,14 +51,12 @@ Applying ${:U...} to "" (eval-defined, u
 Result of ${:UM*e} is "M*e" (eval-defined, defined)
 Indirect modifier "M*e" from "${:UM*e}"
 Applying ${:M...} to "value" (eval-defined, defined)
-Pattern[] for [value] is [*e]
+Pattern for ':M' is "*e"
 ModifyWords: split "value" into 1 words
-VarMatch [value] [*e]
 Result of ${:M*e} is "value" (eval-defined, defined)
 Applying ${:M...} to "value" (eval-defined, defined)
-Pattern[] for [value] is [valu[e]]
+Pattern for ':M' is "valu[e]"
 ModifyWords: split "value" into 1 words
-VarMatch [value] [valu[e]]
 Result of ${:Mvalu[e]} is "value" (eval-defined, defined)
 Var_Parse: ${:UVAR} (eval)
 Applying ${:U...} to "" (eval, undefined)

Index: src/usr.bin/make/unit-tests/varmod-match-escape.exp
diff -u src/usr.bin/make/unit-tests/varmod-match-escape.exp:1.9 src/usr.bin/make/unit-tests/varmod-match-escape.exp:1.10
--- src/usr.bin/make/unit-tests/varmod-match-escape.exp:1.9	Sat Apr  3 22:02:59 2021
+++ src/usr.bin/make/unit-tests/varmod-match-escape.exp	Mon Apr  5 12:51:35 2021
@@ -5,26 +5,16 @@ Applying ${SPECIALS:M...} to "\: : \\ * 
 Var_Parse: ${:U}\: (eval-defined)
 Applying ${:U} to "" (eval-defined, undefined)
 Result of ${:U} is "" (eval-defined, defined)
-Pattern[SPECIALS] for [\: : \\ * \*] is [\:]
+Pattern for ':M' is "\:"
 ModifyWords: split "\: : \\ * \*" into 5 words
-VarMatch [\:] [\:]
-VarMatch [:] [\:]
-VarMatch [\\] [\:]
-VarMatch [*] [\:]
-VarMatch [\*] [\:]
 Result of ${SPECIALS:M${:U}\:} is ":" (eval-defined, regular)
 Var_Parse: ${SPECIALS:M\:${:U}} (eval-defined)
 Applying ${SPECIALS:M...} to "\: : \\ * \*" (eval-defined, regular)
 Var_Parse: ${:U} (eval-defined)
 Applying ${:U} to "" (eval-defined, undefined)
 Result of ${:U} is "" (eval-defined, defined)
-Pattern[SPECIALS] for [\: : \\ * \*] is [:]
+Pattern for ':M' is ":"
 ModifyWords: split "\: : \\ * \*" into 5 words
-VarMatch [\:] [:]
-VarMatch [:] [:]
-VarMatch [\\] [:]
-VarMatch [*] [:]
-VarMatch [\*] [:]
 Result of ${SPECIALS:M\:${:U}} is ":" (eval-defined, regular)
 lhs = ":", rhs = ":", op = !=
 Global:VALUES = : :: :\:
@@ -34,22 +24,16 @@ Applying ${VALUES:M...} to ": :: :\:" (e
 Var_Parse: ${:U:} (eval-defined)
 Applying ${:U} to "" (eval-defined, undefined)
 Result of ${:U} is "" (eval-defined, defined)
-Pattern[VALUES] for [: :: :\:] is [:]
+Pattern for ':M' is ":"
 ModifyWords: split ": :: :\:" into 3 words
-VarMatch [:] [:]
-VarMatch [::] [:]
-VarMatch [:\:] [:]
 Result of ${VALUES:M\:${:U\:}} is ":" (eval-defined, regular)
 Var_Parse: ${VALUES:M${:U\:}\:} (eval-defined)
 Applying ${VALUES:M...} to ": :: :\:" (eval-defined, regular)
 Var_Parse: ${:U\:}\: (eval-defined)
 Applying ${:U...} to "" (eval-defined, undefined)
 Result of ${:U\:} is ":" (eval-defined, defined)
-Pattern[VALUES] for [: :: :\:] is [:\:]
+Pattern for ':M' is ":\:"
 ModifyWords: split ": :: :\:" into 3 words
-VarMatch [:] [:\:]
-VarMatch [::] [:\:]
-VarMatch [:\:] [:\:]
 Result of ${VALUES:M${:U\:}\:} is "::" (eval-defined, regular)
 lhs = ":", rhs = "::", op = !=
 make: "varmod-match-escape.mk" line 42: warning: XXX: Oops

Reply via email to