Reviewers: ulan,

Description:
Regexp parser: reset flag after scanning ahead for capture groups.

When the regexp pattern parser encounters an unbound reference to a
capturing group, it needs to scan ahead to decide whether it really
is a reference.  The scan advances to the end of the pattern string
and sets has_more_ to false, but fails to reset it to true so that
later on, parsing a character class wrongly fails.

[email protected]
BUG=v8:2690

Please review this at https://chromiumcodereview.appspot.com/15712006/

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

Affected files:
  M src/parser.cc
  A + test/mjsunit/regress/regress-2690.js


Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 5eec342168a820c898b6978367c6830ae06140f3..a93600f960655756d89b55471004b8f45583088e 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -5130,6 +5130,7 @@ void RegExpParser::Advance() {

 void RegExpParser::Reset(int pos) {
   next_pos_ = pos;
+  has_more_ = (pos < in()->length());
   Advance();
 }

Index: test/mjsunit/regress/regress-2690.js
diff --git a/test/mjsunit/regress/regress-crbug-172345.js b/test/mjsunit/regress/regress-2690.js
similarity index 94%
copy from test/mjsunit/regress/regress-crbug-172345.js
copy to test/mjsunit/regress/regress-2690.js
index 711501caa791f2974635ac4dd894568a2e3fc982..5fe7dc42dc693cf7f0a3e9a2b13c0f7b306189e2 100644
--- a/test/mjsunit/regress/regress-crbug-172345.js
+++ b/test/mjsunit/regress/regress-2690.js
@@ -25,10 +25,5 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-function f(a,i) {
-  return a[i];
-}
+assertTrue(/\1[a]/.test("\1a"));

-f([1,2,3], "length");
-f([1,2,3], "length");
-f([1,2,3], 2);


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to