version 1.67, 2012/11/03 13:59:27 |
version 1.68, 2015/05/05 21:51:09 |
Line 181 static Token condPushBack=TOK_NONE; /* |
|
Line 181 static Token condPushBack=TOK_NONE; /* |
|
static unsigned int cond_depth = 0; /* current .if nesting level */ |
static unsigned int cond_depth = 0; /* current .if nesting level */ |
static unsigned int cond_min_depth = 0; /* depth at makefile open */ |
static unsigned int cond_min_depth = 0; /* depth at makefile open */ |
|
|
|
/* |
|
* Indicate when we should be strict about lhs of comparisons. |
|
* TRUE when Cond_EvalExpression is called from Cond_Eval (.if etc) |
|
* FALSE when Cond_EvalExpression is called from var.c:ApplyModifiers |
|
* since lhs is already expanded and we cannot tell if |
|
* it was a variable reference or not. |
|
*/ |
|
static Boolean lhsStrict; |
|
|
static int |
static int |
istoken(const char *str, const char *tok, size_t len) |
istoken(const char *str, const char *tok, size_t len) |
{ |
{ |
Line 517 CondCvtArg(char *str, double *value) |
|
Line 526 CondCvtArg(char *str, double *value) |
|
*/ |
*/ |
/* coverity:[+alloc : arg-*2] */ |
/* coverity:[+alloc : arg-*2] */ |
static char * |
static char * |
CondGetString(Boolean doEval, Boolean *quoted, void **freeIt) |
CondGetString(Boolean doEval, Boolean *quoted, void **freeIt, Boolean strictLHS) |
{ |
{ |
Buffer buf; |
Buffer buf; |
char *cp; |
char *cp; |
Line 601 CondGetString(Boolean doEval, Boolean *q |
|
Line 610 CondGetString(Boolean doEval, Boolean *q |
|
condExpr--; /* don't skip over next char */ |
condExpr--; /* don't skip over next char */ |
break; |
break; |
default: |
default: |
|
if (strictLHS && !qt && *start != '$' && |
|
!isdigit((unsigned char) *start)) { |
|
/* lhs must be quoted, a variable reference or number */ |
|
if (*freeIt) { |
|
free(*freeIt); |
|
*freeIt = NULL; |
|
} |
|
str = NULL; |
|
goto cleanup; |
|
} |
Buf_AddByte(&buf, *condExpr); |
Buf_AddByte(&buf, *condExpr); |
break; |
break; |
} |
} |
Line 648 compare_expression(Boolean doEval) |
|
Line 667 compare_expression(Boolean doEval) |
|
* Parse the variable spec and skip over it, saving its |
* Parse the variable spec and skip over it, saving its |
* value in lhs. |
* value in lhs. |
*/ |
*/ |
lhs = CondGetString(doEval, &lhsQuoted, &lhsFree); |
lhs = CondGetString(doEval, &lhsQuoted, &lhsFree, lhsStrict); |
if (!lhs) |
if (!lhs) |
goto done; |
goto done; |
|
|
Line 709 compare_expression(Boolean doEval) |
|
Line 728 compare_expression(Boolean doEval) |
|
goto done; |
goto done; |
} |
} |
|
|
rhs = CondGetString(doEval, &rhsQuoted, &rhsFree); |
rhs = CondGetString(doEval, &rhsQuoted, &rhsFree, FALSE); |
if (!rhs) |
if (!rhs) |
goto done; |
goto done; |
|
|
Line 1135 CondE(Boolean doEval) |
|
Line 1154 CondE(Boolean doEval) |
|
*----------------------------------------------------------------------- |
*----------------------------------------------------------------------- |
*/ |
*/ |
int |
int |
Cond_EvalExpression(const struct If *info, char *line, Boolean *value, int eprint) |
Cond_EvalExpression(const struct If *info, char *line, Boolean *value, int eprint, Boolean strictLHS) |
{ |
{ |
static const struct If *dflt_info; |
static const struct If *dflt_info; |
const struct If *sv_if_info = if_info; |
const struct If *sv_if_info = if_info; |
Line 1143 Cond_EvalExpression(const struct If *inf |
|
Line 1162 Cond_EvalExpression(const struct If *inf |
|
Token sv_condPushBack = condPushBack; |
Token sv_condPushBack = condPushBack; |
int rval; |
int rval; |
|
|
|
lhsStrict = strictLHS; |
|
|
while (*line == ' ' || *line == '\t') |
while (*line == ' ' || *line == '\t') |
line++; |
line++; |
|
|
Line 1359 Cond_Eval(char *line) |
|
Line 1380 Cond_Eval(char *line) |
|
} |
} |
|
|
/* And evaluate the conditional expresssion */ |
/* And evaluate the conditional expresssion */ |
if (Cond_EvalExpression(ifp, line, &value, 1) == COND_INVALID) { |
if (Cond_EvalExpression(ifp, line, &value, 1, TRUE) == COND_INVALID) { |
/* Syntax error in conditional, error message already output. */ |
/* Syntax error in conditional, error message already output. */ |
/* Skip everything to matching .endif */ |
/* Skip everything to matching .endif */ |
cond_state[cond_depth] = SKIP_TO_ELSE; |
cond_state[cond_depth] = SKIP_TO_ELSE; |