Module Name:    src
Committed By:   rillig
Date:           Fri May  1 16:29:34 UTC 2020

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

Log Message:
usr.bin/make: add test demonstrating that .for stops at newline


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/forloop.exp \
    src/usr.bin/make/unit-tests/forloop.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/forloop.exp
diff -u src/usr.bin/make/unit-tests/forloop.exp:1.1 src/usr.bin/make/unit-tests/forloop.exp:1.2
--- src/usr.bin/make/unit-tests/forloop.exp:1.1	Thu Aug 21 13:44:51 2014
+++ src/usr.bin/make/unit-tests/forloop.exp	Fri May  1 16:29:34 2020
@@ -7,12 +7,13 @@ x=-I"This or that"
 x=-Ithat
 x="-DTHIS=\"this and that\""
 cfl=-I/this -I"This or that" -Ithat "-DTHIS=\"this and that\""
+newline-item=(a)
 a=one b="two and three"
 a=four b="five"
 a=ONE b="TWO AND THREE"
 a=FOUR b="FIVE"
 We expect an error next:
-make: "forloop.mk" line 38: Wrong number of words (9) in .for substitution list with 2 vars
+make: "forloop.mk" line 46: Wrong number of words (9) in .for substitution list with 2 vars
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 OK
Index: src/usr.bin/make/unit-tests/forloop.mk
diff -u src/usr.bin/make/unit-tests/forloop.mk:1.1 src/usr.bin/make/unit-tests/forloop.mk:1.2
--- src/usr.bin/make/unit-tests/forloop.mk:1.1	Thu Aug 21 13:44:51 2014
+++ src/usr.bin/make/unit-tests/forloop.mk	Fri May  1 16:29:34 2020
@@ -1,4 +1,4 @@
-# $Id: forloop.mk,v 1.1 2014/08/21 13:44:51 apb Exp $
+# $Id: forloop.mk,v 1.2 2020/05/01 16:29:34 rillig Exp $
 
 all: for-loop
 
@@ -33,7 +33,15 @@ X!= echo 'cfl=${cfl}' >&2; echo
 .for a b in ${EMPTY}
 X!= echo 'a=$a b=$b' >&2; echo
 .endfor
-.endif
+
+# Since at least 1993, iteration stops at the first newline.
+# Back then, the .newline variable didn't exist, therefore it was unlikely
+# that a newline ever occured.
+.for var in a${.newline}b${.newline}c
+X!= echo 'newline-item=('${var:Q}')' 1>&2; echo
+.endfor
+
+.endif	# for-fail
 
 .for a b in ${LIST} ${LIST:tu} ${XTRA_LIST}
 X!= echo 'a=$a b=$b' >&2; echo

Reply via email to