Module Name:    src
Committed By:   rillig
Date:           Sun Jul 19 07:08:10 UTC 2020

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

Log Message:
make(1): demonstrate inconsistent :ts behavior among modifiers


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/modts.exp \
    src/usr.bin/make/unit-tests/modts.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/modts.exp
diff -u src/usr.bin/make/unit-tests/modts.exp:1.2 src/usr.bin/make/unit-tests/modts.exp:1.3
--- src/usr.bin/make/unit-tests/modts.exp:1.2	Mon Mar  7 20:20:35 2016
+++ src/usr.bin/make/unit-tests/modts.exp	Sun Jul 19 07:08:09 2020
@@ -36,4 +36,9 @@ LIST:ts/x:tu="\X:tu}"
 FU_mod-ts="a/b/cool"
 FU_mod-ts:ts:T="cool" == cool?
 B.${AAA:ts}="Baaa" == Baaa?
+:ts :S => aaxBbxaaxbbxaaxbb
+:ts :S space    => axa a axc
+:ts :S space :M => axaxaxaxc
+:ts :S    => axa a axc
+:ts :S :@ => axa a axc
 exit status 0
Index: src/usr.bin/make/unit-tests/modts.mk
diff -u src/usr.bin/make/unit-tests/modts.mk:1.2 src/usr.bin/make/unit-tests/modts.mk:1.3
--- src/usr.bin/make/unit-tests/modts.mk:1.2	Mon Mar  7 20:20:35 2016
+++ src/usr.bin/make/unit-tests/modts.mk	Sun Jul 19 07:08:09 2020
@@ -7,7 +7,7 @@ FU_mod-ts = a / b / cool
 AAA= a a a
 B.aaa= Baaa
 
-all:   mod-ts
+all:   mod-ts mod-ts-space
 
 # Use print or printf iff they are builtin.
 # XXX note that this causes problems, when make decides 
@@ -42,3 +42,19 @@ mod-ts:
 	@${PRINT} 'FU_$@="${FU_${@:ts}:ts}"'
 	@${PRINT} 'FU_$@:ts:T="${FU_${@:ts}:ts:T}" == cool?'
 	@${PRINT} 'B.$${AAA:ts}="${B.${AAA:ts}}" == Baaa?'
+
+mod-ts-space:
+	# After the :ts modifier, the whole string is interpreted as a single
+	# word since all spaces have been replaced with x.
+	@${PRINT} ':ts :S => '${aa bb aa bb aa bb:L:tsx:S,b,B,:Q}
+
+	# The :ts modifier also applies to word separators that are added
+	# afterwards.
+	@${PRINT} ':ts :S space    => '${a ababa c:L:tsx:S,b, ,g:Q}
+	@${PRINT} ':ts :S space :M => '${a ababa c:L:tsx:S,b, ,g:M*:Q}
+
+	# Not all modifiers behave this way though.  Some of them always use
+	# a space as word separator instead of the :ts separator.
+	# This seems like an oversight during implementation.
+	@${PRINT} ':ts :S    => '${a ababa c:L:tsx:S,b, ,g:Q}
+	@${PRINT} ':ts :S :@ => '${a ababa c:L:tsx:S,b, ,g:@v@${v}@:Q}

Reply via email to