Files
Sutou KouheiandClaude Opus 5.5 186ebd63da [ruby/strscan] Reset the number of registers after string pattern
match
(https://github.com/ruby/strscan/pull/221)

`set_registers()` used `onig_region_set()` that doesn't change
`num_regs` when the region is already allocated. So `StringScanner#size`
and `#captures` after a string pattern match reported the number of
registers of the previous `Regexp` match:

```ruby
s = StringScanner.new("abc")
s.scan(/(a)(b)/)
s.scan("c")
s.size     # => 3 (should be 1)
s.captures # => [nil, nil] (should be [])
```

Use `onig_region_resize()` like `adjust_registers_to_matched()` does.
This is consistent with the JRuby and TruffleRuby implementations.

https://github.com/ruby/strscan/commit/f829eade26

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 04:58:27 +00:00
..