From 2f7290d4b3b1fd01f840f07c1db46929e3319db2 Mon Sep 17 00:00:00 2001 From: shirosaki Date: Wed, 11 Apr 2012 12:05:19 +0000 Subject: * io.c (rb_io_eof): use eof() instead of io_fillbuf(). It's because io_unread() doesn't work properly when reading CRLF with read(length) and mode 'r'. [ruby-core:44189][Bug #6271] * test/ruby/test_io_m17n.rb (TestIO_M17N#test_read_crlf_and_eof): test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35296 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- io.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'io.c') diff --git a/io.c b/io.c index ca7f1b2e92..f0c851519f 100644 --- a/io.c +++ b/io.c @@ -1614,6 +1614,11 @@ rb_io_eof(VALUE io) if (READ_CHAR_PENDING(fptr)) return Qfalse; if (READ_DATA_PENDING(fptr)) return Qfalse; READ_CHECK(fptr); +#if defined(RUBY_TEST_CRLF_ENVIRONMENT) || defined(_WIN32) + if (!NEED_READCONV(fptr) && NEED_NEWLINE_DECORATOR_ON_READ(fptr)) { + return eof(fptr->fd) ? Qtrue : Qfalse; + } +#endif if (io_fillbuf(fptr) < 0) { return Qtrue; } -- cgit v1.2.3