Module Name: src
Committed By: rillig
Date: Sat Nov 7 14:40:51 UTC 2020
Modified Files:
src/usr.bin/make: cond.c
src/usr.bin/make/unit-tests: cond-func-defined.exp cond-func-defined.mk
Log Message:
make(1): add test for parse error in function defined()
To generate a diff of this commit:
cvs rdiff -u -r1.180 -r1.181 src/usr.bin/make/cond.c
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/cond-func-defined.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/cond-func-defined.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/cond.c
diff -u src/usr.bin/make/cond.c:1.180 src/usr.bin/make/cond.c:1.181
--- src/usr.bin/make/cond.c:1.180 Sat Nov 7 14:37:30 2020
+++ src/usr.bin/make/cond.c Sat Nov 7 14:40:51 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: cond.c,v 1.180 2020/11/07 14:37:30 rillig Exp $ */
+/* $NetBSD: cond.c,v 1.181 2020/11/07 14:40:51 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -93,7 +93,7 @@
#include "dir.h"
/* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: cond.c,v 1.180 2020/11/07 14:37:30 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.181 2020/11/07 14:40:51 rillig Exp $");
/*
* The parsing of conditional expressions is based on this grammar:
@@ -200,7 +200,7 @@ CondParser_SkipWhitespace(CondParser *pa
* func says whether the argument belongs to an actual function, or
* whether the parsed argument is passed to the default function.
*
- * Return the length of the argument. */
+ * Return the length of the argument, or 0 on error. */
static size_t
ParseFuncArg(const char **pp, Boolean doEval, const char *func,
char **out_arg) {
Index: src/usr.bin/make/unit-tests/cond-func-defined.exp
diff -u src/usr.bin/make/unit-tests/cond-func-defined.exp:1.3 src/usr.bin/make/unit-tests/cond-func-defined.exp:1.4
--- src/usr.bin/make/unit-tests/cond-func-defined.exp:1.3 Thu Aug 20 17:45:47 2020
+++ src/usr.bin/make/unit-tests/cond-func-defined.exp Sat Nov 7 14:40:51 2020
@@ -1,5 +1,7 @@
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: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
Index: src/usr.bin/make/unit-tests/cond-func-defined.mk
diff -u src/usr.bin/make/unit-tests/cond-func-defined.mk:1.5 src/usr.bin/make/unit-tests/cond-func-defined.mk:1.6
--- src/usr.bin/make/unit-tests/cond-func-defined.mk:1.5 Sat Oct 24 08:46:08 2020
+++ src/usr.bin/make/unit-tests/cond-func-defined.mk Sat Nov 7 14:40:51 2020
@@ -1,4 +1,4 @@
-# $NetBSD: cond-func-defined.mk,v 1.5 2020/10/24 08:46:08 rillig Exp $
+# $NetBSD: cond-func-defined.mk,v 1.6 2020/11/07 14:40:51 rillig Exp $
#
# Tests for the defined() function in .if conditions.
@@ -29,5 +29,12 @@ ${:UA B}= variable name with spaces
. error
.endif
+# Parse error: missing closing parenthesis; see ParseFuncArg.
+.if defined(DEF
+. error
+.else
+. error
+.endif
+
all:
@:;