=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/make/cond.c,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- src/usr.bin/make/cond.c 2006/01/20 23:10:19 1.31 +++ src/usr.bin/make/cond.c 2007/01/04 18:01:32 1.32 @@ -1,5 +1,5 @@ /* $OpenPackages$ */ -/* $OpenBSD: cond.c,v 1.31 2006/01/20 23:10:19 espie Exp $ */ +/* $OpenBSD: cond.c,v 1.32 2007/01/04 18:01:32 espie Exp $ */ /* $NetBSD: cond.c,v 1.7 1996/11/06 17:59:02 christos Exp $ */ /* @@ -75,6 +75,8 @@ * T -> $(varspec) op value * T -> $(varspec) == "string" * T -> $(varspec) != "string" + * T -> "string" == "string" + * T -> "string" != "string" * T -> ( E ) * T -> ! T * op -> == | != | > | < | >= | <= @@ -110,6 +112,8 @@ static Token CondE(bool); static Token CondHandleVarSpec(bool); static Token CondHandleDefault(bool); +static Token CondHandleComparison(char *, bool, bool); +static Token CondHandleString(bool); static const char *find_cond(const char *); @@ -365,16 +369,12 @@ static Token CondHandleVarSpec(bool doEval) { - Token t; char *lhs; - const char *rhs; - const char *op; size_t varSpecLen; bool doFree; /* Parse the variable spec and skip over it, saving its * value in lhs. */ - t = Err; lhs = Var_Parse(condExpr, NULL, doEval,&varSpecLen,&doFree); if (lhs == var_Error) /* Even if !doEval, we still report syntax errors, which @@ -396,11 +396,44 @@ for (;*condExpr && !isspace(*condExpr); condExpr++) Buf_AddChar(&buf, *condExpr); - lhs = Buf_Retrieve(&buf); - + lhs = Var_Subst(Buf_Retrieve(&buf), NULL, doEval); + Buf_Destroy(&buf); doFree = true; } + return CondHandleComparison(lhs, doFree, doEval); +} + +static Token +CondHandleString(bool doEval) +{ + char *lhs; + const char *begin; + BUFFER buf; + + /* find the extent of the string */ + begin = ++condExpr; + while (*condExpr && *condExpr != '"') { + condExpr++; + } + + Buf_Init(&buf, 0); + Buf_Addi(&buf, begin, condExpr); + if (*condExpr == '"') + condExpr++; + lhs = Var_Subst(Buf_Retrieve(&buf), NULL, doEval); + Buf_Destroy(&buf); + return CondHandleComparison(lhs, true, doEval); +} + +static Token +CondHandleComparison(char *lhs, bool doFree, bool doEval) +{ + Token t; + const char *rhs; + const char *op; + + t = Err; /* Skip whitespace to get to the operator. */ while (isspace(*condExpr)) condExpr++; @@ -707,6 +740,8 @@ case '\n': case '\0': return EndOfFile; + case '"': + return CondHandleString(doEval); case '$': return CondHandleVarSpec(doEval); default: