From 21dab1c69e16fd8dcfb9564211b31885d628d595 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 30 Jan 2019 17:10:31 +0100 Subject: 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 --- util/normalize/main.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) 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) { -- cgit v1.2.3