From 43b0df42da6ff88de0ad0b9148b9d293278e7b5b Mon Sep 17 00:00:00 2001 From: rillig Date: Fri, 26 Oct 2007 09:41:49 +0000 Subject: Emit a warning if the function name "empty" is followed by anything other than an open parenthesis. Currently, the following lines are all valid and equivalent: .if empty(foo) .if empty or nonempty or whatever(foo) .if empty?????????????(foo) .if empty ${foo} (bar) All except the first line are probably mistakes. --- devel/bmake/files/cond.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'devel/bmake') diff --git a/devel/bmake/files/cond.c b/devel/bmake/files/cond.c index 504d907d188..e9dae8dba84 100644 --- a/devel/bmake/files/cond.c +++ b/devel/bmake/files/cond.c @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.1.1.1 2005/12/02 00:02:59 sjg Exp $ */ +/* $NetBSD: cond.c,v 1.2 2007/10/26 09:41:49 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: cond.c,v 1.1.1.1 2005/12/02 00:02:59 sjg Exp $"; +static char rcsid[] = "$NetBSD: cond.c,v 1.2 2007/10/26 09:41:49 rillig Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: cond.c,v 1.1.1.1 2005/12/02 00:02:59 sjg Exp $"); +__RCSID("$NetBSD: cond.c,v 1.2 2007/10/26 09:41:49 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -898,12 +898,18 @@ error: condExpr += 5; + if (condExpr[0] != '(') + Parse_Error(PARSE_WARNING, "Extra characters after \"empty\""); for (arglen = 0; condExpr[arglen] != '(' && condExpr[arglen] != '\0'; arglen += 1) continue; if (condExpr[arglen] != '\0') { + /* Var_Parse usually gets a string like "$(varname)". + * It doesn't care about the first character, so + * we can pass anything here, even the 'y' of "empty". + */ val = Var_Parse(&condExpr[arglen - 1], VAR_CMD, FALSE, &length, &doFree); if (val == var_Error) { -- cgit v1.2.3