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): add test for parse error in function d...



details:   https://anonhg.NetBSD.org/src/rev/6d22cebb229a
branches:  trunk
changeset: 956773:6d22cebb229a
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Nov 07 14:40:51 2020 +0000

description:
make(1): add test for parse error in function defined()

diffstat:

 usr.bin/make/cond.c                           |  6 +++---
 usr.bin/make/unit-tests/cond-func-defined.exp |  2 ++
 usr.bin/make/unit-tests/cond-func-defined.mk  |  9 ++++++++-
 3 files changed, 13 insertions(+), 4 deletions(-)

diffs (60 lines):

diff -r 7723d6af3884 -r 6d22cebb229a usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Sat Nov 07 14:37:30 2020 +0000
+++ b/usr.bin/make/cond.c       Sat Nov 07 14:40:51 2020 +0000
@@ -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 @@
  *     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) {
diff -r 7723d6af3884 -r 6d22cebb229a usr.bin/make/unit-tests/cond-func-defined.exp
--- a/usr.bin/make/unit-tests/cond-func-defined.exp     Sat Nov 07 14:37:30 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-func-defined.exp     Sat Nov 07 14:40:51 2020 +0000
@@ -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
diff -r 7723d6af3884 -r 6d22cebb229a usr.bin/make/unit-tests/cond-func-defined.mk
--- a/usr.bin/make/unit-tests/cond-func-defined.mk      Sat Nov 07 14:37:30 2020 +0000
+++ b/usr.bin/make/unit-tests/cond-func-defined.mk      Sat Nov 07 14:40:51 2020 +0000
@@ -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 @@
 .  error
 .endif
 
+# Parse error: missing closing parenthesis; see ParseFuncArg.
+.if defined(DEF
+.  error
+.else
+.  error
+.endif
+
 all:
        @:;



Home | Main Index | Thread Index | Old Index