Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Unified Diff: src/regexp.js

Issue 11451005: Fix spec violations related to regexp.lastIndex (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects-inl.h ('k') | src/runtime.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/regexp.js
diff --git a/src/regexp.js b/src/regexp.js
index a3675f033248ba59ffb983967e7951476b3b1e67..da1883f3a427ec0edbdfd45af99e219071215b79 100644
--- a/src/regexp.js
+++ b/src/regexp.js
@@ -161,6 +161,7 @@ function RegExpExecNoTests(regexp, string, start) {
lastMatchInfoOverride = null;
return BuildResultFromMatchInfo(matchInfo, string);
}
+ regexp.lastIndex = 0;
return null;
}
@@ -193,7 +194,7 @@ function RegExpExec(string) {
var matchIndices = %_RegExpExec(this, string, i, lastMatchInfo);
if (matchIndices === null) {
- if (global) this.lastIndex = 0;
+ this.lastIndex = 0;
return null;
}
@@ -256,7 +257,10 @@ function RegExpTest(string) {
%_Log('regexp', 'regexp-exec,%0r,%1S,%2i', [regexp, string, lastIndex]);
// matchIndices is either null or the lastMatchInfo array.
var matchIndices = %_RegExpExec(regexp, string, 0, lastMatchInfo);
- if (matchIndices === null) return false;
+ if (matchIndices === null) {
+ this.lastIndex = 0;
+ return false;
+ }
lastMatchInfoOverride = null;
return true;
}
« no previous file with comments | « src/objects-inl.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698