summaryrefslogtreecommitdiff
path: root/src/linguist
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2023-03-30 11:48:59 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2023-04-01 09:34:50 +0200
commit089dbec0f808a6f3e2fb1232016779a60d1beef2 (patch)
treebd861cbd713808e66466fc0f4c09f9e468272f08 /src/linguist
parentd5007c7a556a94df6ea76a368804dac729aab83a (diff)
downloadqttools-089dbec0f808a6f3e2fb1232016779a60d1beef2.tar.gz
lupdate: Simplify C++ raw string literal detection
Use the isStringLiteralPrefix function that was introduced in an earlier commit. Change-Id: I0095ca45e232639317c6fe6fcfd2ee57fe8b1caa Reviewed-by: Kai Köhne <kai.koehne@qt.io>
Diffstat (limited to 'src/linguist')
-rw-r--r--src/linguist/lupdate/cpp.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/linguist/lupdate/cpp.cpp b/src/linguist/lupdate/cpp.cpp
index bf1d358b6..51a144ccd 100644
--- a/src/linguist/lupdate/cpp.cpp
+++ b/src/linguist/lupdate/cpp.cpp
@@ -343,6 +343,15 @@ static bool isStringLiteralPrefix(const QStringView s)
|| s == u"u8"_s;
}
+static bool isRawStringLiteralPrefix(QStringView s)
+{
+ if (s.endsWith(u'R')) {
+ s.chop(1);
+ return s.isEmpty() || isStringLiteralPrefix(s);
+ }
+ return false;
+}
+
static const QString strQ_OBJECT = u"Q_OBJECT"_s;
static const QString strclass = u"class"_s;
static const QString strenum = u"enum"_s;
@@ -643,10 +652,7 @@ CppParser::TokenType CppParser::getToken()
}
// a C++11 raw string literal?
- if (yyCh == '"' && (
- yyWord == QLatin1String("R") || yyWord == QLatin1String("LR") || yyWord == QLatin1String("u8R") ||
- yyWord == QLatin1String("uR") || yyWord == QLatin1String("UR")
- )) {
+ if (yyCh == '"' && isRawStringLiteralPrefix(yyWord)) {
ptr = reinterpret_cast<ushort *>(const_cast<QChar *>(yyWord.unicode()));
//get delimiter
QString delimiter;