Reviewers: Mads Ager,

Description:
Less intrusive patch for regexp bug.

Please review this at http://codereview.chromium.org/2843024/show

Affected files:
  M src/regexp.js


Index: src/regexp.js
diff --git a/src/regexp.js b/src/regexp.js
index 79ac44bb0308ad60f8d122488a2a3ae6cd9ff682..f0945b34594433675edc14d66768e2de56760264 100644
--- a/src/regexp.js
+++ b/src/regexp.js
@@ -197,7 +197,6 @@ function RegExpExec(string) {
       %_ObjectEquals(cache.regExp, this) &&
       %_ObjectEquals(cache.subject, string)) {
     if (cache.answerSaved) {
-      if (this.global) this.lastIndex = 0;
       return CloneRegExpResult(cache.answer);
     } else {
       saveAnswer = true;
@@ -231,7 +230,10 @@ function RegExpExec(string) {
   var matchIndices = %_RegExpExec(this, s, i, lastMatchInfo);

   if (matchIndices == null) {
-    if (this.global) this.lastIndex = 0;
+    if (this.global) {
+      this.lastIndex = 0;
+      if (lastIndex != 0) return matchIndices;
+    }
     cache.lastIndex = lastIndex;
     cache.regExp = this;
     cache.subject = s;


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

Reply via email to