[前][次][番号順一覧][スレッド一覧]

ruby-changes:48640

From: nobu <ko1@a...>
Date: Mon, 13 Nov 2017 14:50:59 +0900 (JST)
Subject: [ruby-changes:48640] nobu:r60755 (trunk): regexec.c: invalidate previously matched position

nobu	2017-11-13 14:50:54 +0900 (Mon, 13 Nov 2017)

  New Revision: 60755

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60755

  Log:
    regexec.c: invalidate previously matched position
    
    * regexec.c (match_at): invalidate end position not yet matched
      when new start position is pushed, to dispose previously stored
      position.  [ruby-core:83743] [Bug #14101]

  Modified files:
    trunk/regexec.c
    trunk/test/ruby/test_regexp.rb
Index: regexec.c
===================================================================
--- regexec.c	(revision 60754)
+++ regexec.c	(revision 60755)
@@ -2506,6 +2506,7 @@ match_at(regex_t* reg, const UChar* str, https://github.com/ruby/ruby/blob/trunk/regexec.c#L2506
     CASE(OP_MEMORY_START)  MOP_IN(OP_MEMORY_START);
       GET_MEMNUM_INC(mem, p);
       mem_start_stk[mem] = (OnigStackIndex )((void* )s);
+      mem_end_stk[mem] = INVALID_STACK_INDEX;
       MOP_OUT;
       JUMP;
 
Index: test/ruby/test_regexp.rb
===================================================================
--- test/ruby/test_regexp.rb	(revision 60754)
+++ test/ruby/test_regexp.rb	(revision 60755)
@@ -1238,6 +1238,9 @@ class TestRegexp < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_regexp.rb#L1238
 
     assert_equal(0, /\/\*((?~\*\/))\*\// =~ "/*abc*def/xyz*/ /* */")
     assert_equal("abc*def/xyz", $1)
+
+    assert_equal(0, /(?~(a)c)/ =~ "abb")
+    assert_nil($1)
   end
 
   # This assertion is for porting x2() tests in testpy.py of Onigmo.

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]