Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/strscan/strscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ set_registers(struct strscanner *p, size_t pos, size_t length)
const int at = 0;
OnigRegion *regs = &(p->regs);
onig_region_clear(regs);
if (onig_region_set(regs, at, 0, 0)) return;
if (onig_region_resize(regs, at + 1) != 0) return;
if (p->fixed_anchor_p) {
regs->beg[at] = pos + p->curr;
regs->end[at] = pos + p->curr + length;
Expand Down
21 changes: 21 additions & 0 deletions test/strscan/test_stringscanner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,27 @@ def test_size
assert_equal(4, s.size)
end

def test_size_after_string_match
s = create_string_scanner("abc")
s.scan(/(a)(b)/)
s.scan("c")
assert_equal([1, []], [s.size, s.captures])
end

def test_size_after_getch
s = create_string_scanner("abc")
s.scan(/(a)(b)/)
s.getch
assert_equal([1, []], [s.size, s.captures])
end

def test_size_after_get_byte
s = create_string_scanner("abc")
s.scan(/(a)(b)/)
s.get_byte
assert_equal([1, []], [s.size, s.captures])
end

def test_captures
s = create_string_scanner("Timestamp: Fri Dec 12 1975 14:39")
s.scan("Timestamp: ")
Expand Down
Loading