Actions
Bug #19252
closedIO::Buffer.pread last argument is always ignored?
Description
I am trying to document new IO::Buffer#pread
and #pwrite
methods.
According to what I can guess from code and tests, this code:
IO::Buffer.for('teststring') do |buffer|
buffer.pread(File.open('/dev/urandom', 'rb'), 0, 2, 3)
p buffer.get_string
end
...is expected to read 2 chars from /dev/urandom
, starting from 0th char, and write it to buffer starting from its 3rd byte.
Actual output:
"F\x94ststring"
E.g. two first chars of the buffer are replaced.
Am I missing something, or is it a legitimate bug?..
UPD: Seems the same for pwrite
:
IO::Buffer.for('1234567').pwrite(File.open('tmp/buf.txt', 'wb'), 0, 2, 3) # expected to write "45" to file
`cat tmp/buf.txt`
# => "12"
Updated by ioquatix (Samuel Williams) over 2 years ago
It looks like the base pointer is not computed correctly, let me check and fix it.
Updated by ioquatix (Samuel Williams) over 2 years ago
Actions
Like0
Like0Like0Like0