mirror of
https://github.com/ruby/ruby.git
synced 2026-10-28 16:36:20 +08:00
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>