summaryrefslogtreecommitdiff
path: root/usr.bin/make/unit-tests
diff options
context:
space:
mode:
authorsjg <sjg@NetBSD.org>2017-01-30 02:46:20 +0000
committersjg <sjg@NetBSD.org>2017-01-30 02:46:20 +0000
commit4e63770db0aa9deb37dd7a7ffde5886a413a8cc0 (patch)
tree1cd70e2e5d11a68541c039292e5f22e88ebf4c6d /usr.bin/make/unit-tests
parent44a97d0210b25fc07d55c10591df4ee477b9da14 (diff)
Add :range and :_
:range replaces var value with an integer sequence one per word in the current var value. :_ stores the current var value in $_ so that it can be referred to later in the modifier series. Reviewed by: christos
Diffstat (limited to 'usr.bin/make/unit-tests')
-rw-r--r--usr.bin/make/unit-tests/varmisc.exp2
-rw-r--r--usr.bin/make/unit-tests/varmisc.mk14
2 files changed, 14 insertions, 2 deletions
diff --git a/usr.bin/make/unit-tests/varmisc.exp b/usr.bin/make/unit-tests/varmisc.exp
index 555534f2f51..e6ce3545f1d 100644
--- a/usr.bin/make/unit-tests/varmisc.exp
+++ b/usr.bin/make/unit-tests/varmisc.exp
@@ -19,4 +19,6 @@ do not evaluate or expand :? if discarding
is set
year=2016 month=04 day=01
date=20160401
+Version=1.2.3 == 10203
+Literal=3.4.5 == 30405
exit status 0
diff --git a/usr.bin/make/unit-tests/varmisc.mk b/usr.bin/make/unit-tests/varmisc.mk
index 4b856c43d3d..5de314700a1 100644
--- a/usr.bin/make/unit-tests/varmisc.mk
+++ b/usr.bin/make/unit-tests/varmisc.mk
@@ -1,9 +1,9 @@
-# $Id: varmisc.mk,v 1.6 2017/01/14 22:58:04 sjg Exp $
+# $Id: varmisc.mk,v 1.7 2017/01/30 02:46:20 sjg Exp $
#
# Miscellaneous variable tests.
all: unmatched_var_paren D_true U_true D_false U_false Q_lhs Q_rhs NQ_none \
- strftime
+ strftime cmpv
unmatched_var_paren:
@echo ${foo::=foo-text}
@@ -49,3 +49,13 @@ strftime:
@echo ${year=%Y month=%m day=%d:L:gmtime=1459494000}
@echo date=${%Y%m%d:L:${gmtime=${April1}:L}}
+# big jumps to handle 3 digits per step
+M_cmpv.units = 1 100 10000 1000000
+# this will produce the same result as the .for loop below
+M_cmpv = S,., ,g:_:range:@i@+ $${_:[-$$i]} \* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh
+
+Version = 1.2.3
+
+cmpv:
+ @echo Version=${Version} == ${Version:${M_cmpv}}
+ @echo Literal=3.4.5 == ${3.4.5:L:${M_cmpv}}