diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-08-12 11:51:02 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-08-12 11:51:02 +0000 |
commit | fa07823abbdf85f8cec7a1a08996d8c88c9631e0 (patch) | |
tree | 43cfa474585323596a4f187f4a7e6bc063f3ed1d | |
parent | 78e4b57ce1212ca16d9685ce48bf9abd66f8dfef (diff) |
merge revision(s) 63252: [Backport #14707]
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]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@64320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | string.c | 1 | ||||
-rw-r--r-- | test/ruby/test_string.rb | 2 | ||||
-rw-r--r-- | version.h | 2 |
3 files changed, 4 insertions, 1 deletions
@@ -8950,6 +8950,7 @@ scan_once(VALUE str, VALUE pat, long *start, int set_backref_str) else { match = rb_backref_get(); regs = RMATCH_REGS(match); + pos = BEG(0); end = END(0); } if (pos == end) { diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index f91ec297e0..c37191bda9 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -1537,6 +1537,8 @@ CODE 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 @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.5.2" #define RUBY_RELEASE_DATE "2018-08-12" -#define RUBY_PATCHLEVEL 67 +#define RUBY_PATCHLEVEL 68 #define RUBY_RELEASE_YEAR 2018 #define RUBY_RELEASE_MONTH 8 |