Module Name: src
Committed By: rillig
Date: Fri Aug 7 20:10:35 UTC 2020
Modified Files:
src/usr.bin/make/unit-tests: modmisc.exp modmisc.mk
Log Message:
make(1): add tests for creative variable names in the :@ modifier
To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/make/unit-tests/modmisc.exp
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/make/unit-tests/modmisc.mk
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/unit-tests/modmisc.exp
diff -u src/usr.bin/make/unit-tests/modmisc.exp:1.35 src/usr.bin/make/unit-tests/modmisc.exp:1.36
--- src/usr.bin/make/unit-tests/modmisc.exp:1.35 Sat Aug 1 18:14:08 2020
+++ src/usr.bin/make/unit-tests/modmisc.exp Fri Aug 7 20:10:35 2020
@@ -36,6 +36,10 @@ make: Regex compilation error: (details
: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:() () ().
Index: src/usr.bin/make/unit-tests/modmisc.mk
diff -u src/usr.bin/make/unit-tests/modmisc.mk:1.33 src/usr.bin/make/unit-tests/modmisc.mk:1.34
--- src/usr.bin/make/unit-tests/modmisc.mk:1.33 Mon Aug 3 15:43:32 2020
+++ src/usr.bin/make/unit-tests/modmisc.mk Fri Aug 7 20:10:35 2020
@@ -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 @@ mod-regex:
# 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