Reviewers: Erik Corry, Message: Review, please.
Description: Scanning for captures only happen when a decimal escape gives a number that is too big to be a useful back reference. It won't happen at all in meaningfull ECMAScript compliant regexps. Please review this at http://codereview.chromium.org/12634 Affected files: M src/parser.cc M src/regexp-macro-assembler-ia32.cc Index: src/parser.cc diff --git a/src/parser.cc b/src/parser.cc index ff9bbdc4bd7c85030a0a25b9cd14e0f49da34290..41336c2727098a2cf1c79d1c4b5e158753ca08c1 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -3865,6 +3865,7 @@ static bool IsSpecialClassEscape(uc32 c) { // noncapturing parentheses and can skip character classes and backslash-escaped // characters. void RegExpParser::ScanForCaptures() { + capture_count_ = captures_started(); int n; while ((n = current()) != kEndMarker) { Advance(); @@ -3901,29 +3902,29 @@ bool RegExpParser::ParseBackReferenceIndex(int* index_out) { // This is a not according the the ECMAScript specification. According to // that, one must accept values up to the total number of left capturing // parentheses in the entire input, even if they are meaningless. - if (!is_scanned_for_captures_) { - int saved_position = position(); - ScanForCaptures(); - Reset(saved_position); - } - if (capture_count_ == 0) return false; int start = position(); int value = Next() - '0'; - if (value > capture_count_) return false; Advance(2); while (true) { uc32 c = current(); if (IsDecimalDigit(c)) { value = 10 * value + (c - '0'); - if (value > capture_count_) { - Reset(start); - return false; - } Advance(); } else { break; } } + if (value > captures_started()) { + if (!is_scanned_for_captures_) { + int saved_position = position(); + ScanForCaptures(); + Reset(saved_position); + } + if (value > capture_count_) { + Reset(start); + return false; + } + } *index_out = value; return true; } @@ -4120,7 +4121,6 @@ RegExpTree* RegExpParser::ParseGroup(bool* ok) { captures_ = new ZoneList<RegExpCapture*>(2); } captures_->Add(NULL); - if (!is_scanned_for_captures_) capture_count_++; } int capture_index = captures_started(); RegExpTree* body = ParseDisjunction(CHECK_OK); Index: src/regexp-macro-assembler-ia32.cc diff --git a/src/regexp-macro-assembler-ia32.cc b/src/regexp-macro-assembler-ia32.cc index 1004fea28693b28afb1ae22e2bd61022e17f45f0..786fafeed376d1da99c978146d5d1681003940a2 100644 --- a/src/regexp-macro-assembler-ia32.cc +++ b/src/regexp-macro-assembler-ia32.cc @@ -320,7 +320,6 @@ void RegExpMacroAssemblerIA32::DispatchByteMap( } - void RegExpMacroAssemblerIA32::DispatchHighByteMap( byte start, Label* byte_map, --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "v8-dev" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/v8-dev?hl=en -~----------~----~----~----~------~----~------~--~---
