Reviewers: ulan,

Message:
[email protected]

Description:
Fix indexing bug in regexp, part 2.

The previous fix initialized the start index incorrectly.

BUG=


Please review this at http://codereview.chromium.org/10834291/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/jsregexp.cc
  M test/mjsunit/regress/regress-crbug-142087.js


Index: src/jsregexp.cc
diff --git a/src/jsregexp.cc b/src/jsregexp.cc
index 0bca6a997d4ce7e9f55a3787c0dd4e262f1a29af..ae25432a587d19b9adb1c0d9f9bdc206ed161bda 100644
--- a/src/jsregexp.cc
+++ b/src/jsregexp.cc
@@ -748,12 +748,12 @@ RegExpImpl::GlobalCache::GlobalCache(Handle<JSRegExp> regexp,

   // Set state so that fetching the results the first time triggers a call
   // to the compiled regexp.
-  current_match_index_ = max_matches_;
+  current_match_index_ = max_matches_ - 1;
   num_matches_ = max_matches_;
ASSERT(registers_per_match_ >= 2); // Each match has at least one capture.
   ASSERT_GE(register_array_size_, registers_per_match_);
   int32_t* last_match =
-      &register_array_[(current_match_index_ - 1) * registers_per_match_];
+      &register_array_[current_match_index_ * registers_per_match_];
   last_match[0] = -1;
   last_match[1] = 0;
 }
Index: test/mjsunit/regress/regress-crbug-142087.js
diff --git a/test/mjsunit/regress/regress-crbug-142087.js b/test/mjsunit/regress/regress-crbug-142087.js index 6a1dbf7b86ac88b12f6227f54bbf7d8f5f766a78..881ca60fba3d86827bb681c771fe10b9e06fa96c 100644
--- a/test/mjsunit/regress/regress-crbug-142087.js
+++ b/test/mjsunit/regress/regress-crbug-142087.js
@@ -27,7 +27,7 @@

 var string = "What are you looking for?";

-var expected_match = [];
+var expected_match = [""];
 for (var i = 0; i < string.length; i++) {
   expected_match.push("");
 }


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to