diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2012-04-23 18:11:57 +0300 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-04-24 21:45:00 +0200 |
commit | ba0d752c2dcfbbfb9a1ebc40ce01e40c64d21494 (patch) | |
tree | 4cc6b17075e222dfb85af477248ad3d03af7a1e7 /src | |
parent | 4ca3d4ebab4f1133e48b3cfd978378fc1928cff3 (diff) |
workaround issue where casing diff overflows signed short
there are two such codepoints were added in the Unicode 5.1:
U+1D79 LATIN SMALL LETTER INSULAR G
U+A77D LATIN CAPITAL LETTER INSULAR G
two more of them were added in the Unicode 6.0:
U+0265 LATIN SMALL LETTER TURNED H
U+A78D LATIN CAPITAL LETTER TURNED H
and two more were added in the Unicode 6.1:
U+0266 LATIN SMALL LETTER H WITH HOOK
U+A7AA LATIN CAPITAL LETTER H WITH HOOK
we map them like special cases with length == 1
(note: all are in BMP which is checked explicitly in the generator)
Change-Id: I8a34164eb3ee2e575b7799cc12d4b96ad5bcd9c6
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qchar.cpp | 35 | ||||
-rw-r--r-- | src/corelib/tools/qstring.cpp | 13 | ||||
-rw-r--r-- | src/corelib/tools/qunicodetables_p.h | 2 |
3 files changed, 39 insertions, 11 deletions
diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp index 3034e430ef..74df59ab5b 100644 --- a/src/corelib/tools/qchar.cpp +++ b/src/corelib/tools/qchar.cpp @@ -1053,33 +1053,48 @@ template <typename T> static inline T toLowerCase_helper(T uc) { const QUnicodeTables::Properties *p = qGetProp(uc); - if (!p->lowerCaseSpecial) - return uc + p->lowerCaseDiff; - return uc; + if (p->lowerCaseSpecial) { + const ushort *specialCase = specialCaseMap + p->lowerCaseDiff; + if (*specialCase == 1) + return specialCase[1]; + } + return uc + p->lowerCaseDiff; } template <typename T> static inline T toUpperCase_helper(T uc) { const QUnicodeTables::Properties *p = qGetProp(uc); - if (!p->upperCaseSpecial) - return uc + p->upperCaseDiff; - return uc; + if (p->upperCaseSpecial) { + const ushort *specialCase = specialCaseMap + p->upperCaseDiff; + if (*specialCase == 1) + return specialCase[1]; + } + return uc + p->upperCaseDiff; } template <typename T> static inline T toTitleCase_helper(T uc) { const QUnicodeTables::Properties *p = qGetProp(uc); - if (!p->titleCaseSpecial) - return uc + p->titleCaseDiff; - return uc; + if (p->titleCaseSpecial) { + const ushort *specialCase = specialCaseMap + p->titleCaseDiff; + if (*specialCase == 1) + return specialCase[1]; + } + return uc + p->titleCaseDiff; } template <typename T> static inline T toCaseFolded_helper(T uc) { - return uc + qGetProp(uc)->caseFoldDiff; + const QUnicodeTables::Properties *p = qGetProp(uc); + if (p->caseFoldSpecial) { + const ushort *specialCase = specialCaseMap + p->caseFoldDiff; + if (*specialCase == 1) + return specialCase[1]; + } + return uc + p->caseFoldDiff; } /*! diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 65b52f3229..39747aa3e9 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -5263,7 +5263,20 @@ QString QString::toCaseFolded() const prop = qGetProp(*p); } if (prop->caseFoldSpecial) { + const ushort *specialCase = specialCaseMap + prop->caseFoldDiff; + ushort length = *specialCase++; +#if 0 + int pos = pp - s.d->data; + s.resize(s.d->size + length - 1); + pp = s.d->data + pos; + while (length--) + *pp++ = *specialCase++; +#else //### we currently don't support full case foldings + Q_ASSERT(length == 1); + Q_UNUSED(length) + *pp++ = *specialCase; +#endif } else { *pp++ = *p + prop->caseFoldDiff; } diff --git a/src/corelib/tools/qunicodetables_p.h b/src/corelib/tools/qunicodetables_p.h index 0b8115035c..d8f8340673 100644 --- a/src/corelib/tools/qunicodetables_p.h +++ b/src/corelib/tools/qunicodetables_p.h @@ -76,7 +76,7 @@ namespace QUnicodeTables { ushort lowerCaseSpecial : 1; ushort upperCaseSpecial : 1; ushort titleCaseSpecial : 1; - ushort caseFoldSpecial : 1; /* currently unused */ + ushort caseFoldSpecial : 1; signed short mirrorDiff : 16; signed short lowerCaseDiff : 16; signed short upperCaseDiff : 16; |