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,56 +2511,48 @@ 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) { bool isOp = false;
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) { if (quoted) {
args += c; // Ditto if (c == '"')
} else { quoted = false;
bool isOp = false; else if (c == '!' && test.isEmpty())
if (c == '(') { invert = true;
isFunc = true; else
if (parens) test += c;
args += c; } else if (c == '(') {
++parens; isFunc = true;
} else if (c == ')') { if (parens)
--parens;
if (parens)
args += c;
} else if (!parens) {
if (c == ':' || c == '|')
isOp = true;
else if (c == '!' && test.isEmpty())
invert = true;
else
test += c;
} else {
args += c; args += c;
++parens;
} else if (c == ')') {
--parens;
if (parens)
args += c;
} else if (!parens) {
if (c == '"')
quoted = true;
else if (c == ':' || c == '|')
isOp = true;
else if (c == '!' && test.isEmpty())
invert = true;
else
test += c;
} else {
args += c;
}
if (!quoted && !parens && (isOp || d == ed)) {
if (m_cumulative || (orOp != ret)) {
if (isFunc)
ret = evaluateConditionalFunction(test, args);
else
ret = isActiveConfig(test, true);
ret ^= invert;
} }
if (!parens && (isOp || d == ed)) { orOp = (c == '|');
if (m_cumulative || (orOp != ret)) { invert = false;
if (isFunc) isFunc = false;
ret = evaluateConditionalFunction(test, args); test.clear();
else args.clear();
ret = isActiveConfig(test, true);
ret ^= invert;
}
orOp = (c == '|');
invert = false;
isFunc = false;
test.clear();
args.clear();
}
} }
} }
return returnBool(ret); return returnBool(ret);