diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-02-06 13:01:14 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-02-13 12:23:56 +0100 |
commit | 4d6f211f640a8278d287879ffb70a62303452ab7 (patch) | |
tree | e2d53ac3de290c0cc954daea7e25f3aa121aba39 /src/linguist/lupdate | |
parent | 00cc7b2e4a39eea81abf46b485a98c2cfc79630c (diff) | |
download | qttools-4d6f211f640a8278d287879ffb70a62303452ab7.tar.gz |
lupdate: Disambiguate string constants
Complements 0f092219165ecd5751ef73cb939364134a0319ee.
Pick-to: 6.5
Task-number: QTBUG-109394
Change-Id: I098f2d42bbc367cee89284fb6fb2d2c7cfc5c54d
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/linguist/lupdate')
-rw-r--r-- | src/linguist/lupdate/cpp.cpp | 6 | ||||
-rw-r--r-- | src/linguist/lupdate/python.cpp | 6 | ||||
-rw-r--r-- | src/linguist/lupdate/qdeclarative.cpp | 8 |
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) { |