From: Oswald Buddenhagen Date: Wed, 31 Jul 2013 14:22:10 +0000 (+0200) Subject: cancel complex constructs at end of #define X-Git-Tag: accepted/tizen/20131212.181521~89^2~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6ada735ac09c4e07adc9f9b40ece76c59713390e;p=platform%2Fupstream%2Fqttools.git cancel complex constructs at end of #define it's possible that we encounter the end of a #define statement while in the middle of a complex construct (which is part of a macro, obviously). we should discard those, as otherwise Weird Things may happen. Change-Id: Ie9608ad0215e105ab5e5bac110e4118029fa6c15 Reviewed-by: hjk Reviewed-by: Oswald Buddenhagen --- diff --git a/src/linguist/lupdate/cpp.cpp b/src/linguist/lupdate/cpp.cpp index 30c12f4..096be64 100644 --- a/src/linguist/lupdate/cpp.cpp +++ b/src/linguist/lupdate/cpp.cpp @@ -293,7 +293,7 @@ private: enum { Tok_Eof, Tok_class, Tok_friend, Tok_namespace, Tok_using, Tok_return, Tok_tr, Tok_trUtf8, Tok_translate, Tok_translateUtf8, Tok_trid, - Tok_Q_OBJECT, Tok_Q_DECLARE_TR_FUNCTIONS, Tok_Access, + Tok_Q_OBJECT, Tok_Q_DECLARE_TR_FUNCTIONS, Tok_Access, Tok_Cancel, Tok_Ident, Tok_Comment, Tok_String, Tok_Arrow, Tok_Colon, Tok_ColonColon, Tok_Equals, Tok_LeftBracket, Tok_RightBracket, Tok_LeftBrace, Tok_RightBrace, Tok_LeftParen, Tok_RightParen, Tok_Comma, Tok_Semicolon, @@ -818,6 +818,8 @@ uint CppParser::getToken() yyBraceDepth = yyMinBraceDepth; yyMinBraceDepth = 0; inDefine = false; + yyCh = getChar(); + return Tok_Cancel; // Break out of any multi-token constructs } yyCh = getChar(); break; @@ -1529,7 +1531,7 @@ bool CppParser::matchExpression() continue; } else if (yyTok == Tok_Arrow) { yyTok = getToken(); - } else if (parenlevel == 0) { + } else if (parenlevel == 0 || yyTok == Tok_Cancel) { return false; } } @@ -1713,6 +1715,8 @@ void CppParser::parseInternal(ConversionData &cd, const QStringList &includeStac yyTok = getToken(); if (yyTok == Tok_Eof) goto goteof; + if (yyTok == Tok_Cancel) + goto case_default; } while (yyTok != Tok_LeftBrace); } else { if (yyTok != Tok_LeftBrace) { diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp index f2d6532..04e3b14 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp @@ -136,7 +136,7 @@ class ForwardDecl; struct FT_Service_ ## name ## Rec_ -/* removing this comment will break this test */ + void Dialog2::func3() {