Bug #5714 » read_binmode2.patch
io.c | ||
---|---|---|
if (len == 0) return str;
|
||
READ_CHECK(fptr);
|
||
#ifdef O_BINARY
|
||
if (!(fptr->mode & FMODE_BINMODE)) {
|
||
SET_BINARY_MODE_WITH_SEEK_CUR(fptr);
|
||
}
|
||
#endif
|
||
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
|