Use qsizetype in QRegularExpression

PCRE2 already uses size_t which we can now make full use of.

Change-Id: Icb5efd5c6ef27f2e31a9780bf62f5671ddc603cd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Marcel Krems 2020-08-25 01:33:00 +02:00
parent 4d5a048d96
commit 257285553f
3 changed files with 119 additions and 119 deletions

View File

@ -738,7 +738,7 @@ struct QRegularExpressionPrivate : QSharedData
};
void doMatch(QRegularExpressionMatchPrivate *priv,
int offset,
qsizetype offset,
CheckSubjectStringOption checkSubjectStringOption = CheckSubjectString,
const QRegularExpressionMatchPrivate *previous = nullptr) const;
@ -758,7 +758,7 @@ struct QRegularExpressionPrivate : QSharedData
// it is set to nullptr
pcre2_code_16 *compiledPattern;
int errorCode;
int errorOffset;
qsizetype errorOffset;
int capturingCount;
bool usingCrLfNewlines;
bool isDirty;
@ -787,7 +787,7 @@ struct QRegularExpressionMatchPrivate : QSharedData
// the capturedOffsets vector contains pairs of (start, end) positions
// for each captured substring
QList<int> capturedOffsets;
QList<qsizetype> capturedOffsets;
int capturedCount = 0;
@ -904,7 +904,7 @@ void QRegularExpressionPrivate::compilePattern()
nullptr);
if (!compiledPattern) {
errorOffset = static_cast<int>(patternErrorOffset);
errorOffset = qsizetype(patternErrorOffset);
return;
} else {
// ignore whatever PCRE2 wrote into errorCode -- leave it to 0 to mean "no error"
@ -1070,8 +1070,8 @@ int QRegularExpressionPrivate::captureIndexForName(QStringView name) const
and re-run pcre2_match_16.
*/
static int safe_pcre2_match_16(const pcre2_code_16 *code,
PCRE2_SPTR16 subject, int length,
int startOffset, int options,
PCRE2_SPTR16 subject, qsizetype length,
qsizetype startOffset, int options,
pcre2_match_data_16 *matchData,
pcre2_match_context_16 *matchContext)
{
@ -1118,14 +1118,14 @@ static int safe_pcre2_match_16(const pcre2_code_16 *code,
must advance over it.
*/
void QRegularExpressionPrivate::doMatch(QRegularExpressionMatchPrivate *priv,
int offset,
qsizetype offset,
CheckSubjectStringOption checkSubjectStringOption,
const QRegularExpressionMatchPrivate *previous) const
{
Q_ASSERT(priv);
Q_ASSUME(priv != previous);
const int subjectLength = priv->subject.length();
const qsizetype subjectLength = priv->subject.size();
if (offset < 0)
offset += subjectLength;
@ -1235,10 +1235,10 @@ void QRegularExpressionPrivate::doMatch(QRegularExpressionMatchPrivate *priv,
// copy the captured substrings offsets, if any
if (priv->capturedCount) {
PCRE2_SIZE *ovector = pcre2_get_ovector_pointer_16(matchData);
int * const capturedOffsets = priv->capturedOffsets.data();
qsizetype *const capturedOffsets = priv->capturedOffsets.data();
for (int i = 0; i < priv->capturedCount * 2; ++i)
capturedOffsets[i] = static_cast<int>(ovector[i]);
capturedOffsets[i] = qsizetype(ovector[i]);
// For partial matches, PCRE2 and PCRE1 differ in behavior when lookbehinds
// are involved. PCRE2 reports the real begin of the match and the maximum
@ -1555,7 +1555,7 @@ QString QRegularExpression::errorString() const
\sa pattern(), isValid(), errorString()
*/
int QRegularExpression::patternErrorOffset() const
qsizetype QRegularExpression::patternErrorOffset() const
{
d.data()->compilePattern();
return d->errorOffset;
@ -1572,7 +1572,7 @@ int QRegularExpression::patternErrorOffset() const
\sa QRegularExpressionMatch, {normal matching}
*/
QRegularExpressionMatch QRegularExpression::match(const QString &subject,
int offset,
qsizetype offset,
MatchType matchType,
MatchOptions matchOptions) const
{
@ -1603,7 +1603,7 @@ QRegularExpressionMatch QRegularExpression::match(const QString &subject,
\sa QRegularExpressionMatch, {normal matching}
*/
QRegularExpressionMatch QRegularExpression::match(QStringView subjectView,
int offset,
qsizetype offset,
MatchType matchType,
MatchOptions matchOptions) const
{
@ -1629,7 +1629,7 @@ QRegularExpressionMatch QRegularExpression::match(QStringView subjectView,
\sa QRegularExpressionMatchIterator, {global matching}
*/
QRegularExpressionMatchIterator QRegularExpression::globalMatch(const QString &subject,
int offset,
qsizetype offset,
MatchType matchType,
MatchOptions matchOptions) const
{
@ -1661,7 +1661,7 @@ QRegularExpressionMatchIterator QRegularExpression::globalMatch(const QString &s
\sa QRegularExpressionMatchIterator, {global matching}
*/
QRegularExpressionMatchIterator QRegularExpression::globalMatch(QStringView subjectView,
int offset,
qsizetype offset,
MatchType matchType,
MatchOptions matchOptions) const
{
@ -1758,12 +1758,12 @@ size_t qHash(const QRegularExpression &key, size_t seed) noexcept
QString QRegularExpression::escape(QStringView str)
{
QString result;
const int count = str.size();
const qsizetype count = str.size();
result.reserve(count * 2);
// everything but [a-zA-Z0-9_] gets escaped,
// cf. perldoc -f quotemeta
for (int i = 0; i < count; ++i) {
for (qsizetype i = 0; i < count; ++i) {
const QChar current = str.at(i);
if (current == QChar::Null) {
@ -1866,10 +1866,10 @@ QString QRegularExpression::escape(QStringView str)
*/
QString QRegularExpression::wildcardToRegularExpression(QStringView pattern, WildcardConversionOptions options)
{
const int wclen = pattern.length();
const qsizetype wclen = pattern.size();
QString rx;
rx.reserve(wclen + wclen / 16);
int i = 0;
qsizetype i = 0;
const QChar *wc = pattern.data();
#ifdef Q_OS_WIN
@ -2147,7 +2147,7 @@ QStringView QRegularExpressionMatch::capturedView(int nth) const
if (nth < 0 || nth > lastCapturedIndex())
return QStringView();
int start = capturedStart(nth);
qsizetype start = capturedStart(nth);
if (start == -1) // didn't capture
return QStringView();
@ -2239,7 +2239,7 @@ QStringList QRegularExpressionMatch::capturedTexts() const
\sa capturedEnd(), capturedLength(), captured()
*/
int QRegularExpressionMatch::capturedStart(int nth) const
qsizetype QRegularExpressionMatch::capturedStart(int nth) const
{
if (nth < 0 || nth > lastCapturedIndex())
return -1;
@ -2255,7 +2255,7 @@ int QRegularExpressionMatch::capturedStart(int nth) const
\sa capturedStart(), capturedEnd(), captured()
*/
int QRegularExpressionMatch::capturedLength(int nth) const
qsizetype QRegularExpressionMatch::capturedLength(int nth) const
{
// bound checking performed by these two functions
return capturedEnd(nth) - capturedStart(nth);
@ -2268,7 +2268,7 @@ int QRegularExpressionMatch::capturedLength(int nth) const
\sa capturedStart(), capturedLength(), captured()
*/
int QRegularExpressionMatch::capturedEnd(int nth) const
qsizetype QRegularExpressionMatch::capturedEnd(int nth) const
{
if (nth < 0 || nth > lastCapturedIndex())
return -1;
@ -2285,7 +2285,7 @@ int QRegularExpressionMatch::capturedEnd(int nth) const
\sa capturedEnd(), capturedLength(), captured()
*/
int QRegularExpressionMatch::capturedStart(const QString &name) const
qsizetype QRegularExpressionMatch::capturedStart(const QString &name) const
{
return capturedStart(qToStringViewIgnoringNull(name));
}
@ -2299,7 +2299,7 @@ int QRegularExpressionMatch::capturedStart(const QString &name) const
\sa capturedStart(), capturedEnd(), captured()
*/
int QRegularExpressionMatch::capturedLength(const QString &name) const
qsizetype QRegularExpressionMatch::capturedLength(const QString &name) const
{
return capturedLength(qToStringViewIgnoringNull(name));
}
@ -2312,7 +2312,7 @@ int QRegularExpressionMatch::capturedLength(const QString &name) const
\sa capturedStart(), capturedLength(), captured()
*/
int QRegularExpressionMatch::capturedEnd(const QString &name) const
qsizetype QRegularExpressionMatch::capturedEnd(const QString &name) const
{
return capturedEnd(qToStringViewIgnoringNull(name));
}
@ -2328,7 +2328,7 @@ int QRegularExpressionMatch::capturedEnd(const QString &name) const
\sa capturedEnd(), capturedLength(), captured()
*/
int QRegularExpressionMatch::capturedStart(QStringView name) const
qsizetype QRegularExpressionMatch::capturedStart(QStringView name) const
{
if (name.isEmpty()) {
qWarning("QRegularExpressionMatch::capturedStart: empty capturing group name passed");
@ -2351,7 +2351,7 @@ int QRegularExpressionMatch::capturedStart(QStringView name) const
\sa capturedStart(), capturedEnd(), captured()
*/
int QRegularExpressionMatch::capturedLength(QStringView name) const
qsizetype QRegularExpressionMatch::capturedLength(QStringView name) const
{
if (name.isEmpty()) {
qWarning("QRegularExpressionMatch::capturedLength: empty capturing group name passed");
@ -2373,7 +2373,7 @@ int QRegularExpressionMatch::capturedLength(QStringView name) const
\sa capturedStart(), capturedLength(), captured()
*/
int QRegularExpressionMatch::capturedEnd(QStringView name) const
qsizetype QRegularExpressionMatch::capturedEnd(QStringView name) const
{
if (name.isEmpty()) {
qWarning("QRegularExpressionMatch::capturedEnd: empty capturing group name passed");

View File

@ -96,7 +96,7 @@ public:
void setPattern(const QString &pattern);
bool isValid() const;
int patternErrorOffset() const;
qsizetype patternErrorOffset() const;
QString errorString() const;
int captureCount() const;
@ -119,22 +119,22 @@ public:
Q_DECLARE_FLAGS(MatchOptions, MatchOption)
QRegularExpressionMatch match(const QString &subject,
int offset = 0,
qsizetype offset = 0,
MatchType matchType = NormalMatch,
MatchOptions matchOptions = NoMatchOption) const;
QRegularExpressionMatch match(QStringView subjectView,
int offset = 0,
qsizetype offset = 0,
MatchType matchType = NormalMatch,
MatchOptions matchOptions = NoMatchOption) const;
QRegularExpressionMatchIterator globalMatch(const QString &subject,
int offset = 0,
qsizetype offset = 0,
MatchType matchType = NormalMatch,
MatchOptions matchOptions = NoMatchOption) const;
QRegularExpressionMatchIterator globalMatch(QStringView subjectView,
int offset = 0,
qsizetype offset = 0,
MatchType matchType = NormalMatch,
MatchOptions matchOptions = NoMatchOption) const;
@ -234,19 +234,19 @@ public:
QStringList capturedTexts() const;
int capturedStart(int nth = 0) const;
int capturedLength(int nth = 0) const;
int capturedEnd(int nth = 0) const;
qsizetype capturedStart(int nth = 0) const;
qsizetype capturedLength(int nth = 0) const;
qsizetype capturedEnd(int nth = 0) const;
#if QT_STRINGVIEW_LEVEL < 2
int capturedStart(const QString &name) const;
int capturedLength(const QString &name) const;
int capturedEnd(const QString &name) const;
qsizetype capturedStart(const QString &name) const;
qsizetype capturedLength(const QString &name) const;
qsizetype capturedEnd(const QString &name) const;
#endif
int capturedStart(QStringView name) const;
int capturedLength(QStringView name) const;
int capturedEnd(QStringView name) const;
qsizetype capturedStart(QStringView name) const;
qsizetype capturedLength(QStringView name) const;
qsizetype capturedEnd(QStringView name) const;
private:
friend class QRegularExpression;

View File

@ -214,9 +214,9 @@ void consistencyCheck(const QRegularExpressionMatch &match)
QVERIFY(match.lastCapturedIndex() == 0);
for (int i = 0; i <= match.lastCapturedIndex(); ++i) {
int startPos = match.capturedStart(i);
int endPos = match.capturedEnd(i);
int length = match.capturedLength(i);
qsizetype startPos = match.capturedStart(i);
qsizetype endPos = match.capturedEnd(i);
qsizetype length = match.capturedLength(i);
QString captured = match.captured(i);
QStringView capturedView = match.capturedView(i);
@ -300,7 +300,7 @@ template<typename QREMatch, typename QREMatchFunc, typename Subject, typename Re
static void testMatchImpl(const QRegularExpression &regexp,
QREMatchFunc matchingMethod,
const Subject &subject,
int offset,
qsizetype offset,
QRegularExpression::MatchType matchType,
QRegularExpression::MatchOptions matchOptions,
const Result &result)
@ -334,7 +334,7 @@ static void testMatch(const QRegularExpression &regexp,
QREMatchFuncForString matchingMethodForString,
QREMatchFuncForStringRef matchingMethodForStringRef,
const QString &subject,
int offset,
qsizetype offset,
QRegularExpression::MatchType matchType,
QRegularExpression::MatchOptions matchOptions,
const Result &result)
@ -352,10 +352,10 @@ static void testMatch(const QRegularExpression &regexp,
result);
}
typedef QRegularExpressionMatch (QRegularExpression::*QREMatchStringPMF)(const QString &, int, QRegularExpression::MatchType, QRegularExpression::MatchOptions) const;
typedef QRegularExpressionMatch (QRegularExpression::*QREMatchStringViewPMF)(QStringView, int, QRegularExpression::MatchType, QRegularExpression::MatchOptions) const;
typedef QRegularExpressionMatchIterator (QRegularExpression::*QREGlobalMatchStringPMF)(const QString &, int, QRegularExpression::MatchType, QRegularExpression::MatchOptions) const;
typedef QRegularExpressionMatchIterator (QRegularExpression::*QREGlobalMatchStringViewPMF)(QStringView, int, QRegularExpression::MatchType, QRegularExpression::MatchOptions) const;
typedef QRegularExpressionMatch (QRegularExpression::*QREMatchStringPMF)(const QString &, qsizetype, QRegularExpression::MatchType, QRegularExpression::MatchOptions) const;
typedef QRegularExpressionMatch (QRegularExpression::*QREMatchStringViewPMF)(QStringView, qsizetype, QRegularExpression::MatchType, QRegularExpression::MatchOptions) const;
typedef QRegularExpressionMatchIterator (QRegularExpression::*QREGlobalMatchStringPMF)(const QString &, qsizetype, QRegularExpression::MatchType, QRegularExpression::MatchOptions) const;
typedef QRegularExpressionMatchIterator (QRegularExpression::*QREGlobalMatchStringViewPMF)(QStringView, qsizetype, QRegularExpression::MatchType, QRegularExpression::MatchOptions) const;
void tst_QRegularExpression::provideRegularExpressions()
{
@ -626,19 +626,19 @@ void tst_QRegularExpression::normalMatch_data()
{
QTest::addColumn<QRegularExpression>("regexp");
QTest::addColumn<QString>("subject");
QTest::addColumn<int>("offset");
QTest::addColumn<qsizetype>("offset");
QTest::addColumn<QRegularExpression::MatchOptions>("matchOptions");
QTest::addColumn<Match>("match");
Match m;
int offset = 0;
qsizetype offset = 0;
m.clear();
m.isValid = true; m.hasMatch = true;
m.captured << "string" << "string";
QTest::newRow("match01") << QRegularExpression("(\\bstring\\b)")
<< "a string"
<< 0
<< qsizetype(0)
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -647,7 +647,7 @@ void tst_QRegularExpression::normalMatch_data()
m.captured << "a string" << "a" << "string";
QTest::newRow("match02") << QRegularExpression("(\\w+) (\\w+)")
<< "a string"
<< 0
<< qsizetype(0)
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -658,7 +658,7 @@ void tst_QRegularExpression::normalMatch_data()
m.namedCaptured["noun"] = "string";
QTest::newRow("match03") << QRegularExpression("(?<article>\\w+) (?<noun>\\w+)")
<< "a string"
<< 0
<< qsizetype(0)
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -667,7 +667,7 @@ void tst_QRegularExpression::normalMatch_data()
m.captured << " string" << QString() << "string";
QTest::newRow("match04") << QRegularExpression("(\\w+)? (\\w+)")
<< " string"
<< 0
<< qsizetype(0)
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -676,7 +676,7 @@ void tst_QRegularExpression::normalMatch_data()
m.captured << " string" << QString("") << "string";
QTest::newRow("match05") << QRegularExpression("(\\w*) (\\w+)")
<< " string"
<< 0
<< qsizetype(0)
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -684,7 +684,7 @@ void tst_QRegularExpression::normalMatch_data()
m.isValid = true; m.hasMatch = true;
m.captured << "c123def" << "c12" << "3" << "def";
offset = 2;
for (int i = 0; i <= offset; ++i) {
for (qsizetype i = 0; i <= offset; ++i) {
QTest::newRow(("match06-offset" + QByteArray::number(i)).constData())
<< QRegularExpression("(\\w*)(\\d+)(\\w*)")
<< QStringLiteral("abc123def").mid(offset - i)
@ -697,7 +697,7 @@ void tst_QRegularExpression::normalMatch_data()
m.isValid = true; m.hasMatch = true;
m.captured << QString("");
offset = 9;
for (int i = 0; i <= offset; ++i) {
for (qsizetype i = 0; i <= offset; ++i) {
QTest::newRow(("match07-offset" + QByteArray::number(i)).constData())
<< QRegularExpression("\\w*")
<< QStringLiteral("abc123def").mid(offset - i)
@ -711,7 +711,7 @@ void tst_QRegularExpression::normalMatch_data()
m.captured << QString("a string") << QString("a string") << QString("");
QTest::newRow("match08") << QRegularExpression("(.*)(.*)")
<< "a string"
<< 0
<< qsizetype(0)
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -720,7 +720,7 @@ void tst_QRegularExpression::normalMatch_data()
m.captured << QString("a string") << QString("") << QString("a string");
QTest::newRow("match09") << QRegularExpression("(.*?)(.*)")
<< "a string"
<< 0
<< qsizetype(0)
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -735,7 +735,7 @@ void tst_QRegularExpression::normalMatch_data()
m.namedCaptured["nonexisting3"] = QString();
QTest::newRow("match10") << QRegularExpression("(?<article>\\w+) (?<noun>\\w+)")
<< "a string"
<< 0
<< qsizetype(0)
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -746,7 +746,7 @@ void tst_QRegularExpression::normalMatch_data()
m.namedCaptured["nonexisting"] = QString();
QTest::newRow("match11") << QRegularExpression("(?<digits>\\d*)")
<< "abcde"
<< 0
<< qsizetype(0)
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -758,7 +758,7 @@ void tst_QRegularExpression::normalMatch_data()
QTest::newRow("match12")
<< QRegularExpression("\\Bbcd\\B")
<< "abcde"
<< 1
<< qsizetype(1)
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -768,14 +768,14 @@ void tst_QRegularExpression::normalMatch_data()
m.isValid = true;
QTest::newRow("nomatch01") << QRegularExpression("\\d+")
<< "a string"
<< 0
<< qsizetype(0)
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
m.clear();
m.isValid = true;
offset = 1;
for (int i = 0; i <= offset; ++i) {
for (qsizetype i = 0; i <= offset; ++i) {
QTest::newRow(("nomatch02-offset" + QByteArray::number(i)).constData())
<< QRegularExpression("(\\w+) (\\w+)")
<< QStringLiteral("a string").mid(offset - i)
@ -787,7 +787,7 @@ void tst_QRegularExpression::normalMatch_data()
m.clear();
m.isValid = true;
offset = 9;
for (int i = 0; i <= offset; ++i) {
for (qsizetype i = 0; i <= offset; ++i) {
QTest::newRow(("nomatch03-offset" + QByteArray::number(i)).constData())
<< QRegularExpression("\\w+")
<< QStringLiteral("abc123def").mid(offset - i)
@ -802,7 +802,7 @@ void tst_QRegularExpression::normalMatch_data()
m.isValid = true;
QTest::newRow("anchoredmatch01") << QRegularExpression("\\d+")
<< "abc123def"
<< 0
<< qsizetype(0)
<< QRegularExpression::MatchOptions(QRegularExpression::AnchorAtOffsetMatchOption)
<< m;
@ -813,7 +813,7 @@ void tst_QRegularExpression::normalMatch_data()
m.captured << "678";
QTest::newRow("negativeoffset01") << QRegularExpression("\\d+")
<< "abc123def678ghi"
<< -6
<< qsizetype(-6)
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -822,7 +822,7 @@ void tst_QRegularExpression::normalMatch_data()
m.captured << "678";
QTest::newRow("negativeoffset02") << QRegularExpression("\\d+")
<< "abc123def678ghi"
<< -8
<< qsizetype(-8)
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -831,7 +831,7 @@ void tst_QRegularExpression::normalMatch_data()
m.captured << "678ghi" << "678" << "ghi";
QTest::newRow("negativeoffset03") << QRegularExpression("(\\d+)(\\w+)")
<< "abc123def678ghi"
<< -8
<< qsizetype(-8)
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -839,7 +839,7 @@ void tst_QRegularExpression::normalMatch_data()
m.isValid = true;
QTest::newRow("negativeoffset04") << QRegularExpression("\\d+")
<< "abc123def678ghi"
<< -3
<< qsizetype(-3)
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -848,7 +848,7 @@ void tst_QRegularExpression::normalMatch_data()
m.captured << "678";
QTest::newRow("negativeoffset05") << QRegularExpression("^\\d+", QRegularExpression::MultilineOption)
<< "a\nbc123\ndef\n678gh\ni"
<< -10
<< qsizetype(-10)
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
}
@ -858,7 +858,7 @@ void tst_QRegularExpression::normalMatch()
{
QFETCH(QRegularExpression, regexp);
QFETCH(QString, subject);
QFETCH(int, offset);
QFETCH(qsizetype, offset);
QFETCH(QRegularExpression::MatchOptions, matchOptions);
QFETCH(Match, match);
@ -876,20 +876,20 @@ void tst_QRegularExpression::partialMatch_data()
{
QTest::addColumn<QRegularExpression>("regexp");
QTest::addColumn<QString>("subject");
QTest::addColumn<int>("offset");
QTest::addColumn<qsizetype>("offset");
QTest::addColumn<QRegularExpression::MatchType>("matchType");
QTest::addColumn<QRegularExpression::MatchOptions>("matchOptions");
QTest::addColumn<Match>("match");
Match m;
int offset = 0;
qsizetype offset = 0;
m.clear();
m.isValid = true; m.hasPartialMatch = true;
m.captured << "str";
QTest::newRow("softmatch01") << QRegularExpression("string")
<< "a str"
<< 0
<< qsizetype(0)
<< QRegularExpression::PartialPreferCompleteMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -899,7 +899,7 @@ void tst_QRegularExpression::partialMatch_data()
m.captured << " str";
QTest::newRow("softmatch02") << QRegularExpression("\\bstring\\b")
<< "a str"
<< 0
<< qsizetype(0)
<< QRegularExpression::PartialPreferCompleteMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -909,7 +909,7 @@ void tst_QRegularExpression::partialMatch_data()
m.captured << " str";
QTest::newRow("softmatch03") << QRegularExpression("(\\bstring\\b)")
<< "a str"
<< 0
<< qsizetype(0)
<< QRegularExpression::PartialPreferCompleteMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -919,7 +919,7 @@ void tst_QRegularExpression::partialMatch_data()
m.captured << "8 Dec 19";
QTest::newRow("softmatch04") << QRegularExpression("^(\\d{1,2}) (\\w{3}) (\\d{4})$")
<< "8 Dec 19"
<< 0
<< qsizetype(0)
<< QRegularExpression::PartialPreferCompleteMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -929,7 +929,7 @@ void tst_QRegularExpression::partialMatch_data()
m.captured << "8 Dec 1985" << "8" << "Dec" << "1985";
QTest::newRow("softmatch05") << QRegularExpression("^(\\d{1,2}) (\\w{3}) (\\d{4})$")
<< "8 Dec 1985"
<< 0
<< qsizetype(0)
<< QRegularExpression::PartialPreferCompleteMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -939,7 +939,7 @@ void tst_QRegularExpression::partialMatch_data()
m.captured << "def";
QTest::newRow("softmatch06") << QRegularExpression("abc\\w+X|def")
<< "abcdef"
<< 0
<< qsizetype(0)
<< QRegularExpression::PartialPreferCompleteMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -949,7 +949,7 @@ void tst_QRegularExpression::partialMatch_data()
m.captured << "abcdef";
QTest::newRow("softmatch07") << QRegularExpression("abc\\w+X|defY")
<< "abcdef"
<< 0
<< qsizetype(0)
<< QRegularExpression::PartialPreferCompleteMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -958,7 +958,7 @@ void tst_QRegularExpression::partialMatch_data()
m.isValid = true; m.hasPartialMatch = true;
m.captured << "def";
offset = 1;
for (int i = 0; i <= offset; ++i) {
for (qsizetype i = 0; i <= offset; ++i) {
QTest::newRow(("softmatch08-offset" + QByteArray::number(i)).constData())
<< QRegularExpression("abc\\w+X|defY")
<< QStringLiteral("abcdef").mid(offset - i)
@ -975,7 +975,7 @@ void tst_QRegularExpression::partialMatch_data()
m.captured << "str";
QTest::newRow("hardmatch01") << QRegularExpression("string")
<< "a str"
<< 0
<< qsizetype(0)
<< QRegularExpression::PartialPreferFirstMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -985,7 +985,7 @@ void tst_QRegularExpression::partialMatch_data()
m.captured << " str";
QTest::newRow("hardmatch02") << QRegularExpression("\\bstring\\b")
<< "a str"
<< 0
<< qsizetype(0)
<< QRegularExpression::PartialPreferFirstMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -995,7 +995,7 @@ void tst_QRegularExpression::partialMatch_data()
m.captured << " str";
QTest::newRow("hardmatch03") << QRegularExpression("(\\bstring\\b)")
<< "a str"
<< 0
<< qsizetype(0)
<< QRegularExpression::PartialPreferFirstMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -1005,7 +1005,7 @@ void tst_QRegularExpression::partialMatch_data()
m.captured << "8 Dec 19";
QTest::newRow("hardmatch04") << QRegularExpression("^(\\d{1,2}) (\\w{3}) (\\d{4})$")
<< "8 Dec 19"
<< 0
<< qsizetype(0)
<< QRegularExpression::PartialPreferFirstMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -1015,7 +1015,7 @@ void tst_QRegularExpression::partialMatch_data()
m.captured << "8 Dec 1985";
QTest::newRow("hardmatch05") << QRegularExpression("^(\\d{1,2}) (\\w{3}) (\\d{4})$")
<< "8 Dec 1985"
<< 0
<< qsizetype(0)
<< QRegularExpression::PartialPreferFirstMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -1025,7 +1025,7 @@ void tst_QRegularExpression::partialMatch_data()
m.captured << "abcdef";
QTest::newRow("hardmatch06") << QRegularExpression("abc\\w+X|def")
<< "abcdef"
<< 0
<< qsizetype(0)
<< QRegularExpression::PartialPreferFirstMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -1035,7 +1035,7 @@ void tst_QRegularExpression::partialMatch_data()
m.captured << "abcdef";
QTest::newRow("hardmatch07") << QRegularExpression("abc\\w+X|defY")
<< "abcdef"
<< 0
<< qsizetype(0)
<< QRegularExpression::PartialPreferFirstMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -1044,7 +1044,7 @@ void tst_QRegularExpression::partialMatch_data()
m.isValid = true; m.hasPartialMatch = true;
m.captured << "def";
offset = 1;
for (int i = 0; i <= offset; ++i) {
for (qsizetype i = 0; i <= offset; ++i) {
QTest::newRow(("hardmatch08-offset" + QByteArray::number(i)).constData())
<< QRegularExpression("abc\\w+X|defY")
<< QStringLiteral("abcdef").mid(offset - i)
@ -1059,7 +1059,7 @@ void tst_QRegularExpression::partialMatch_data()
m.captured << "ab";
QTest::newRow("hardmatch09") << QRegularExpression("abc|ab")
<< "ab"
<< 0
<< qsizetype(0)
<< QRegularExpression::PartialPreferFirstMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -1069,7 +1069,7 @@ void tst_QRegularExpression::partialMatch_data()
m.captured << "abc";
QTest::newRow("hardmatch10") << QRegularExpression("abc(def)?")
<< "abc"
<< 0
<< qsizetype(0)
<< QRegularExpression::PartialPreferFirstMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -1079,7 +1079,7 @@ void tst_QRegularExpression::partialMatch_data()
m.captured << "abc";
QTest::newRow("hardmatch11") << QRegularExpression("(abc)*")
<< "abc"
<< 0
<< qsizetype(0)
<< QRegularExpression::PartialPreferFirstMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -1091,7 +1091,7 @@ void tst_QRegularExpression::partialMatch_data()
m.isValid = true;
QTest::newRow("nomatch01") << QRegularExpression("abc\\w+X|defY")
<< "123456"
<< 0
<< qsizetype(0)
<< QRegularExpression::PartialPreferCompleteMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -1100,7 +1100,7 @@ void tst_QRegularExpression::partialMatch_data()
m.isValid = true;
QTest::newRow("nomatch02") << QRegularExpression("abc\\w+X|defY")
<< "123456"
<< 0
<< qsizetype(0)
<< QRegularExpression::PartialPreferFirstMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -1109,7 +1109,7 @@ void tst_QRegularExpression::partialMatch_data()
m.isValid = true;
QTest::newRow("nomatch03") << QRegularExpression("abc\\w+X|defY")
<< "ab123"
<< 0
<< qsizetype(0)
<< QRegularExpression::PartialPreferCompleteMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -1118,7 +1118,7 @@ void tst_QRegularExpression::partialMatch_data()
m.isValid = true;
QTest::newRow("nomatch04") << QRegularExpression("abc\\w+X|defY")
<< "ab123"
<< 0
<< qsizetype(0)
<< QRegularExpression::PartialPreferFirstMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< m;
@ -1129,7 +1129,7 @@ void tst_QRegularExpression::partialMatch()
{
QFETCH(QRegularExpression, regexp);
QFETCH(QString, subject);
QFETCH(int, offset);
QFETCH(qsizetype, offset);
QFETCH(QRegularExpression::MatchType, matchType);
QFETCH(QRegularExpression::MatchOptions, matchOptions);
QFETCH(Match, match);
@ -1148,7 +1148,7 @@ void tst_QRegularExpression::globalMatch_data()
{
QTest::addColumn<QRegularExpression>("regexp");
QTest::addColumn<QString>("subject");
QTest::addColumn<int>("offset");
QTest::addColumn<qsizetype>("offset");
QTest::addColumn<QRegularExpression::MatchType>("matchType");
QTest::addColumn<QRegularExpression::MatchOptions>("matchOptions");
QTest::addColumn<QList<Match> >("matchList");
@ -1167,7 +1167,7 @@ void tst_QRegularExpression::globalMatch_data()
matchList << m;
QTest::newRow("globalmatch01") << QRegularExpression("\\w+")
<< "the quick fox"
<< 0
<< qsizetype(0)
<< QRegularExpression::NormalMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< matchList;
@ -1183,7 +1183,7 @@ void tst_QRegularExpression::globalMatch_data()
matchList << m;
QTest::newRow("globalmatch02") << QRegularExpression("(\\w+?)(\\w+)")
<< "the quick fox"
<< 0
<< qsizetype(0)
<< QRegularExpression::NormalMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< matchList;
@ -1201,14 +1201,14 @@ void tst_QRegularExpression::globalMatch_data()
matchList << m;
QTest::newRow("globalmatch03") << QRegularExpression("\\G(?:\\w\\w\\w)*?AAA")
<< "ACA""GTG""CGA""AAA""AAA""AAG""GAA""AAG""AAA""AAA"
<< 0
<< qsizetype(0)
<< QRegularExpression::NormalMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< matchList;
QTest::newRow("globalmatch04") << QRegularExpression("(?:\\w\\w\\w)*?AAA")
<< "ACA""GTG""CGA""AAA""AAA""AAG""GAA""AAG""AAA""AAA"
<< 0
<< qsizetype(0)
<< QRegularExpression::NormalMatch
<< QRegularExpression::MatchOptions(QRegularExpression::AnchorAtOffsetMatchOption)
<< matchList;
@ -1233,7 +1233,7 @@ void tst_QRegularExpression::globalMatch_data()
QTest::newRow("globalmatch_emptycaptures01") << QRegularExpression("a*b*|c")
<< "ccaabbd"
<< 0
<< qsizetype(0)
<< QRegularExpression::NormalMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< matchList;
@ -1256,7 +1256,7 @@ void tst_QRegularExpression::globalMatch_data()
QTest::newRow("globalmatch_emptycaptures02") << QRegularExpression(".*")
<< "the\nquick\nfox"
<< 0
<< qsizetype(0)
<< QRegularExpression::NormalMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< matchList;
@ -1281,7 +1281,7 @@ void tst_QRegularExpression::globalMatch_data()
QTest::newRow("globalmatch_emptycaptures03") << QRegularExpression(".*")
<< "the\nquick\nfox\n"
<< 0
<< qsizetype(0)
<< QRegularExpression::NormalMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< matchList;
@ -1304,7 +1304,7 @@ void tst_QRegularExpression::globalMatch_data()
QTest::newRow("globalmatch_emptycaptures04") << QRegularExpression("(*CRLF).*")
<< "the\r\nquick\r\nfox"
<< 0
<< qsizetype(0)
<< QRegularExpression::NormalMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< matchList;
@ -1329,7 +1329,7 @@ void tst_QRegularExpression::globalMatch_data()
QTest::newRow("globalmatch_emptycaptures05") << QRegularExpression("(*CRLF).*")
<< "the\r\nquick\r\nfox\r\n"
<< 0
<< qsizetype(0)
<< QRegularExpression::NormalMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< matchList;
@ -1356,7 +1356,7 @@ void tst_QRegularExpression::globalMatch_data()
QTest::newRow("globalmatch_emptycaptures06") << QRegularExpression("(*ANYCRLF).*")
<< "the\r\nquick\nfox\rjumped"
<< 0
<< qsizetype(0)
<< QRegularExpression::NormalMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< matchList;
@ -1378,7 +1378,7 @@ void tst_QRegularExpression::globalMatch_data()
matchList << m;
QTest::newRow("globalmatch_emptycaptures07") << QRegularExpression("[\\x{0000}-\\x{FFFF}]*")
<< QString::fromUtf8("ABC""\xf0\x9d\x85\x9d""DEF""\xf0\x9d\x85\x9e""GHI")
<< 0
<< qsizetype(0)
<< QRegularExpression::NormalMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< matchList;
@ -1396,7 +1396,7 @@ void tst_QRegularExpression::globalMatch_data()
matchList << m;
QTest::newRow("globalmatch_emptycaptures08") << QRegularExpression("[\\x{0000}-\\x{FFFF}]*")
<< QString::fromUtf8("ABC""\xc3\x80""\xf0\x9d\x85\x9d""\xc3\x80""DEF""\xc3\x80")
<< 0
<< qsizetype(0)
<< QRegularExpression::NormalMatch
<< QRegularExpression::MatchOptions(QRegularExpression::NoMatchOption)
<< matchList;
@ -1406,7 +1406,7 @@ void tst_QRegularExpression::globalMatch()
{
QFETCH(QRegularExpression, regexp);
QFETCH(QString, subject);
QFETCH(int, offset);
QFETCH(qsizetype, offset);
QFETCH(QRegularExpression::MatchType, matchType);
QFETCH(QRegularExpression::MatchOptions, matchOptions);
QFETCH(QList<Match>, matchList);
@ -2185,9 +2185,9 @@ void tst_QRegularExpression::wildcard_data()
{
QTest::addColumn<QString>("pattern");
QTest::addColumn<QString>("string");
QTest::addColumn<int>("foundIndex");
QTest::addColumn<qsizetype>("foundIndex");
auto addRow = [](const char *pattern, const char *string, int foundIndex) {
auto addRow = [](const char *pattern, const char *string, qsizetype foundIndex) {
QTest::newRow(pattern) << pattern << string << foundIndex;
};
@ -2241,7 +2241,7 @@ void tst_QRegularExpression::wildcard()
{
QFETCH(QString, pattern);
QFETCH(QString, string);
QFETCH(int, foundIndex);
QFETCH(qsizetype, foundIndex);
QRegularExpression re(QRegularExpression::wildcardToRegularExpression(pattern));
QRegularExpressionMatch match = re.match(string);