diff options
author | Ulf Hermann <[email protected]> | 2022-09-01 11:32:44 +0200 |
---|---|---|
committer | Ulf Hermann <[email protected]> | 2022-09-07 16:56:51 +0200 |
commit | ac26bab290e7d38a3a40077c6fdd1673a008b55f (patch) | |
tree | d048bc34cdc6a42a61b2649042c50c71fca67f87 /src/3rdparty/masm | |
parent | 826b77c8cf0ffbef4f95e7b9e72eb9dc25936657 (diff) |
Fix our unicode stub for the Yarr interpreter
The interpreter expects the semantics of ICU's u_tolower and u_toupper
for the functions called u_tolower and u_toupper. This means they should
only perform simple case conversions. QChar tries all possible case
conversions.
Task-number: QTBUG-100242
Change-Id: If5f27b12e55459b64460adc2c56e6de026754803
Reviewed-by: Edward Welbourne <[email protected]>
Reviewed-by: Fabian Kosmale <[email protected]>
Reviewed-by: Ievgenii Meshcheriakov <[email protected]>
Diffstat (limited to 'src/3rdparty/masm')
-rw-r--r-- | src/3rdparty/masm/stubs/wtf/unicode/Unicode.h | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/3rdparty/masm/stubs/wtf/unicode/Unicode.h b/src/3rdparty/masm/stubs/wtf/unicode/Unicode.h index 0f7f005c89..34e331f887 100644 --- a/src/3rdparty/masm/stubs/wtf/unicode/Unicode.h +++ b/src/3rdparty/masm/stubs/wtf/unicode/Unicode.h @@ -39,25 +39,28 @@ #ifndef UNICODE_H #define UNICODE_H -#include <QChar> +#include <QtCore/private/qunicodetables_p.h> +#include <QtCore/qchar.h> typedef unsigned char LChar; typedef unsigned short UChar; typedef int32_t UChar32; namespace Unicode { - inline UChar toLower(UChar ch) { - return QChar::toLower(ch); - } - - inline UChar toUpper(UChar ch) { - return QChar::toUpper(ch); - } + // u_tolower applies only Simple_Lowercase_Mapping. This is in contrast to QChar::toLower. inline UChar32 u_tolower(UChar32 ch) { - return QChar::toLower(ch); + if (ch > QChar::LastValidCodePoint) + return ch; + const auto fold = QUnicodeTables::properties(char32_t(ch))->cases[QUnicodeTables::LowerCase]; + return fold.special ? ch : (ch + fold.diff); } + + // u_toupper applies only Simple_Uppercase_Mapping. This is in contrast to QChar::toUpper. inline UChar32 u_toupper(UChar32 ch) { - return QChar::toUpper(ch); + if (ch > QChar::LastValidCodePoint) + return ch; + const auto fold = QUnicodeTables::properties(char32_t(ch))->cases[QUnicodeTables::UpperCase]; + return fold.special ? ch : (ch + fold.diff); } } |