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