diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/text/qregularexpression.cpp | 11 | ||||
-rw-r--r-- | src/corelib/text/qstring.cpp | 20 |
2 files changed, 18 insertions, 13 deletions
diff --git a/src/corelib/text/qregularexpression.cpp b/src/corelib/text/qregularexpression.cpp index a8ff90b5072..061f2bfa0e3 100644 --- a/src/corelib/text/qregularexpression.cpp +++ b/src/corelib/text/qregularexpression.cpp @@ -800,13 +800,14 @@ struct QRegularExpressionMatchIteratorPrivate : QSharedData (pass it to qUtf16Printable, etc.), so we need to check for that. */ Q_DECL_COLD_FUNCTION -void qtWarnAboutInvalidRegularExpression(const QString &pattern, const char *where) +void qtWarnAboutInvalidRegularExpression(const QString &pattern, const char *cls, const char *method) { if (pattern.isValidUtf16()) { - qWarning("%s(): called on an invalid QRegularExpression object " - "(pattern is '%ls')", where, qUtf16Printable(pattern)); + qWarning("%s::%s(): called on an invalid QRegularExpression object " + "(pattern is '%ls')", cls, method, qUtf16Printable(pattern)); } else { - qWarning("%s(): called on an invalid QRegularExpression object", where); + qWarning("%s::%s(): called on an invalid QRegularExpression object", + cls, method); } } @@ -1118,7 +1119,7 @@ void QRegularExpressionPrivate::doMatch(QRegularExpressionMatchPrivate *priv, return; if (Q_UNLIKELY(!compiledPattern)) { - qtWarnAboutInvalidRegularExpression(pattern, "QRegularExpressionPrivate::doMatch"); + qtWarnAboutInvalidRegularExpression(pattern, "QRegularExpressionPrivate", "doMatch"); return; } diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index a72abadcd0f..5d82ddf1e4a 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -1637,7 +1637,11 @@ static int qArgDigitValue(QChar ch) noexcept #if QT_CONFIG(regularexpression) Q_DECL_COLD_FUNCTION -void qtWarnAboutInvalidRegularExpression(const QString &pattern, const char *where); +static void qtWarnAboutInvalidRegularExpression(const QRegularExpression &re, const char *cls, const char *method) +{ + extern void qtWarnAboutInvalidRegularExpression(const QString &pattern, const char *cls, const char *method); + qtWarnAboutInvalidRegularExpression(re.pattern(), cls, method); +} #endif /*! @@ -4721,7 +4725,7 @@ Q_DECLARE_TYPEINFO(QStringCapture, Q_PRIMITIVE_TYPE); QString &QString::replace(const QRegularExpression &re, const QString &after) { if (!re.isValid()) { - qtWarnAboutInvalidRegularExpression(re.pattern(), "QString::replace"); + qtWarnAboutInvalidRegularExpression(re, "QString", "replace"); return *this; } @@ -5241,7 +5245,7 @@ static QString extractSections(QSpan<qt_section_chunk> sections, qsizetype start QString QString::section(const QRegularExpression &re, qsizetype start, qsizetype end, SectionFlags flags) const { if (!re.isValid()) { - qtWarnAboutInvalidRegularExpression(re.pattern(), "QString::section"); + qtWarnAboutInvalidRegularExpression(re, "QString", "section"); return QString(); } @@ -8341,7 +8345,7 @@ static ResultList splitString(const String &source, const QRegularExpression &re { ResultList list; if (!re.isValid()) { - qtWarnAboutInvalidRegularExpression(re.pattern(), "QString::split"); + qtWarnAboutInvalidRegularExpression(re, "QString", "split"); return list; } @@ -9971,7 +9975,7 @@ qsizetype QtPrivate::lastIndexOf(QLatin1StringView haystack, qsizetype from, QLa qsizetype QtPrivate::indexOf(QStringView viewHaystack, const QString *stringHaystack, const QRegularExpression &re, qsizetype from, QRegularExpressionMatch *rmatch) { if (!re.isValid()) { - qtWarnAboutInvalidRegularExpression(re.pattern(), "QString(View)::indexOf"); + qtWarnAboutInvalidRegularExpression(re, "QString(View)", "indexOf"); return -1; } @@ -9996,7 +10000,7 @@ qsizetype QtPrivate::indexOf(QStringView haystack, const QRegularExpression &re, qsizetype QtPrivate::lastIndexOf(QStringView viewHaystack, const QString *stringHaystack, const QRegularExpression &re, qsizetype from, QRegularExpressionMatch *rmatch) { if (!re.isValid()) { - qtWarnAboutInvalidRegularExpression(re.pattern(), "QString(View)::lastIndexOf"); + qtWarnAboutInvalidRegularExpression(re, "QString(View)", "lastIndexOf"); return -1; } @@ -10028,7 +10032,7 @@ qsizetype QtPrivate::lastIndexOf(QStringView haystack, const QRegularExpression bool QtPrivate::contains(QStringView viewHaystack, const QString *stringHaystack, const QRegularExpression &re, QRegularExpressionMatch *rmatch) { if (!re.isValid()) { - qtWarnAboutInvalidRegularExpression(re.pattern(), "QString(View)::contains"); + qtWarnAboutInvalidRegularExpression(re, "QString(View)", "contains"); return false; } QRegularExpressionMatch m = stringHaystack @@ -10048,7 +10052,7 @@ bool QtPrivate::contains(QStringView haystack, const QRegularExpression &re, QRe qsizetype QtPrivate::count(QStringView haystack, const QRegularExpression &re) { if (!re.isValid()) { - qtWarnAboutInvalidRegularExpression(re.pattern(), "QString(View)::count"); + qtWarnAboutInvalidRegularExpression(re, "QString(View)", "count"); return 0; } qsizetype count = 0; |