From ba0d752c2dcfbbfb9a1ebc40ce01e40c64d21494 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Mon, 23 Apr 2012 18:11:57 +0300 Subject: 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 Reviewed-by: Lars Knoll --- util/unicode/main.cpp | 58 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 17 deletions(-) (limited to 'util') diff --git a/util/unicode/main.cpp b/util/unicode/main.cpp index d769176c6f..488026d0d5 100644 --- a/util/unicode/main.cpp +++ b/util/unicode/main.cpp @@ -383,7 +383,7 @@ static const char *property_string = " ushort lowerCaseSpecial : 1;\n" " ushort upperCaseSpecial : 1;\n" " ushort titleCaseSpecial : 1;\n" - " ushort caseFoldSpecial : 1; /* currently unused */\n" + " ushort caseFoldSpecial : 1;\n" " signed short mirrorDiff : 16;\n" " signed short lowerCaseDiff : 16;\n" " signed short upperCaseDiff : 16;\n" @@ -785,10 +785,16 @@ static void readUnicodeData() int upperCase = properties[UD_UpperCase].toInt(&ok, 16); Q_ASSERT(ok); int diff = upperCase - codepoint; - if (qAbs(diff) >= (1<<14)) - qWarning() << "upperCaseDiff exceeded (" << hex << codepoint << "->" << upperCase << ")"; - data.p.upperCaseDiff = diff; - maxUpperCaseDiff = qMax(maxUpperCaseDiff, qAbs(diff)); + if (qAbs(diff) >= (1<<14)) { + qWarning() << "upperCaseDiff exceeded (" << hex << codepoint << "->" << upperCase << "); map it for special case"; + // if the condition below doesn't hold anymore we need to modify our special upper casing code in qchar.cpp + Q_ASSERT(!QChar::requiresSurrogates(codepoint) && !QChar::requiresSurrogates(upperCase)); + data.p.upperCaseSpecial = true; + data.p.upperCaseDiff = appendToSpecialCaseMap(QList() << upperCase); + } else { + data.p.upperCaseDiff = diff; + maxUpperCaseDiff = qMax(maxUpperCaseDiff, qAbs(diff)); + } if (QChar::requiresSurrogates(codepoint) || QChar::requiresSurrogates(upperCase)) { // if the conditions below doesn't hold anymore we need to modify our upper casing code Q_ASSERT(QChar::highSurrogate(codepoint) == QChar::highSurrogate(upperCase)); @@ -799,10 +805,16 @@ static void readUnicodeData() int lowerCase = properties[UD_LowerCase].toInt(&ok, 16); Q_ASSERT(ok); int diff = lowerCase - codepoint; - if (qAbs(diff) >= (1<<14)) - qWarning() << "lowerCaseDiff exceeded (" << hex << codepoint << "->" << lowerCase << ")"; - data.p.lowerCaseDiff = diff; - maxLowerCaseDiff = qMax(maxLowerCaseDiff, qAbs(diff)); + if (qAbs(diff) >= (1<<14)) { + qWarning() << "lowerCaseDiff exceeded (" << hex << codepoint << "->" << lowerCase << "); map it for special case"; + // if the condition below doesn't hold anymore we need to modify our special lower casing code in qchar.cpp + Q_ASSERT(!QChar::requiresSurrogates(codepoint) && !QChar::requiresSurrogates(lowerCase)); + data.p.lowerCaseSpecial = true; + data.p.lowerCaseDiff = appendToSpecialCaseMap(QList() << lowerCase); + } else { + data.p.lowerCaseDiff = diff; + maxLowerCaseDiff = qMax(maxLowerCaseDiff, qAbs(diff)); + } if (QChar::requiresSurrogates(codepoint) || QChar::requiresSurrogates(lowerCase)) { // if the conditions below doesn't hold anymore we need to modify our lower casing code Q_ASSERT(QChar::highSurrogate(codepoint) == QChar::highSurrogate(lowerCase)); @@ -816,10 +828,16 @@ static void readUnicodeData() int titleCase = properties[UD_TitleCase].toInt(&ok, 16); Q_ASSERT(ok); int diff = titleCase - codepoint; - if (qAbs(diff) >= (1<<14)) - qWarning() << "titleCaseDiff exceeded (" << hex << codepoint << "->" << titleCase << ")"; - data.p.titleCaseDiff = diff; - maxTitleCaseDiff = qMax(maxTitleCaseDiff, qAbs(diff)); + if (qAbs(diff) >= (1<<14)) { + qWarning() << "titleCaseDiff exceeded (" << hex << codepoint << "->" << titleCase << "); map it for special case"; + // if the condition below doesn't hold anymore we need to modify our special title casing code in qchar.cpp + Q_ASSERT(!QChar::requiresSurrogates(codepoint) && !QChar::requiresSurrogates(titleCase)); + data.p.titleCaseSpecial = true; + data.p.titleCaseDiff = appendToSpecialCaseMap(QList() << titleCase); + } else { + data.p.titleCaseDiff = diff; + maxTitleCaseDiff = qMax(maxTitleCaseDiff, qAbs(diff)); + } if (QChar::requiresSurrogates(codepoint) || QChar::requiresSurrogates(titleCase)) { // if the conditions below doesn't hold anymore we need to modify our title casing code Q_ASSERT(QChar::highSurrogate(codepoint) == QChar::highSurrogate(titleCase)); @@ -1355,10 +1373,16 @@ static void readCaseFolding() if (foldMap.size() == 1) { int caseFolded = foldMap.at(0); int diff = caseFolded - codepoint; - if (qAbs(diff) >= (1<<14)) - qWarning() << "caseFoldDiff exceeded (" << hex << codepoint << "->" << caseFolded << ")"; - ud.p.caseFoldDiff = diff; - maxCaseFoldDiff = qMax(maxCaseFoldDiff, qAbs(diff)); + if (qAbs(diff) >= (1<<14)) { + qWarning() << "caseFoldDiff exceeded (" << hex << codepoint << "->" << caseFolded << "); map it for special case"; + // if the condition below doesn't hold anymore we need to modify our special case folding code in qchar.cpp + Q_ASSERT(!QChar::requiresSurrogates(codepoint) && !QChar::requiresSurrogates(caseFolded)); + ud.p.caseFoldSpecial = true; + ud.p.caseFoldDiff = appendToSpecialCaseMap(foldMap); + } else { + ud.p.caseFoldDiff = diff; + maxCaseFoldDiff = qMax(maxCaseFoldDiff, qAbs(diff)); + } if (QChar::requiresSurrogates(codepoint) || QChar::requiresSurrogates(caseFolded)) { // if the conditions below doesn't hold anymore we need to modify our case folding code Q_ASSERT(QChar::highSurrogate(codepoint) == QChar::highSurrogate(caseFolded)); -- cgit v1.2.3