Skip to content

Commit

Permalink
Prepare for landing ICU68
Browse files Browse the repository at this point in the history
In the landing process of ICU68 we found these need to be changed
since ICU68 no longer define TRUE and FALSE for UBool to
avoid C++20 problem.

Bug: 1138555
Change-Id: I64fd98c99864aa86b07280537a780105cb0eabbe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2473522
Reviewed-by: Frank Tang <ftang@chromium.org>
Reviewed-by: Colin Blundell <blundell@chromium.org>
Reviewed-by: Dominic Battré <battre@chromium.org>
Reviewed-by: Guillaume Jenkins <gujen@google.com>
Reviewed-by: Jungshik Shin <jshin@chromium.org>
Reviewed-by: Mihai Sardarescu <msarda@chromium.org>
Reviewed-by: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: Mustafa Emre Acer <meacer@chromium.org>
Reviewed-by: Marian Fechete <marianfe@google.com>
Reviewed-by: Matthew Denton <mpdenton@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818713}
  • Loading branch information
FrankYFTang authored and Commit Bot committed Oct 20, 2020
1 parent 9579753 commit 4d16e52
Show file tree
Hide file tree
Showing 17 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion base/i18n/icu_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ void InitializeIcuTimeZone() {
// https://ssl.icu-project.org/trac/ticket/13208 .
string16 zone_id = android::GetDefaultTimeZoneId();
icu::TimeZone::adoptDefault(icu::TimeZone::createTimeZone(
icu::UnicodeString(FALSE, zone_id.data(), zone_id.length())));
icu::UnicodeString(false, zone_id.data(), zone_id.length())));
#elif defined(OS_FUCHSIA)
// The platform-specific mechanisms used by ICU's detectHostTimeZone() to
// determine the default time zone will not work on Fuchsia. Therefore,
Expand Down
4 changes: 2 additions & 2 deletions base/i18n/string_compare.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ UCollationResult CompareString16WithCollator(const icu::Collator& collator,
StringPiece16 rhs) {
UErrorCode error = U_ZERO_ERROR;
UCollationResult result = collator.compare(
icu::UnicodeString(FALSE, lhs.data(), static_cast<int>(lhs.length())),
icu::UnicodeString(FALSE, rhs.data(), static_cast<int>(rhs.length())),
icu::UnicodeString(false, lhs.data(), static_cast<int>(lhs.length())),
icu::UnicodeString(false, rhs.data(), static_cast<int>(rhs.length())),
error);
DCHECK(U_SUCCESS(error));
return result;
Expand Down
2 changes: 1 addition & 1 deletion base/i18n/time_formatting.cc
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ bool TimeDurationFormatWithSeconds(const TimeDelta time,
icu::FieldPosition ignore(icu::FieldPosition::DONT_CARE);
measure_format.formatMeasures(measures, 3, formatted, ignore, status);
*out = i18n::UnicodeStringToString16(formatted);
return U_SUCCESS(status) == TRUE;
return U_SUCCESS(status);
}

string16 DateIntervalFormat(const Time& begin_time,
Expand Down
8 changes: 4 additions & 4 deletions components/autofill/core/common/autofill_regexes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class AutofillRegexes {
icu::RegexMatcher* AutofillRegexes::GetMatcher(const base::string16& pattern) {
auto it = matchers_.find(pattern);
if (it == matchers_.end()) {
const icu::UnicodeString icu_pattern(FALSE, pattern.data(),
const icu::UnicodeString icu_pattern(false, pattern.data(),
pattern.length());

UErrorCode status = U_ZERO_ERROR;
Expand Down Expand Up @@ -71,21 +71,21 @@ bool MatchesPattern(const base::string16& input,
base::AutoLock lock(*g_lock);

icu::RegexMatcher* matcher = g_autofill_regexes->GetMatcher(pattern);
icu::UnicodeString icu_input(FALSE, input.data(), input.length());
icu::UnicodeString icu_input(false, input.data(), input.length());
matcher->reset(icu_input);

UErrorCode status = U_ZERO_ERROR;
UBool matched = matcher->find(0, status);
DCHECK(U_SUCCESS(status));

if (matched == TRUE && match) {
if (matched && match) {
icu::UnicodeString match_unicode =
matcher->group(group_to_be_captured, status);
DCHECK(U_SUCCESS(status));
*match = base::i18n::UnicodeStringToString16(match_unicode);
}

return matched == TRUE;
return matched;
}

} // namespace autofill
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ bool UnicodeToUTF8(const std::vector<UChar32>& source, std::string* target) {
// |target|.
bool AppendUnicodeToUTF8(const UChar32 source, std::string* target) {
char bytes[4];
UBool error = FALSE;
UBool error = false;
size_t offset = 0;
U8_APPEND(bytes, offset, base::size(bytes), source, error);
if (error == FALSE) {
if (error == false) {
target->append(bytes, offset);
}
return error == FALSE;
return !error;
}

} // namespace autofill_assistant
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ bool IsUsernameAllowedByPattern(base::StringPiece username,

// See if the username matches the policy-provided pattern.
UErrorCode status = U_ZERO_ERROR;
const icu::UnicodeString icu_pattern(FALSE, utf16_pattern.data(),
const icu::UnicodeString icu_pattern(false, utf16_pattern.data(),
utf16_pattern.length());
icu::RegexMatcher matcher(icu_pattern, UREGEX_CASE_INSENSITIVE, status);
if (!U_SUCCESS(status)) {
Expand Down
2 changes: 1 addition & 1 deletion components/spellcheck/renderer/spellcheck_worditerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ bool SpellcheckWordIterator::Normalize(size_t input_start,
// spellchecker and we need manual normalization as well. The normalized
// text does not have to be NUL-terminated since its characters are copied to
// string16, which adds a NUL character when we need.
icu::UnicodeString input(FALSE, &text_[input_start],
icu::UnicodeString input(false, &text_[input_start],
base::checked_cast<int32_t>(input_length));
UErrorCode status = U_ZERO_ERROR;
icu::UnicodeString output;
Expand Down
4 changes: 2 additions & 2 deletions components/url_formatter/spoof_checks/idn_spoof_checker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ IDNSpoofChecker::Result IDNSpoofChecker::SafeToDisplayAsUnicode(
return Result::kICUSpoofChecks;
}

icu::UnicodeString label_string(FALSE /* isTerminated */, label.data(),
icu::UnicodeString label_string(false /* isTerminated */, label.data(),
base::checked_cast<int32_t>(label.size()));

// A punycode label with 'xn--' prefix is not subject to the URL
Expand Down Expand Up @@ -711,7 +711,7 @@ bool IDNSpoofChecker::IsWholeScriptConfusableAllowedForTLD(
base::StringPiece tld,
base::StringPiece16 tld_unicode) {
icu::UnicodeString tld_string(
FALSE /* isTerminated */, tld_unicode.data(),
false /* isTerminated */, tld_unicode.data(),
base::checked_cast<int32_t>(tld_unicode.size()));
// Allow if the TLD contains any letter from the script, in which case it's
// likely to be a TLD in that script.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ SkeletonGenerator::~SkeletonGenerator() = default;
Skeletons SkeletonGenerator::GetSkeletons(base::StringPiece16 hostname) {
Skeletons skeletons;
size_t hostname_length = hostname.length() - (hostname.back() == '.' ? 1 : 0);
icu::UnicodeString host(FALSE, hostname.data(), hostname_length);
icu::UnicodeString host(false, hostname.data(), hostname_length);
// If input has any characters outside Latin-Greek-Cyrillic and [0-9._-],
// there is no point in getting rid of diacritics because combining marks
// attached to non-LGC characters are already blocked.
Expand Down
2 changes: 1 addition & 1 deletion content/zygote/zygote_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ base::ProcessId Zygote::ReadArgsAndFork(base::PickleIterator iter,
if (!iter.ReadString16(&timezone_id))
return -1;
icu::TimeZone::adoptDefault(icu::TimeZone::createTimeZone(
icu::UnicodeString(FALSE, timezone_id.data(), timezone_id.length())));
icu::UnicodeString(false, timezone_id.data(), timezone_id.length())));

if (!iter.ReadInt(&numfds))
return -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void TimeZoneMonitorAndroid::TimeZoneChangedFromJava(
// See base/i18n/icu_util.cc:InitializeIcuTimeZone() for more information.
base::string16 zone_id = base::android::GetDefaultTimeZoneId();
std::unique_ptr<icu::TimeZone> new_zone(icu::TimeZone::createTimeZone(
icu::UnicodeString(FALSE, zone_id.data(), zone_id.length())));
icu::UnicodeString(false, zone_id.data(), zone_id.length())));
UpdateIcuAndNotifyClients(std::move(new_zone));
}

Expand Down
12 changes: 6 additions & 6 deletions third_party/blink/renderer/core/exported/web_view_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4868,18 +4868,18 @@ TEST_F(ShowUnhandledTapTest, ShowUnhandledTapUIIfNeeded) {

TEST_F(ShowUnhandledTapTest, ShowUnhandledTapUIIfNeededWithMutateDom) {
// Test dom mutation.
TestEachMouseEvent("mutateDom", FALSE);
TestEachMouseEvent("mutateDom", false);

// Test without any DOM mutation.
TestEachMouseEvent("none", TRUE);
TestEachMouseEvent("none", true);
}

TEST_F(ShowUnhandledTapTest, ShowUnhandledTapUIIfNeededWithMutateStyle) {
// Test style mutation.
TestEachMouseEvent("mutateStyle", FALSE);
TestEachMouseEvent("mutateStyle", false);

// Test checkbox:indeterminate style mutation.
TestEachMouseEvent("mutateIndeterminate", FALSE);
TestEachMouseEvent("mutateIndeterminate", false);

// Test click div with :active style.
Tap("style_active");
Expand All @@ -4888,10 +4888,10 @@ TEST_F(ShowUnhandledTapTest, ShowUnhandledTapUIIfNeededWithMutateStyle) {

TEST_F(ShowUnhandledTapTest, ShowUnhandledTapUIIfNeededWithPreventDefault) {
// Test swallowing.
TestEachMouseEvent("preventDefault", FALSE);
TestEachMouseEvent("preventDefault", false);

// Test without any preventDefault.
TestEachMouseEvent("none", TRUE);
TestEachMouseEvent("none", true);
}

TEST_F(ShowUnhandledTapTest, ShowUnhandledTapUIIfNeededWithNonTriggeringNodes) {
Expand Down
4 changes: 2 additions & 2 deletions third_party/blink/renderer/platform/text/locale_icu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@ static String GetDateFormatPattern(const UDateFormat* date_format) {
return g_empty_string;

UErrorCode status = U_ZERO_ERROR;
int32_t length = udat_toPattern(date_format, TRUE, nullptr, 0, &status);
int32_t length = udat_toPattern(date_format, true, nullptr, 0, &status);
if (status != U_BUFFER_OVERFLOW_ERROR || !length)
return g_empty_string;
StringBuffer<UChar> buffer(length);
status = U_ZERO_ERROR;
udat_toPattern(date_format, TRUE, buffer.Characters(), length, &status);
udat_toPattern(date_format, true, buffer.Characters(), length, &status);
if (U_FAILURE(status))
return g_empty_string;
return String::Adopt(buffer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,13 @@ static inline bool TextInChunkOrOutOfRange(UText* text,
text->chunkOffset = offset <= std::numeric_limits<int32_t>::max()
? static_cast<int32_t>(offset)
: 0;
is_accessible = TRUE;
is_accessible = true;
return true;
}
if (native_index >= native_length &&
text->chunkNativeLimit == native_length) {
text->chunkOffset = text->chunkLength;
is_accessible = FALSE;
is_accessible = false;
return true;
}
} else {
Expand All @@ -331,12 +331,12 @@ static inline bool TextInChunkOrOutOfRange(UText* text,
text->chunkOffset = offset <= std::numeric_limits<int32_t>::max()
? static_cast<int32_t>(offset)
: 0;
is_accessible = TRUE;
is_accessible = true;
return true;
}
if (native_index <= 0 && !text->chunkNativeStart) {
text->chunkOffset = 0;
is_accessible = FALSE;
is_accessible = false;
return true;
}
}
Expand All @@ -347,7 +347,7 @@ static UBool TextLatin1Access(UText* text,
int64_t native_index,
UBool forward) {
if (!text->context)
return FALSE;
return false;
int64_t native_length = TextNativeLength(text);
UBool is_accessible;
if (TextInChunkOrOutOfRange(text, native_index, native_length, forward,
Expand All @@ -371,7 +371,7 @@ static UBool TextLatin1Access(UText* text,
DCHECK_EQ(new_context, kPriorContext);
TextLatin1SwitchToPriorContext(text, native_index, native_length, forward);
}
return TRUE;
return true;
}

static const struct UTextFuncs kTextLatin1Funcs = {
Expand Down Expand Up @@ -511,7 +511,7 @@ static void TextUTF16SwitchToPriorContext(UText* text,

static UBool TextUTF16Access(UText* text, int64_t native_index, UBool forward) {
if (!text->context)
return FALSE;
return false;
int64_t native_length = TextNativeLength(text);
UBool is_accessible;
if (TextInChunkOrOutOfRange(text, native_index, native_length, forward,
Expand All @@ -533,7 +533,7 @@ static UBool TextUTF16Access(UText* text, int64_t native_index, UBool forward) {
DCHECK_EQ(new_context, kPriorContext);
TextUTF16SwitchToPriorContext(text, native_index, native_length, forward);
}
return TRUE;
return true;
}

static const struct UTextFuncs kTextUTF16Funcs = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ void NormalizeCharactersIntoNFCForm(const UChar* characters,
DCHECK(U_SUCCESS(status));
int32_t input_length = static_cast<int32_t>(length);
// copy-on-write.
icu::UnicodeString normalized(FALSE, characters, input_length);
icu::UnicodeString normalized(false, characters, input_length);
// In the vast majority of cases, input is already NFC. Run a quick check
// to avoid normalizing the entire input unnecessarily.
int32_t normalized_prefix_length =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ void TextCodecICU::CreateICUConverter() const {
DLOG_IF(ERROR, err == U_AMBIGUOUS_ALIAS_WARNING)
<< "ICU ambiguous alias warning for encoding: " << encoding_.GetName();
if (converter_icu_)
ucnv_setFallback(converter_icu_, TRUE);
ucnv_setFallback(converter_icu_, true);
}

int TextCodecICU::DecodeToBuffer(UChar* target,
Expand Down
6 changes: 3 additions & 3 deletions ui/base/l10n/formatter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ void Formatter::Format(Unit unit,
int value,
icu::UnicodeString* formatted_string) const {
DCHECK(simple_format_[unit]);
DCHECK(formatted_string->isEmpty() == TRUE);
DCHECK(formatted_string->isEmpty());
UErrorCode error = U_ZERO_ERROR;
FormatNumberInPlural(*simple_format_[unit],
value, formatted_string, &error);
Expand All @@ -250,7 +250,7 @@ void Formatter::Format(TwoUnits units,
<< "Detailed() not implemented for your (format, length) combination!";
DCHECK(detailed_format_[units][1])
<< "Detailed() not implemented for your (format, length) combination!";
DCHECK(formatted_string->isEmpty() == TRUE);
DCHECK(formatted_string->isEmpty());
UErrorCode error = U_ZERO_ERROR;
FormatNumberInPlural(*detailed_format_[units][0], value_1,
formatted_string, &error);
Expand Down Expand Up @@ -283,7 +283,7 @@ std::unique_ptr<icu::MessageFormat> Formatter::InitFormat(
base::string16 pattern = l10n_util::GetStringUTF16(pluralities.id);
UErrorCode error = U_ZERO_ERROR;
std::unique_ptr<icu::MessageFormat> format(new icu::MessageFormat(
icu::UnicodeString(FALSE, pattern.data(), pattern.length()), error));
icu::UnicodeString(false, pattern.data(), pattern.length()), error));
DCHECK(U_SUCCESS(error));
if (format.get())
return format;
Expand Down

0 comments on commit 4d16e52

Please sign in to comment.