summaryrefslogtreecommitdiffstats
path: root/util/unicode
diff options
context:
space:
mode:
Diffstat (limited to 'util/unicode')
-rw-r--r--util/unicode/main.cpp49
1 files changed, 31 insertions, 18 deletions
diff --git a/util/unicode/main.cpp b/util/unicode/main.cpp
index 8ba992f72b..40294eba4d 100644
--- a/util/unicode/main.cpp
+++ b/util/unicode/main.cpp
@@ -472,17 +472,23 @@ 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);
+
+ int i = 0;
+ 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 +1534,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 +2250,19 @@ 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[] = {";
+ int i = 0;
+ 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";