Skip to content

Commit 34a9207

Browse files
jameshilliardrichardlau
authored andcommitted
Fix build with ICU >= 68.
Adapted from: https://chromium-review.googlesource.com/c/v8/v8/+/2477751 Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
1 parent 8a9f949 commit 34a9207

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

deps/v8/src/objects/js-list-format.cc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ namespace v8 {
2929
namespace internal {
3030

3131
namespace {
32+
#if U_ICU_VERSION_MAJOR_NUM < 68
3233
const char* kStandard = "standard";
3334
const char* kOr = "or";
3435
const char* kUnit = "unit";
@@ -41,8 +42,24 @@ const char* kUnitNarrow = "unit-narrow";
4142

4243
const char* GetIcuStyleString(JSListFormat::Style style,
4344
JSListFormat::Type type) {
45+
#else
46+
UListFormatterWidth GetIcuWidth(JSListFormat::Style style) {
47+
switch (style) {
48+
case JSListFormat::Style::LONG:
49+
return ULISTFMT_WIDTH_WIDE;
50+
case JSListFormat::Style::SHORT:
51+
return ULISTFMT_WIDTH_SHORT;
52+
case JSListFormat::Style::NARROW:
53+
return ULISTFMT_WIDTH_NARROW;
54+
}
55+
UNREACHABLE();
56+
}
57+
58+
UListFormatterType GetIcuType(JSListFormat::Type type) {
59+
#endif
4460
switch (type) {
4561
case JSListFormat::Type::CONJUNCTION:
62+
#if U_ICU_VERSION_MAJOR_NUM < 68
4663
switch (style) {
4764
case JSListFormat::Style::LONG:
4865
return kStandard;
@@ -51,7 +68,11 @@ const char* GetIcuStyleString(JSListFormat::Style style,
5168
case JSListFormat::Style::NARROW:
5269
return kStandardNarrow;
5370
}
71+
#else
72+
return ULISTFMT_TYPE_AND;
73+
#endif
5474
case JSListFormat::Type::DISJUNCTION:
75+
#if U_ICU_VERSION_MAJOR_NUM < 68
5576
switch (style) {
5677
case JSListFormat::Style::LONG:
5778
return kOr;
@@ -60,7 +81,11 @@ const char* GetIcuStyleString(JSListFormat::Style style,
6081
case JSListFormat::Style::NARROW:
6182
return kOrNarrow;
6283
}
84+
#else
85+
return ULISTFMT_TYPE_OR;
86+
#endif
6387
case JSListFormat::Type::UNIT:
88+
#if U_ICU_VERSION_MAJOR_NUM < 68
6489
switch (style) {
6590
case JSListFormat::Style::LONG:
6691
return kUnit;
@@ -69,6 +94,9 @@ const char* GetIcuStyleString(JSListFormat::Style style,
6994
case JSListFormat::Style::NARROW:
7095
return kUnitNarrow;
7196
}
97+
#else
98+
return ULISTFMT_TYPE_UNITS;
99+
#endif
72100
}
73101
UNREACHABLE();
74102
}
@@ -170,7 +198,11 @@ MaybeHandle<JSListFormat> JSListFormat::New(Isolate* isolate, Handle<Map> map,
170198
icu::Locale icu_locale = r.icu_locale;
171199
UErrorCode status = U_ZERO_ERROR;
172200
icu::ListFormatter* formatter = icu::ListFormatter::createInstance(
201+
#if U_ICU_VERSION_MAJOR_NUM < 68
173202
icu_locale, GetIcuStyleString(style_enum, type_enum), status);
203+
#else
204+
icu_locale, GetIcuType(type_enum), GetIcuWidth(style_enum), status);
205+
#endif
174206
if (U_FAILURE(status)) {
175207
delete formatter;
176208
FATAL("Failed to create ICU list formatter, are ICU data files missing?");

0 commit comments

Comments
 (0)