summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/make/cond.c49
1 files changed, 42 insertions, 7 deletions
diff --git a/usr.bin/make/cond.c b/usr.bin/make/cond.c
index 62944e6c519..9eafb5c5d87 100644
--- a/usr.bin/make/cond.c
+++ b/usr.bin/make/cond.c
@@ -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 CondF(bool);
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 @@ CondCvtArg(const char *str, double *value)
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 @@ CondHandleVarSpec(bool doEval)
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 @@ CondToken(bool doEval)
case '\n':
case '\0':
return EndOfFile;
+ case '"':
+ return CondHandleString(doEval);
case '$':
return CondHandleVarSpec(doEval);
default: