diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2019-01-30 17:10:31 +0100 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2019-01-31 14:11:17 +0000 |
commit | 21dab1c69e16fd8dcfb9564211b31885d628d595 (patch) | |
tree | 60f280e45574934a9329f8fdfa32f78373bf1a26 | |
parent | bb13c8f9ce616e76ef9ec604bb8f26c7a9c00e8d (diff) |
normalize: Respect keyword bounds for SIGNAL/SLOT
This tool tried to normalize signatures for things like
Q_PRIVATE_SLOT and SIGNAL_INDEX. Check for valid keyword characters
before and after the search string.
Fixes: QTBUG-38172
Change-Id: I9b7e31d5b283da23ecbbe87e9e670a62e4f53ae7
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
-rw-r--r-- | util/normalize/main.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/util/normalize/main.cpp b/util/normalize/main.cpp index aa5edd6..b4bfd81 100644 --- a/util/normalize/main.cpp +++ b/util/normalize/main.cpp @@ -74,13 +74,24 @@ QString signature(const QString &line, int pos) return QString(); } +bool isValidIdentifierChar(const QChar c) +{ + return c == QLatin1Char('_') || c.isLetterOrNumber(); +} + bool checkSignature(const QString &fileName, QString &line, const char *sig) { static QStringList fileList; + const int siglen = strlen(sig); int idx = -1; bool found = false; while ((idx = line.indexOf(sig, ++idx)) != -1) { + if (idx > 0 && isValidIdentifierChar(line.at(idx - 1))) + continue; + int endIdx = idx + siglen; + if (endIdx < line.length() && isValidIdentifierChar(line.at(endIdx))) + continue; const QByteArray sl(signature(line, idx).toLocal8Bit()); QByteArray nsl(QMetaObject::normalizedSignature(sl.constData())); if (sl != nsl) { |