Bug #5714 » read_binmode.patch
| io.c | ||
|---|---|---|
|
if (len == 0) return str;
|
||
|
READ_CHECK(fptr);
|
||
|
SET_BINARY_MODE_WITH_SEEK_CUR(fptr);
|
||
|
n = io_fread(str, 0, fptr);
|
||
|
if (n == 0) {
|
||
|
if (fptr->fd < 0) return Qnil;
|
||
| test/ruby/test_io_m17n.rb | ||
|---|---|---|
|
end
|
||
|
end
|
||
|
end if /mswin|mingw/ =~ RUBY_PLATFORM
|
||
|
def test_read_with_length
|
||
|
with_tmpdir {
|
||
|
str = "ab\r\nc"
|
||
|
generate_file('tmp', str)
|
||
|
s = open("tmp", "r") {|f|
|
||
|
# read with length should be binary mode
|
||
|
assert_equal(str, f.read(5))
|
||
|
}
|
||
|
}
|
||
|
end if /mswin|mingw/ =~ RUBY_PLATFORM
|
||
|
end
|
||