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: Ie5a2f402399b51120214a9ce8c8e4f5c249d0160
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3225781
Reviewed-by: Jungshik Shin <[email protected]>
Commit-Queue: Frank Tang <[email protected]>
Cr-Commit-Position: refs/heads/main@{#932782}
NOKEYCHECK=True
GitOrigin-RevId: 1556ec8248fe58e802191662a319c683fe52e3f1
  • Loading branch information
FrankYFTang authored and copybara-github committed Oct 19, 2021
1 parent 1259764 commit 209fad8
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions i18n/string_search.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ RepeatingStringSearch::RepeatingStringSearch(const std::u16string& find_this,
search_ = usearch_open(find_this_.data(), find_this_.size(), in_this_.data(),
in_this_.size(), locale.data(), /*breakiter=*/nullptr,
&status);
DCHECK(status == U_ZERO_ERROR || status == U_USING_FALLBACK_WARNING ||
status == U_USING_DEFAULT_WARNING);
DCHECK(U_SUCCESS(status));
if (U_SUCCESS(status)) {
// http://icu-project.org/apiref/icu4c40/ucol_8h.html#6a967f36248b0a1bc7654f538ee8ba96
// Set comparison level to UCOL_PRIMARY to ignore secondary and tertiary
Expand All @@ -147,7 +146,7 @@ bool RepeatingStringSearch::NextMatchResult(int& match_index,
const int match_start = usearch_next(search_, &status);
if (U_FAILURE(status) || match_start == USEARCH_DONE)
return false;
DCHECK_EQ(U_ZERO_ERROR, status);
DCHECK(U_SUCCESS(status));
match_index = match_start;
match_length = usearch_getMatchedLength(search_);
return true;
Expand Down

0 comments on commit 209fad8

Please sign in to comment.