make if() evaluation more qmake-like

... which basically means "break it".
This commit is contained in:
Oswald Buddenhagen
2010-05-17 14:19:56 +02:00
parent a292fb1d77
commit 583d688ee4

View File

@@ -2497,7 +2497,6 @@ ProItem::ProItemReturn ProFileEvaluator::Private::evaluateConditionalFunction(
return ProItem::ReturnFalse;
}
QString cond = args.first();
bool escaped = false; // This is more than qmake does
bool quoted = false;
bool ret = true;
bool orOp = false;
@@ -2512,24 +2511,15 @@ ProItem::ProItemReturn ProFileEvaluator::Private::evaluateConditionalFunction(
const QChar *ed = d + cond.length();
while (d < ed) {
ushort c = (d++)->unicode();
if (!escaped) {
if (c == '\\') {
escaped = true;
args += c; // Assume no-one quotes the test name
continue;
} else if (c == '"') {
quoted = !quoted;
args += c; // Ditto
continue;
}
} else {
escaped = false;
}
if (quoted) {
args += c; // Ditto
} else {
bool isOp = false;
if (c == '(') {
if (quoted) {
if (c == '"')
quoted = false;
else if (c == '!' && test.isEmpty())
invert = true;
else
test += c;
} else if (c == '(') {
isFunc = true;
if (parens)
args += c;
@@ -2539,7 +2529,9 @@ ProItem::ProItemReturn ProFileEvaluator::Private::evaluateConditionalFunction(
if (parens)
args += c;
} else if (!parens) {
if (c == ':' || c == '|')
if (c == '"')
quoted = true;
else if (c == ':' || c == '|')
isOp = true;
else if (c == '!' && test.isEmpty())
invert = true;
@@ -2548,7 +2540,7 @@ ProItem::ProItemReturn ProFileEvaluator::Private::evaluateConditionalFunction(
} else {
args += c;
}
if (!parens && (isOp || d == ed)) {
if (!quoted && !parens && (isOp || d == ed)) {
if (m_cumulative || (orOp != ret)) {
if (isFunc)
ret = evaluateConditionalFunction(test, args);
@@ -2563,7 +2555,6 @@ ProItem::ProItemReturn ProFileEvaluator::Private::evaluateConditionalFunction(
args.clear();
}
}
}
return returnBool(ret);
}
case T_CONFIG: {