From dc69526aed2c661a0ce189020a8c53205b3e9952 Mon Sep 17 00:00:00 2001 From: Marc Espie Date: Thu, 11 Oct 2012 14:56:18 +0000 Subject: fix make's cond parser to be able to handle .if 5 < 7 directly. okay millert@ --- usr.bin/make/cond.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'usr.bin/make') diff --git a/usr.bin/make/cond.c b/usr.bin/make/cond.c index c9d09badcb2..12d0ccc9110 100644 --- a/usr.bin/make/cond.c +++ b/usr.bin/make/cond.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cond.c,v 1.45 2012/10/09 19:51:50 espie Exp $ */ +/* $OpenBSD: cond.c,v 1.46 2012/10/11 14:56:17 espie Exp $ */ /* $NetBSD: cond.c,v 1.7 1996/11/06 17:59:02 christos Exp $ */ /* @@ -77,6 +77,7 @@ * T -> $(varspec) != "string" * T -> "string" == "string" * T -> "string" != "string" + * T -> number op number * T -> ( E ) * T -> ! T * op -> == | != | > | < | >= | <= @@ -115,6 +116,7 @@ static Token CondHandleVarSpec(bool); static Token CondHandleDefault(bool); static Token CondHandleComparison(char *, bool, bool); static Token CondHandleString(bool); +static Token CondHandleNumber(bool); static const char *find_cond(const char *); @@ -384,6 +386,20 @@ CondCvtArg(const char *str, double *value) } +static Token +CondHandleNumber(bool doEval) +{ + const char *end; + char *lhs; + + end = condExpr; + while (!isspace(*end) && strchr("!=><", *end) == NULL) + end++; + lhs = Str_dupi(condExpr, end); + condExpr = end; + return CondHandleComparison(lhs, true, doEval); +} + static Token CondHandleVarSpec(bool doEval) { @@ -760,6 +776,9 @@ CondToken(bool doEval) return CondHandleString(doEval); case '$': return CondHandleVarSpec(doEval); + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + return CondHandleNumber(doEval); default: return CondHandleDefault(doEval); } -- cgit v1.2.3