Fix character ranges in case insensitive regexp
R=jgruber@chromium.org Bug: chromium:971383 Change-Id: I39d26a63c0735f595a809959c06cb2ac1c141451 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1648098 Commit-Queue: Frank Tang <ftang@chromium.org> Auto-Submit: Yang Guo <yangguo@chromium.org> Reviewed-by: Frank Tang <ftang@chromium.org> Cr-Commit-Position: refs/heads/master@{#62044}
This commit is contained in:
parent
ac30897d76
commit
9bcacf60f8
16
src/d8/d8.cc
16
src/d8/d8.cc
@ -48,6 +48,10 @@
|
||||
#include "src/utils/utils.h"
|
||||
#include "src/wasm/wasm-engine.h"
|
||||
|
||||
#ifdef V8_INTL_SUPPORT
|
||||
#include "unicode/locid.h"
|
||||
#endif // V8_INTL_SUPPORT
|
||||
|
||||
#if !defined(_WIN32) && !defined(_WIN64)
|
||||
#include <unistd.h> // NOLINT
|
||||
#else
|
||||
@ -2826,6 +2830,9 @@ bool Shell::SetOptions(int argc, char* argv[]) {
|
||||
} else if (strncmp(argv[i], "--icu-data-file=", 16) == 0) {
|
||||
options.icu_data_file = argv[i] + 16;
|
||||
argv[i] = nullptr;
|
||||
} else if (strncmp(argv[i], "--icu-locale=", 13) == 0) {
|
||||
options.icu_locale = argv[i] + 13;
|
||||
argv[i] = nullptr;
|
||||
#ifdef V8_USE_EXTERNAL_STARTUP_DATA
|
||||
} else if (strncmp(argv[i], "--natives_blob=", 15) == 0) {
|
||||
options.natives_blob = argv[i] + 15;
|
||||
@ -3325,8 +3332,17 @@ void Shell::CleanupWorkers() {
|
||||
int Shell::Main(int argc, char* argv[]) {
|
||||
v8::base::EnsureConsoleOutput();
|
||||
if (!SetOptions(argc, argv)) return 1;
|
||||
|
||||
v8::V8::InitializeICUDefaultLocation(argv[0], options.icu_data_file);
|
||||
|
||||
#ifdef V8_INTL_SUPPORT
|
||||
if (options.icu_locale != nullptr) {
|
||||
icu::Locale locale(options.icu_locale);
|
||||
UErrorCode error_code = U_ZERO_ERROR;
|
||||
icu::Locale::setDefault(locale, error_code);
|
||||
}
|
||||
#endif // V8_INTL_SUPPORT
|
||||
|
||||
v8::platform::InProcessStackDumping in_process_stack_dumping =
|
||||
options.disable_in_process_stack_traces
|
||||
? v8::platform::InProcessStackDumping::kDisabled
|
||||
|
@ -329,6 +329,7 @@ class ShellOptions {
|
||||
CodeCacheOptions code_cache_options = CodeCacheOptions::kNoProduceCache;
|
||||
SourceGroup* isolate_sources = nullptr;
|
||||
const char* icu_data_file = nullptr;
|
||||
const char* icu_locale = nullptr;
|
||||
const char* natives_blob = nullptr;
|
||||
const char* snapshot_blob = nullptr;
|
||||
bool trace_enabled = false;
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "src/zone/zone-list-inl.h"
|
||||
|
||||
#ifdef V8_INTL_SUPPORT
|
||||
#include "unicode/locid.h"
|
||||
#include "unicode/uniset.h"
|
||||
#include "unicode/utypes.h"
|
||||
#endif // V8_INTL_SUPPORT
|
||||
@ -5948,9 +5949,10 @@ void CharacterRange::AddCaseEquivalents(Isolate* isolate, Zone* zone,
|
||||
if (top > String::kMaxOneByteCharCode) top = String::kMaxOneByteCharCode;
|
||||
}
|
||||
already_added.add(bottom, top);
|
||||
icu::Locale locale = icu::Locale::getRoot();
|
||||
while (bottom <= top) {
|
||||
icu::UnicodeString upper(bottom);
|
||||
upper.toUpper();
|
||||
upper.toUpper(locale);
|
||||
icu::UnicodeSet expanded(bottom, bottom);
|
||||
expanded.closeOver(USET_CASE_INSENSITIVE);
|
||||
for (int32_t i = 0; i < expanded.getRangeCount(); i++) {
|
||||
@ -5958,7 +5960,7 @@ void CharacterRange::AddCaseEquivalents(Isolate* isolate, Zone* zone,
|
||||
UChar32 end = expanded.getRangeEnd(i);
|
||||
while (start <= end) {
|
||||
icu::UnicodeString upper2(start);
|
||||
upper2.toUpper();
|
||||
upper2.toUpper(locale);
|
||||
// Only add if the upper case are the same.
|
||||
if (upper[0] == upper2[0]) {
|
||||
others.add(start);
|
||||
|
7
test/mjsunit/regress/regress-crbug-971383.js
Normal file
7
test/mjsunit/regress/regress-crbug-971383.js
Normal file
@ -0,0 +1,7 @@
|
||||
// Copyright 2019 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// Flags: --icu-locale=tr
|
||||
|
||||
assertEquals(["HIJK"], "HIJK".match(/[a-z]+/gi));
|
Loading…
Reference in New Issue
Block a user