ruby-changes:51045
From: nobu <ko1@a...>
Date: Tue, 24 Apr 2018 21:25:52 +0900 (JST)
Subject: [ruby-changes:51045] nobu:r63252 (trunk): string.c: fix scanned substring with `\K`
nobu 2018-04-24 21:25:46 +0900 (Tue, 24 Apr 2018) New Revision: 63252 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63252 Log: string.c: fix scanned substring with `\K` * string.c (scan_once): fix the matched substring with `\K`, the beginning of that string may differ from the matched position. [ruby-core:86663] [Bug #14707] Modified files: trunk/string.c trunk/test/ruby/test_string.rb Index: test/ruby/test_string.rb =================================================================== --- test/ruby/test_string.rb (revision 63251) +++ test/ruby/test_string.rb (revision 63252) @@ -1542,6 +1542,8 @@ CODE https://github.com/ruby/ruby/blob/trunk/test/ruby/test_string.rb#L1542 assert_nil($~) assert_equal(3, S("hello hello hello").scan("hello".taint).count(&:tainted?)) + + assert_equal(%w[1 2 3], S("a1 a2 a3").scan(/a\K./)) end def test_size Index: string.c =================================================================== --- string.c (revision 63251) +++ string.c (revision 63252) @@ -9046,6 +9046,7 @@ scan_once(VALUE str, VALUE pat, long *st https://github.com/ruby/ruby/blob/trunk/string.c#L9046 else { match = rb_backref_get(); regs = RMATCH_REGS(match); + pos = BEG(0); end = END(0); } if (pos == end) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/