Less intrusive patch for regexp bug.
authorlrn@chromium.org <lrn@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 25 Jun 2010 07:51:46 +0000 (07:51 +0000)
committerlrn@chromium.org <lrn@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 25 Jun 2010 07:51:46 +0000 (07:51 +0000)
Review URL: http://codereview.chromium.org/2843024

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4947 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/regexp.js

index 79ac44b..f0945b3 100644 (file)
@@ -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;