ruby-changes:73407
From: nagachika <ko1@a...>
Date: Sun, 4 Sep 2022 16:25:28 +0900 (JST)
Subject: [ruby-changes:73407] 1cfc139f6d (ruby_3_1): merge revision(s) d8189ed23f02dd197453279aeee9be1785337d4f: [Backport #18670]
https://git.ruby-lang.org/ruby.git/commit/?id=1cfc139f6d From 1cfc139f6d0cb80d6024b0c416976194929417cf Mon Sep 17 00:00:00 2001 From: nagachika <nagachika@r...> Date: Sun, 4 Sep 2022 16:00:14 +0900 Subject: merge revision(s) d8189ed23f02dd197453279aeee9be1785337d4f: [Backport #18670] Return only captured range in `MatchData` [Bug #18670] --- re.c | 2 +- test/ruby/test_regexp.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) --- re.c | 2 +- test/ruby/test_regexp.rb | 1 + version.h | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/re.c b/re.c index d91909a743..1ecb067399 100644 --- a/re.c +++ b/re.c @@ -2120,7 +2120,7 @@ match_aref(int argc, VALUE *argv, VALUE match) https://github.com/ruby/ruby/blob/trunk/re.c#L2120 else if (beg > num_regs) { return Qnil; } - else if (beg+len > num_regs) { + if (beg+len > num_regs) { len = num_regs - beg; } return match_ary_subseq(match, beg, len, Qnil); diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index b4e4f725b3..c183988303 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -467,6 +467,7 @@ class TestRegexp < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_regexp.rb#L467 assert_nil(m[5]) assert_raise(IndexError) { m[:foo] } assert_raise(TypeError) { m[nil] } + assert_equal(["baz", nil], m[-2, 3]) end def test_match_values_at diff --git a/version.h b/version.h index 826c72a564..27440ec8ee 100644 --- a/version.h +++ b/version.h @@ -11,11 +11,11 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L11 # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR #define RUBY_VERSION_TEENY 3 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 44 +#define RUBY_PATCHLEVEL 45 #define RUBY_RELEASE_YEAR 2022 #define RUBY_RELEASE_MONTH 9 -#define RUBY_RELEASE_DAY 3 +#define RUBY_RELEASE_DAY 4 #include "ruby/version.h" -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/