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: clean up debug logging for ':M' and ':N'



details:   https://anonhg.NetBSD.org/src/rev/ef1114546879
branches:  trunk
changeset: 960998:ef1114546879
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Apr 05 12:51:35 2021 +0000

description:
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.

diffstat:

 usr.bin/make/unit-tests/directive-export-impl.exp |   4 +-
 usr.bin/make/unit-tests/vardebug.exp              |  13 +++--------
 usr.bin/make/unit-tests/varmod-match-escape.exp   |  24 +++-------------------
 usr.bin/make/var.c                                |  10 ++++----
 4 files changed, 15 insertions(+), 36 deletions(-)

diffs (161 lines):

diff -r ced071fb8736 -r ef1114546879 usr.bin/make/unit-tests/directive-export-impl.exp
--- a/usr.bin/make/unit-tests/directive-export-impl.exp Mon Apr 05 12:19:22 2021 +0000
+++ b/usr.bin/make/unit-tests/directive-export-impl.exp Mon Apr 05 12:51:35 2021 +0000
@@ -6,7 +6,7 @@
 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 @@
 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(: )
diff -r ced071fb8736 -r ef1114546879 usr.bin/make/unit-tests/vardebug.exp
--- a/usr.bin/make/unit-tests/vardebug.exp      Mon Apr 05 12:19:22 2021 +0000
+++ b/usr.bin/make/unit-tests/vardebug.exp      Mon Apr 05 12:51:35 2021 +0000
@@ -19,15 +19,12 @@
 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 @@
 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)
diff -r ced071fb8736 -r ef1114546879 usr.bin/make/unit-tests/varmod-match-escape.exp
--- a/usr.bin/make/unit-tests/varmod-match-escape.exp   Mon Apr 05 12:19:22 2021 +0000
+++ b/usr.bin/make/unit-tests/varmod-match-escape.exp   Mon Apr 05 12:51:35 2021 +0000
@@ -5,26 +5,16 @@
 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 @@
 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
diff -r ced071fb8736 -r ef1114546879 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Mon Apr 05 12:19:22 2021 +0000
+++ b/usr.bin/make/var.c        Mon Apr 05 12:51:35 2021 +0000
@@ -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 @@
 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 @@
 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 @@
                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;
 }



Home | Main Index | Thread Index | Old Index