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): add tests for creative vari...



details:   https://anonhg.NetBSD.org/src/rev/8c595078b9af
branches:  trunk
changeset: 937053:8c595078b9af
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Aug 07 20:10:35 2020 +0000

description:
make(1): add tests for creative variable names in the :@ modifier

diffstat:

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

diffs (43 lines):

diff -r 5c0fe77a5f72 -r 8c595078b9af usr.bin/make/unit-tests/modmisc.exp
--- a/usr.bin/make/unit-tests/modmisc.exp       Fri Aug 07 19:24:27 2020 +0000
+++ b/usr.bin/make/unit-tests/modmisc.exp       Fri Aug 07 20:10:35 2020 +0000
@@ -36,6 +36,10 @@
 :a c:
 :x__ 3 x__ 3:
 :+one+ +two+ +three+:
+:x1y x2y x3y:
+:x1y x2y x3y:
+:mod-loop-varname: :x1y x2y x3y: ::
+:x1y x2y x3y:
 mod-loop-resolve:w1d2d3w w2i3w w1i2d3 2i${RES3}w w1d2d3 2i${RES3} 1i${RES2}w:
 mod-loop-varname-dollar:(1) (2) (3).
 mod-loop-varname-dollar:() () ().
diff -r 5c0fe77a5f72 -r 8c595078b9af usr.bin/make/unit-tests/modmisc.mk
--- a/usr.bin/make/unit-tests/modmisc.mk        Fri Aug 07 19:24:27 2020 +0000
+++ b/usr.bin/make/unit-tests/modmisc.mk        Fri Aug 07 20:10:35 2020 +0000
@@ -1,4 +1,4 @@
-# $Id: modmisc.mk,v 1.33 2020/08/03 15:43:32 rillig Exp $
+# $Id: modmisc.mk,v 1.34 2020/08/07 20:10:35 rillig Exp $
 #
 # miscellaneous modifier tests
 
@@ -164,6 +164,19 @@
 # Therefore, in -dL mode, this is forbidden, see lint.mk.
 mod-loop-varname:
        @echo :${:Uone two three:@${:Ubar:S,b,v,}@+${var}+@:Q}:
+       # ":::" is a very creative variable name, unlikely in practice
+       # The expression ${\:\:\:} would not work since backslashes can only
+       # be escaped in the modifiers, but not in the variable name.
+       @echo :${:U1 2 3:@:::@x${${:U\:\:\:}}y@}:
+       # "@@" is another creative variable name.
+       @echo :${:U1 2 3:@\@\@@x${@@}y@}:
+       # Even "@" works as a variable name since the variable is installed
+       # in the "current" scope, which in this case is the one from the
+       # target.
+       @echo :$@: :${:U1 2 3:@\@@x${@}y@}: :$@:
+       # In extreme cases, even the backslash can be used as variable name.
+       # It needs to be doubled though.
+       @echo :${:U1 2 3:@\\@x${${:Ux:S,x,\\,}}y@}:
 
 # The :@ modifier resolves the variables a little more often than expected.
 # In particular, it resolves _all_ variables from the context, and not only



Home | Main Index | Thread Index | Old Index