mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
io/wait: fix return value for buffered read
* ext/io/wait/wait.c (io_nread): wrap return value with INT2FIX Thanks to Yura Sokolov <funny.falcon@gmail.com> [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
This commit is contained in:
parent
40564c1e3b
commit
26e1ebdc1e
3 changed files with 10 additions and 2 deletions
|
@ -1,3 +1,11 @@
|
|||
Mon Mar 2 06:01:41 2015 Eric Wong <e@80x24.org>
|
||||
|
||||
* ext/io/wait/wait.c (io_nread): wrap return value with INT2FIX
|
||||
Thanks to Yura Sokolov <funny.falcon@gmail.com>
|
||||
[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 <nobu@ruby-lang.org>
|
||||
|
||||
* configure.in (RUBY_REPLACE_TYPE): restore convertible type from
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue