mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
3471d0f6d6
commit
2c8f16e6c0
2 changed files with 3 additions and 0 deletions
1
string.c
1
string.c
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue