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

Unified Diff: regexp2000/src/jsregexp.cc

Issue 9110: Experimental: Fixed bug in RegExp Parser. Added feature counting in parser. (Closed)
Patch Set: Merged changes to tip of experimental branch. Created 12 years, 1 month 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 | « regexp2000/src/jsregexp.h ('k') | regexp2000/src/list.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: regexp2000/src/jsregexp.cc
diff --git a/regexp2000/src/jsregexp.cc b/regexp2000/src/jsregexp.cc
index 6beb7818e064ee7cc52fd230208fb2ab57aea63c..b642a52885229dff466e93133500f65d925f7c5f 100644
--- a/regexp2000/src/jsregexp.cc
+++ b/regexp2000/src/jsregexp.cc
@@ -204,19 +204,24 @@ Handle<Object> RegExpImpl::Compile(Handle<JSRegExp> re,
re->set_data(*cached);
result = re;
} else {
- SafeStringInputBuffer buffer(pattern.location());
+ SafeStringInputBuffer buffer(pattern.location());
Handle<String> error_text;
- RegExpTree* ast = ParseRegExp(&buffer, &error_text);
+ bool has_escapes;
+ RegExpTree* ast = ParseRegExp(&buffer, &error_text, &has_escapes);
if (!error_text.is_null()) {
// Throw an exception if we fail to parse the pattern.
return CreateRegExpException(re, pattern, error_text, "malformed_regexp");
}
RegExpAtom* atom = ast->AsAtom();
if (atom != NULL && !flags.is_ignore_case()) {
- Vector<const uc16> atom_pattern = atom->data();
- // Test if pattern equals atom_pattern and reuse pattern if it does.
- Handle<String> atom_string = Factory::NewStringFromTwoByte(atom_pattern);
- result = AtomCompile(re, atom_string, flags);
+ if (has_escapes) {
+ Vector<const uc16> atom_pattern = atom->data();
+ Handle<String> atom_string =
+ Factory::NewStringFromTwoByte(atom_pattern);
+ result = AtomCompile(re, pattern, flags, atom_string);
+ } else {
+ result = AtomCompile(re, pattern, flags, pattern);
+ }
} else {
result = JsrePrepare(re, pattern, flags);
}
@@ -265,8 +270,9 @@ Handle<Object> RegExpImpl::ExecGlobal(Handle<JSRegExp> regexp,
Handle<Object> RegExpImpl::AtomCompile(Handle<JSRegExp> re,
Handle<String> pattern,
- JSRegExp::Flags flags) {
- Factory::SetRegExpData(re, JSRegExp::ATOM, pattern, flags, pattern);
+ JSRegExp::Flags flags,
+ Handle<String> match_pattern) {
+ Factory::SetRegExpData(re, JSRegExp::ATOM, pattern, flags, match_pattern);
return re;
}
@@ -943,7 +949,8 @@ static void AddClassNegated(const uc16 *elmv,
}
-void CharacterRange::AddClassEscape(uc16 type, ZoneList<CharacterRange>* ranges) {
+void CharacterRange::AddClassEscape(uc16 type,
+ ZoneList<CharacterRange>* ranges) {
switch (type) {
case 's':
AddClass(kSpaceRanges, kSpaceRangeCount, ranges);
« no previous file with comments | « regexp2000/src/jsregexp.h ('k') | regexp2000/src/list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698