Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make make(1): re-add improved assertion in ParseGetLine



details:   https://anonhg.NetBSD.org/src/rev/83ac89847255
branches:  trunk
changeset: 948244:83ac89847255
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Dec 22 08:51:30 2020 +0000

description:
make(1): re-add improved assertion in ParseGetLine

diffstat:

 usr.bin/make/parse.c                 |   6 +++---
 usr.bin/make/unit-tests/opt-file.exp |   1 +
 usr.bin/make/unit-tests/opt-file.mk  |  11 ++++++++++-
 3 files changed, 14 insertions(+), 4 deletions(-)

diffs (69 lines):

diff -r 852933d08a7a -r 83ac89847255 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Tue Dec 22 08:31:13 2020 +0000
+++ b/usr.bin/make/parse.c      Tue Dec 22 08:51:30 2020 +0000
@@ -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 @@
                }
 
                /* 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)
diff -r 852933d08a7a -r 83ac89847255 usr.bin/make/unit-tests/opt-file.exp
--- a/usr.bin/make/unit-tests/opt-file.exp      Tue Dec 22 08:31:13 2020 +0000
+++ b/usr.bin/make/unit-tests/opt-file.exp      Tue Dec 22 08:51:30 2020 +0000
@@ -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
diff -r 852933d08a7a -r 83ac89847255 usr.bin/make/unit-tests/opt-file.mk
--- a/usr.bin/make/unit-tests/opt-file.mk       Tue Dec 22 08:31:13 2020 +0000
+++ b/usr.bin/make/unit-tests/opt-file.mk       Tue Dec 22 08:51:30 2020 +0000
@@ -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 @@
        @${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.



Home | Main Index | Thread Index | Old Index