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 test for modifier part ...



details:   https://anonhg.NetBSD.org/src/rev/36924a9ef1fa
branches:  trunk
changeset: 936503:36924a9ef1fa
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Jul 28 00:13:29 2020 +0000

description:
make(1): add test for modifier part with unbalanced braces

diffstat:

 usr.bin/make/unit-tests/moderrs.exp |   4 ++++
 usr.bin/make/unit-tests/moderrs.mk  |  14 +++++++++++++-
 2 files changed, 17 insertions(+), 1 deletions(-)

diffs (49 lines):

diff -r 641e9e47c119 -r 36924a9ef1fa usr.bin/make/unit-tests/moderrs.exp
--- a/usr.bin/make/unit-tests/moderrs.exp       Tue Jul 28 00:01:13 2020 +0000
+++ b/usr.bin/make/unit-tests/moderrs.exp       Tue Jul 28 00:13:29 2020 +0000
@@ -19,6 +19,10 @@
 make: Unclosed substitution for UNDEF (@ missing)
 
 1 2 3
+modloop-close:
+make: Unclosed variable specification (expecting '}') for "UNDEF" (value "1}... 2}... 3}...") modifier @
+1}... 2}... 3}...
+1}... 2}... 3}...
 Expect: 2 errors about missing ] delimiter
 make: Unclosed substitution for UNDEF (] missing)
 
diff -r 641e9e47c119 -r 36924a9ef1fa usr.bin/make/unit-tests/moderrs.mk
--- a/usr.bin/make/unit-tests/moderrs.mk        Tue Jul 28 00:01:13 2020 +0000
+++ b/usr.bin/make/unit-tests/moderrs.mk        Tue Jul 28 00:13:29 2020 +0000
@@ -1,4 +1,4 @@
-# $Id: moderrs.mk,v 1.4 2020/07/26 14:39:46 rillig Exp $
+# $Id: moderrs.mk,v 1.5 2020/07/28 00:13:29 rillig Exp $
 #
 # various modifier error tests
 
@@ -9,6 +9,7 @@
 MOD_S:= ${MOD_TERM},
 
 all:   modunkn modunknV varterm vartermV modtermV modloop
+all:   modloop-close
 all:   modwords
 all:   modexclam
 
@@ -38,6 +39,17 @@
        @echo ${UNDEF:U1 2 3:@var@...}
        @echo ${UNDEF:U1 2 3:@var@${var}@}
 
+# The closing brace after the ${var} is part of the replacement string.
+# In ParseModifierPart, braces and parentheses don't have to be balanced.
+# This is contrary to the :M, :N modifiers, where both parentheses and
+# braces must be balanced.
+# This is also contrary to the SysV modifier, where only the actually
+# used delimiter (either braces or parentheses) must be balanced.
+modloop-close:
+       @echo $@:
+       @echo ${UNDEF:U1 2 3:@var@${var}}...@
+       @echo ${UNDEF:U1 2 3:@var@${var}}...@}
+
 modwords:
        @echo "Expect: 2 errors about missing ] delimiter"
        @echo ${UNDEF:U1 2 3:[}



Home | Main Index | Thread Index | Old Index