Subject: make: syntax error on empty(NOSUCH)
To: None <tech-toolchain@netbsd.org>
From: Simon J. Gerraty <sjg@crufty.net>
List: tech-toolchain
Date: 09/03/2003 00:59:24
There was a brief discussion a while back about whether make should 
give a syntax error on

.if empty(NOSUCH)

if NOSUCH is undefined.  Using:

.if defined(NOSUCH) && empty(NOSUCH)

or 

.if !defined(NOSUCH) || empty(NOSUCH)

are the canonical approaches to avoiding such errors.

Anyway, turns out that (as far as I can see) cond.c always passes TRUE
for the doEval boolean which is passed to Var_Parse as its err boolean
which causes it to return Var_Error for the undefined variable.  This
doesn't seem right.
The patch below causes

.if empty(NOSUCH)

to return TRUE for the undefined variable, while still throwing up an
error for syntax errors and such.

Question is... is this something worth "fixing" or given there are
viable work arounds leave well enough alone?

--sjg

Index: cond.c
===================================================================
RCS file: /cvsroot/src/usr.bin/make/cond.c,v
retrieving revision 1.17
diff -u -p -r1.17 cond.c
--- cond.c	2003/08/07 11:14:49	1.17
+++ cond.c	2003/09/03 07:45:49
@@ -886,7 +886,7 @@ error:
 
 		    if (condExpr[arglen] != '\0') {
 			val = Var_Parse(&condExpr[arglen - 1], VAR_CMD,
-					doEval, &length, &doFree);
+					FALSE, &length, &doFree);
 			if (val == var_Error) {
 			    t = Err;
 			} else {