Skip to content

Commit 1b7af5b

Browse files
richardlauguybedford
authored andcommitted
deps: restore minimum ICU version to 65
This modifies 40df0dc so that the changes it applies are only used if ICU 67 or greater is used, and restores the previous code path for versions of ICU below 67. The minimum ICU version was bumped to 67 in Node.js 14.6.0 by #34356 but the referenced V8 commit[1] isn't on `v14.x-staging` and appears to have been reverted on V8 8.4[2] so this PR also restores the minimum ICU version to 65. [1] v8/v8@611e412 [2] v8/v8@eeccede PR-URL: #39068 Backport-PR-URL: #39451 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Beth Griggs <[email protected]>
1 parent 99f3b73 commit 1b7af5b

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

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

+51
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,58 @@
2424
#include "unicode/fpositer.h"
2525
#include "unicode/listformatter.h"
2626
#include "unicode/ulistformatter.h"
27+
#include "unicode/uvernum.h"
2728

2829
namespace v8 {
2930
namespace internal {
3031

3132
namespace {
3233

34+
#if U_ICU_VERSION_MAJOR_NUM < 67
35+
const char* kStandard = "standard";
36+
const char* kOr = "or";
37+
const char* kUnit = "unit";
38+
const char* kStandardShort = "standard-short";
39+
const char* kOrShort = "or-short";
40+
const char* kUnitShort = "unit-short";
41+
const char* kStandardNarrow = "standard-narrow";
42+
const char* kOrNarrow = "or-narrow";
43+
const char* kUnitNarrow = "unit-narrow";
44+
45+
const char* GetIcuStyleString(JSListFormat::Style style,
46+
JSListFormat::Type type) {
47+
switch (type) {
48+
case JSListFormat::Type::CONJUNCTION:
49+
switch (style) {
50+
case JSListFormat::Style::LONG:
51+
return kStandard;
52+
case JSListFormat::Style::SHORT:
53+
return kStandardShort;
54+
case JSListFormat::Style::NARROW:
55+
return kStandardNarrow;
56+
}
57+
case JSListFormat::Type::DISJUNCTION:
58+
switch (style) {
59+
case JSListFormat::Style::LONG:
60+
return kOr;
61+
case JSListFormat::Style::SHORT:
62+
return kOrShort;
63+
case JSListFormat::Style::NARROW:
64+
return kOrNarrow;
65+
}
66+
case JSListFormat::Type::UNIT:
67+
switch (style) {
68+
case JSListFormat::Style::LONG:
69+
return kUnit;
70+
case JSListFormat::Style::SHORT:
71+
return kUnitShort;
72+
case JSListFormat::Style::NARROW:
73+
return kUnitNarrow;
74+
}
75+
}
76+
UNREACHABLE();
77+
}
78+
#else
3379
UListFormatterWidth GetIcuWidth(JSListFormat::Style style) {
3480
switch (style) {
3581
case JSListFormat::Style::LONG:
@@ -53,6 +99,7 @@ UListFormatterType GetIcuType(JSListFormat::Type type) {
5399
}
54100
UNREACHABLE();
55101
}
102+
#endif
56103

57104
} // namespace
58105

@@ -151,7 +198,11 @@ MaybeHandle<JSListFormat> JSListFormat::New(Isolate* isolate, Handle<Map> map,
151198
icu::Locale icu_locale = r.icu_locale;
152199
UErrorCode status = U_ZERO_ERROR;
153200
icu::ListFormatter* formatter = icu::ListFormatter::createInstance(
201+
#if U_ICU_VERSION_MAJOR_NUM < 67
202+
icu_locale, GetIcuStyleString(style_enum, type_enum), status);
203+
#else
154204
icu_locale, GetIcuType(type_enum), GetIcuWidth(style_enum), status);
205+
#endif
155206
if (U_FAILURE(status)) {
156207
delete formatter;
157208
FATAL("Failed to create ICU list formatter, are ICU data files missing?");

0 commit comments

Comments
 (0)