Module Name:    src
Committed By:   rillig
Date:           Sun Dec 12 08:36:21 UTC 2021

Modified Files:
        src/usr.bin/make: cond.c
        src/usr.bin/make/unit-tests: cond-func.exp

Log Message:
make: generate more specific error message on malformed conditional


To generate a diff of this commit:
cvs rdiff -u -r1.298 -r1.299 src/usr.bin/make/cond.c
cvs rdiff -u -r1.6 -r1.7 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.298 src/usr.bin/make/cond.c:1.299
--- src/usr.bin/make/cond.c:1.298	Sat Dec 11 11:13:30 2021
+++ src/usr.bin/make/cond.c	Sun Dec 12 08:36:21 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.298 2021/12/11 11:13:30 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.299 2021/12/12 08:36:21 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.298 2021/12/11 11:13:30 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.299 2021/12/12 08:36:21 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -230,11 +230,6 @@ ParseFuncArg(CondParser *par, const char
 	if (func != NULL)
 		p++;		/* Skip opening '(' - verified by caller */
 
-	if (*p == '\0') {
-		*out_arg = NULL; /* Missing closing parenthesis: */
-		return 0;	/* .if defined( */
-	}
-
 	cpp_skip_hspace(&p);
 
 	Buf_InitSize(&argBuf, 16);
@@ -778,8 +773,9 @@ CondParser_FuncCall(CondParser *par, boo
 
 	arglen = ParseFuncArg(par, &cp, doEval, fn->fn_name, &arg);
 	if (arglen == 0) {
-		par->p = cp;
 		*out_token = TOK_FALSE;
+		free(arg);
+		par->p = cp;
 		return true;
 	}
 

Index: src/usr.bin/make/unit-tests/cond-func.exp
diff -u src/usr.bin/make/unit-tests/cond-func.exp:1.6 src/usr.bin/make/unit-tests/cond-func.exp:1.7
--- src/usr.bin/make/unit-tests/cond-func.exp:1.6	Fri Jan 22 00:12:01 2021
+++ src/usr.bin/make/unit-tests/cond-func.exp	Sun Dec 12 08:36:21 2021
@@ -6,7 +6,7 @@ make: "cond-func.mk" line 102: A plain f
 make: "cond-func.mk" line 109: A plain function name is parsed as !empty(...).
 make: "cond-func.mk" line 119: Symbols may start with a function name.
 make: "cond-func.mk" line 124: Symbols may start with a function name.
-make: "cond-func.mk" line 130: Malformed conditional (defined()
+make: "cond-func.mk" line 130: Missing closing parenthesis for defined()
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Reply via email to