Module Name: src
Committed By: rillig
Date: Sat Jan 8 10:22:03 UTC 2022
Modified Files:
src/usr.bin/make/unit-tests: directive-for.exp directive-for.mk
Log Message:
tests/make: demonstrate edge case in parsing .for loops
To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/directive-for.exp
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/directive-for.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/directive-for.exp
diff -u src/usr.bin/make/unit-tests/directive-for.exp:1.10 src/usr.bin/make/unit-tests/directive-for.exp:1.11
--- src/usr.bin/make/unit-tests/directive-for.exp:1.10 Sun Jan 2 01:35:31 2022
+++ src/usr.bin/make/unit-tests/directive-for.exp Sat Jan 8 10:22:03 2022
@@ -26,6 +26,17 @@ make: "directive-for.mk" line 187: 1 ope
make: "directive-for.mk" line 203: for-less endfor
make: "directive-for.mk" line 204: if-less endif
make: "directive-for.mk" line 212: if-less endif
+For: end for 1
+For: loop body:
+.\
+ for inner in i
+.\
+ endfor
+make: "directive-for.mk" line 229: Unexpected end of file in .for loop
+For: loop body:
+.\
+ endfor
+make: "directive-for.mk" line 228: for-less endfor
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
Index: src/usr.bin/make/unit-tests/directive-for.mk
diff -u src/usr.bin/make/unit-tests/directive-for.mk:1.11 src/usr.bin/make/unit-tests/directive-for.mk:1.12
--- src/usr.bin/make/unit-tests/directive-for.mk:1.11 Sun Jan 2 01:35:31 2022
+++ src/usr.bin/make/unit-tests/directive-for.mk Sat Jan 8 10:22:03 2022
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for.mk,v 1.11 2022/01/02 01:35:31 rillig Exp $
+# $NetBSD: directive-for.mk,v 1.12 2022/01/08 10:22:03 rillig Exp $
#
# Tests for the .for directive.
#
@@ -212,3 +212,19 @@ var= outer
. endif # expect: if-less endif
. endfor # no 'for-less endfor'
.endif # no 'if-less endif'
+
+
+# When make parses a .for loop, it assumes that there is no line break between
+# the '.' and the 'for' or 'endfor', as there is no practical reason to break
+# the line at this point. When make scans the outer .for loop, it does not
+# recognize the inner directives as such. When make scans the inner .for
+# loop, it recognizes the '.\n for' but does not recognize the '.\n endfor',
+# as LK_FOR_BODY preserves the backslash-newline sequences.
+.MAKEFLAGS: -df
+.for outer in o
+.\
+ for inner in i
+.\
+ endfor
+.endfor
+.MAKEFLAGS: -d0