Skip to content

Commit

Permalink
deps: V8: cherry-pick b0a7f5691113
Browse files Browse the repository at this point in the history
Original commit message:

    Update to ICU68-1

    ICU68-1 change the output skeleton format. So we need to change
    resolvedOptions code for 68 migration.

    Chromium roll
    https://chromium-review.googlesource.com/c/chromium/src/+/2474093

    Bug: v8:10945
    Change-Id: I3b2c7fbe8abb22df8fa51287c498ca3245b8c55b
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2477431
    Commit-Queue: Frank Tang <[email protected]>
    Reviewed-by: Jakob Kummerow <[email protected]>
    Reviewed-by: Shu-yu Guo <[email protected]>
    Cr-Commit-Position: refs/heads/master@{#70972}

Refs: v8/v8@b0a7f56

PR-URL: #39051
Fixes: #39050
Reviewed-By: Jiawen Geng <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
  • Loading branch information
targos authored and richardlau committed Jul 20, 2021
1 parent e3223ed commit 9b69069
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 53 deletions.
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
'v8_embedder_string': '-node.73',
'v8_embedder_string': '-node.74',

##### V8 defaults for Node.js #####

Expand Down
2 changes: 1 addition & 1 deletion deps/v8/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ deps = {
'v8/third_party/depot_tools':
Var('chromium_url') + '/chromium/tools/depot_tools.git' + '@' + 'd4e6fb6573e0955110a2c69be29557f6626d9ae6',
'v8/third_party/icu':
Var('chromium_url') + '/chromium/deps/icu.git' + '@' + 'f2223961702f00a8833874b0560d615a2cc42738',
Var('chromium_url') + '/chromium/deps/icu.git' + '@' + 'c2a4cae149aae7fd30c4cbe3cf1b30df03b386f1',
'v8/third_party/instrumented_libraries':
Var('chromium_url') + '/chromium/src/third_party/instrumented_libraries.git' + '@' + 'bb3f1802c237dd19105dd0f7919f99e536a39d10',
'v8/buildtools':
Expand Down
80 changes: 30 additions & 50 deletions deps/v8/src/objects/js-number-format.cc
Original file line number Diff line number Diff line change
Expand Up @@ -389,17 +389,17 @@ Handle<String> CurrencySignString(Isolate* isolate,
Handle<String> UnitDisplayString(Isolate* isolate,
const icu::UnicodeString& skeleton) {
// Ex: skeleton as
// "measure-unit/length-meter .### rounding-mode-half-up unit-width-full-name"
// "unit/length-meter .### rounding-mode-half-up unit-width-full-name"
if (skeleton.indexOf("unit-width-full-name") >= 0) {
return ReadOnlyRoots(isolate).long_string_handle();
}
// Ex: skeleton as
// "measure-unit/length-meter .### rounding-mode-half-up unit-width-narrow".
// "unit/length-meter .### rounding-mode-half-up unit-width-narrow".
if (skeleton.indexOf("unit-width-narrow") >= 0) {
return ReadOnlyRoots(isolate).narrow_string_handle();
}
// Ex: skeleton as
// "measure-unit/length-foot .### rounding-mode-half-up"
// "unit/length-foot .### rounding-mode-half-up"
return ReadOnlyRoots(isolate).short_string_handle();
}

Expand All @@ -422,7 +422,7 @@ Notation NotationFromSkeleton(const icu::UnicodeString& skeleton) {
return Notation::COMPACT;
}
// Ex: skeleton as
// "measure-unit/length-foot .### rounding-mode-half-up"
// "unit/length-foot .### rounding-mode-half-up"
return Notation::STANDARD;
}

Expand Down Expand Up @@ -562,14 +562,14 @@ namespace {

// Ex: percent .### rounding-mode-half-up
// Special case for "percent"
// Ex: "measure-unit/length-kilometer per-measure-unit/duration-hour .###
// rounding-mode-half-up" should return "kilometer-per-unit".
// Ex: "measure-unit/duration-year .### rounding-mode-half-up" should return
// Ex: "unit/milliliter-per-acre .### rounding-mode-half-up"
// should return "milliliter-per-acre".
// Ex: "unit/year .### rounding-mode-half-up" should return
// "year".
std::string UnitFromSkeleton(const icu::UnicodeString& skeleton) {
std::string str;
str = skeleton.toUTF8String<std::string>(str);
std::string search("measure-unit/");
std::string search("unit/");
size_t begin = str.find(search);
if (begin == str.npos) {
// Special case for "percent".
Expand All @@ -578,64 +578,44 @@ std::string UnitFromSkeleton(const icu::UnicodeString& skeleton) {
}
return "";
}
// Skip the type (ex: "length").
// "measure-unit/length-kilometer per-measure-unit/duration-hour"
// b
begin = str.find("-", begin + search.size());
// Ex:
// "unit/acre .### rounding-mode-half-up"
// b
// Ex:
// "unit/milliliter-per-acre .### rounding-mode-half-up"
// b
begin += search.size();
if (begin == str.npos) {
return "";
}
begin++; // Skip the '-'.
// Find the end of the subtype.
size_t end = str.find(" ", begin);
// "measure-unit/length-kilometer per-measure-unit/duration-hour"
// b e
// Ex:
// "unit/acre .### rounding-mode-half-up"
// b e
// Ex:
// "unit/milliliter-per-acre .### rounding-mode-half-up"
// b e
if (end == str.npos) {
end = str.size();
return str.substr(begin, end - begin);
}
// "measure-unit/length-kilometer per-measure-unit/duration-hour"
// b e
// [result ]
std::string result = str.substr(begin, end - begin);
begin = end + 1;
// "measure-unit/length-kilometer per-measure-unit/duration-hour"
// [result ]eb
std::string search_per("per-measure-unit/");
begin = str.find(search_per, begin);
// "measure-unit/length-kilometer per-measure-unit/duration-hour"
// [result ]e b
if (begin == str.npos) {
return result;
}
// Skip the type (ex: "duration").
begin = str.find("-", begin + search_per.size());
// "measure-unit/length-kilometer per-measure-unit/duration-hour"
// [result ]e b
if (begin == str.npos) {
return result;
}
begin++; // Skip the '-'.
// "measure-unit/length-kilometer per-measure-unit/duration-hour"
// [result ]e b
end = str.find(" ", begin);
if (end == str.npos) {
end = str.size();
}
// "measure-unit/length-kilometer per-measure-unit/duration-hour"
// [result ] b e
return result + "-per-" + str.substr(begin, end - begin);
return str.substr(begin, end - begin);
}

Style StyleFromSkeleton(const icu::UnicodeString& skeleton) {
if (skeleton.indexOf("currency/") >= 0) {
return Style::CURRENCY;
}
if (skeleton.indexOf("measure-unit/") >= 0) {
if (skeleton.indexOf("scale/100") >= 0 &&
skeleton.indexOf("measure-unit/concentr-percent") >= 0) {
if (skeleton.indexOf("percent") >= 0) {
// percent precision-integer rounding-mode-half-up scale/100
if (skeleton.indexOf("scale/100") >= 0) {
return Style::PERCENT;
} else {
return Style::UNIT;
}
}
// Before ICU68: "measure-unit/", since ICU68 "unit/"
if (skeleton.indexOf("unit/") >= 0) {
return Style::UNIT;
}
return Style::DECIMAL;
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/test/cctest/test-api-icu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ TEST(LocaleConfigurationChangeNotification) {

SetIcuLocale("zh_CN");
isolate->LocaleConfigurationChangeNotification();
CheckLocaleSpecificValues("zh-CN", "2020/2/14 下午1:45:00", "10,000.3");
CheckLocaleSpecificValues("zh-CN", "2020/2/14下午1:45:00", "10,000.3");

UErrorCode error_code = U_ZERO_ERROR;
icu::Locale::setDefault(default_locale, error_code);
Expand Down

0 comments on commit 9b69069

Please sign in to comment.