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
10 changes: 8 additions & 2 deletions .github/workflows/modgc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,14 @@ jobs:
if: ${{ matrix.test_task == 'check' && matrix.skipped_tests }}

- name: Set timeout scale
run: echo "RUBY_TEST_TIMEOUT_SCALE=10" >> $GITHUB_ENV # subprocess assertion timeouts flake on slower/contended macOS runners, especially with the slower MMTk GC
if: ${{ contains(matrix.os, 'macos') }}
run: |
scale=$((os_scale * gc_scale))
echo "RUBY_TEST_TIMEOUT_SCALE=$scale" >> "$GITHUB_ENV"
env:
# Subprocess assertion timeouts flake on slower or contended macOS
# runners and with the slower MMTk GC.
os_scale: ${{ contains(matrix.os, 'macos') && 3 || 1 }}
gc_scale: ${{ matrix.gc.name == 'mmtk' && 3 || 1 }}

- name: Set up Launchable
id: launchable
Expand Down
5 changes: 5 additions & 0 deletions ext/strscan/strscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1862,8 +1862,13 @@ strscan_integer_at(int argc, VALUE *argv, VALUE self)
return Qnil;

beg = adjust_register_position(p, p->regs.beg[i]);
if (beg > S_LEN(p))
return Qnil;
end = adjust_register_position(p, p->regs.end[i]);
end = minl(end, S_LEN(p));
len = end - beg;
if (len == 0)
return Qnil;
ptr = S_PBEG(p) + beg;
#ifdef HAVE_RB_INT_PARSE_CSTR
{
Expand Down
20 changes: 20 additions & 0 deletions test/strscan/test_stringscanner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,26 @@ def test_integer_at_base_auto
assert_integer_at(s, 0, 0) # 0xaf
end

def test_integer_at_shrunk
omit("not supported on TruffleRuby") if RUBY_ENGINE == "truffleruby"

s = create_string_scanner(+"before 29 after")
s.skip_until(" ")
assert_equal("29", s.scan(/\d+/))
s.string.replace("before ")
assert_nil(s.integer_at(0))
end

def test_integer_at_shrunk_partial
omit("not supported on TruffleRuby") if RUBY_ENGINE == "truffleruby"

s = create_string_scanner(+"before 29 after")
s.skip_until(" ")
assert_equal("29", s.scan(/\d+/))
s.string.replace("before 2")
assert_integer_at(s, 2)
end

def test_pre_match
s = create_string_scanner('a b c d e')
s.scan(/\w/)
Expand Down
1 change: 1 addition & 0 deletions win32/Makefile.sub
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,7 @@ s,@SHELL@,$$(COMSPEC),;t t
s,@BUILD_FILE_SEPARATOR@,\,;t t
s,@PATH_SEPARATOR@,;,;t t
s,@CFLAGS@,$(CFLAGS),;t t
s,@warnflags@,$(WARNFLAGS),;t t
s,@WERRORFLAG@,$(WERRORFLAG),;t t
s,@DEFS@,$(DEFS),;t t
s,@CPPFLAGS@,$(CPPFLAGS),;t t
Expand Down