summaryrefslogtreecommitdiff
path: root/src/linguist
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-01-12 16:15:20 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-01-16 10:30:59 +0100
commit0f092219165ecd5751ef73cb939364134a0319ee (patch)
tree70fe6742ee77e401a5c75e8fd592437fd72e5e20 /src/linguist
parentb0ae730d4e6c76a48fa573651ef9f1351d71366e (diff)
downloadqttools-0f092219165ecd5751ef73cb939364134a0319ee.tar.gz
linguist: Support Unity builds
Disambiguate static functions. Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: I699bfd86b6018e15b5882b5911e1c4720fdbe4d5 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/linguist')
-rw-r--r--src/linguist/lprodump/CMakeLists.txt3
-rw-r--r--src/linguist/lprodump/main.cpp7
-rw-r--r--src/linguist/lupdate/CMakeLists.txt3
-rw-r--r--src/linguist/shared/qrcreader.cpp2
-rw-r--r--src/linguist/shared/qrcreader.h7
-rw-r--r--src/linguist/shared/runqttool.cpp4
-rw-r--r--src/linguist/shared/ts.cpp26
-rw-r--r--src/linguist/shared/xliff.cpp24
8 files changed, 41 insertions, 35 deletions
diff --git a/src/linguist/lprodump/CMakeLists.txt b/src/linguist/lprodump/CMakeLists.txt
index bfe267eac..ad4e5fd82 100644
--- a/src/linguist/lprodump/CMakeLists.txt
+++ b/src/linguist/lprodump/CMakeLists.txt
@@ -37,6 +37,9 @@ qt_internal_add_tool(${target_name}
LIBRARIES
Qt::CorePrivate
)
+
+set_source_files_properties(../shared/qmakeparser.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
+
qt_internal_return_unless_building_tools()
# Resources:
diff --git a/src/linguist/lprodump/main.cpp b/src/linguist/lprodump/main.cpp
index 354f67daf..caa59992b 100644
--- a/src/linguist/lprodump/main.cpp
+++ b/src/linguist/lprodump/main.cpp
@@ -119,13 +119,6 @@ public:
static EvalHandler evalHandler;
-static bool isSupportedExtension(const QString &ext)
-{
- return ext == QLatin1String("qml")
- || ext == QLatin1String("js") || ext == QLatin1String("qs")
- || ext == QLatin1String("ui") || ext == QLatin1String("jui");
-}
-
static QStringList getResources(const QString &resourceFile, QMakeVfs *vfs)
{
Q_ASSERT(vfs);
diff --git a/src/linguist/lupdate/CMakeLists.txt b/src/linguist/lupdate/CMakeLists.txt
index 308b96356..b0b723904 100644
--- a/src/linguist/lupdate/CMakeLists.txt
+++ b/src/linguist/lupdate/CMakeLists.txt
@@ -53,6 +53,9 @@ qt_internal_add_tool(${target_name}
Qt::CorePrivate
Qt::Tools
)
+
+set_source_files_properties(python.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
+
qt_internal_return_unless_building_tools()
#### Keys ignored in scope 1:.:.:lupdate.pro:<TRUE>:
diff --git a/src/linguist/shared/qrcreader.cpp b/src/linguist/shared/qrcreader.cpp
index 66f14bea6..2f450106f 100644
--- a/src/linguist/shared/qrcreader.cpp
+++ b/src/linguist/shared/qrcreader.cpp
@@ -8,7 +8,7 @@
#include <QtCore/qfileinfo.h>
#include <QtCore/qxmlstream.h>
-static bool isSupportedExtension(const QString &ext)
+bool isSupportedExtension(const QString &ext)
{
return ext == QLatin1String("qml")
|| ext == QLatin1String("js") || ext == QLatin1String("qs")
diff --git a/src/linguist/shared/qrcreader.h b/src/linguist/shared/qrcreader.h
index f0b609b67..6a0886c9c 100644
--- a/src/linguist/shared/qrcreader.h
+++ b/src/linguist/shared/qrcreader.h
@@ -1,6 +1,9 @@
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+#ifndef QRCREADER_H
+#define QRCREADER_H
+
#include <QtCore/qstring.h>
#include <QtCore/qstringlist.h>
@@ -15,3 +18,7 @@ public:
};
ReadQrcResult readQrcFile(const QString &resourceFile, const QString &content);
+
+bool isSupportedExtension(const QString &ext);
+
+#endif // QRCREADER_H
diff --git a/src/linguist/shared/runqttool.cpp b/src/linguist/shared/runqttool.cpp
index 1257ff899..13d8bb07c 100644
--- a/src/linguist/shared/runqttool.cpp
+++ b/src/linguist/shared/runqttool.cpp
@@ -26,7 +26,7 @@ static QString qtToolFilePath(const QString &toolName, QLibraryInfo::LibraryPath
return QDir::cleanPath(filePath);
}
-static void printErr(const QString &out)
+static void rtPrintErr(const QString &out)
{
std::cerr << qUtf8Printable(out);
}
@@ -86,7 +86,7 @@ std::unique_ptr<QTemporaryFile> createProjectDescription(QStringList args)
{
std::unique_ptr<QTemporaryFile> file(new QTemporaryFile(QStringLiteral("XXXXXX.json")));
if (!file->open()) {
- printErr(FMT::tr("Cannot create temporary file: %1\n").arg(file->errorString()));
+ rtPrintErr(FMT::tr("Cannot create temporary file: %1\n").arg(file->errorString()));
exit(1);
}
file->close();
diff --git a/src/linguist/shared/ts.cpp b/src/linguist/shared/ts.cpp
index 229b5cb98..5d26a6867 100644
--- a/src/linguist/shared/ts.cpp
+++ b/src/linguist/shared/ts.cpp
@@ -404,13 +404,13 @@ bool TSReader::read(Translator &translator)
return true;
}
-static QString numericEntity(int ch)
+static QString tsNumericEntity(int ch)
{
return QString(ch <= 0x20 ? QLatin1String("<byte value=\"x%1\"/>")
: QLatin1String("&#x%1;")) .arg(ch, 0, 16);
}
-static QString protect(const QString &str)
+static QString tsProtect(const QString &str)
{
QString result;
result.reserve(str.size() * 12 / 10);
@@ -435,7 +435,7 @@ static QString protect(const QString &str)
break;
default:
if ((c < 0x20 || (ch > QChar(0x7f) && ch.isSpace())) && c != '\n' && c != '\t')
- result += numericEntity(c);
+ result += tsNumericEntity(c);
else // this also covers surrogates
result += QChar(c);
}
@@ -450,7 +450,7 @@ static void writeExtras(QTextStream &t, const char *indent,
for (auto it = extras.cbegin(), end = extras.cend(); it != end; ++it) {
if (!drops.match(it.key()).hasMatch()) {
outs << (QStringLiteral("<extra-") + it.key() + QLatin1Char('>')
- + protect(it.value())
+ + tsProtect(it.value())
+ QStringLiteral("</extra-") + it.key() + QLatin1Char('>'));
}
}
@@ -467,7 +467,7 @@ static void writeVariants(QTextStream &t, const char *indent, const QString &inp
int start = 0;
forever {
t << "\n " << indent << "<lengthvariant>"
- << protect(input.mid(start, offset - start))
+ << tsProtect(input.mid(start, offset - start))
<< "</lengthvariant>";
if (offset == input.size())
break;
@@ -478,7 +478,7 @@ static void writeVariants(QTextStream &t, const char *indent, const QString &inp
}
t << "\n" << indent;
} else {
- t << ">" << protect(input);
+ t << ">" << tsProtect(input);
}
}
@@ -534,7 +534,7 @@ bool saveTS(const Translator &translator, QIODevice &dev, ConversionData &cd)
for (const QString &context : std::as_const(contextOrder)) {
t << "<context>\n"
" <name>"
- << protect(context)
+ << tsProtect(context)
<< "</name>\n";
for (const TranslatorMessage &msg : std::as_const(messageOrder[context])) {
//msg.dump();
@@ -584,27 +584,27 @@ bool saveTS(const Translator &translator, QIODevice &dev, ConversionData &cd)
}
t << " <source>"
- << protect(msg.sourceText())
+ << tsProtect(msg.sourceText())
<< "</source>\n";
if (!msg.oldSourceText().isEmpty())
- t << " <oldsource>" << protect(msg.oldSourceText()) << "</oldsource>\n";
+ t << " <oldsource>" << tsProtect(msg.oldSourceText()) << "</oldsource>\n";
if (!msg.comment().isEmpty()) {
t << " <comment>"
- << protect(msg.comment())
+ << tsProtect(msg.comment())
<< "</comment>\n";
}
if (!msg.oldComment().isEmpty())
- t << " <oldcomment>" << protect(msg.oldComment()) << "</oldcomment>\n";
+ t << " <oldcomment>" << tsProtect(msg.oldComment()) << "</oldcomment>\n";
if (!msg.extraComment().isEmpty())
- t << " <extracomment>" << protect(msg.extraComment())
+ t << " <extracomment>" << tsProtect(msg.extraComment())
<< "</extracomment>\n";
if (!msg.translatorComment().isEmpty())
- t << " <translatorcomment>" << protect(msg.translatorComment())
+ t << " <translatorcomment>" << tsProtect(msg.translatorComment())
<< "</translatorcomment>\n";
t << " <translation";
diff --git a/src/linguist/shared/xliff.cpp b/src/linguist/shared/xliff.cpp
index a0e728d7a..f54f7758a 100644
--- a/src/linguist/shared/xliff.cpp
+++ b/src/linguist/shared/xliff.cpp
@@ -101,7 +101,7 @@ static char charFromEscape(char escape)
return escape;
}
-static QString numericEntity(int ch, bool makePhs)
+static QString xlNumericEntity(int ch, bool makePhs)
{
// ### This needs to be reviewed, to reflect the updated XLIFF-PO spec.
if (!makePhs || ch < 7 || ch > 0x0d)
@@ -116,7 +116,7 @@ static QString numericEntity(int ch, bool makePhs)
.arg(++id) .arg(name) .arg(escapechar);
}
-static QString protect(const QString &str, bool makePhs = true)
+static QString xlProtect(const QString &str, bool makePhs = true)
{
QString result;
int len = str.size();
@@ -140,7 +140,7 @@ static QString protect(const QString &str, bool makePhs = true)
break;
default:
if (c < 0x20 && c != '\r' && c != '\n' && c != '\t')
- result += numericEntity(c, makePhs);
+ result += xlNumericEntity(c, makePhs);
else // this also covers surrogates
result += QChar(c);
}
@@ -156,7 +156,7 @@ static void writeExtras(QTextStream &ts, int indent,
if (!drops.match(it.key()).hasMatch()) {
writeIndent(ts, indent);
ts << "<trolltech:" << it.key() << '>'
- << protect(it.value())
+ << xlProtect(it.value())
<< "</trolltech:" << it.key() << ">\n";
}
}
@@ -185,25 +185,25 @@ static void writeComment(QTextStream &ts, const TranslatorMessage &msg, const QR
if (!msg.comment().isEmpty()) {
writeIndent(ts, indent);
ts << "<context-group><context context-type=\"" << contextMsgctxt << "\">"
- << protect(msg.comment(), false)
+ << xlProtect(msg.comment(), false)
<< "</context></context-group>\n";
}
if (!msg.oldComment().isEmpty()) {
writeIndent(ts, indent);
ts << "<context-group><context context-type=\"" << contextOldMsgctxt << "\">"
- << protect(msg.oldComment(), false)
+ << xlProtect(msg.oldComment(), false)
<< "</context></context-group>\n";
}
writeExtras(ts, indent, msg.extras(), drops);
if (!msg.extraComment().isEmpty()) {
writeIndent(ts, indent);
ts << "<note annotates=\"source\" from=\"developer\">"
- << protect(msg.extraComment()) << "</note>\n";
+ << xlProtect(msg.extraComment()) << "</note>\n";
}
if (!msg.translatorComment().isEmpty()) {
writeIndent(ts, indent);
ts << "<note from=\"translator\">"
- << protect(msg.translatorComment()) << "</note>\n";
+ << xlProtect(msg.translatorComment()) << "</note>\n";
}
}
@@ -264,7 +264,7 @@ static void writeTransUnits(QTextStream &ts, const TranslatorMessage &msg, const
source = *srcit;
++srcit;
} // else just repeat last element
- ts << "<source xml:space=\"preserve\">" << protect(source) << "</source>\n";
+ ts << "<source xml:space=\"preserve\">" << xlProtect(source) << "</source>\n";
bool puttrans = false;
QString translation;
@@ -281,7 +281,7 @@ static void writeTransUnits(QTextStream &ts, const TranslatorMessage &msg, const
ts << "<alt-trans>\n";
++indent;
writeIndent(ts, indent);
- ts << "<source xml:space=\"preserve\"" << pluralStr << '>' << protect(*oldsrcit) << "</source>\n";
+ ts << "<source xml:space=\"preserve\"" << pluralStr << '>' << xlProtect(*oldsrcit) << "</source>\n";
if (!puttrans) {
writeIndent(ts, indent);
ts << "<target restype=\"" << restypeDummy << "\"/>\n";
@@ -290,7 +290,7 @@ static void writeTransUnits(QTextStream &ts, const TranslatorMessage &msg, const
if (puttrans) {
writeIndent(ts, indent);
- ts << "<target xml:space=\"preserve\"" << state << ">" << protect(translation) << "</target>\n";
+ ts << "<target xml:space=\"preserve\"" << state << ">" << xlProtect(translation) << "</target>\n";
}
if (oldsrcit != oldsrcend) {
@@ -780,7 +780,7 @@ bool saveXLIFF(const Translator &translator, QIODevice &dev, ConversionData &cd)
if (!ctx.isEmpty()) {
writeIndent(ts, indent);
ts << "<group restype=\"" << restypeContext << "\""
- << " resname=\"" << protect(ctx) << "\">\n";
+ << " resname=\"" << xlProtect(ctx) << "\">\n";
++indent;
}