Revert of [regexp] extend property classes by script category. (patchset #1 id:1 of https://codereview.chromium.org/1774513002/ )
Reason for revert: wrong noi18n expectations Original issue's description: > [regexp] extend property classes by script category. > > R=littledan@chromium.org > BUG=v8:4743 > LOG=N > > Committed: https://crrev.com/22f6735ccbe2e341d341e61b9c38ce308b8da655 > Cr-Commit-Position: refs/heads/master@{#34553} TBR=littledan@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=v8:4743 Review URL: https://codereview.chromium.org/1772563003 Cr-Commit-Position: refs/heads/master@{#34554}
This commit is contained in:
parent
22f6735ccb
commit
7dc13c2a8c
@ -43,10 +43,6 @@ inline bool IsAlphaNumeric(uc32 c) {
|
|||||||
return IsInRange(AsciiAlphaToLower(c), 'a', 'z') || IsDecimalDigit(c);
|
return IsInRange(AsciiAlphaToLower(c), 'a', 'z') || IsDecimalDigit(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool IsAlpha(uc32 c) {
|
|
||||||
return IsInRange(AsciiAlphaToLower(c), 'a', 'z');
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool IsDecimalDigit(uc32 c) {
|
inline bool IsDecimalDigit(uc32 c) {
|
||||||
// ECMA-262, 3rd, 7.8.3 (p 16)
|
// ECMA-262, 3rd, 7.8.3 (p 16)
|
||||||
return IsInRange(c, '0', '9');
|
return IsInRange(c, '0', '9');
|
||||||
|
@ -18,7 +18,6 @@ inline bool IsCarriageReturn(uc32 c);
|
|||||||
inline bool IsLineFeed(uc32 c);
|
inline bool IsLineFeed(uc32 c);
|
||||||
inline bool IsAsciiIdentifier(uc32 c);
|
inline bool IsAsciiIdentifier(uc32 c);
|
||||||
inline bool IsAlphaNumeric(uc32 c);
|
inline bool IsAlphaNumeric(uc32 c);
|
||||||
inline bool IsAlpha(uc32 c);
|
|
||||||
inline bool IsDecimalDigit(uc32 c);
|
inline bool IsDecimalDigit(uc32 c);
|
||||||
inline bool IsHexDigit(uc32 c);
|
inline bool IsHexDigit(uc32 c);
|
||||||
inline bool IsOctalDigit(uc32 c);
|
inline bool IsOctalDigit(uc32 c);
|
||||||
|
@ -838,38 +838,32 @@ bool RegExpParser::ParseUnicodeEscape(uc32* value) {
|
|||||||
|
|
||||||
ZoneList<CharacterRange>* RegExpParser::ParsePropertyClass() {
|
ZoneList<CharacterRange>* RegExpParser::ParsePropertyClass() {
|
||||||
#ifdef V8_I18N_SUPPORT
|
#ifdef V8_I18N_SUPPORT
|
||||||
ZoneList<char> property_name(0, zone());
|
char property_name[3];
|
||||||
|
memset(property_name, 0, sizeof(property_name));
|
||||||
if (current() == '{') {
|
if (current() == '{') {
|
||||||
for (Advance(); IsAlpha(current()); Advance()) {
|
Advance();
|
||||||
property_name.Add(static_cast<char>(current()), zone());
|
if (current() < 'A' || current() > 'Z') return nullptr;
|
||||||
|
property_name[0] = static_cast<char>(current());
|
||||||
|
Advance();
|
||||||
|
if (current() >= 'a' && current() <= 'z') {
|
||||||
|
property_name[1] = static_cast<char>(current());
|
||||||
|
Advance();
|
||||||
}
|
}
|
||||||
if (current() != '}') return nullptr;
|
if (current() != '}') return nullptr;
|
||||||
} else if (IsAlpha(current())) {
|
} else if (current() >= 'A' && current() <= 'Z') {
|
||||||
property_name.Add(static_cast<char>(current()), zone());
|
property_name[0] = static_cast<char>(current());
|
||||||
} else {
|
} else {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
Advance();
|
Advance();
|
||||||
property_name.Add(0, zone()); // null-terminate string.
|
|
||||||
|
|
||||||
// Property names are defined in unicode database files. For aliases of
|
int32_t category =
|
||||||
// these property names, see PropertyValueAliases.txt.
|
u_getPropertyValueEnum(UCHAR_GENERAL_CATEGORY_MASK, property_name);
|
||||||
UProperty kPropertyClasses[] = {
|
if (category == UCHAR_INVALID_CODE) return nullptr;
|
||||||
// General_Category (gc) found in PropertyValueAliases.txt
|
|
||||||
UCHAR_GENERAL_CATEGORY_MASK,
|
|
||||||
// Script (sc) found in Scripts.txt
|
|
||||||
UCHAR_SCRIPT,
|
|
||||||
};
|
|
||||||
|
|
||||||
for (int i = 0; i < arraysize(kPropertyClasses); i++) {
|
|
||||||
UProperty property_class = kPropertyClasses[i];
|
|
||||||
int32_t category = u_getPropertyValueEnum(
|
|
||||||
property_class, property_name.ToConstVector().start());
|
|
||||||
if (category == UCHAR_INVALID_CODE) continue;
|
|
||||||
|
|
||||||
USet* set = uset_openEmpty();
|
USet* set = uset_openEmpty();
|
||||||
UErrorCode ec = U_ZERO_ERROR;
|
UErrorCode ec = U_ZERO_ERROR;
|
||||||
uset_applyIntPropertyValue(set, property_class, category, &ec);
|
uset_applyIntPropertyValue(set, UCHAR_GENERAL_CATEGORY_MASK, category, &ec);
|
||||||
ZoneList<CharacterRange>* ranges = nullptr;
|
ZoneList<CharacterRange>* ranges = nullptr;
|
||||||
if (ec == U_ZERO_ERROR && !uset_isEmpty(set)) {
|
if (ec == U_ZERO_ERROR && !uset_isEmpty(set)) {
|
||||||
uset_removeAllStrings(set);
|
uset_removeAllStrings(set);
|
||||||
@ -887,10 +881,9 @@ ZoneList<CharacterRange>* RegExpParser::ParsePropertyClass() {
|
|||||||
}
|
}
|
||||||
uset_close(set);
|
uset_close(set);
|
||||||
return ranges;
|
return ranges;
|
||||||
}
|
#else // V8_I18N_SUPPORT
|
||||||
#endif // V8_I18N_SUPPORT
|
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
#endif // V8_I18N_SUPPORT
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RegExpParser::ParseUnlimitedLengthHexNumber(int max_value, uc32* value) {
|
bool RegExpParser::ParseUnlimitedLengthHexNumber(int max_value, uc32* value) {
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
// Copyright 2016 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: --harmony-regexp-property
|
|
||||||
|
|
||||||
function t(re, s) { assertTrue(re.test(s)); }
|
|
||||||
function f(re, s) { assertFalse(re.test(s)); }
|
|
||||||
|
|
||||||
t(/\p{Common}+/u, ".");
|
|
||||||
f(/\p{Common}+/u, "supercalifragilisticexpialidocious");
|
|
||||||
|
|
||||||
t(/\p{Han}+/u, "话说天下大势,分久必合,合久必分");
|
|
||||||
t(/\p{Hani}+/u, "吾庄后有一桃园,花开正盛");
|
|
||||||
f(/\p{Han}+/u, "おはようございます");
|
|
||||||
f(/\p{Hani}+/u, "Something is rotten in the state of Denmark");
|
|
||||||
|
|
||||||
t(/\p{Latin}+/u, "Wie froh bin ich, daß ich weg bin!");
|
|
||||||
t(/\p{Latn}+/u,
|
|
||||||
"It was a bright day in April, and the clocks were striking thirteen");
|
|
||||||
f(/\p{Latin}+/u, "奔腾千里荡尘埃,渡水登山紫雾开");
|
|
||||||
f(/\p{Latn}+/u, "いただきます");
|
|
||||||
|
|
||||||
t(/\p{Hiragana}/u, "いただきます");
|
|
||||||
t(/\p{Hira}/u, "ありがとうございました");
|
|
||||||
f(/\p{Hiragana}/u,
|
|
||||||
"Als Gregor Samsa eines Morgens aus unruhigen Träumen erwachte");
|
|
||||||
f(/\p{Hira}/u, "Call me Ishmael");
|
|
||||||
|
|
||||||
t(/\p{Phoenician}/u, "\u{10900}\u{1091a}");
|
|
||||||
t(/\p{Phnx}/u, "\u{1091f}\u{10916}");
|
|
||||||
f(/\p{Phoenician}/u, "Arthur est un perroquet");
|
|
||||||
f(/\p{Phnx}/u, "设心狠毒非良士,操卓原来一路人");
|
|
||||||
|
|
||||||
t(/\p{Grek}/u, "ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ");
|
|
||||||
t(/\p{Greek}/u, "μῆνιν ἄειδε θεὰ Πηληϊάδεω Ἀχιλῆος");
|
|
||||||
f(/\p{Greek}/u, "高贤未服英雄志,屈节偏生杰士疑");
|
|
||||||
f(/\p{Greek}/u,
|
|
||||||
"Mr. Jones, of the Manor Farm, had locked the hen-houses for the night");
|
|
Loading…
Reference in New Issue
Block a user