diff options
Diffstat (limited to 'util/unicode/main.cpp')
-rw-r--r-- | util/unicode/main.cpp | 53 |
1 files changed, 35 insertions, 18 deletions
diff --git a/util/unicode/main.cpp b/util/unicode/main.cpp index 8ba992f72b..4a11ec667b 100644 --- a/util/unicode/main.cpp +++ b/util/unicode/main.cpp @@ -472,17 +472,26 @@ static int appendToSpecialCaseMap(const QList<int> &map) utf16map << val; } } - specialCaseMaxLen = qMax(specialCaseMaxLen, utf16map.size()); - utf16map << 0; - - for (int i = 0; i < specialCaseMap.size() - utf16map.size() + 1; ++i) { - int j; - for (j = 0; j < utf16map.size(); ++j) { - if (specialCaseMap.at(i+j) != utf16map.at(j)) - break; + int length = utf16map.size(); + utf16map.prepend(length); + specialCaseMaxLen = qMax(specialCaseMaxLen, length); + + if (specialCaseMap.isEmpty()) + specialCaseMap << 0; // placeholder + + int i = 1; + while (i < specialCaseMap.size()) { + int n = specialCaseMap.at(i); + if (n == length) { + int j; + for (j = 1; j <= n; ++j) { + if (specialCaseMap.at(i+j) != utf16map.at(j)) + break; + } + if (j > n) + return i; } - if (j == utf16map.size()) - return i; + i += n + 1; } int pos = specialCaseMap.size(); @@ -1528,7 +1537,8 @@ static inline void foldCase(uint ch, ushort *out) *(out++) = ch + p->caseFoldDiff; } else { const ushort *folded = specialCaseMap + p->caseFoldDiff; - while (*folded) + ushort length = *folded++; + while (length--) *out++ = *folded++; } *out = 0; @@ -2243,13 +2253,20 @@ static QByteArray createPropertyInfo() " return (QUnicodeTables::LineBreakClass)qGetProp(ucs4)->line_break_class;\n" "}\n\n"; - out += "static const ushort specialCaseMap[] = {\n "; - for (int i = 0; i < specialCaseMap.size(); ++i) { - out += QByteArray(" 0x") + QByteArray::number(specialCaseMap.at(i), 16); - if (i < specialCaseMap.size() - 1) - out += ","; - if (!specialCaseMap.at(i)) - out += "\n "; + + out += "static const ushort specialCaseMap[] = {\n"; + out += " 0x0, // placeholder"; + int i = 1; + while (i < specialCaseMap.size()) { + out += "\n "; + int n = specialCaseMap.at(i); + int j; + for (j = 0; j <= n; ++j) { + out += QByteArray(" 0x") + QByteArray::number(specialCaseMap.at(i+j), 16); + if (i+j < specialCaseMap.size() - 1) + out += ","; + } + i += n + 1; } out += "\n};\n"; out += "#define SPECIAL_CASE_MAX_LEN " + QByteArray::number(specialCaseMaxLen) + "\n\n"; |