diff options
author | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2013-12-10 21:54:23 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-07 19:49:08 +0100 |
commit | 34158d0902ba6810ec4b0382425e75b07aa4e05d (patch) | |
tree | 364094c46ee9a57648e569aa5a81101247c52104 | |
parent | 5357ec65cd4857552b617596794018ce61cfe44c (diff) |
dissolve getMacroArgs() function
the replacement is less efficient, but also less obscure and more
robust.
Change-Id: Iee0538b5515c01116a4227f35d52f8166f1c730d
Reviewed-by: hjk <hjk121@nokiamail.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
-rw-r--r-- | src/linguist/lupdate/cpp.cpp | 53 |
1 files changed, 20 insertions, 33 deletions
diff --git a/src/linguist/lupdate/cpp.cpp b/src/linguist/lupdate/cpp.cpp index aa32cda43..80cb422c8 100644 --- a/src/linguist/lupdate/cpp.cpp +++ b/src/linguist/lupdate/cpp.cpp @@ -253,7 +253,6 @@ private: int getChar(); TokenType getToken(); - bool getMacroArgs(); void processComment(); @@ -465,33 +464,6 @@ int CppParser::getChar() } } -// This ignores commas, parens and comments. -// IOW, it understands only a single, simple argument. -bool CppParser::getMacroArgs() -{ - // Failing this assertion would mean losing the preallocated buffer. - Q_ASSERT(yyWord.isDetached()); - - while (isspace(yyCh)) - yyCh = getChar(); - if (yyCh != '(') - return false; - do { - yyCh = getChar(); - } while (isspace(yyCh)); - ushort *ptr = (ushort *)yyWord.unicode(); - while (yyCh != ')') { - if (yyCh == EOF) - return false; - *ptr++ = yyCh; - yyCh = getChar(); - } - yyCh = getChar(); - for (; ptr != (ushort *)yyWord.unicode() && isspace(*(ptr - 1)); --ptr) ; - yyWord.resize(ptr - (ushort *)yyWord.unicode()); - return true; -} - STRING(Q_OBJECT); STRING(class); STRING(friend); @@ -1764,12 +1736,27 @@ void CppParser::handleTrId() void CppParser::handleDeclareTrFunctions() { - if (getMacroArgs()) { - Namespace *ns = modifyNamespace(&namespaces); - ns->hasTrFunctions = true; - ns->trQualification = yyWord; - ns->trQualification.detach(); + QString name; + yyTok = getToken(); + if (yyTok != Tok_LeftParen) + return; + forever { + yyTok = getToken(); + if (yyTok != Tok_Ident) + return; + name += yyWord; + name.detach(); + yyTok = getToken(); + if (yyTok == Tok_RightParen) + break; + if (yyTok != Tok_ColonColon) + return; + name += QLatin1String("::"); } + Namespace *ns = modifyNamespace(&namespaces); + ns->hasTrFunctions = true; + ns->trQualification = name; + ns->trQualification.detach(); } void CppParser::parse(ConversionData &cd, const QStringList &includeStack, |