ruby-changes:44979
From: nobu <ko1@a...>
Date: Mon, 12 Dec 2016 11:38:58 +0900 (JST)
Subject: [ruby-changes:44979] nobu:r57051 (trunk): re.c: char boundary
nobu 2016-12-12 11:38:53 +0900 (Mon, 12 Dec 2016) New Revision: 57051 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57051 Log: re.c: char boundary * re.c (rb_reg_match_m_p): consider char boundary. rb_str_subpos does not adjust to the boundary if len == 0. Modified files: trunk/re.c trunk/test/ruby/test_regexp.rb Index: re.c =================================================================== --- re.c (revision 57050) +++ re.c (revision 57051) @@ -3243,8 +3243,8 @@ rb_reg_match_m_p(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/re.c#L3243 if (pos < 0) return Qfalse; } if (pos > 0) { - long len = 0; - char *beg = rb_str_subpos(str, pos, &len); + long len = 1; + const char *beg = rb_str_subpos(str, pos, &len); if (!beg) return Qfalse; pos = beg - RSTRING_PTR(str); } Index: test/ruby/test_regexp.rb =================================================================== --- test/ruby/test_regexp.rb (revision 57050) +++ test/ruby/test_regexp.rb (revision 57051) @@ -543,7 +543,8 @@ class TestRegexp < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_regexp.rb#L543 assert_equal(true, /../.match?('abc', -2)) assert_equal(false, /../.match?("abc", -4)) assert_equal(false, /../.match?("abc", 4)) - assert_equal(true, /../n.match?("\u3042" + '\x', 1)) + assert_equal(true, /../.match?("\u3042xx", 1)) + assert_equal(false, /../.match?("\u3042x", 1)) assert_equal(true, /\z/.match?("")) assert_equal(true, /\z/.match?("abc")) assert_equal(true, /R.../.match?("Ruby")) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/