From: Peter Edberg Date: Wed, 9 Sep 2015 03:55:20 +0000 (+0000) Subject: ICU-11786 Terminate internalNext/Prev when we reach text limit, not just at UBRK_DONE... X-Git-Tag: milestone-59-0-1~907 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e4d76d4125b8eaf61491f1454de9da9d52f51775;p=icu ICU-11786 Terminate internalNext/Prev when we reach text limit, not just at UBRK_DONE, so more tests for #11770 can pass X-SVN-Rev: 37913 --- diff --git a/icu4c/source/common/filteredbrk.cpp b/icu4c/source/common/filteredbrk.cpp index 35c08715349..391f52b5fd4 100644 --- a/icu4c/source/common/filteredbrk.cpp +++ b/icu4c/source/common/filteredbrk.cpp @@ -342,9 +342,10 @@ SimpleFilteredSentenceBreakIterator::internalNext(int32_t n) { // refresh text resetState(status); if(U_FAILURE(status)) return UBRK_DONE; // bail out + int64_t utextLen = utext_nativeLength(fText.getAlias()); //if(debug2) u_printf("str, native len=%d\n", utext_nativeLength(fText.getAlias())); - while (n != UBRK_DONE) { // outer loop runs once per underlying break (from fDelegate). + while (n != UBRK_DONE && n != utextLen) { // outer loop runs once per underlying break (from fDelegate). SimpleFilteredSentenceBreakIterator::EFBMatchResult m = breakExceptionAt(n); switch(m) { @@ -373,7 +374,7 @@ SimpleFilteredSentenceBreakIterator::internalPrev(int32_t n) { if(U_FAILURE(status)) return UBRK_DONE; // bail out //if(debug2) u_printf("str, native len=%d\n", utext_nativeLength(fText.getAlias())); - while (n != UBRK_DONE) { // outer loop runs once per underlying break (from fDelegate). + while (n != UBRK_DONE && n != 0) { // outer loop runs once per underlying break (from fDelegate). SimpleFilteredSentenceBreakIterator::EFBMatchResult m = breakExceptionAt(n); switch(m) {