From d2f1556246a1570c0b4fa4cea00bdbc80aa566cf Mon Sep 17 00:00:00 2001 From: Syn Wee Quek Date: Thu, 31 Jul 2003 19:51:12 +0000 Subject: [PATCH] ICU-3083 supplementary bug fixed. problem was that a wrong ce was given to estimate the estimated offset. X-SVN-Rev: 12720 --- .../ibm/icu/dev/test/search/SearchTest.java | 33 ++++++++++++++++++- icu4j/src/com/ibm/icu/text/StringSearch.java | 12 +++---- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/icu4j/src/com/ibm/icu/dev/test/search/SearchTest.java b/icu4j/src/com/ibm/icu/dev/test/search/SearchTest.java index 688c9f5f6d2..abdd3058b11 100755 --- a/icu4j/src/com/ibm/icu/dev/test/search/SearchTest.java +++ b/icu4j/src/com/ibm/icu/dev/test/search/SearchTest.java @@ -207,7 +207,23 @@ public class SearchTest extends TestFmwk { SearchData SUPPLEMENTARY[] = { /* 012345678901234567890123456789012345678901234567890012345678901234567890123456789012345678901234567890012345678901234567890123456789 */ new SearchData("abc \uD800\uDC00 \uD800\uDC01 \uD801\uDC00 \uD800\uDC00abc abc\uD800\uDC00 \uD800\uD800\uDC00 \uD800\uDC00\uDC00", - "\uD800\uDC00", null, Collator.TERTIARY, null, new int[] {4, 13, 22, 26, 29, -1}, new int[] {2, 2, 2, 2, 2}), + "\uD800\uDC00", null, Collator.TERTIARY, null, + new int[] {4, 13, 22, 26, 29, -1}, new int[] {2, 2, 2, 2, 2}), + new SearchData("and\uD834\uDDB9this sentence", "\uD834\uDDB9", null, + Collator.TERTIARY, null, new int[] {3, -1}, + new int[] {2}), + new SearchData("and \uD834\uDDB9 this sentence", " \uD834\uDDB9 ", + null, Collator.TERTIARY, null, new int[] {3, -1}, + new int[] {4}), + new SearchData("and-\uD834\uDDB9-this sentence", "-\uD834\uDDB9-", + null, Collator.TERTIARY, null, new int[] {3, -1}, + new int[] {4}), + new SearchData("and,\uD834\uDDB9,this sentence", ",\uD834\uDDB9,", + null, Collator.TERTIARY, null, new int[] {3, -1}, + new int[] {4}), + new SearchData("and?\uD834\uDDB9?this sentence", "?\uD834\uDDB9?", + null, Collator.TERTIARY, null, new int[] {3, -1}, + new int[] {4}), new SearchData(null, null, null, Collator.TERTIARY, null, new int[] {-1}, new int[] {0}) }; @@ -371,6 +387,21 @@ public class SearchTest extends TestFmwk { new SearchData("abc \uD800\uDC00 \uD800\uDC01 \uD801\uDC00 \uD800\uDC00abc abc\uD800\uDC00 \uD800\uD800\uDC00 \uD800\uDC00\uDC00", "\uD800\uDC00", null, Collator.TERTIARY, null, new int[] {4, 13, 22, 26, 29, -1}, new int[] {2, 2, 2, 2, 2}), + new SearchData("and\uD834\uDDB9this sentence", "\uD834\uDDB9", null, + Collator.TERTIARY, null, new int[] {3, -1}, + new int[] {2}), + new SearchData("and \uD834\uDDB9 this sentence", " \uD834\uDDB9 ", + null, Collator.TERTIARY, null, new int[] {3, -1}, + new int[] {4}), + new SearchData("and-\uD834\uDDB9-this sentence", "-\uD834\uDDB9-", + null, Collator.TERTIARY, null, new int[] {3, -1}, + new int[] {4}), + new SearchData("and,\uD834\uDDB9,this sentence", ",\uD834\uDDB9,", + null, Collator.TERTIARY, null, new int[] {3, -1}, + new int[] {4}), + new SearchData("and?\uD834\uDDB9?this sentence", "?\uD834\uDDB9?", + null, Collator.TERTIARY, null, new int[] {3, -1}, + new int[] {4}), new SearchData(null, null, null, Collator.TERTIARY, null, new int[] {-1}, new int[] {0}) }; diff --git a/icu4j/src/com/ibm/icu/text/StringSearch.java b/icu4j/src/com/ibm/icu/text/StringSearch.java index c505843a134..22aff1214bb 100755 --- a/icu4j/src/com/ibm/icu/text/StringSearch.java +++ b/icu4j/src/com/ibm/icu/text/StringSearch.java @@ -5,8 +5,8 @@ ******************************************************************************* * * $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/text/StringSearch.java,v $ - * $Date: 2003/07/03 23:18:37 $ - * $Revision: 1.24 $ + * $Date: 2003/07/31 19:51:12 $ + * $Revision: 1.25 $ * ***************************************************************************************** */ @@ -2796,8 +2796,6 @@ public final class StringSearch extends SearchIterator } } - targetce = lastce; - while (found && patternceindex > 0) { targetce = m_colEIter_.previous(); if (targetce == CollationElementIterator.NULLORDER) { @@ -2814,8 +2812,7 @@ public final class StringSearch extends SearchIterator } if (!found) { - textoffset = shiftForward(textoffset, targetce, - patternceindex); + textoffset = shiftForward(textoffset, lastce, patternceindex); // status checked at loop. patternceindex = m_pattern_.m_CELength_; continue; @@ -2880,7 +2877,6 @@ public final class StringSearch extends SearchIterator break; } } - targetce = lastce; while (found && patternceindex > 0) { targetce = m_colEIter_.previous(); @@ -2903,7 +2899,7 @@ public final class StringSearch extends SearchIterator } if (!found) { - textoffset = shiftForward(textoffset, targetce, patternceindex); + textoffset = shiftForward(textoffset, lastce, patternceindex); // status checked at loop patternceindex = m_pattern_.m_CELength_; continue;