mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-21 12:40:02 +00:00
ICU-8761 Merging #8484 endless loop in RuleBasedCollator.getSortKeyBytes (r30184) from trunk.
X-SVN-Rev: 30522
This commit is contained in:
parent
e9e98061f4
commit
235e21e5da
2 changed files with 23 additions and 5 deletions
|
@ -1690,10 +1690,19 @@ public final class CollationElementIterator
|
|||
// Source string char was not in contraction table.
|
||||
// Unless it is a discontiguous contraction, we are done
|
||||
int miss = ch;
|
||||
if(UTF16.isLeadSurrogate(ch)) { // in order to do the proper detection, we
|
||||
// need to see if we're dealing with a supplementary
|
||||
miss = UCharacterProperty.getRawSupplementary(ch, (char) nextChar());
|
||||
}
|
||||
// ticket 8484 - porting changes from C for 6101
|
||||
// We test whether the next two char are surrogate pairs.
|
||||
// This test is done if the iterator is not in the end.
|
||||
// If there is no surrogate pair, the iterator
|
||||
// goes back one if needed.
|
||||
if(UTF16.isLeadSurrogate(ch) && !isEnd()) {
|
||||
char surrNextChar = (char)nextChar();
|
||||
if (UTF16.isTrailSurrogate(surrNextChar)) {
|
||||
miss = UCharacterProperty.getRawSupplementary(ch, surrNextChar);
|
||||
} else {
|
||||
previousChar();
|
||||
}
|
||||
}
|
||||
int sCC;
|
||||
if (maxCC == 0 || (sCC = getCombiningClass(miss)) == 0
|
||||
|| sCC > maxCC || (allSame != 0 && sCC == maxCC) ||
|
||||
|
|
|
@ -1134,7 +1134,16 @@ public class CollationRegressionTest extends TestFmwk {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Fixing the infinite loop for surrogates
|
||||
public void Test8484()
|
||||
{
|
||||
String s = "\u9FE1\uCEF3\u2798\uAAB6\uDA7C";
|
||||
Collator coll = Collator.getInstance();
|
||||
CollationKey collKey = coll.getCollationKey(s);
|
||||
logln("Pass: " + collKey.toString() + " generated OK.");
|
||||
}
|
||||
|
||||
/*
|
||||
* Test case for ticket#8624
|
||||
* Bad collation key with upper first option.
|
||||
|
|
Loading…
Add table
Reference in a new issue