Skip to content

Commit

Permalink
Test ICU status correctly by using U_SUCCESS
Browse files Browse the repository at this point in the history
This correction is needed for ICU70 which lazy build the
internal break iterator instead of during constructor therefore
shift the return of U_USING_DEFAULT_WARNING in status
from usearch_open() to usearch_next(). Instead of explicitly
check different possible status code the DCHECK should just
use ICU macro U_SUCCESS() instead.

This change is needed to land to unblock the landing of ICU70
which have unicode-org/icu#1473
that shift the returning of U_USING_DEFAULT_WARNING in status.

Bug: 1260116
Change-Id: Ic1ed3dccc5d95e3fd1804321dc98fbe7255cff4d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3225401
Commit-Queue: Kent Tamura <[email protected]>
Commit-Queue: Frank Tang <[email protected]>
Reviewed-by: Kent Tamura <[email protected]>
Cr-Commit-Position: refs/heads/main@{#931923}
NOKEYCHECK=True
GitOrigin-RevId: 1bc5bb4ba6c7922ad7dd57bd57cb5644c6efccd8
  • Loading branch information
FrankYFTang authored and copybara-github committed Oct 15, 2021
1 parent bc0dc55 commit 60ca560
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions blink/renderer/core/editing/iterators/text_searcher_icu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ UStringSearch* CreateSearcher() {
UStringSearch* searcher =
usearch_open(&kNewlineCharacter, 1, &kNewlineCharacter, 1,
search_collator_name.Utf8().c_str(), nullptr, &status);
DCHECK(status == U_ZERO_ERROR || status == U_USING_FALLBACK_WARNING ||
status == U_USING_DEFAULT_WARNING)
<< status;
DCHECK(U_SUCCESS(status)) << status;
return searcher;
}

Expand Down Expand Up @@ -177,7 +175,7 @@ bool TextSearcherICU::NextMatchResult(MatchResultICU& result) {
bool TextSearcherICU::NextMatchResultInternal(MatchResultICU& result) {
UErrorCode status = U_ZERO_ERROR;
const int match_start = usearch_next(searcher_, &status);
DCHECK_EQ(status, U_ZERO_ERROR);
DCHECK(U_SUCCESS(status));

// TODO(iceman): It is possible to use |usearch_getText| function
// to retrieve text length and not store it explicitly.
Expand Down Expand Up @@ -228,7 +226,7 @@ bool TextSearcherICU::IsCorrectKanaMatch(const UChar* text,
void TextSearcherICU::SetPattern(const UChar* pattern, wtf_size_t length) {
UErrorCode status = U_ZERO_ERROR;
usearch_setPattern(searcher_, pattern, length, &status);
DCHECK_EQ(status, U_ZERO_ERROR);
DCHECK(U_SUCCESS(status));
}

void TextSearcherICU::SetCaseSensitivity(bool case_sensitive) {
Expand Down

0 comments on commit 60ca560

Please sign in to comment.