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: replace parse error "Need an operator" wi...



details:   https://anonhg.NetBSD.org/src/rev/5b33d84f7f40
branches:  trunk
changeset: 959143:5b33d84f7f40
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Feb 01 21:56:03 2021 +0000

description:
make: replace parse error "Need an operator" with better message

The previous error message is not easily understandable since it is
missing a crucial detail, the column where the operator is needed.
Without this information, the author of the makefile gets no useful
hint.  Furthermore, there are several types of operators in makefiles:

        the dependency operators ':', '!', '::',
        the variable assignment operators '=', '!=', '+=', '?=', ':=',
        the conditional operators '&&', '||', '!',
        the comparison operators '==', '!=', '>', '>=', '<', '<='.

This leaves too much ambiguity.

Replace this error message with "Invalid line type", which is more
generic, more accurate and thus less misleading.

diffstat:

 usr.bin/make/parse.c                      |  6 +++---
 usr.bin/make/unit-tests/var-op-assign.exp |  2 +-
 usr.bin/make/unit-tests/varname.exp       |  2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diffs (49 lines):

diff -r 18e4b1d81610 -r 5b33d84f7f40 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Mon Feb 01 21:38:20 2021 +0000
+++ b/usr.bin/make/parse.c      Mon Feb 01 21:56:03 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.534 2021/01/30 20:53:29 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.535 2021/02/01 21:56:03 rillig Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "pathnames.h"
 
 /*     "@(#)parse.c    8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.534 2021/01/30 20:53:29 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.535 2021/02/01 21:56:03 rillig Exp $");
 
 /* types and constants */
 
@@ -1018,7 +1018,7 @@
                Parse_Error(PARSE_FATAL, "Unknown directive \"%.*s\"",
                    (int)(dirend - dirstart), dirstart);
        } else
-               Parse_Error(PARSE_FATAL, "Need an operator");
+               Parse_Error(PARSE_FATAL, "Invalid line type");
 }
 
 static void
diff -r 18e4b1d81610 -r 5b33d84f7f40 usr.bin/make/unit-tests/var-op-assign.exp
--- a/usr.bin/make/unit-tests/var-op-assign.exp Mon Feb 01 21:38:20 2021 +0000
+++ b/usr.bin/make/unit-tests/var-op-assign.exp Mon Feb 01 21:56:03 2021 +0000
@@ -1,5 +1,5 @@
 this will be evaluated later
-make: "var-op-assign.mk" line 59: Need an operator
+make: "var-op-assign.mk" line 59: Invalid line type
 make: "var-op-assign.mk" line 93: Parsing still continues until here.
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
diff -r 18e4b1d81610 -r 5b33d84f7f40 usr.bin/make/unit-tests/varname.exp
--- a/usr.bin/make/unit-tests/varname.exp       Mon Feb 01 21:38:20 2021 +0000
+++ b/usr.bin/make/unit-tests/varname.exp       Mon Feb 01 21:56:03 2021 +0000
@@ -14,7 +14,7 @@
 Applying ${:U...} to "" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF)
 Result of ${:UVAR\(\(\(} is "VAR\(\(\(" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF|VEF_DEF)
 Global:.ALLTARGETS =  VAR(((=) VAR\(\(\(=
-make: "varname.mk" line 35: Need an operator
+make: "varname.mk" line 35: Invalid line type
 Var_Parse: ${VARNAME} with VARE_WANTRES
 Global:VAR((( = try3
 Global:.MAKEFLAGS =  -r -k -d v -d



Home | Main Index | Thread Index | Old Index