Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Unified Diff: src/regexp/regexp-parser.cc

Issue 2725583002: [regexp] fix /\W/ui wrt \u017f and \u212a. (Closed)
Patch Set: address comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/regexp/regexp-ast.h ('k') | test/mjsunit/es7/regexp-ui-word.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/regexp/regexp-parser.cc
diff --git a/src/regexp/regexp-parser.cc b/src/regexp/regexp-parser.cc
index 3621f7d96e4fbf4634b7a214d7beb5defa019eae..9da863f23f4bdbcbb36287104a42517b97cd742e 100644
--- a/src/regexp/regexp-parser.cc
+++ b/src/regexp/regexp-parser.cc
@@ -270,7 +270,7 @@ RegExpTree* RegExpParser::ParseDisjunction() {
// everything except \x0a, \x0d, \u2028 and \u2029
ZoneList<CharacterRange>* ranges =
new (zone()) ZoneList<CharacterRange>(2, zone());
- CharacterRange::AddClassEscape('.', ranges, zone());
+ CharacterRange::AddClassEscape('.', ranges, false, zone());
RegExpCharacterClass* cc =
new (zone()) RegExpCharacterClass(ranges, false);
builder->AddCharacterClass(cc);
@@ -377,7 +377,8 @@ RegExpTree* RegExpParser::ParseDisjunction() {
Advance(2);
ZoneList<CharacterRange>* ranges =
new (zone()) ZoneList<CharacterRange>(2, zone());
- CharacterRange::AddClassEscape(c, ranges, zone());
+ CharacterRange::AddClassEscape(c, ranges,
+ unicode() && ignore_case(), zone());
RegExpCharacterClass* cc =
new (zone()) RegExpCharacterClass(ranges, false);
builder->AddCharacterClass(cc);
@@ -1389,9 +1390,11 @@ static const uc16 kNoCharClass = 0;
// escape (i.e., 's' means whitespace, from '\s').
static inline void AddRangeOrEscape(ZoneList<CharacterRange>* ranges,
uc16 char_class, CharacterRange range,
+ bool add_unicode_case_equivalents,
Zone* zone) {
if (char_class != kNoCharClass) {
- CharacterRange::AddClassEscape(char_class, ranges, zone);
+ CharacterRange::AddClassEscape(char_class, ranges,
+ add_unicode_case_equivalents, zone);
} else {
ranges->Add(range, zone);
}
@@ -1431,6 +1434,7 @@ RegExpTree* RegExpParser::ParseCharacterClass() {
}
ZoneList<CharacterRange>* ranges =
new (zone()) ZoneList<CharacterRange>(2, zone());
+ bool add_unicode_case_equivalents = unicode() && ignore_case();
while (has_more() && current() != ']') {
bool parsed_property = ParseClassProperty(ranges CHECK_FAILED);
if (parsed_property) continue;
@@ -1443,7 +1447,8 @@ RegExpTree* RegExpParser::ParseCharacterClass() {
// following code report an error.
break;
} else if (current() == ']') {
- AddRangeOrEscape(ranges, char_class, first, zone());
+ AddRangeOrEscape(ranges, char_class, first,
+ add_unicode_case_equivalents, zone());
ranges->Add(CharacterRange::Singleton('-'), zone());
break;
}
@@ -1455,9 +1460,11 @@ RegExpTree* RegExpParser::ParseCharacterClass() {
// ES2015 21.2.2.15.1 step 1.
return ReportError(CStrVector(kRangeInvalid));
}
- AddRangeOrEscape(ranges, char_class, first, zone());
+ AddRangeOrEscape(ranges, char_class, first,
+ add_unicode_case_equivalents, zone());
ranges->Add(CharacterRange::Singleton('-'), zone());
- AddRangeOrEscape(ranges, char_class_2, next, zone());
+ AddRangeOrEscape(ranges, char_class_2, next,
+ add_unicode_case_equivalents, zone());
continue;
}
// ES2015 21.2.2.15.1 step 6.
@@ -1466,7 +1473,8 @@ RegExpTree* RegExpParser::ParseCharacterClass() {
}
ranges->Add(CharacterRange::Range(first.from(), next.to()), zone());
} else {
- AddRangeOrEscape(ranges, char_class, first, zone());
+ AddRangeOrEscape(ranges, char_class, first, add_unicode_case_equivalents,
+ zone());
}
}
if (!has_more()) {
« no previous file with comments | « src/regexp/regexp-ast.h ('k') | test/mjsunit/es7/regexp-ui-word.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698