summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <[email protected]>2025-06-05 15:22:45 +0200
committerMarc Mutz <[email protected]>2025-06-05 17:24:59 +0000
commit5053c692ade69896655aa30a1d1fc6f29bce12f8 (patch)
tree6db5cfd69a807e793796d45e4f6573c84564249d
parent5f18b5256c9ce704107bfe41ba3e2c24e5c7a263 (diff)
util/normalize: parse at the 8-bit levelHEADmaster
Like so much Qt code overusing UTF-16, the old code converted each line into a QString, and then, to feed into normalizedSignature(), back into 8-bit, and then back into UTF-16 and then, when modifying, back to 8-bit. Just do everything in 8-bit. Yes, this means setFöö() will likely not work anymore when source code is encoded in UTF-8, but MOC can't store that, anyway, AFAIK, so we're not losing anything. If it becomes a problem, it's easy to fix in isValidIdentifier(). Change-Id: Ibf03032ed892c968db3db2f28c188455317d3377 Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Edward Welbourne <[email protected]>
-rw-r--r--util/normalize/main.cpp23
1 files changed, 11 insertions, 12 deletions
diff --git a/util/normalize/main.cpp b/util/normalize/main.cpp
index 6730606..659f5b6 100644
--- a/util/normalize/main.cpp
+++ b/util/normalize/main.cpp
@@ -17,33 +17,33 @@
static bool printFilename = true;
static bool modify = false;
-QString signature(const QString &line, int pos)
+static QByteArray signature(const QByteArray &line, int pos)
{
int start = pos;
// find first open parentheses
- while (start < line.length() && line.at(start) != QLatin1Char('('))
+ while (start < line.length() && line.at(start) != '(')
++start;
int i = ++start;
int par = 1;
// find matching closing parentheses
while (i < line.length() && par > 0) {
- if (line.at(i) == QLatin1Char('('))
+ if (line.at(i) == '(')
++par;
- else if (line.at(i) == QLatin1Char(')'))
+ else if (line.at(i) == ')')
--par;
++i;
}
if (par == 0)
return line.mid(start, i - start - 1);
- return QString();
+ return QByteArray();
}
-bool isValidIdentifierChar(const QChar c)
+static bool isValidIdentifierChar(char c)
{
- return c == QLatin1Char('_') || c.isLetterOrNumber();
+ return c == '_' || QChar::isLetterOrNumber(uchar(c));
}
-bool checkSignature(const QString &fileName, QString &line, const char *sig)
+static bool checkSignature(const QString &fileName, QByteArray &line, const char *sig)
{
static QStringList fileList;
@@ -56,7 +56,7 @@ bool checkSignature(const QString &fileName, QString &line, const char *sig)
int endIdx = idx + siglen;
if (endIdx < line.length() && isValidIdentifierChar(line.at(endIdx)))
continue;
- const QByteArray sl(signature(line, idx).toLocal8Bit());
+ const QByteArray sl = signature(line, idx);
QByteArray nsl(QMetaObject::normalizedSignature(sl.constData()));
if (sl != nsl) {
found = true;
@@ -95,10 +95,9 @@ void check(const QString &fileName)
QStringList lines;
bool found = false;
while (true) {
- QByteArray bline = file.readLine();
- if (bline.isEmpty())
+ QByteArray line = file.readLine();
+ if (line.isEmpty())
break;
- QString line = QString::fromLocal8Bit(bline);
found |= checkSignature(fileName, line, "SLOT");
found |= checkSignature(fileName, line, "SIGNAL");
if (modify)