diff options
| author | Marc Mutz <[email protected]> | 2025-10-16 12:57:51 +0200 |
|---|---|---|
| committer | Marc Mutz <[email protected]> | 2025-10-19 16:25:16 +0000 |
| commit | e3ab3825cdffde880436157bb5646208f152f915 (patch) | |
| tree | 5c5438f540c52569dea24f219dc92af16bac03bb /src | |
| parent | 3eab7aca75fc44677e6b3f0e050b8f3ea174d0bd (diff) | |
QChar: avoid char{32→16}_t narrowing in normalizationQuickCheckHelper()
Same pattern as in the previous few patches: the old code used a
char32_t to temporarily store a UTF-16 code point, narrowing it back
to char16_t in a call to QChar::surrogateToUcs4(), triggering Clang 21
-Wcharacter-conversion.
Solution is also the same: keep the UTF-16 code unit in a separate
variable, until we have determined whether it needs surrogate decoding
or merely promotion to char32_t.
Amends 2e0a4b13addf1f56112bac38448be96fb02f650d.
Pick-to: 6.10 6.8 6.5
Change-Id: I291871c73b26a1766c30f0c1c6858e09d9693678
Reviewed-by: Ahmad Samir <[email protected]>
Diffstat (limited to 'src')
| -rw-r--r-- | src/corelib/text/qchar.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/corelib/text/qchar.cpp b/src/corelib/text/qchar.cpp index 4b89f67d276..d3011c34538 100644 --- a/src/corelib/text/qchar.cpp +++ b/src/corelib/text/qchar.cpp @@ -2092,7 +2092,7 @@ static bool normalizationQuickCheckHelper(QString *str, QString::NormalizationFo uchar lastCombining = 0; for (qsizetype i = from; i < length; ++i) { qsizetype pos = i; - char32_t uc = string[i]; + const char16_t uc = string[i]; if (uc < 0x80) { // ASCII characters are stable code points lastCombining = 0; @@ -2100,6 +2100,7 @@ static bool normalizationQuickCheckHelper(QString *str, QString::NormalizationFo continue; } + char32_t ucs4; if (QChar::isHighSurrogate(uc)) { ushort low = string[i + 1]; if (!QChar::isLowSurrogate(low)) { @@ -2109,10 +2110,12 @@ static bool normalizationQuickCheckHelper(QString *str, QString::NormalizationFo continue; } ++i; - uc = QChar::surrogateToUcs4(uc, low); + ucs4 = QChar::surrogateToUcs4(uc, low); + } else { + ucs4 = uc; } - const QUnicodeTables::Properties *p = qGetProp(uc); + const QUnicodeTables::Properties *p = qGetProp(ucs4); if (p->combiningClass < lastCombining && p->combiningClass > 0) return false; |
