summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qchar.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2020-05-06 11:05:08 +0200
committerMarc Mutz <marc.mutz@kdab.com>2020-05-11 08:45:36 +0200
commit2c1425898d21fb050da69eb5f423e6f4ba86080a (patch)
tree38660a61922a8ed9900b75e2d8456905ae8de56a /src/corelib/text/qchar.cpp
parent1030d934c4e385c2c53abbcb4e457a86a8db3436 (diff)
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>
Diffstat (limited to 'src/corelib/text/qchar.cpp')
-rw-r--r--src/corelib/text/qchar.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/corelib/text/qchar.cpp b/src/corelib/text/qchar.cpp
index 94d2322fa6..49622bf196 100644
--- a/src/corelib/text/qchar.cpp
+++ b/src/corelib/text/qchar.cpp
@@ -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()));