diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2009-05-14 15:14:37 (GMT) |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2009-07-20 12:30:35 (GMT) |
commit | b8159c06ca621b29fe1d61a1a52fb67223b5c0e0 (patch) | |
tree | 42dbd88d5364fdd51261fcd2b56e573be867063d /tools/linguist | |
parent | 7074ea4c4160f50aa40aade5cd983df6ea9ebacd (diff) | |
download | Qt-b8159c06ca621b29fe1d61a1a52fb67223b5c0e0.zip Qt-b8159c06ca621b29fe1d61a1a52fb67223b5c0e0.tar.gz Qt-b8159c06ca621b29fe1d61a1a52fb67223b5c0e0.tar.bz2 |
implement {greater,less}Than(), equals(), clear() & unset()
cherry-picked dbdbe92d5d66cbd466bcc0aea532ce79a034ab84 from creator
Diffstat (limited to 'tools/linguist')
-rw-r--r-- | tools/linguist/shared/profileevaluator.cpp | 58 |
1 files changed, 53 insertions, 5 deletions
diff --git a/tools/linguist/shared/profileevaluator.cpp b/tools/linguist/shared/profileevaluator.cpp index c17f9f6..ac653b0 100644 --- a/tools/linguist/shared/profileevaluator.cpp +++ b/tools/linguist/shared/profileevaluator.cpp @@ -1816,11 +1816,6 @@ ProItem::ProItemReturn ProFileEvaluator::Private::evaluateConditionalFunction( #if 0 case T_INFILE: case T_REQUIRES: - case T_GREATERTHAN: - case T_LESSTHAN: - case T_EQUALS: - case T_CLEAR: - case T_UNSET: case T_EVAL: case T_IF: case T_BREAK: @@ -1899,6 +1894,59 @@ ProItem::ProItemReturn ProFileEvaluator::Private::evaluateConditionalFunction( } return returnBool(values(args.first()).count() == args[1].toInt()); } + case T_GREATERTHAN: + case T_LESSTHAN: { + if (args.count() != 2) { + q->logMessage(format("%1(variable, value) requires two arguments.").arg(function)); + return ProItem::ReturnFalse; + } + QString rhs(args[1]), lhs(values(args[0]).join(QString(Option::field_sep))); + bool ok; + int rhs_int = rhs.toInt(&ok); + if (ok) { // do integer compare + int lhs_int = lhs.toInt(&ok); + if (ok) { + if (func_t == T_GREATERTHAN) + return returnBool(lhs_int > rhs_int); + return returnBool(lhs_int < rhs_int); + } + } + if (func_t == T_GREATERTHAN) + return returnBool(lhs > rhs); + return returnBool(lhs < rhs); + } + case T_EQUALS: + if (args.count() != 2) { + q->logMessage(format("%1(variable, value) requires two arguments.").arg(function)); + return ProItem::ReturnFalse; + } + return returnBool(values(args[0]).join(QString(Option::field_sep)) == args[1]); + case T_CLEAR: { + if (m_skipLevel && !m_cumulative) + return ProItem::ReturnFalse; + if (args.count() != 1) { + q->logMessage(format("%1(variable) requires one argument.").arg(function)); + return ProItem::ReturnFalse; + } + QHash<QString, QStringList>::Iterator it = m_valuemap.find(args[0]); + if (it == m_valuemap.end()) + return ProItem::ReturnFalse; + it->clear(); + return ProItem::ReturnTrue; + } + case T_UNSET: { + if (m_skipLevel && !m_cumulative) + return ProItem::ReturnFalse; + if (args.count() != 1) { + q->logMessage(format("%1(variable) requires one argument.").arg(function)); + return ProItem::ReturnFalse; + } + QHash<QString, QStringList>::Iterator it = m_valuemap.find(args[0]); + if (it == m_valuemap.end()) + return ProItem::ReturnFalse; + m_valuemap.erase(it); + return ProItem::ReturnTrue; + } case T_INCLUDE: { if (m_skipLevel && !m_cumulative) return ProItem::ReturnFalse; |