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/jruby/org/jruby/ext/strscan/RubyStringScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ private RubyString newString(Ruby runtime, int start, int length) {
ByteList byteList = str.getByteList();
int begin = byteList.begin();

ByteList newByteList = new ByteList(byteList.unsafeBytes(), begin + start, begin + length, byteList.getEncoding(), true);
ByteList newByteList = new ByteList(byteList.unsafeBytes(), begin + start, length, byteList.getEncoding(), true);

return RubyString.newString(runtime, newByteList);
}
Expand Down
8 changes: 8 additions & 0 deletions test/strscan/test_stringscanner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -841,4 +841,12 @@ def test_skip_with_begenning_of_line_anchor_not_match
assert_equal 1, s.skip(/a/)
assert_nil s.skip(/^b/)
end

# ruby/strscan#86
def test_scan_shared_string
s = "hellohello"[5..-1]
ss = StringScanner.new(s).scan(/hello/)

assert_equal "hello", ss
end
end