mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Fix a bug with surrogate characters
This is a pretty bad bug :/ Bug: 7013840 Change-Id: I12c7cfa4fa9d56b2c1fee6e6222c64fe20b88fa3
This commit is contained in:
parent
764dd71203
commit
6c721b5f68
@ -556,6 +556,7 @@ public class FusionDictionary implements Iterable<Word> {
|
|||||||
final StringBuilder checker = DBG ? new StringBuilder() : null;
|
final StringBuilder checker = DBG ? new StringBuilder() : null;
|
||||||
|
|
||||||
CharGroup currentGroup;
|
CharGroup currentGroup;
|
||||||
|
final int codePointCountInS = s.codePointCount(0, s.length());
|
||||||
do {
|
do {
|
||||||
int indexOfGroup = findIndexOfChar(node, s.codePointAt(index));
|
int indexOfGroup = findIndexOfChar(node, s.codePointAt(index));
|
||||||
if (CHARACTER_NOT_FOUND == indexOfGroup) return null;
|
if (CHARACTER_NOT_FOUND == indexOfGroup) return null;
|
||||||
@ -570,12 +571,12 @@ public class FusionDictionary implements Iterable<Word> {
|
|||||||
index = newIndex;
|
index = newIndex;
|
||||||
|
|
||||||
if (DBG) checker.append(new String(currentGroup.mChars, 0, currentGroup.mChars.length));
|
if (DBG) checker.append(new String(currentGroup.mChars, 0, currentGroup.mChars.length));
|
||||||
if (index < s.length()) {
|
if (index < codePointCountInS) {
|
||||||
node = currentGroup.mChildren;
|
node = currentGroup.mChildren;
|
||||||
}
|
}
|
||||||
} while (null != node && index < s.length());
|
} while (null != node && index < codePointCountInS);
|
||||||
|
|
||||||
if (index < s.length()) return null;
|
if (index < codePointCountInS) return null;
|
||||||
if (!currentGroup.isTerminal()) return null;
|
if (!currentGroup.isTerminal()) return null;
|
||||||
if (DBG && !s.equals(checker.toString())) return null;
|
if (DBG && !s.equals(checker.toString())) return null;
|
||||||
return currentGroup;
|
return currentGroup;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user