Fixes unicode character class recognition

This commit is contained in:
konsoletyper 2014-03-13 10:50:45 +04:00
parent b7f1bb58a6
commit 2178ac34e5

View File

@ -97,7 +97,7 @@ public class UnicodeHelper {
byte b = bytes[i]; byte b = bytes[i];
if (i < bytes.length - 1 && b == bytes[i + 1]) { if (i < bytes.length - 1 && b == bytes[i + 1]) {
int count = 0; int count = 0;
while (i < bytes.length && bytes[i + count] == b) { while (count < 16384 && i < bytes.length && bytes[i + count] == b) {
++count; ++count;
} }
i += count; i += count;
@ -137,15 +137,18 @@ public class UnicodeHelper {
count |= pos * digit; count |= pos * digit;
pos *= 0x40; pos *= 0x40;
} }
} else if (b > 32) { } else if (b >= 32) {
b -= 32; b -= 32;
count = decodeByte(encoded.charAt(++i)); count = decodeByte(encoded.charAt(++i));
} else { } else {
count = 1; count = 1;
} }
if (count == 1) { if (b != 0 || count < 128) {
buffer[index++] = b; if (index + count >= buffer.length) {
} else if (b != 0) { ranges[rangeIndex++] = new Range(codePoint, codePoint + index, Arrays.copyOf(buffer, index));
codePoint += index + count;
index = 0;
}
while (count-- > 0) { while (count-- > 0) {
buffer[index++] = b; buffer[index++] = b;
} }