summaryrefslogtreecommitdiffstats
path: root/src/linguist/shared/qmakeparser.cpp
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2015-02-18 10:54:24 +0100
committerOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2015-12-18 14:43:51 +0000
commit13a8efa6e906161c8e55fd58326152e3fab29875 (patch)
treec8a7bef57ca2df93901414761b86fa1c84959eee /src/linguist/shared/qmakeparser.cpp
parentb4c81341becb7c422fee1f58c62aed3744efb8e6 (diff)
don't write pointless TokAnd at start of control scopes
a colon after else/for is non-AND-ing, i.e., it's no logical operator, but "punctuation". therefore, putting an operator into the token stream is bogus. it didn't hurt execution, so it went unnoticed, but it still wasted some bytes and cpu cycles. Change-Id: If5578074257feed299bda1630bf0dfe72eb395ae Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com> (cherry picked from qtbase/bec885380a091dc0b37b372acf88cc3d17c80779)
Diffstat (limited to 'src/linguist/shared/qmakeparser.cpp')
-rw-r--r--src/linguist/shared/qmakeparser.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/linguist/shared/qmakeparser.cpp b/src/linguist/shared/qmakeparser.cpp
index f8c9ab071..2820f76f7 100644
--- a/src/linguist/shared/qmakeparser.cpp
+++ b/src/linguist/shared/qmakeparser.cpp
@@ -910,8 +910,14 @@ void QMakeParser::flushCond(ushort *&tokPtr)
void QMakeParser::putOperator(ushort *&tokPtr)
{
- if (m_operator != NoOperator) {
- putTok(tokPtr, (m_operator == AndOperator) ? TokAnd : TokOr);
+ if (m_operator== AndOperator) {
+ // A colon must be used after else and for() if no brace is used,
+ // but in this case it is obviously not a binary operator.
+ if (m_state == StCond)
+ putTok(tokPtr, TokAnd);
+ m_operator = NoOperator;
+ } else if (m_operator == OrOperator) {
+ putTok(tokPtr, TokOr);
m_operator = NoOperator;
}
}