| Index: src/jsregexp.cc
|
| ===================================================================
|
| --- src/jsregexp.cc (revision 1152)
|
| +++ src/jsregexp.cc (working copy)
|
| @@ -1963,39 +1963,40 @@
|
| }
|
|
|
|
|
| -int ActionNode::EatsAtLeast(int recursion_depth) {
|
| +int ActionNode::EatsAtLeast(int still_to_find, int recursion_depth) {
|
| if (recursion_depth > RegExpCompiler::kMaxRecursion) return 0;
|
| if (type_ == POSITIVE_SUBMATCH_SUCCESS) return 0; // Rewinds input!
|
| - return on_success()->EatsAtLeast(recursion_depth + 1);
|
| + return on_success()->EatsAtLeast(still_to_find, recursion_depth + 1);
|
| }
|
|
|
|
|
| -int AssertionNode::EatsAtLeast(int recursion_depth) {
|
| +int AssertionNode::EatsAtLeast(int still_to_find, int recursion_depth) {
|
| if (recursion_depth > RegExpCompiler::kMaxRecursion) return 0;
|
| - return on_success()->EatsAtLeast(recursion_depth + 1);
|
| + return on_success()->EatsAtLeast(still_to_find, recursion_depth + 1);
|
| }
|
|
|
|
|
| -int BackReferenceNode::EatsAtLeast(int recursion_depth) {
|
| +int BackReferenceNode::EatsAtLeast(int still_to_find, int recursion_depth) {
|
| if (recursion_depth > RegExpCompiler::kMaxRecursion) return 0;
|
| - return on_success()->EatsAtLeast(recursion_depth + 1);
|
| + return on_success()->EatsAtLeast(still_to_find, recursion_depth + 1);
|
| }
|
|
|
|
|
| -int TextNode::EatsAtLeast(int recursion_depth) {
|
| +int TextNode::EatsAtLeast(int still_to_find, int recursion_depth) {
|
| int answer = Length();
|
| - if (answer >= 4) return answer;
|
| + if (answer >= still_to_find) return answer;
|
| if (recursion_depth > RegExpCompiler::kMaxRecursion) return answer;
|
| - return answer + on_success()->EatsAtLeast(recursion_depth + 1);
|
| + return answer + on_success()->EatsAtLeast(still_to_find - answer,
|
| + recursion_depth + 1);
|
| }
|
|
|
|
|
| -int NegativeLookaheadChoiceNode:: EatsAtLeast(int recursion_depth) {
|
| +int NegativeLookaheadChoiceNode:: EatsAtLeast(int still_to_find, int recursion_depth) {
|
| if (recursion_depth > RegExpCompiler::kMaxRecursion) return 0;
|
| // Alternative 0 is the negative lookahead, alternative 1 is what comes
|
| // afterwards.
|
| RegExpNode* node = alternatives_->at(1).node();
|
| - return node->EatsAtLeast(recursion_depth + 1);
|
| + return node->EatsAtLeast(still_to_find, recursion_depth + 1);
|
| }
|
|
|
|
|
| @@ -2010,7 +2011,8 @@
|
| }
|
|
|
|
|
| -int ChoiceNode::EatsAtLeastHelper(int recursion_depth,
|
| +int ChoiceNode::EatsAtLeastHelper(int still_to_find,
|
| + int recursion_depth,
|
| RegExpNode* ignore_this_node) {
|
| if (recursion_depth > RegExpCompiler::kMaxRecursion) return 0;
|
| int min = 100;
|
| @@ -2018,20 +2020,20 @@
|
| for (int i = 0; i < choice_count; i++) {
|
| RegExpNode* node = alternatives_->at(i).node();
|
| if (node == ignore_this_node) continue;
|
| - int node_eats_at_least = node->EatsAtLeast(recursion_depth + 1);
|
| + int node_eats_at_least = node->EatsAtLeast(still_to_find, recursion_depth + 1);
|
| if (node_eats_at_least < min) min = node_eats_at_least;
|
| }
|
| return min;
|
| }
|
|
|
|
|
| -int LoopChoiceNode::EatsAtLeast(int recursion_depth) {
|
| - return EatsAtLeastHelper(recursion_depth, loop_node_);
|
| +int LoopChoiceNode::EatsAtLeast(int still_to_find, int recursion_depth) {
|
| + return EatsAtLeastHelper(still_to_find, recursion_depth, loop_node_);
|
| }
|
|
|
|
|
| -int ChoiceNode::EatsAtLeast(int recursion_depth) {
|
| - return EatsAtLeastHelper(recursion_depth, NULL);
|
| +int ChoiceNode::EatsAtLeast(int still_to_find, int recursion_depth) {
|
| + return EatsAtLeastHelper(still_to_find, recursion_depth, NULL);
|
| }
|
|
|
|
|
| @@ -2811,7 +2813,7 @@
|
|
|
|
|
| int ChoiceNode::CalculatePreloadCharacters(RegExpCompiler* compiler) {
|
| - int preload_characters = EatsAtLeast(0);
|
| + int preload_characters = EatsAtLeast(4, 0);
|
| #ifdef CAN_READ_UNALIGNED
|
| bool ascii = compiler->ascii();
|
| if (ascii) {
|
|
|