diff options
| -rw-r--r-- | ext/io/wait/wait.c | 8 | ||||
| -rw-r--r-- | io.c | 4 | ||||
| -rw-r--r-- | test/io/wait/test_io_wait_uncommon.rb | 30 | ||||
| -rw-r--r-- | version.h | 2 |
4 files changed, 37 insertions, 7 deletions
diff --git a/ext/io/wait/wait.c b/ext/io/wait/wait.c index 8835670e59..255b12d236 100644 --- a/ext/io/wait/wait.c +++ b/ext/io/wait/wait.c @@ -84,7 +84,7 @@ io_nread(VALUE io) ioctl_arg n; GetOpenFile(io, fptr); - rb_io_check_readable(fptr); + rb_io_check_char_readable(fptr); len = rb_io_read_pending(fptr); if (len > 0) return INT2FIX(len); @@ -143,7 +143,7 @@ io_ready_p(VALUE io) #endif GetOpenFile(io, fptr); - rb_io_check_readable(fptr); + rb_io_check_char_readable(fptr); if (rb_io_read_pending(fptr)) return Qtrue; #ifndef HAVE_RB_IO_WAIT @@ -178,7 +178,7 @@ io_wait_readable(int argc, VALUE *argv, VALUE io) #endif GetOpenFile(io, fptr); - rb_io_check_readable(fptr); + rb_io_check_char_readable(fptr); #ifndef HAVE_RB_IO_WAIT tv = get_timeout(argc, argv, &timerec); @@ -252,7 +252,7 @@ io_wait_priority(int argc, VALUE *argv, VALUE io) rb_io_t *fptr = NULL; RB_IO_POINTER(io, fptr); - rb_io_check_readable(fptr); + rb_io_check_char_readable(fptr); if (rb_io_read_pending(fptr)) return Qtrue; @@ -9744,7 +9744,7 @@ io_wait_readable(int argc, VALUE *argv, VALUE io) rb_io_t *fptr; RB_IO_POINTER(io, fptr); - rb_io_check_readable(fptr); + rb_io_check_char_readable(fptr); if (rb_io_read_pending(fptr)) return Qtrue; @@ -9791,7 +9791,7 @@ io_wait_priority(int argc, VALUE *argv, VALUE io) rb_io_t *fptr = NULL; RB_IO_POINTER(io, fptr); - rb_io_check_readable(fptr); + rb_io_check_char_readable(fptr); if (rb_io_read_pending(fptr)) return Qtrue; diff --git a/test/io/wait/test_io_wait_uncommon.rb b/test/io/wait/test_io_wait_uncommon.rb index 0f922f4e24..0f97ac35d9 100644 --- a/test/io/wait/test_io_wait_uncommon.rb +++ b/test/io/wait/test_io_wait_uncommon.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true require 'test/unit' +require 'io/wait' # test uncommon device types to check portability problems # We may optimize IO#wait_*able for non-Linux kernels in the future @@ -74,4 +75,33 @@ class TestIOWaitUncommon < Test::Unit::TestCase def test_wait_writable_null check_dev(IO::NULL, :wait_writable) end + + def test_after_ungetc_ready? + check_dev(IO::NULL, mode: "r") {|fp| + assert_respond_to fp, :ready? + fp.ungetc(?a) + assert_predicate fp, :ready? + } + end + + def test_after_ungetc_wait_readable + check_dev(IO::NULL, mode: "r") {|fp| + fp.ungetc(?a) + assert_predicate fp, :wait_readable + } + end + + def test_after_ungetc_in_text_ready? + check_dev(IO::NULL, mode: "rt") {|fp| + fp.ungetc(?a) + assert_predicate fp, :ready? + } + end + + def test_after_ungetc_in_text_wait_readable + check_dev(IO::NULL, mode: "rt") {|fp| + fp.ungetc(?a) + assert_predicate fp, :wait_readable + } + end end @@ -11,7 +11,7 @@ # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR #define RUBY_VERSION_TEENY 10 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 184 +#define RUBY_PATCHLEVEL 185 #include "ruby/version.h" #include "ruby/internal/abi.h" |
