summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-04-14 19:36:06 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-04-14 19:36:06 +0000
commit7201291187cdeb0e842280a3d77e41094993d0b7 (patch)
treec91e52d013ad7c22d3eb2f8327f0cef02bda42d2
parent0e84de2b9830e3b752ba5f8d97aa3c38924aafc5 (diff)
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@35331 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog10
-rw-r--r--io.c5
-rw-r--r--test/ruby/test_io_m17n.rb16
-rw-r--r--version.h2
4 files changed, 32 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index ee15273a52..fa937de3d0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Sun Apr 15 04:35:48 2012 Hiroshi Shirosaki <h.shirosaki@gmail.com>
+
+ * 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@ruby-lang.org>
* io.c (io_unread): fixed memory leak. report by nagachika via IRC.
diff --git a/io.c b/io.c
index 4bb53cb969..bbe5da93e8 100644
--- a/io.c
+++ b/io.c
@@ -1444,6 +1444,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;
}
diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb
index c6cff18957..560cd03def 100644
--- a/test/ruby/test_io_m17n.rb
+++ b/test/ruby/test_io_m17n.rb
@@ -2362,4 +2362,20 @@ EOT
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
diff --git a/version.h b/version.h
index a270fcea70..7c8db42fa8 100644
--- a/version.h
+++ b/version.h
@@ -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