ICU-3087 Fix of &h<H&CH=\u0427

X-SVN-Rev: 12605
This commit is contained in:
Syn Wee Quek 2003-07-09 00:12:44 +00:00
parent 611dd4429a
commit 446189a6ae
2 changed files with 57 additions and 5 deletions

View file

@ -1008,6 +1008,37 @@ public class CollationMiscTest extends TestFmwk{
genericRulesStarter("[backwards 2]&A<<\u00e6/e<<<\u00c6/E", data);
}
public void TestJ3087()
{
String rule[] = {"&h<H&CH=\u0427",
"&CH=\u0427&h<H",
"&CH=\u0427"};
RuleBasedCollator rbc = null;
CollationElementIterator iter1;
CollationElementIterator iter2;
for (int i = 0; i < rule.length; i ++) {
try {
rbc = new RuleBasedCollator(rule[i]);
} catch (Exception e) {
System.out.println(e.getMessage());
}
iter1 = rbc.getCollationElementIterator("CH");
iter2 = rbc.getCollationElementIterator("\u0427");
int ce1 = CollationElementIterator.IGNORABLE;
int ce2 = CollationElementIterator.IGNORABLE;
while (ce1 != CollationElementIterator.NULLORDER
&& ce2 != CollationElementIterator.NULLORDER) {
ce1 = iter1.next();
ce2 = iter2.next();
if (ce1 != ce2) {
errln("Error generating RuleBasedCollator with the rule "
+ rule[i]);
errln("CH != \\u0427");
}
}
}
}
public void TestJ831() {
String[] data = {
"I",

View file

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/CollationParsedRuleBuilder.java,v $
* $Date: 2003/06/03 18:49:33 $
* $Revision: 1.20 $
* $Date: 2003/07/09 00:12:44 $
* $Revision: 1.21 $
*
*******************************************************************************
*/
@ -1495,8 +1495,10 @@ final class CollationParsedRuleBuilder
/**
* @param ceparts list of collation elements parts
* @param token rule token
* @exception Exception thrown when forming case bits for expansions fails
*/
private void doCE(int ceparts[], CollationRuleParser.Token token)
throws Exception
{
// this one makes the table and stuff
// int noofbytes[] = new int[3];
@ -1524,6 +1526,7 @@ final class CollationParsedRuleBuilder
if (cei < m_utilIntBuffer_[1]) {
value |= ((ceparts[1] >> (32 - ((cei + 1) << 3))) & 0xFF) << 8;
}
if (cei < m_utilIntBuffer_[2]) {
value |= ((ceparts[2] >> (32 - ((cei+1) << 3))) & 0x3F);
}
@ -1536,7 +1539,23 @@ final class CollationParsedRuleBuilder
}
else { // there is at least something
token.m_CELength_ = cei;
}
}
// Case bits handling for expansion
int startoftokenrule = token.m_source_ & 0xFF;
if ((token.m_source_ >>> 24) > 1) {
// Do it manually
int length = token.m_source_ >>> 24;
String tokenstr = token.m_rules_.substring(startoftokenrule,
startoftokenrule + length);
token.m_CE_[0] |= getCaseBits(tokenstr);
}
else {
// Copy it from the UCA
int caseCE
= getFirstCE(token.m_rules_.charAt(startoftokenrule));
token.m_CE_[0] |= (caseCE & 0xC0);
}
}
/**
@ -1564,8 +1583,7 @@ final class CollationParsedRuleBuilder
* @exception Exception thrown when internal program error occurs
*/
private void createElements(BuildTable t,
CollationRuleParser.TokenListHeader lh)
throws Exception
CollationRuleParser.TokenListHeader lh)
{
CollationRuleParser.Token tok = lh.m_first_;
m_utilElement_.clear();
@ -1678,6 +1696,8 @@ final class CollationParsedRuleBuilder
break;
}
}
/***
// Case bits handling
m_utilElement_.m_CEs_[0] &= 0xFFFFFF3F;
@ -1694,6 +1714,7 @@ final class CollationParsedRuleBuilder
m_utilElement_.m_CEs_[0] |= (caseCE & 0xC0);
}
***/
// and then, add it
addAnElement(t, m_utilElement_);
tok = tok.m_next_;