QRegularExpression: cast to PCRE2_SPTR16

It seems that PCRE2_UCHAR16 is exactly ushort, even though it's
documented to be uint16_t. There's no requirement for these to be the
same type, nor for the PCRE typedef to continue to point to the same
type, so add explicit casts.

Change-Id: I89f65d29feaada84ea00688976a123364857bc58
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
Marc Mutz 2020-05-10 20:51:34 +02:00
parent 8a0f100e97
commit 9e56d28663

View File

@ -898,7 +898,7 @@ void QRegularExpressionPrivate::compilePattern()
options |= PCRE2_UTF;
PCRE2_SIZE patternErrorOffset;
compiledPattern = pcre2_compile_16(pattern.utf16(),
compiledPattern = pcre2_compile_16(reinterpret_cast<PCRE2_SPTR16>(pattern.utf16()),
pattern.length(),
options,
&errorCode,
@ -1163,12 +1163,12 @@ QRegularExpressionMatchPrivate *QRegularExpressionPrivate::doMatch(const QString
if (!previousMatchWasEmpty) {
result = safe_pcre2_match_16(compiledPattern,
subjectUtf16, subjectLength,
reinterpret_cast<PCRE2_SPTR16>(subjectUtf16), subjectLength,
offset, pcreOptions,
matchData, matchContext);
} else {
result = safe_pcre2_match_16(compiledPattern,
subjectUtf16, subjectLength,
reinterpret_cast<PCRE2_SPTR16>(subjectUtf16), subjectLength,
offset, pcreOptions | PCRE2_NOTEMPTY_ATSTART | PCRE2_ANCHORED,
matchData, matchContext);
@ -1186,7 +1186,7 @@ QRegularExpressionMatchPrivate *QRegularExpressionPrivate::doMatch(const QString
}
result = safe_pcre2_match_16(compiledPattern,
subjectUtf16, subjectLength,
reinterpret_cast<PCRE2_SPTR16>(subjectUtf16), subjectLength,
offset, pcreOptions,
matchData, matchContext);
}