From 3543ed2f3c5d3bf6e36e8456539f2d25343d4a52 Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Thu, 17 Jun 2021 16:10:14 -0400 Subject: [PATCH] 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 https://github.com/nodejs/node/pull/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] https://github.com/v8/v8/commit/611e412768a7bc87a20d0315635b0bf76a5bab46 [2] https://github.com/v8/v8/commit/eeccedee1882f1f870b37d12978cd818934b375d PR-URL: https://github.com/nodejs/node/pull/39068 Reviewed-By: Michael Dawson Reviewed-By: Colin Ihrig Reviewed-By: Beth Griggs --- deps/v8/src/objects/js-list-format.cc | 51 +++++++++++++++++++++++++++ tools/icu/icu_versions.json | 2 +- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/deps/v8/src/objects/js-list-format.cc b/deps/v8/src/objects/js-list-format.cc index 0cd7d1bb6b58bb..2294a6f77499b2 100644 --- a/deps/v8/src/objects/js-list-format.cc +++ b/deps/v8/src/objects/js-list-format.cc @@ -24,12 +24,58 @@ #include "unicode/fpositer.h" #include "unicode/listformatter.h" #include "unicode/ulistformatter.h" +#include "unicode/uvernum.h" namespace v8 { namespace internal { namespace { +#if U_ICU_VERSION_MAJOR_NUM < 67 +const char* kStandard = "standard"; +const char* kOr = "or"; +const char* kUnit = "unit"; +const char* kStandardShort = "standard-short"; +const char* kOrShort = "or-short"; +const char* kUnitShort = "unit-short"; +const char* kStandardNarrow = "standard-narrow"; +const char* kOrNarrow = "or-narrow"; +const char* kUnitNarrow = "unit-narrow"; + +const char* GetIcuStyleString(JSListFormat::Style style, + JSListFormat::Type type) { + switch (type) { + case JSListFormat::Type::CONJUNCTION: + switch (style) { + case JSListFormat::Style::LONG: + return kStandard; + case JSListFormat::Style::SHORT: + return kStandardShort; + case JSListFormat::Style::NARROW: + return kStandardNarrow; + } + case JSListFormat::Type::DISJUNCTION: + switch (style) { + case JSListFormat::Style::LONG: + return kOr; + case JSListFormat::Style::SHORT: + return kOrShort; + case JSListFormat::Style::NARROW: + return kOrNarrow; + } + case JSListFormat::Type::UNIT: + switch (style) { + case JSListFormat::Style::LONG: + return kUnit; + case JSListFormat::Style::SHORT: + return kUnitShort; + case JSListFormat::Style::NARROW: + return kUnitNarrow; + } + } + UNREACHABLE(); +} +#else UListFormatterWidth GetIcuWidth(JSListFormat::Style style) { switch (style) { case JSListFormat::Style::LONG: @@ -53,6 +99,7 @@ UListFormatterType GetIcuType(JSListFormat::Type type) { } UNREACHABLE(); } +#endif } // namespace @@ -124,7 +171,11 @@ MaybeHandle JSListFormat::New(Isolate* isolate, Handle 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 < 67 + icu_locale, GetIcuStyleString(style_enum, type_enum), status); +#else icu_locale, GetIcuType(type_enum), GetIcuWidth(style_enum), status); +#endif if (U_FAILURE(status) || formatter == nullptr) { delete formatter; THROW_NEW_ERROR(isolate, NewRangeError(MessageTemplate::kIcuError), diff --git a/tools/icu/icu_versions.json b/tools/icu/icu_versions.json index 19a05a679a987b..a14ea6db2887ae 100644 --- a/tools/icu/icu_versions.json +++ b/tools/icu/icu_versions.json @@ -1,3 +1,3 @@ { - "minimum_icu": 67 + "minimum_icu": 65 }