Module Name: src
Committed By: rillig
Date: Mon Dec 18 11:13:51 UTC 2023
Modified Files:
src/usr.bin/make/unit-tests: varmod-subst-regex.mk varmod-subst.mk
Log Message:
tests/make: fix typo in test for ':C' modifier
The expression ${U:...} was always undefined, as there was no variable
named 'U'; the intended form was ${:U:...}. Due to this typo, the
comments in the tests for the ':S' and the ':C' modifier contradicted
each other.
To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/varmod-subst-regex.mk
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod-subst.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-subst-regex.mk
diff -u src/usr.bin/make/unit-tests/varmod-subst-regex.mk:1.10 src/usr.bin/make/unit-tests/varmod-subst-regex.mk:1.11
--- src/usr.bin/make/unit-tests/varmod-subst-regex.mk:1.10 Sun Dec 17 14:07:22 2023
+++ src/usr.bin/make/unit-tests/varmod-subst-regex.mk Mon Dec 18 11:13:51 2023
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-subst-regex.mk,v 1.10 2023/12/17 14:07:22 rillig Exp $
+# $NetBSD: varmod-subst-regex.mk,v 1.11 2023/12/18 11:13:51 rillig Exp $
#
# Tests for the :C,from,to, variable modifier.
@@ -88,23 +88,43 @@ all: unmatched-subexpression
# Like the ':S' modifier, the ':C' modifier matches on an expression
# that contains no words at all, but only if the regular expression matches an
# empty string, for example, when the regular expression is anchored at the
-# beginning or the end of the word.
-.if "<${U:S,^,prefix,}> <${:U:C,^,prefix,}>" != "<> <prefix>"
+# beginning or the end of the word. An unanchored regular expression that
+# matches the empty string is uncommon in practice, as it would match before
+# each character of the word.
+.if "<${:U:S,,unanchored,}> <${:U:C,.?,unanchored,}>" != "<> <unanchored>"
. error
.endif
-.if "<${U:S,$,suffix,}> <${:U:C,$,suffix,}>" != "<> <suffix>"
+.if "<${:U:S,^,prefix,}> <${:U:C,^,prefix,}>" != "<prefix> <prefix>"
. error
.endif
-.if "<${U:S,^$,whole,}> <${:U:C,^$,whole,}>" != "<> <whole>"
+.if "<${:U:S,$,suffix,}> <${:U:C,$,suffix,}>" != "<suffix> <suffix>"
. error
.endif
-.if "<${U:S,^,prefix,g}> <${:U:C,^,prefix,g}>" != "<> <prefix>"
+.if "<${:U:S,^$,whole,}> <${:U:C,^$,whole,}>" != "<whole> <whole>"
. error
.endif
-.if "<${U:S,$,suffix,g}> <${:U:C,$,suffix,g}>" != "<> <suffix>"
+.if "<${:U:S,,unanchored,g}> <${:U:C,.?,unanchored,g}>" != "<> <unanchored>"
. error
.endif
-.if "<${U:S,^$,whole,g}> <${:U:C,^$,whole,g}>" != "<> <whole>"
+.if "<${:U:S,^,prefix,g}> <${:U:C,^,prefix,g}>" != "<prefix> <prefix>"
+. error
+.endif
+.if "<${:U:S,$,suffix,g}> <${:U:C,$,suffix,g}>" != "<suffix> <suffix>"
+. error
+.endif
+.if "<${:U:S,^$,whole,g}> <${:U:C,^$,whole,g}>" != "<whole> <whole>"
+. error
+.endif
+.if "<${:U:S,,unanchored,W}> <${:U:C,.?,unanchored,W}>" != "<> <unanchored>"
+. error
+.endif
+.if "<${:U:S,^,prefix,W}> <${:U:C,^,prefix,W}>" != "<prefix> <prefix>"
+. error
+.endif
+.if "<${:U:S,$,suffix,W}> <${:U:C,$,suffix,W}>" != "<suffix> <suffix>"
+. error
+.endif
+.if "<${:U:S,^$,whole,W}> <${:U:C,^$,whole,W}>" != "<whole> <whole>"
. error
.endif
Index: src/usr.bin/make/unit-tests/varmod-subst.mk
diff -u src/usr.bin/make/unit-tests/varmod-subst.mk:1.13 src/usr.bin/make/unit-tests/varmod-subst.mk:1.14
--- src/usr.bin/make/unit-tests/varmod-subst.mk:1.13 Sun Dec 17 14:07:22 2023
+++ src/usr.bin/make/unit-tests/varmod-subst.mk Mon Dec 18 11:13:51 2023
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-subst.mk,v 1.13 2023/12/17 14:07:22 rillig Exp $
+# $NetBSD: varmod-subst.mk,v 1.14 2023/12/18 11:13:51 rillig Exp $
#
# Tests for the :S,from,to, variable modifier.
@@ -142,8 +142,9 @@ WORDS= sequences of letters
.endif
-# In an empty expression, the ':S' modifier matches a single time if the
-# search string is anchored at the beginning or at the end.
+# In an empty expression, the ':S' modifier matches a single time, but only if
+# the search string is empty and anchored at either the beginning or the end
+# of the word.
.if ${:U:S,,out-of-nothing,} != ""
. error
.endif
@@ -156,6 +157,30 @@ WORDS= sequences of letters
.if ${:U:S,^$,out-of-nothing,} != "out-of-nothing"
. error
.endif
+.if ${:U:S,,out-of-nothing,g} != ""
+. error
+.endif
+.if ${:U:S,^,out-of-nothing,g} != "out-of-nothing"
+. error
+.endif
+.if ${:U:S,$,out-of-nothing,g} != "out-of-nothing"
+. error
+.endif
+.if ${:U:S,^$,out-of-nothing,g} != "out-of-nothing"
+. error
+.endif
+.if ${:U:S,,out-of-nothing,W} != ""
+. error
+.endif
+.if ${:U:S,^,out-of-nothing,W} != "out-of-nothing"
+. error
+.endif
+.if ${:U:S,$,out-of-nothing,W} != "out-of-nothing"
+. error
+.endif
+.if ${:U:S,^$,out-of-nothing,W} != "out-of-nothing"
+. error
+.endif
mod-subst: