expect meta data only at the beginning of statements.
this required syntax fixes in some unrelated autotests.
Task-number: QTBUG-11866
Change-Id: Ic0c0c150ac8648df6953a510b8eb0c199c8d3ae2
Reviewed-by: hjk <hjk121@nokiamail.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
// Parser state
uint yyTok;
+ bool metaExpected;
QString context;
QString text;
QString comment;
yyBraceDepth = yyMinBraceDepth;
yyMinBraceDepth = 0;
inDefine = false;
+ metaExpected = true;
yyCh = getChar();
return Tok_Cancel; // Break out of any multi-token constructs
}
#endif
int line;
bool yyTokColonSeen = false; // Start of c'tor's initializer list
+ metaExpected = true;
yyWord.reserve(yyInStr.size()); // Rather insane. That's because we do no length checking.
yyInPtr = (const ushort *)yyInStr.unicode();
prospectiveContext.clear();
pendingContext.clear();
+ metaExpected = true;
yyTok = getToken();
}
break;
functionContextUnresolved.clear();
prospectiveContext.clear();
pendingContext.clear();
+ metaExpected = true;
yyTok = getToken();
} else if (yyTok == Tok_Equals) {
// e.g. namespace Is = OuterSpace::InnerSpace;
} else if (yyTok == Tok_LeftBrace) {
// Anonymous namespace
namespaceDepths.push(namespaces.count());
+ metaExpected = true;
yyTok = getToken();
}
break;
extracomment.clear();
msgid.clear();
extra.clear();
+ metaExpected = false;
yyTok = getToken();
break;
case Tok_translateUtf8:
extracomment.clear();
msgid.clear();
extra.clear();
+ metaExpected = false;
yyTok = getToken();
break;
case Tok_trid:
extracomment.clear();
msgid.clear();
extra.clear();
+ metaExpected = false;
break;
case Tok_Q_DECLARE_TR_FUNCTIONS:
if (getMacroArgs()) {
if (yyTok == Tok_Ident && !yyParenDepth)
prospectiveContext.clear();
}
+ metaExpected = false;
break;
case Tok_Arrow:
yyTok = getToken();
msgid.clear();
extra.clear();
}
+ metaExpected = true;
yyTok = getToken();
break;
case Tok_Access:
do {
yyTok = getToken();
} while (yyTok == Tok_Access); // Multiple specifiers are possible, e.g. "public slots"
+ metaExpected = true;
if (yyTok == Tok_Colon)
goto case_default;
break;
if (yyTok == Tok_Colon)
yyTokColonSeen = true;
}
+ metaExpected = true;
yyTok = getToken();
break;
case Tok_LeftBrace:
}
yyTokColonSeen = false;
// fallthrough
+ case Tok_Comma:
case Tok_LeftParen:
+ metaExpected = true;
+ yyTok = getToken();
+ break;
case Tok_RightParen:
+ metaExpected = false;
yyTok = getToken();
break;
default:
void CppParser::processComment()
{
- if (!tor)
+ if (!tor || !metaExpected)
return;
const QChar *ptr = yyWord.unicode();
**
****************************************************************************/
-QT_TRANSLATE_NOOP("context", "just a message")
+QT_TRANSLATE_NOOP("context", "just a message");
//: This is one comment
-QT_TRANSLATE_NOOP("context", "just a message")
+QT_TRANSLATE_NOOP("context", "just a message");
//: This is a comment, too.
-QT_TRANSLATE_NOOP("context", "just a message")
+QT_TRANSLATE_NOOP("context", "just a message");
//: extra comment for NOOP
//: which spans multiple lines
-QT_TRANSLATE_NOOP("scope", "string") // 4.4 says the line of this is at the next statement
+QT_TRANSLATE_NOOP("scope", "string") /*: complain & ignore */; // 4.4 says the line of this is at the next statement
//: extra comment for NOOP3
-QT_TRANSLATE_NOOP3_UTF8("scope", "string", "comment") // 4.4 doesn't see this
+QT_TRANSLATE_NOOP3_UTF8("scope", "string", "comment"); // 4.4 doesn't see this
QT_TRANSLATE_NOOP("scope", "string " // this is an interleaved comment
- "continuation on next line")
+ "continuation on next line");
class TestingTake17 : QObject {
//: again an extra comment, this time for id-based NOOP
//% "This is supposed\tto be quoted \" newline\n"
//% "backslashed \\ stuff."
-QT_TRID_NOOP("this_a_id")
+QT_TRID_NOOP("this_a_id");
//~ some thing
//% "This needs to be here. Really."
{
tr("and does that?");
}
+
+
+
+// QTBUG-11866: magic comment parsing is too greedy
+Class42::hello(int something /*= 17 */, QString str = Class42::tr("eyo"))
+{
+}
<source>and does that?</source>
<translation type="unfinished"></translation>
</message>
+ <message>
+ <location filename="main.cpp" line="394"/>
+ <source>eyo</source>
+ <translation type="unfinished"></translation>
+ </message>
</context>
<context>
<name>Dialog2</name>