Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v12.x] Fix build with ICU >= 68. #39440

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions deps/v8/src/objects/js-list-format.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ namespace v8 {
namespace internal {

namespace {
#if U_ICU_VERSION_MAJOR_NUM < 68
const char* kStandard = "standard";
const char* kOr = "or";
const char* kUnit = "unit";
Expand All @@ -41,8 +42,24 @@ const char* kUnitNarrow = "unit-narrow";

const char* GetIcuStyleString(JSListFormat::Style style,
JSListFormat::Type type) {
#else
UListFormatterWidth GetIcuWidth(JSListFormat::Style style) {
switch (style) {
case JSListFormat::Style::LONG:
return ULISTFMT_WIDTH_WIDE;
case JSListFormat::Style::SHORT:
return ULISTFMT_WIDTH_SHORT;
case JSListFormat::Style::NARROW:
return ULISTFMT_WIDTH_NARROW;
}
UNREACHABLE();
}

UListFormatterType GetIcuType(JSListFormat::Type type) {
#endif
switch (type) {
case JSListFormat::Type::CONJUNCTION:
#if U_ICU_VERSION_MAJOR_NUM < 68
switch (style) {
case JSListFormat::Style::LONG:
return kStandard;
Expand All @@ -51,7 +68,11 @@ const char* GetIcuStyleString(JSListFormat::Style style,
case JSListFormat::Style::NARROW:
return kStandardNarrow;
}
#else
return ULISTFMT_TYPE_AND;
#endif
case JSListFormat::Type::DISJUNCTION:
#if U_ICU_VERSION_MAJOR_NUM < 68
switch (style) {
case JSListFormat::Style::LONG:
return kOr;
Expand All @@ -60,7 +81,11 @@ const char* GetIcuStyleString(JSListFormat::Style style,
case JSListFormat::Style::NARROW:
return kOrNarrow;
}
#else
return ULISTFMT_TYPE_OR;
#endif
case JSListFormat::Type::UNIT:
#if U_ICU_VERSION_MAJOR_NUM < 68
switch (style) {
case JSListFormat::Style::LONG:
return kUnit;
Expand All @@ -69,6 +94,9 @@ const char* GetIcuStyleString(JSListFormat::Style style,
case JSListFormat::Style::NARROW:
return kUnitNarrow;
}
#else
return ULISTFMT_TYPE_UNITS;
#endif
}
UNREACHABLE();
}
Expand Down Expand Up @@ -170,7 +198,11 @@ MaybeHandle<JSListFormat> JSListFormat::New(Isolate* isolate, Handle<Map> map,
icu::Locale icu_locale = r.icu_locale;
UErrorCode status = U_ZERO_ERROR;
icu::ListFormatter* formatter = icu::ListFormatter::createInstance(
#if U_ICU_VERSION_MAJOR_NUM < 68
icu_locale, GetIcuStyleString(style_enum, type_enum), status);
#else
icu_locale, GetIcuType(type_enum), GetIcuWidth(style_enum), status);
#endif
if (U_FAILURE(status)) {
delete formatter;
FATAL("Failed to create ICU list formatter, are ICU data files missing?");
Expand Down