Module Name:    src
Committed By:   rillig
Date:           Sun Nov  1 22:10:57 UTC 2020

Modified Files:
        src/usr.bin/make/unit-tests: varmod-sysv.exp varmod-sysv.mk

Log Message:
make(1): add tests for parsing the SysV variable modifier


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-sysv.exp
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/varmod-sysv.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/varmod-sysv.exp
diff -u src/usr.bin/make/unit-tests/varmod-sysv.exp:1.3 src/usr.bin/make/unit-tests/varmod-sysv.exp:1.4
--- src/usr.bin/make/unit-tests/varmod-sysv.exp:1.3	Tue Oct  6 21:05:21 2020
+++ src/usr.bin/make/unit-tests/varmod-sysv.exp	Sun Nov  1 22:10:57 2020
@@ -1 +1,5 @@
-exit status 0
+make: Unfinished modifier for word203 ('=' missing)
+make: "varmod-sysv.mk" line 203: Malformed conditional (${word203:L:from${:D=}to})
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1

Index: src/usr.bin/make/unit-tests/varmod-sysv.mk
diff -u src/usr.bin/make/unit-tests/varmod-sysv.mk:1.9 src/usr.bin/make/unit-tests/varmod-sysv.mk:1.10
--- src/usr.bin/make/unit-tests/varmod-sysv.mk:1.9	Sat Oct 31 11:06:24 2020
+++ src/usr.bin/make/unit-tests/varmod-sysv.mk	Sun Nov  1 22:10:57 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-sysv.mk,v 1.9 2020/10/31 11:06:24 rillig Exp $
+# $NetBSD: varmod-sysv.mk,v 1.10 2020/11/01 22:10:57 rillig Exp $
 #
 # Tests for the ${VAR:from=to} variable modifier, which replaces the suffix
 # "from" with "to".  It can also use '%' as a wildcard.
@@ -196,6 +196,25 @@
 .  error
 .endif
 
+# This is not a SysV modifier since the nested variable expression expands
+# to an empty string.  The '=' in it should be irrelevant during parsing.
+# As of 2020-11-01, this seemingly correct modifier leads to a parse error.
+# XXX
+.if ${word203:L:from${:D=}to}
+.  error
+.endif
+
+# XXX: This specially constructed case demonstrates that the SysV modifier
+# lasts longer than expected.  The whole expression initially has the value
+# "fromto}...".  The next modifier is a SysV modifier.  ApplyModifier_SysV
+# parses the modifier as "from${:D=}to", ending at the '}'.  Next, the two
+# parts of the modifier are parsed using ParseModifierPart, which scans
+# differently, properly handling nested variable expressions.  The two parts
+# are now "fromto}..." and "replaced".
+.if "${:Ufromto\}...:from${:D=}to}...=replaced}" != "replaced"
+.  error
+.endif
+
 # As of 2020-10-06, the right-hand side of the SysV modifier is expanded
 # twice.  The first expansion happens in ApplyModifier_SysV, where the
 # modifier is split into its two parts.  The second expansion happens

Reply via email to