ruby-changes:23280
From: naruse <ko1@a...>
Date: Sun, 15 Apr 2012 04:36:20 +0900 (JST)
Subject: [ruby-changes:23280] naruse:r35331 (ruby_1_9_3): merge revision(s) 35296: [Backport #6295]
naruse 2012-04-15 04:36:06 +0900 (Sun, 15 Apr 2012) New Revision: 35331 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35331 Log: merge revision(s) 35296: [Backport #6295] * 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. Modified files: branches/ruby_1_9_3/ChangeLog branches/ruby_1_9_3/io.c branches/ruby_1_9_3/test/ruby/test_io_m17n.rb branches/ruby_1_9_3/version.h Index: ruby_1_9_3/ChangeLog =================================================================== --- ruby_1_9_3/ChangeLog (revision 35330) +++ ruby_1_9_3/ChangeLog (revision 35331) @@ -1,3 +1,13 @@ +Sun Apr 15 04:35:48 2012 Hiroshi Shirosaki <h.shirosaki@g...> + + * 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. + Sun Apr 15 03:00:54 2012 NAKAMURA Usaku <usa@r...> * io.c (io_unread): fixed memory leak. report by nagachika via IRC. Index: ruby_1_9_3/io.c =================================================================== --- ruby_1_9_3/io.c (revision 35330) +++ ruby_1_9_3/io.c (revision 35331) @@ -1444,6 +1444,11 @@ 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; } Index: ruby_1_9_3/version.h =================================================================== --- ruby_1_9_3/version.h (revision 35330) +++ ruby_1_9_3/version.h (revision 35331) @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.3" -#define RUBY_PATCHLEVEL 180 +#define RUBY_PATCHLEVEL 181 #define RUBY_RELEASE_DATE "2012-04-15" #define RUBY_RELEASE_YEAR 2012 Index: ruby_1_9_3/test/ruby/test_io_m17n.rb =================================================================== --- ruby_1_9_3/test/ruby/test_io_m17n.rb (revision 35330) +++ ruby_1_9_3/test/ruby/test_io_m17n.rb (revision 35331) @@ -2362,4 +2362,20 @@ end } end if /mswin|mingw/ =~ RUBY_PLATFORM + + def test_read_crlf_and_eof + bug6271 = '[ruby-core:44189]' + with_tmpdir { + str = "a\r\nb\r\nc\r\n" + generate_file("tmp", str) + open("tmp", "r") do |f| + i = 0 + until f.eof? + assert_equal(str[i], f.read(1), bug6271) + i += 1 + end + assert_equal(str.size, i, bug6271) + end + } + end if /mswin|mingw/ =~ RUBY_PLATFORM end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/