Module Name: src
Committed By: rillig
Date: Sat Aug 19 10:52:14 UTC 2023
Modified Files:
src/usr.bin/make: parse.c
src/usr.bin/make/unit-tests: dep-op-missing.exp directive-dinclude.exp
directive-dinclude.mk directive-export-gmake.exp
directive-export-gmake.mk directive-hyphen-include.exp
directive-hyphen-include.mk directive-include.exp
directive-include.mk directive-sinclude.exp directive-sinclude.mk
directive.exp directive.mk parse.exp parse.mk var-op-assign.exp
var-op-assign.mk varname.exp varname.mk
Log Message:
make: add more details to error message about invalid lines
To generate a diff of this commit:
cvs rdiff -u -r1.704 -r1.705 src/usr.bin/make/parse.c
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/dep-op-missing.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/directive-dinclude.exp \
src/usr.bin/make/unit-tests/directive-dinclude.mk \
src/usr.bin/make/unit-tests/directive-export-gmake.exp \
src/usr.bin/make/unit-tests/directive-hyphen-include.exp \
src/usr.bin/make/unit-tests/directive-hyphen-include.mk \
src/usr.bin/make/unit-tests/directive-sinclude.exp
cvs rdiff -u -r1.4 -r1.5 \
src/usr.bin/make/unit-tests/directive-export-gmake.mk \
src/usr.bin/make/unit-tests/directive-sinclude.mk \
src/usr.bin/make/unit-tests/parse.exp
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/directive-include.exp
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/directive-include.mk
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/directive.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/directive.mk \
src/usr.bin/make/unit-tests/var-op-assign.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/parse.mk
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/var-op-assign.mk
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/varname.exp
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/varname.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.704 src/usr.bin/make/parse.c:1.705
--- src/usr.bin/make/parse.c:1.704 Fri Jun 23 06:08:56 2023
+++ src/usr.bin/make/parse.c Sat Aug 19 10:52:13 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.704 2023/06/23 06:08:56 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.705 2023/08/19 10:52:13 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -105,7 +105,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.704 2023/06/23 06:08:56 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.705 2023/08/19 10:52:13 rillig Exp $");
/* Detects a multiple-inclusion guard in a makefile. */
typedef enum {
@@ -887,7 +887,7 @@ InvalidLineType(const char *line)
Parse_Error(PARSE_FATAL, "Unknown directive \"%.*s\"",
(int)(dirend - dirstart), dirstart);
} else
- Parse_Error(PARSE_FATAL, "Invalid line type");
+ Parse_Error(PARSE_FATAL, "Invalid line '%s'", line);
}
static void
Index: src/usr.bin/make/unit-tests/dep-op-missing.exp
diff -u src/usr.bin/make/unit-tests/dep-op-missing.exp:1.1 src/usr.bin/make/unit-tests/dep-op-missing.exp:1.2
--- src/usr.bin/make/unit-tests/dep-op-missing.exp:1.1 Tue Dec 14 00:02:57 2021
+++ src/usr.bin/make/unit-tests/dep-op-missing.exp Sat Aug 19 10:52:13 2023
@@ -1,4 +1,4 @@
-make: "dep-op-missing.tmp" line 1: Invalid line type
+make: "dep-op-missing.tmp" line 1: Invalid line 'target'
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 0
Index: src/usr.bin/make/unit-tests/directive-dinclude.exp
diff -u src/usr.bin/make/unit-tests/directive-dinclude.exp:1.2 src/usr.bin/make/unit-tests/directive-dinclude.exp:1.3
--- src/usr.bin/make/unit-tests/directive-dinclude.exp:1.2 Sun Jan 23 21:48:59 2022
+++ src/usr.bin/make/unit-tests/directive-dinclude.exp Sat Aug 19 10:52:13 2023
@@ -1,4 +1,4 @@
-make: "directive-dinclude-error.inc" line 1: Invalid line type
+make: "directive-dinclude-error.inc" line 1: Invalid line 'syntax error'
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
Index: src/usr.bin/make/unit-tests/directive-dinclude.mk
diff -u src/usr.bin/make/unit-tests/directive-dinclude.mk:1.2 src/usr.bin/make/unit-tests/directive-dinclude.mk:1.3
--- src/usr.bin/make/unit-tests/directive-dinclude.mk:1.2 Sun Jan 23 21:48:59 2022
+++ src/usr.bin/make/unit-tests/directive-dinclude.mk Sat Aug 19 10:52:13 2023
@@ -1,4 +1,4 @@
-# $NetBSD: directive-dinclude.mk,v 1.2 2022/01/23 21:48:59 rillig Exp $
+# $NetBSD: directive-dinclude.mk,v 1.3 2023/08/19 10:52:13 rillig Exp $
#
# Tests for the .dinclude directive, which includes another file,
# silently skipping it if it cannot be opened. This is primarily used for
@@ -16,7 +16,7 @@
.dinclude "${MAKEFILE}/subdir"
# Errors that are not related to opening the file are still reported.
-# expect: make: "directive-dinclude-error.inc" line 1: Invalid line type
+# expect: make: "directive-dinclude-error.inc" line 1: Invalid line 'syntax error'
_!= echo 'syntax error' > directive-dinclude-error.inc
.dinclude "${.CURDIR}/directive-dinclude-error.inc"
_!= rm directive-dinclude-error.inc
Index: src/usr.bin/make/unit-tests/directive-export-gmake.exp
diff -u src/usr.bin/make/unit-tests/directive-export-gmake.exp:1.2 src/usr.bin/make/unit-tests/directive-export-gmake.exp:1.3
--- src/usr.bin/make/unit-tests/directive-export-gmake.exp:1.2 Sat Aug 19 10:33:32 2023
+++ src/usr.bin/make/unit-tests/directive-export-gmake.exp Sat Aug 19 10:52:13 2023
@@ -1,4 +1,4 @@
-make: "directive-export-gmake.mk" line 74: Invalid line type
+make: "directive-export-gmake.mk" line 73: Invalid line 'export VAR=1'
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
Index: src/usr.bin/make/unit-tests/directive-hyphen-include.exp
diff -u src/usr.bin/make/unit-tests/directive-hyphen-include.exp:1.2 src/usr.bin/make/unit-tests/directive-hyphen-include.exp:1.3
--- src/usr.bin/make/unit-tests/directive-hyphen-include.exp:1.2 Sun Jan 23 21:48:59 2022
+++ src/usr.bin/make/unit-tests/directive-hyphen-include.exp Sat Aug 19 10:52:13 2023
@@ -1,4 +1,4 @@
-make: "directive-hyphen-include-error.inc" line 1: Invalid line type
+make: "directive-hyphen-include-error.inc" line 1: Invalid line 'syntax error'
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
Index: src/usr.bin/make/unit-tests/directive-hyphen-include.mk
diff -u src/usr.bin/make/unit-tests/directive-hyphen-include.mk:1.2 src/usr.bin/make/unit-tests/directive-hyphen-include.mk:1.3
--- src/usr.bin/make/unit-tests/directive-hyphen-include.mk:1.2 Sun Jan 23 21:48:59 2022
+++ src/usr.bin/make/unit-tests/directive-hyphen-include.mk Sat Aug 19 10:52:13 2023
@@ -1,4 +1,4 @@
-# $NetBSD: directive-hyphen-include.mk,v 1.2 2022/01/23 21:48:59 rillig Exp $
+# $NetBSD: directive-hyphen-include.mk,v 1.3 2023/08/19 10:52:13 rillig Exp $
#
# Tests for the .-include directive, which includes another file,
# silently skipping it if it cannot be opened.
@@ -15,7 +15,7 @@
.-include "${MAKEFILE}/subdir"
# Errors that are not related to opening the file are still reported.
-# expect: make: "directive-hyphen-include-error.inc" line 1: Invalid line type
+# expect: make: "directive-hyphen-include-error.inc" line 1: Invalid line 'syntax error'
_!= echo 'syntax error' > directive-hyphen-include-error.inc
.-include "${.CURDIR}/directive-hyphen-include-error.inc"
_!= rm directive-hyphen-include-error.inc
Index: src/usr.bin/make/unit-tests/directive-sinclude.exp
diff -u src/usr.bin/make/unit-tests/directive-sinclude.exp:1.2 src/usr.bin/make/unit-tests/directive-sinclude.exp:1.3
--- src/usr.bin/make/unit-tests/directive-sinclude.exp:1.2 Sun Jan 23 16:09:38 2022
+++ src/usr.bin/make/unit-tests/directive-sinclude.exp Sat Aug 19 10:52:14 2023
@@ -1,4 +1,4 @@
-make: "directive-include-error.inc" line 1: Invalid line type
+make: "directive-include-error.inc" line 1: Invalid line 'syntax error'
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
Index: src/usr.bin/make/unit-tests/directive-export-gmake.mk
diff -u src/usr.bin/make/unit-tests/directive-export-gmake.mk:1.4 src/usr.bin/make/unit-tests/directive-export-gmake.mk:1.5
--- src/usr.bin/make/unit-tests/directive-export-gmake.mk:1.4 Sat Aug 19 10:33:32 2023
+++ src/usr.bin/make/unit-tests/directive-export-gmake.mk Sat Aug 19 10:52:13 2023
@@ -1,4 +1,4 @@
-# $NetBSD: directive-export-gmake.mk,v 1.4 2023/08/19 10:33:32 rillig Exp $
+# $NetBSD: directive-export-gmake.mk,v 1.5 2023/08/19 10:52:13 rillig Exp $
#
# Tests for the export directive (without leading dot), as in GNU make.
@@ -65,11 +65,10 @@ export VAR=an ${UNDEF} variable
# directive is only recognized if the line does not contain a ':', to allow
# 'export' to be a regular target.
.for value in 1
-# FIXME: The below error message is missing all details. But even if it
-# contained the text of the line, it would be confusing because at the point
+# FIXME: The below error message is confusing because at the point
# where that error message is printed, all expressions from the line have
# already been expanded as part of the dependency line parsing, which in this
# case hides the ':' from the error message.
-# expect+1: Invalid line type
+# expect+1: Invalid line 'export VAR=1'
export VAR=${value}
.endfor
Index: src/usr.bin/make/unit-tests/directive-sinclude.mk
diff -u src/usr.bin/make/unit-tests/directive-sinclude.mk:1.4 src/usr.bin/make/unit-tests/directive-sinclude.mk:1.5
--- src/usr.bin/make/unit-tests/directive-sinclude.mk:1.4 Sun Jan 23 21:48:59 2022
+++ src/usr.bin/make/unit-tests/directive-sinclude.mk Sat Aug 19 10:52:14 2023
@@ -1,4 +1,4 @@
-# $NetBSD: directive-sinclude.mk,v 1.4 2022/01/23 21:48:59 rillig Exp $
+# $NetBSD: directive-sinclude.mk,v 1.5 2023/08/19 10:52:14 rillig Exp $
#
# Tests for the .sinclude directive, which includes another file,
# silently skipping it if it cannot be opened.
@@ -15,7 +15,7 @@
.sinclude "${MAKEFILE}/subdir"
# Errors that are not related to opening the file are still reported.
-# expect: make: "directive-include-error.inc" line 1: Invalid line type
+# expect: make: "directive-include-error.inc" line 1: Invalid line 'syntax error'
_!= echo 'syntax error' > directive-include-error.inc
.sinclude "${.CURDIR}/directive-include-error.inc"
_!= rm directive-include-error.inc
Index: src/usr.bin/make/unit-tests/parse.exp
diff -u src/usr.bin/make/unit-tests/parse.exp:1.4 src/usr.bin/make/unit-tests/parse.exp:1.5
--- src/usr.bin/make/unit-tests/parse.exp:1.4 Thu Jun 1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/parse.exp Sat Aug 19 10:52:14 2023
@@ -1,6 +1,6 @@
make: "parse.mk" line 7: Makefile appears to contain unresolved CVS/RCS/??? merge conflicts
make: "parse.mk" line 14: Makefile appears to contain unresolved CVS/RCS/??? merge conflicts
-make: "parse.mk" line 25: Invalid line type
+make: "parse.mk" line 25: Invalid line 'one-target '
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
Index: src/usr.bin/make/unit-tests/directive-include.exp
diff -u src/usr.bin/make/unit-tests/directive-include.exp:1.10 src/usr.bin/make/unit-tests/directive-include.exp:1.11
--- src/usr.bin/make/unit-tests/directive-include.exp:1.10 Thu Jun 1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/directive-include.exp Sat Aug 19 10:52:14 2023
@@ -7,7 +7,7 @@ make: "directive-include.mk" line 49: Co
make: "directive-include.mk" line 56: Unknown modifier "Z"
make: "directive-include.mk" line 56: Could not find nonexistent.mk
make: "directive-include.mk" line 61: Cannot open /nonexistent
-make: "directive-include.mk" line 66: Invalid line type
+make: "directive-include.mk" line 66: Invalid line 'include'
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
Index: src/usr.bin/make/unit-tests/directive-include.mk
diff -u src/usr.bin/make/unit-tests/directive-include.mk:1.12 src/usr.bin/make/unit-tests/directive-include.mk:1.13
--- src/usr.bin/make/unit-tests/directive-include.mk:1.12 Thu Jun 1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/directive-include.mk Sat Aug 19 10:52:14 2023
@@ -1,4 +1,4 @@
-# $NetBSD: directive-include.mk,v 1.12 2023/06/01 20:56:35 rillig Exp $
+# $NetBSD: directive-include.mk,v 1.13 2023/08/19 10:52:14 rillig Exp $
#
# Tests for the .include directive, which includes another file.
@@ -62,7 +62,7 @@ include /nonexistent # comment
sinclude /nonexistent # comment
include ${:U/dev/null} # comment
include /dev/null /dev/null
-# expect+1: Invalid line type
+# expect+1: Invalid line 'include'
include
# XXX: trailing whitespace in diagnostic, missing quotes around filename
Index: src/usr.bin/make/unit-tests/directive.exp
diff -u src/usr.bin/make/unit-tests/directive.exp:1.7 src/usr.bin/make/unit-tests/directive.exp:1.8
--- src/usr.bin/make/unit-tests/directive.exp:1.7 Sat Mar 26 14:34:07 2022
+++ src/usr.bin/make/unit-tests/directive.exp Sat Aug 19 10:52:14 2023
@@ -7,8 +7,8 @@ Global: .info = value
make: "directive.mk" line 33: := value
Global: .MAKEFLAGS = -r -k -d v -d
Global: .MAKEFLAGS = -r -k -d v -d 0
-make: "directive.mk" line 42: Invalid line type
-make: "directive.mk" line 45: Invalid line type
+make: "directive.mk" line 42: Invalid line 'target-without-colon'
+make: "directive.mk" line 45: Invalid line 'target-without-colon another-target'
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
Index: src/usr.bin/make/unit-tests/directive.mk
diff -u src/usr.bin/make/unit-tests/directive.mk:1.6 src/usr.bin/make/unit-tests/directive.mk:1.7
--- src/usr.bin/make/unit-tests/directive.mk:1.6 Sun Jan 23 16:09:38 2022
+++ src/usr.bin/make/unit-tests/directive.mk Sat Aug 19 10:52:14 2023
@@ -1,4 +1,4 @@
-# $NetBSD: directive.mk,v 1.6 2022/01/23 16:09:38 rillig Exp $
+# $NetBSD: directive.mk,v 1.7 2023/08/19 10:52:14 rillig Exp $
#
# Tests for the preprocessing directives, such as .if or .info.
@@ -38,8 +38,8 @@
# Not even the space after the '.info' can change anything about this.
.${:Uinfo} : source
-# expect+1: Invalid line type
+# expect+1: Invalid line 'target-without-colon'
target-without-colon
-# expect+1: Invalid line type
+# expect+1: Invalid line 'target-without-colon another-target'
target-without-colon another-target
Index: src/usr.bin/make/unit-tests/var-op-assign.exp
diff -u src/usr.bin/make/unit-tests/var-op-assign.exp:1.6 src/usr.bin/make/unit-tests/var-op-assign.exp:1.7
--- src/usr.bin/make/unit-tests/var-op-assign.exp:1.6 Thu Jun 1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/var-op-assign.exp Sat Aug 19 10:52:14 2023
@@ -1,5 +1,5 @@
this will be evaluated later
-make: "var-op-assign.mk" line 60: Invalid line type
+make: "var-op-assign.mk" line 60: Invalid line 'VARIABLE NAME= variable value'
make: "var-op-assign.mk" line 95: Parsing still continues until here.
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
Index: src/usr.bin/make/unit-tests/parse.mk
diff -u src/usr.bin/make/unit-tests/parse.mk:1.5 src/usr.bin/make/unit-tests/parse.mk:1.6
--- src/usr.bin/make/unit-tests/parse.mk:1.5 Thu Jun 1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/parse.mk Sat Aug 19 10:52:14 2023
@@ -1,4 +1,4 @@
-# $NetBSD: parse.mk,v 1.5 2023/06/01 20:56:35 rillig Exp $
+# $NetBSD: parse.mk,v 1.6 2023/08/19 10:52:14 rillig Exp $
#
# Test those parts of the parsing that do not belong in any of the other
# categories.
@@ -21,7 +21,7 @@
# the expanded line's terminating '\0'.
#
# https://bugs.freebsd.org/265119
-# expect+1: Invalid line type
+# expect+1: Invalid line 'one-target '
one-target ${:U }
Index: src/usr.bin/make/unit-tests/var-op-assign.mk
diff -u src/usr.bin/make/unit-tests/var-op-assign.mk:1.9 src/usr.bin/make/unit-tests/var-op-assign.mk:1.10
--- src/usr.bin/make/unit-tests/var-op-assign.mk:1.9 Thu Jun 1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/var-op-assign.mk Sat Aug 19 10:52:14 2023
@@ -1,4 +1,4 @@
-# $NetBSD: var-op-assign.mk,v 1.9 2023/06/01 20:56:35 rillig Exp $
+# $NetBSD: var-op-assign.mk,v 1.10 2023/08/19 10:52:14 rillig Exp $
#
# Tests for the = variable assignment operator, which overwrites an existing
# variable or creates it.
@@ -56,7 +56,7 @@ VAR= ${:! echo 'this will be evaluated l
# In a variable assignment, the variable name must consist of a single word.
# The following line therefore generates a parse error.
-# expect+1: Invalid line type
+# expect+1: Invalid line 'VARIABLE NAME= variable value'
VARIABLE NAME= variable value
# But if the whitespace appears inside parentheses or braces, everything is
Index: src/usr.bin/make/unit-tests/varname.exp
diff -u src/usr.bin/make/unit-tests/varname.exp:1.18 src/usr.bin/make/unit-tests/varname.exp:1.19
--- src/usr.bin/make/unit-tests/varname.exp:1.18 Thu Jun 1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/varname.exp Sat Aug 19 10:52:14 2023
@@ -11,7 +11,7 @@ Var_Parse: ${:UVAR\(\(\(}= try2 (eval-de
Evaluating modifier ${:U...} on value "" (eval-defined, undefined)
Result of ${:UVAR\(\(\(} is "VAR\(\(\(" (eval-defined, defined)
Global: .ALLTARGETS = VAR(((=) VAR\(\(\(=
-make: "varname.mk" line 38: Invalid line type
+make: "varname.mk" line 38: Invalid line 'VAR\(\(\(= try2'
Var_Parse: ${VARNAME} (eval)
Global: VAR((( = try3
Global: .MAKEFLAGS = -r -k -d v -d
Index: src/usr.bin/make/unit-tests/varname.mk
diff -u src/usr.bin/make/unit-tests/varname.mk:1.11 src/usr.bin/make/unit-tests/varname.mk:1.12
--- src/usr.bin/make/unit-tests/varname.mk:1.11 Thu Jun 1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/varname.mk Sat Aug 19 10:52:14 2023
@@ -1,4 +1,4 @@
-# $NetBSD: varname.mk,v 1.11 2023/06/01 20:56:35 rillig Exp $
+# $NetBSD: varname.mk,v 1.12 2023/08/19 10:52:14 rillig Exp $
#
# Tests for special variables, such as .MAKE or .PARSEDIR.
# And for variable names in general.
@@ -34,7 +34,7 @@ ${:UVAR(((}= try1
# as an escape character, therefore the parentheses still count to the nesting
# level, which at the end of the line is still 3. Therefore this is not a
# variable assignment as well.
-# expect+1: Invalid line type
+# expect+1: Invalid line 'VAR\(\(\(= try2'
${:UVAR\(\(\(}= try2
# To assign to a variable with an arbitrary name, the variable name has to
# come from an external source, not the text that is parsed in the assignment