From 26e1ebdc1e3a26edada728000bb25b040d7ff4cc Mon Sep 17 00:00:00 2001 From: normal Date: Sun, 1 Mar 2015 21:03:22 +0000 Subject: [PATCH] io/wait: fix return value for buffered read * ext/io/wait/wait.c (io_nread): wrap return value with INT2FIX Thanks to Yura Sokolov [ruby-core:68369] [Bug#10923] * test/io/wait/test_io_wait.rb (test_nread_buffered): fix broken test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49797 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ ext/io/wait/wait.c | 2 +- test/io/wait/test_io_wait.rb | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index e5dd9fa3e8..93489be61e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Mon Mar 2 06:01:41 2015 Eric Wong + + * ext/io/wait/wait.c (io_nread): wrap return value with INT2FIX + Thanks to Yura Sokolov + [ruby-core:68369] [Bug#10923] + * test/io/wait/test_io_wait.rb (test_nread_buffered): + fix broken test + Sun Mar 1 20:21:16 2015 Nobuyoshi Nakada * configure.in (RUBY_REPLACE_TYPE): restore convertible type from diff --git a/ext/io/wait/wait.c b/ext/io/wait/wait.c index 7e17cb2e89..fd32be79b1 100644 --- a/ext/io/wait/wait.c +++ b/ext/io/wait/wait.c @@ -62,7 +62,7 @@ io_nread(VALUE io) GetOpenFile(io, fptr); rb_io_check_readable(fptr); len = rb_io_read_pending(fptr); - if (len > 0) return len; + if (len > 0) return INT2FIX(len); if (!FIONREAD_POSSIBLE_P(fptr->fd)) return INT2FIX(0); if (ioctl(fptr->fd, FIONREAD, &n)) return INT2FIX(0); if (n > 0) return ioctl_arg2num(n); diff --git a/test/io/wait/test_io_wait.rb b/test/io/wait/test_io_wait.rb index 9d883aa821..7729d45526 100644 --- a/test/io/wait/test_io_wait.rb +++ b/test/io/wait/test_io_wait.rb @@ -31,7 +31,7 @@ class TestIOWait < Test::Unit::TestCase def test_nread_buffered @w.syswrite ".\n!" - assert_equal ".\n", @r.read(2) + assert_equal ".\n", @r.gets assert_equal 1, @r.nread end