From 30f637024b4a50d98d46496ca121f8d7dea946c7 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 13 May 2010 09:45:29 +0000 Subject: [PATCH] * ext/io/console/console.c (get_write_fd): return primary fd if no io is tied for writing. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ ext/io/console/console.c | 2 +- test/io/console/test_io_console.rb | 9 +++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 205e255318..5450d5567f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu May 13 18:45:25 2010 Nobuyoshi Nakada + + * ext/io/console/console.c (get_write_fd): return primary fd if no + io is tied for writing. + Thu May 13 18:15:33 2010 NAKAMURA Usaku * io.c (swallow): should use more_char() instead of fill_cbuf(). diff --git a/ext/io/console/console.c b/ext/io/console/console.c index 0b29c72c7a..67b3b02175 100644 --- a/ext/io/console/console.c +++ b/ext/io/console/console.c @@ -164,7 +164,7 @@ get_write_fd(const rb_io_t *fptr) { VALUE wio = fptr->tied_io_for_writing; rb_io_t *ofptr; - if (!wio) return -1; + if (!wio) return fptr->fd; GetOpenFile(wio, ofptr); return ofptr->fd; } diff --git a/test/io/console/test_io_console.rb b/test/io/console/test_io_console.rb index 2e46176616..7d919c758c 100644 --- a/test/io/console/test_io_console.rb +++ b/test/io/console/test_io_console.rb @@ -70,4 +70,13 @@ class TestIO_Console < Test::Unit::TestCase } end + def test_oflush + PTY.open {|m, s| + s.print "a\n" + s.oflush + s.print "b\n" + assert_equal("b\r\n", m.readpartial(10)) + } + end + end