From d9b009bfed86ac273da4fc589daa34d852437254 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 28 Oct 2009 17:46:14 +0100 Subject: make magic comment parsing stricter there must be a space after the //: and similar comments, otherwise harmless comments of the sort of //====== foo here ===== will be parsed as message ids, etc. --- tools/linguist/lupdate/cpp.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp index 7a616e3..6374912 100644 --- a/tools/linguist/lupdate/cpp.cpp +++ b/tools/linguist/lupdate/cpp.cpp @@ -1899,25 +1899,25 @@ void CppParser::parseInternal(ConversionData &cd, QSet &inclusions) case Tok_Comment: if (!tor) goto case_default; - if (yyWord.startsWith(QLatin1Char(':'))) { - yyWord.remove(0, 1); + if (yyWord.at(0) == QLatin1Char(':') && yyWord.at(1).isSpace()) { + yyWord.remove(0, 2); extracomment += yyWord; extracomment.detach(); - } else if (yyWord.startsWith(QLatin1Char('='))) { - yyWord.remove(0, 1); + } else if (yyWord.at(0) == QLatin1Char('=') && yyWord.at(1).isSpace()) { + yyWord.remove(0, 2); msgid = yyWord.simplified(); msgid.detach(); - } else if (yyWord.startsWith(QLatin1Char('~'))) { - yyWord.remove(0, 1); + } else if (yyWord.at(0) == QLatin1Char('~') && yyWord.at(1).isSpace()) { + yyWord.remove(0, 2); text = yyWord.trimmed(); int k = text.indexOf(QLatin1Char(' ')); if (k > -1) extra.insert(text.left(k), text.mid(k + 1).trimmed()); text.clear(); - } else if (yyWord.startsWith(QLatin1Char('%'))) { - sourcetext.reserve(sourcetext.length() + yyWord.length()); + } else if (yyWord.at(0) == QLatin1Char('%') && yyWord.at(1).isSpace()) { + sourcetext.reserve(sourcetext.length() + yyWord.length() - 2); ushort *ptr = (ushort *)sourcetext.data() + sourcetext.length(); - int p = 1, c; + int p = 2, c; forever { if (p >= yyWord.length()) break; -- cgit v0.12