Module Name: src
Committed By: rillig
Date: Fri Jan 22 00:12:01 UTC 2021
Modified Files:
src/usr.bin/make: cond.c
src/usr.bin/make/unit-tests: cond-func-defined.exp cond-func.exp
Log Message:
make(1): remove "warning" from missing closing parenthesis
This only affects the diagnostics for parse errors that involve a
missing closing parenthesis. Whether or not this is a parse error is
still the same.
It may look redundant to pass both the CondParser and the parsing
position pp to the functions, but that's necessary since during parsing,
not every code path updates the main parsing position immediately.
To generate a diff of this commit:
cvs rdiff -u -r1.252 -r1.253 src/usr.bin/make/cond.c
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/cond-func-defined.exp \
src/usr.bin/make/unit-tests/cond-func.exp
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/cond.c
diff -u src/usr.bin/make/cond.c:1.252 src/usr.bin/make/cond.c:1.253
--- src/usr.bin/make/cond.c:1.252 Thu Jan 21 23:32:28 2021
+++ src/usr.bin/make/cond.c Fri Jan 22 00:12:01 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cond.c,v 1.252 2021/01/21 23:32:28 rillig Exp $ */
+/* $NetBSD: cond.c,v 1.253 2021/01/22 00:12:01 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
#include "dir.h"
/* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: cond.c,v 1.252 2021/01/21 23:32:28 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.253 2021/01/22 00:12:01 rillig Exp $");
/*
* The parsing of conditional expressions is based on this grammar:
@@ -228,7 +228,7 @@ CondParser_SkipWhitespace(CondParser *pa
* Return the length of the argument, or 0 on error.
*/
static size_t
-ParseFuncArg(const char **pp, Boolean doEval, const char *func,
+ParseFuncArg(CondParser *par, const char **pp, Boolean doEval, const char *func,
char **out_arg)
{
const char *p = *pp;
@@ -288,10 +288,9 @@ ParseFuncArg(const char **pp, Boolean do
cpp_skip_hspace(&p);
if (func != NULL && *p++ != ')') {
- Parse_Error(PARSE_WARNING,
- "Missing closing parenthesis for %s()",
- func);
- /* The PARSE_FATAL follows in CondEvalExpression. */
+ Parse_Error(PARSE_FATAL,
+ "Missing closing parenthesis for %s()", func);
+ par->printedError = TRUE;
return 0;
}
@@ -731,8 +730,9 @@ done_lhs:
*/
/*ARGSUSED*/
static size_t
-ParseEmptyArg(const char **pp, Boolean doEval,
- const char *func MAKE_ATTR_UNUSED, char **out_arg)
+ParseEmptyArg(CondParser *par MAKE_ATTR_UNUSED, const char **pp,
+ Boolean doEval, const char *func MAKE_ATTR_UNUSED,
+ char **out_arg)
{
FStr val;
size_t magic_res;
@@ -780,8 +780,8 @@ CondParser_Func(CondParser *par, Boolean
static const struct fn_def {
const char *fn_name;
size_t fn_name_len;
- size_t (*fn_parse)(const char **, Boolean, const char *,
- char **);
+ size_t (*fn_parse)(CondParser *, const char **, Boolean,
+ const char *, char **);
Boolean (*fn_eval)(size_t, const char *);
} fns[] = {
{ "defined", 7, ParseFuncArg, FuncDefined },
@@ -806,7 +806,7 @@ CondParser_Func(CondParser *par, Boolean
if (*cp != '(')
break;
- arglen = fn->fn_parse(&cp, doEval, fn->fn_name, &arg);
+ arglen = fn->fn_parse(par, &cp, doEval, fn->fn_name, &arg);
if (arglen == 0 || arglen == (size_t)-1) {
par->p = cp;
*out_token = arglen == 0 ? TOK_FALSE : TOK_ERROR;
@@ -852,7 +852,7 @@ CondParser_LeafToken(CondParser *par, Bo
* syntax would be invalid if we did "defined(a)" - so instead treat
* as an expression.
*/
- arglen = ParseFuncArg(&cp, doEval, NULL, &arg);
+ arglen = ParseFuncArg(par, &cp, doEval, NULL, &arg);
cp1 = cp;
cpp_skip_whitespace(&cp1);
if (*cp1 == '=' || *cp1 == '!')
Index: src/usr.bin/make/unit-tests/cond-func-defined.exp
diff -u src/usr.bin/make/unit-tests/cond-func-defined.exp:1.5 src/usr.bin/make/unit-tests/cond-func-defined.exp:1.6
--- src/usr.bin/make/unit-tests/cond-func-defined.exp:1.5 Sun Nov 15 14:07:53 2020
+++ src/usr.bin/make/unit-tests/cond-func-defined.exp Fri Jan 22 00:12:01 2021
@@ -1,7 +1,5 @@
-make: "cond-func-defined.mk" line 23: warning: Missing closing parenthesis for defined()
-make: "cond-func-defined.mk" line 23: Malformed conditional (!defined(A B))
-make: "cond-func-defined.mk" line 33: warning: Missing closing parenthesis for defined()
-make: "cond-func-defined.mk" line 33: Malformed conditional (defined(DEF)
+make: "cond-func-defined.mk" line 23: Missing closing parenthesis for defined()
+make: "cond-func-defined.mk" line 33: Missing closing parenthesis for defined()
make: "cond-func-defined.mk" line 45: In .for loops, variable expressions for the loop variables are
make: "cond-func-defined.mk" line 46: substituted at evaluation time. There is no actual variable
make: "cond-func-defined.mk" line 47: involved, even if it feels like it.
Index: src/usr.bin/make/unit-tests/cond-func.exp
diff -u src/usr.bin/make/unit-tests/cond-func.exp:1.5 src/usr.bin/make/unit-tests/cond-func.exp:1.6
--- src/usr.bin/make/unit-tests/cond-func.exp:1.5 Sun Nov 15 14:07:53 2020
+++ src/usr.bin/make/unit-tests/cond-func.exp Fri Jan 22 00:12:01 2021
@@ -1,9 +1,6 @@
-make: "cond-func.mk" line 36: warning: Missing closing parenthesis for defined()
-make: "cond-func.mk" line 36: Malformed conditional (!defined(A B))
-make: "cond-func.mk" line 51: warning: Missing closing parenthesis for defined()
-make: "cond-func.mk" line 51: Malformed conditional (!defined(A&B))
-make: "cond-func.mk" line 54: warning: Missing closing parenthesis for defined()
-make: "cond-func.mk" line 54: Malformed conditional (!defined(A|B))
+make: "cond-func.mk" line 36: Missing closing parenthesis for defined()
+make: "cond-func.mk" line 51: Missing closing parenthesis for defined()
+make: "cond-func.mk" line 54: Missing closing parenthesis for defined()
make: "cond-func.mk" line 94: The empty variable is never defined.
make: "cond-func.mk" line 102: A plain function name is parsed as !empty(...).
make: "cond-func.mk" line 109: A plain function name is parsed as !empty(...).