Module Name: src
Committed By: rillig
Date: Tue Dec 22 08:51:30 UTC 2020
Modified Files:
src/usr.bin/make: parse.c
src/usr.bin/make/unit-tests: opt-file.exp opt-file.mk
Log Message:
make(1): re-add improved assertion in ParseGetLine
To generate a diff of this commit:
cvs rdiff -u -r1.513 -r1.514 src/usr.bin/make/parse.c
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/opt-file.exp
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/opt-file.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/parse.c
diff -u src/usr.bin/make/parse.c:1.513 src/usr.bin/make/parse.c:1.514
--- src/usr.bin/make/parse.c:1.513 Tue Dec 22 08:31:13 2020
+++ src/usr.bin/make/parse.c Tue Dec 22 08:51:30 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.513 2020/12/22 08:31:13 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.514 2020/12/22 08:51:30 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.513 2020/12/22 08:31:13 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.514 2020/12/22 08:51:30 rillig Exp $");
/* types and constants */
@@ -2840,7 +2840,7 @@ ParseGetLine(GetLineMode mode)
}
/* We now have a line of data */
- /* TODO: Remove line_end, it's not necessary here. */
+ assert(ch_isspace(*line_end));
*line_end = '\0';
if (mode == GLM_FOR_BODY)
Index: src/usr.bin/make/unit-tests/opt-file.exp
diff -u src/usr.bin/make/unit-tests/opt-file.exp:1.6 src/usr.bin/make/unit-tests/opt-file.exp:1.7
--- src/usr.bin/make/unit-tests/opt-file.exp:1.6 Tue Dec 22 08:05:08 2020
+++ src/usr.bin/make/unit-tests/opt-file.exp Tue Dec 22 08:51:30 2020
@@ -1,5 +1,6 @@
value
value
+line-with-trailing-whitespace
make: "(stdin)" line 1: Zero byte read from file
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
Index: src/usr.bin/make/unit-tests/opt-file.mk
diff -u src/usr.bin/make/unit-tests/opt-file.mk:1.9 src/usr.bin/make/unit-tests/opt-file.mk:1.10
--- src/usr.bin/make/unit-tests/opt-file.mk:1.9 Tue Dec 22 08:23:12 2020
+++ src/usr.bin/make/unit-tests/opt-file.mk Tue Dec 22 08:51:30 2020
@@ -1,4 +1,4 @@
-# $NetBSD: opt-file.mk,v 1.9 2020/12/22 08:23:12 rillig Exp $
+# $NetBSD: opt-file.mk,v 1.10 2020/12/22 08:51:30 rillig Exp $
#
# Tests for the -f command line option.
@@ -7,6 +7,7 @@
all: .PHONY
all: file-ending-in-backslash
all: file-ending-in-backslash-mmap
+all: line-with-trailing-whitespace
all: file-containing-null-byte
# Passing '-' as the filename reads from stdin. This is unusual but possible.
@@ -45,6 +46,14 @@ file-ending-in-backslash-mmap: .PHONY
@${MAKE} -r -f opt-file-backslash -V VAR
@rm opt-file-backslash
+# Since parse.c 1.511 from 2020-12-22, an assertion in ParseGetLine failed
+# for lines that contained trailing whitespace. Worked around in parse.c
+# 1.513, properly fixed in parse.c 1.514.
+line-with-trailing-whitespace: .PHONY
+ @printf '%s' 'VAR=$@ ' > opt-file-trailing-whitespace
+ @${MAKE} -r -f opt-file-trailing-whitespace -V VAR
+ @rm opt-file-trailing-whitespace
+
# If a file contains null bytes, the rest of the line is skipped, and parsing
# continues in the next line. Throughout the history of make, the behavior
# has changed several times, sometimes knowingly, sometimes by accident.