Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make/unit-tests tests/make: demonstrate edge case in...



details:   https://anonhg.NetBSD.org/src/rev/bfcd34fbb51e
branches:  trunk
changeset: 359515:bfcd34fbb51e
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jan 08 10:22:03 2022 +0000

description:
tests/make: demonstrate edge case in parsing .for loops

diffstat:

 usr.bin/make/unit-tests/directive-for.exp |  11 +++++++++++
 usr.bin/make/unit-tests/directive-for.mk  |  18 +++++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletions(-)

diffs (50 lines):

diff -r ecbdd12a9366 -r bfcd34fbb51e usr.bin/make/unit-tests/directive-for.exp
--- a/usr.bin/make/unit-tests/directive-for.exp Sat Jan 08 09:55:32 2022 +0000
+++ b/usr.bin/make/unit-tests/directive-for.exp Sat Jan 08 10:22:03 2022 +0000
@@ -26,6 +26,17 @@
 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
diff -r ecbdd12a9366 -r bfcd34fbb51e usr.bin/make/unit-tests/directive-for.mk
--- a/usr.bin/make/unit-tests/directive-for.mk  Sat Jan 08 09:55:32 2022 +0000
+++ b/usr.bin/make/unit-tests/directive-for.mk  Sat Jan 08 10:22:03 2022 +0000
@@ -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 @@
 .    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



Home | Main Index | Thread Index | Old Index