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

Side by Side Diff: src/regexp.js

Issue 2826020: Fix bug in regexp exec with global regexps. (Closed)
Patch Set: Addressed review comment. Created 10 years, 6 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-45469.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } 190 }
191 191
192 var cache = regExpCache; 192 var cache = regExpCache;
193 var saveAnswer = false; 193 var saveAnswer = false;
194 194
195 if (%_ObjectEquals(cache.type, 'exec') && 195 if (%_ObjectEquals(cache.type, 'exec') &&
196 %_ObjectEquals(cache.lastIndex, this.lastIndex) && 196 %_ObjectEquals(cache.lastIndex, this.lastIndex) &&
197 %_ObjectEquals(cache.regExp, this) && 197 %_ObjectEquals(cache.regExp, this) &&
198 %_ObjectEquals(cache.subject, string)) { 198 %_ObjectEquals(cache.subject, string)) {
199 if (cache.answerSaved) { 199 if (cache.answerSaved) {
200 if (this.global) this.lastIndex = 0;
200 return CloneRegExpResult(cache.answer); 201 return CloneRegExpResult(cache.answer);
201 } else { 202 } else {
202 saveAnswer = true; 203 saveAnswer = true;
203 } 204 }
204 } 205 }
205 206
206 if (%_ArgumentsLength() == 0) { 207 if (%_ArgumentsLength() == 0) {
207 var regExpInput = LAST_INPUT(lastMatchInfo); 208 var regExpInput = LAST_INPUT(lastMatchInfo);
208 if (IS_UNDEFINED(regExpInput)) { 209 if (IS_UNDEFINED(regExpInput)) {
209 throw MakeError('no_input_to_regexp', [this]); 210 throw MakeError('no_input_to_regexp', [this]);
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); 538 %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE);
538 539
539 for (var i = 1; i < 10; ++i) { 540 for (var i = 1; i < 10; ++i) {
540 %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), DONT_D ELETE); 541 %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), DONT_D ELETE);
541 %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE); 542 %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE);
542 } 543 }
543 } 544 }
544 545
545 546
546 SetupRegExp(); 547 SetupRegExp();
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-45469.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698