summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-02-06 13:01:14 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-02-13 11:52:45 +0000
commitc810853fe0ad6bb9baa2f88cca964c341a75c4c9 (patch)
treefc5f64b422493a6c2d26fb0515ee04360e54957d
parent22c5bf53be8b7541d2959360e2d5dd26b8bf4fda (diff)
lupdate: Disambiguate string constants
Complements 0f092219165ecd5751ef73cb939364134a0319ee. Task-number: QTBUG-109394 Change-Id: I098f2d42bbc367cee89284fb6fb2d2c7cfc5c54d Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 4d6f211f640a8278d287879ffb70a62303452ab7) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/linguist/lupdate/cpp.cpp6
-rw-r--r--src/linguist/lupdate/python.cpp6
-rw-r--r--src/linguist/lupdate/qdeclarative.cpp8
3 files changed, 11 insertions, 9 deletions
diff --git a/src/linguist/lupdate/cpp.cpp b/src/linguist/lupdate/cpp.cpp
index f5b7a7d85..d86481fdc 100644
--- a/src/linguist/lupdate/cpp.cpp
+++ b/src/linguist/lupdate/cpp.cpp
@@ -16,7 +16,7 @@ QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
-static const QString MagicComment = u"TRANSLATOR"_s;
+static const QString CppMagicComment = u"TRANSLATOR"_s;
//#define DIAGNOSE_RETRANSLATABILITY // FIXME: should make a runtime option of this
@@ -2151,8 +2151,8 @@ void CppParser::processComment()
ushort c;
while ((c = uc[idx]) == ' ' || c == '\t' || c == '\n')
++idx;
- if (!memcmp(uc + idx, MagicComment.unicode(), MagicComment.size() * 2)) {
- idx += MagicComment.size();
+ if (!memcmp(uc + idx, CppMagicComment.unicode(), CppMagicComment.size() * 2)) {
+ idx += CppMagicComment.size();
comment = QString::fromRawData(yyWord.unicode() + idx,
yyWord.size() - idx).simplified();
int k = comment.indexOf(QLatin1Char(' '));
diff --git a/src/linguist/lupdate/python.cpp b/src/linguist/lupdate/python.cpp
index 560984e54..69e259920 100644
--- a/src/linguist/lupdate/python.cpp
+++ b/src/linguist/lupdate/python.cpp
@@ -17,7 +17,7 @@
QT_BEGIN_NAMESPACE
-static const char MagicComment[] = "TRANSLATOR ";
+static const char PythonMagicComment[] = "TRANSLATOR ";
/*
The first part of this source file is the Python tokenizer. We skip
@@ -648,8 +648,8 @@ static void parse(Translator &tor, ConversionData &cd,
case Tok_Comment:
comment = yyComment;
comment = comment.simplified();
- if (comment.left(sizeof(MagicComment) - 1) == MagicComment) {
- comment.remove(0, sizeof(MagicComment) - 1);
+ if (comment.left(sizeof(PythonMagicComment) - 1) == PythonMagicComment) {
+ comment.remove(0, sizeof(PythonMagicComment) - 1);
int k = comment.indexOf(' ');
if (k == -1) {
context = comment;
diff --git a/src/linguist/lupdate/qdeclarative.cpp b/src/linguist/lupdate/qdeclarative.cpp
index a99f7dff6..1aabc6eca 100644
--- a/src/linguist/lupdate/qdeclarative.cpp
+++ b/src/linguist/lupdate/qdeclarative.cpp
@@ -30,7 +30,9 @@ QT_BEGIN_NAMESPACE
using namespace QQmlJS;
-static QString MagicComment(QLatin1String("TRANSLATOR"));
+using namespace Qt::StringLiterals;
+
+static QString QmlMagicComment = u"TRANSLATOR"_s;
class FindTrCalls: protected AST::Visitor
{
@@ -369,8 +371,8 @@ void FindTrCalls::processComment(const SourceLocation &loc)
ushort c;
while ((c = chars[idx].unicode()) == ' ' || c == '\t' || c == '\r' || c == '\n')
++idx;
- if (!memcmp(chars + idx, MagicComment.unicode(), MagicComment.size() * 2)) {
- idx += MagicComment.size();
+ if (!memcmp(chars + idx, QmlMagicComment.unicode(), QmlMagicComment.size() * 2)) {
+ idx += QmlMagicComment.size();
QString comment = QString(chars + idx, length - idx).simplified();
int k = comment.indexOf(QLatin1Char(' '));
if (k == -1) {