Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make/unit-tests make(1): explain the mod-subst-dolla...



details:   https://anonhg.NetBSD.org/src/rev/aafbc9e6c610
branches:  trunk
changeset: 937111:aafbc9e6c610
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Aug 09 07:41:14 2020 +0000

description:
make(1): explain the mod-subst-dollar test

diffstat:

 usr.bin/make/unit-tests/modmisc.exp |   1 +
 usr.bin/make/unit-tests/modmisc.mk  |  15 ++++++++++++++-
 2 files changed, 15 insertions(+), 1 deletions(-)

diffs (47 lines):

diff -r 380c0389ebb2 -r aafbc9e6c610 usr.bin/make/unit-tests/modmisc.exp
--- a/usr.bin/make/unit-tests/modmisc.exp       Sun Aug 09 07:26:20 2020 +0000
+++ b/usr.bin/make/unit-tests/modmisc.exp       Sun Aug 09 07:41:14 2020 +0000
@@ -57,6 +57,7 @@
 mod-subst-dollar:$40:
 mod-subst-dollar:U8:
 mod-subst-dollar:$$$$:
+mod-subst-dollar:$$$good3
 mod-loop-dollar:1:
 mod-loop-dollar:${word}$:
 mod-loop-dollar:$3$:
diff -r 380c0389ebb2 -r aafbc9e6c610 usr.bin/make/unit-tests/modmisc.mk
--- a/usr.bin/make/unit-tests/modmisc.mk        Sun Aug 09 07:26:20 2020 +0000
+++ b/usr.bin/make/unit-tests/modmisc.mk        Sun Aug 09 07:41:14 2020 +0000
@@ -1,4 +1,4 @@
-# $Id: modmisc.mk,v 1.37 2020/08/09 07:18:03 rillig Exp $
+# $Id: modmisc.mk,v 1.38 2020/08/09 07:41:14 rillig Exp $
 #
 # miscellaneous modifier tests
 
@@ -207,6 +207,16 @@
 
 # No matter how many dollar characters there are, they all get merged
 # into a single dollar by the :S modifier.
+#
+# As of 2020-08-09, this is because ParseModifierPart sees a '$' and
+# calls Var_Parse to expand the variable.  In all other places, the "$$"
+# is handled outside of Var_Parse.  Var_Parse therefore considers "$$"
+# one of the "really stupid names", skips the first dollar, and parsing
+# continues with the next character.  This repeats for the other dollar
+# signs, except the one before the delimiter.  That one is handled by
+# the code that optionally interprets the '$' as the end-anchor in the
+# first part of the :S modifier.  That code doesn't call Var_Parse but
+# simply copies the dollar to the result.
 mod-subst-dollar:
        @echo $@:${:U1:S,^,$,:Q}:
        @echo $@:${:U2:S,^,$$,:Q}:
@@ -222,6 +232,9 @@
 # Here is an alternative way to generate dollar characters.
 # It's unexpectedly complicated though.
        @echo $@:${:U:range=5:ts\x24:C,[0-9],,g:Q}:
+# In modifiers, dollars are escaped using the backslash, not using another
+# dollar sign.  Therefore, creating a dollar sign is pretty simple:
+       @echo $@:${:Ugood3:S,^,\$\$\$,:Q}
 
 # Demonstrate that it is possible to generate dollar characters using the
 # :@ modifier.



Home | Main Index | Thread Index | Old Index