Modernize foldCase() internal functions

Overload uint/ushort versions with new char16_t/char32_t ones, and
[[deprecate]] the old ones. There's too much churn for doing the
replacement in one patch.

Change-Id: Ib1f90a1c46b80aa0fb1ea00ce614af49f49bd712
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Marc Mutz 2020-05-06 11:05:08 +02:00
parent 1030d934c4
commit 2c1425898d
2 changed files with 26 additions and 1 deletions

View File

@ -1692,6 +1692,7 @@ char32_t QChar::toTitleCase(char32_t ucs4) noexcept
return convertCase_helper(ucs4, QUnicodeTables::TitleCase);
}
[[deprecated]]
static inline uint foldCase(const ushort *ch, const ushort *start)
{
char32_t ucs4 = *ch;
@ -1700,6 +1701,15 @@ static inline uint foldCase(const ushort *ch, const ushort *start)
return convertCase_helper(ucs4, QUnicodeTables::CaseFold);
}
static inline char32_t foldCase(const char16_t *ch, const char16_t *start)
{
char32_t ucs4 = *ch;
if (QChar::isLowSurrogate(ucs4) && ch > start && QChar::isHighSurrogate(*(ch - 1)))
ucs4 = QChar::surrogateToUcs4(*(ch - 1), ucs4);
return convertCase_helper(ucs4, QUnicodeTables::CaseFold);
}
[[deprecated]]
static inline uint foldCase(uint ch, uint &last) noexcept
{
char32_t ucs4 = ch;
@ -1709,11 +1719,26 @@ static inline uint foldCase(uint ch, uint &last) noexcept
return convertCase_helper(ucs4, QUnicodeTables::CaseFold);
}
static inline char32_t foldCase(char32_t ch, char32_t &last) noexcept
{
char32_t ucs4 = ch;
if (QChar::isLowSurrogate(ucs4) && QChar::isHighSurrogate(last))
ucs4 = QChar::surrogateToUcs4(last, ucs4);
last = ch;
return convertCase_helper(ucs4, QUnicodeTables::CaseFold);
}
[[deprecated]]
static inline ushort foldCase(ushort ch) noexcept
{
return convertCase_helper(char16_t{ch}, QUnicodeTables::CaseFold);
}
static inline char16_t foldCase(char16_t ch) noexcept
{
return convertCase_helper(ch, QUnicodeTables::CaseFold);
}
static inline QChar foldCase(QChar ch) noexcept
{
return QChar(foldCase(ch.unicode()));

View File

@ -879,7 +879,7 @@ static int ucstricmp(const QChar *a, const QChar *ae, const char *b, const char
e = a + (be - b);
while (a < e) {
int diff = foldCase(a->unicode()) - foldCase(uchar(*b));
int diff = foldCase(a->unicode()) - foldCase(char16_t{uchar(*b)});
if ((diff))
return diff;
++a;