diff options
Diffstat (limited to 'qmake')
-rw-r--r-- | qmake/library/qmakebuiltins.cpp | 14 | ||||
-rw-r--r-- | qmake/library/qmakeevaluator.cpp | 25 | ||||
-rw-r--r-- | qmake/library/qmakeparser.cpp | 11 | ||||
-rw-r--r-- | qmake/library/qmakeparser.h | 2 | ||||
-rw-r--r-- | qmake/project.cpp | 19 |
5 files changed, 31 insertions, 40 deletions
diff --git a/qmake/library/qmakebuiltins.cpp b/qmake/library/qmakebuiltins.cpp index b735822806..5aef4376ee 100644 --- a/qmake/library/qmakebuiltins.cpp +++ b/qmake/library/qmakebuiltins.cpp @@ -1202,15 +1202,13 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional( VisitReturn ret = ReturnFalse; ProFile *pro = m_parser->parsedProBlock(args.join(statics.field_sep), m_current.pro->fileName(), m_current.line); - if (pro) { - if (m_cumulative || pro->isOk()) { - m_locationStack.push(m_current); - visitProBlock(pro, pro->tokPtr()); - ret = ReturnTrue; // This return value is not too useful, but that's qmake - m_current = m_locationStack.pop(); - } - pro->deref(); + if (m_cumulative || pro->isOk()) { + m_locationStack.push(m_current); + visitProBlock(pro, pro->tokPtr()); + ret = ReturnTrue; // This return value is not too useful, but that's qmake + m_current = m_locationStack.pop(); } + pro->deref(); return ret; } case T_IF: { diff --git a/qmake/library/qmakeevaluator.cpp b/qmake/library/qmakeevaluator.cpp index 68304c2030..b6b8ad1c15 100644 --- a/qmake/library/qmakeevaluator.cpp +++ b/qmake/library/qmakeevaluator.cpp @@ -1303,14 +1303,13 @@ void QMakeEvaluator::setupProject() void QMakeEvaluator::evaluateCommand(const QString &cmds, const QString &where) { if (!cmds.isEmpty()) { - if (ProFile *pro = m_parser->parsedProBlock(cmds, where, -1)) { - if (pro->isOk()) { - m_locationStack.push(m_current); - visitProBlock(pro, pro->tokPtr()); - m_current = m_locationStack.pop(); - } - pro->deref(); + ProFile *pro = m_parser->parsedProBlock(cmds, where, -1); + if (pro->isOk()) { + m_locationStack.push(m_current); + visitProBlock(pro, pro->tokPtr()); + m_current = m_locationStack.pop(); } + pro->deref(); } } @@ -1790,14 +1789,12 @@ bool QMakeEvaluator::evaluateConditional(const QString &cond, const QString &whe { bool ret = false; ProFile *pro = m_parser->parsedProBlock(cond, where, line, QMakeParser::TestGrammar); - if (pro) { - if (pro->isOk()) { - m_locationStack.push(m_current); - ret = visitProBlock(pro, pro->tokPtr()) == ReturnTrue; - m_current = m_locationStack.pop(); - } - pro->deref(); + if (pro->isOk()) { + m_locationStack.push(m_current); + ret = visitProBlock(pro, pro->tokPtr()) == ReturnTrue; + m_current = m_locationStack.pop(); } + pro->deref(); return ret; } diff --git a/qmake/library/qmakeparser.cpp b/qmake/library/qmakeparser.cpp index 3065d4dd5a..64f13d079d 100644 --- a/qmake/library/qmakeparser.cpp +++ b/qmake/library/qmakeparser.cpp @@ -209,10 +209,7 @@ ProFile *QMakeParser::parsedProBlock( const QString &contents, const QString &name, int line, SubGrammar grammar) { ProFile *pro = new ProFile(name); - if (!read(pro, contents, line, grammar)) { - delete pro; - pro = 0; - } + read(pro, contents, line, grammar); return pro; } @@ -232,7 +229,8 @@ bool QMakeParser::read(ProFile *pro, ParseFlags flags) fL1S("Cannot read %1: %2").arg(pro->fileName(), errStr)); return false; } - return read(pro, content, 1, FullGrammar); + read(pro, content, 1, FullGrammar); + return true; } void QMakeParser::putTok(ushort *&tokPtr, ushort tok) @@ -272,7 +270,7 @@ void QMakeParser::finalizeHashStr(ushort *buf, uint len) buf[-2] = (ushort)(hash >> 16); } -bool QMakeParser::read(ProFile *pro, const QString &in, int line, SubGrammar grammar) +void QMakeParser::read(ProFile *pro, const QString &in, int line, SubGrammar grammar) { m_proFile = pro; m_lineNo = line; @@ -845,7 +843,6 @@ bool QMakeParser::read(ProFile *pro, const QString &in, int line, SubGrammar gra leaveScope(tokPtr); tokBuff.resize(tokPtr - (ushort *)tokBuff.constData()); // Reserved capacity stays *pro->itemsRef() = tokBuff; - return true; #undef FLUSH_VALUE_LIST #undef FLUSH_LITERAL diff --git a/qmake/library/qmakeparser.h b/qmake/library/qmakeparser.h index f8bbe905c3..a1e6d10a70 100644 --- a/qmake/library/qmakeparser.h +++ b/qmake/library/qmakeparser.h @@ -130,7 +130,7 @@ private: }; bool read(ProFile *pro, ParseFlags flags); - bool read(ProFile *pro, const QString &content, int line, SubGrammar grammar); + void read(ProFile *pro, const QString &content, int line, SubGrammar grammar); ALWAYS_INLINE void putTok(ushort *&tokPtr, ushort tok); ALWAYS_INLINE void putBlockLen(ushort *&tokPtr, uint len); diff --git a/qmake/project.cpp b/qmake/project.cpp index 45773db784..41bdab728c 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -124,17 +124,16 @@ QStringList QMakeProject::expand(const ProKey &func, const QList<ProStringList> ProString QMakeProject::expand(const QString &expr, const QString &where, int line) { ProString ret; - if (ProFile *pro = m_parser->parsedProBlock(expr, where, line, QMakeParser::ValueGrammar)) { - if (pro->isOk()) { - m_current.pro = pro; - m_current.line = 0; - const ushort *tokPtr = pro->tokPtr(); - ProStringList result = expandVariableReferences(tokPtr, 1, true); - if (!result.isEmpty()) - ret = result.at(0); - } - pro->deref(); + ProFile *pro = m_parser->parsedProBlock(expr, where, line, QMakeParser::ValueGrammar); + if (pro->isOk()) { + m_current.pro = pro; + m_current.line = 0; + const ushort *tokPtr = pro->tokPtr(); + ProStringList result = expandVariableReferences(tokPtr, 1, true); + if (!result.isEmpty()) + ret = result.at(0); } + pro->deref(); return ret; } |