Project

General

Profile

Bug #5714 ยป read_binmode2.patch

h.shirosaki (Hiroshi Shirosaki), 12/10/2011 03:10 PM

View differences:

io.c
2482 2482
    if (len == 0) return str;
2483 2483

  
2484 2484
    READ_CHECK(fptr);
2485
#ifdef O_BINARY
2486
    if (!(fptr->mode & FMODE_BINMODE)) {
2487
	SET_BINARY_MODE_WITH_SEEK_CUR(fptr);
2488
    }
2489
#endif
2485 2490
    n = io_fread(str, 0, fptr);
2486 2491
    if (n == 0) {
2487 2492
	if (fptr->fd < 0) return Qnil;
test/ruby/test_io_m17n.rb
2222 2222
      end
2223 2223
    end
2224 2224
  end if /mswin|mingw/ =~ RUBY_PLATFORM
2225

  
2226
  def test_read_with_length
2227
    with_tmpdir {
2228
      str = "ab\r\nc"
2229
      generate_file('tmp', str)
2230
      s = open("tmp", "r") {|f|
2231
        # read with length should be binary mode
2232
        assert_equal(str, f.read(5))
2233
      }
2234
    }
2235
  end if /mswin|mingw/ =~ RUBY_PLATFORM
2225 2236
end