Project

General

Profile

Bug #5714 ยป read_binmode.patch

h.shirosaki (Hiroshi Shirosaki), 12/08/2011 02:54 PM

View differences:

io.c
2305 2305
    if (len == 0) return str;
2306 2306

  
2307 2307
    READ_CHECK(fptr);
2308
    SET_BINARY_MODE_WITH_SEEK_CUR(fptr);
2308 2309
    n = io_fread(str, 0, fptr);
2309 2310
    if (n == 0) {
2310 2311
	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