diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-24 12:25:46 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-24 12:25:46 +0000 |
commit | 2c8f16e6c0ca8ae886615c048ee14d362bac05f8 (patch) | |
tree | a7ea42e61a67da37017a9031e76c6fe9e255e2a3 | |
parent | 3471d0f6d6619b41b7054bd7bb87e929156abde2 (diff) |
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/trunk@63252 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | string.c | 1 | ||||
-rw-r--r-- | test/ruby/test_string.rb | 2 |
2 files changed, 3 insertions, 0 deletions
@@ -9046,6 +9046,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 d6356fcfa1..1a6d87f11f 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -1542,6 +1542,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 |