From bfed3296ec81c2ca53e65dc3df5b0e8f1e6810ab Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 11 Nov 2021 18:12:18 +0900 Subject: Bump io-wait version to 0.2.0 --- ext/io/wait/io-wait.gemspec | 8 +++++--- ext/io/wait/wait.c | 36 +++++++++++++++++------------------- 2 files changed, 22 insertions(+), 22 deletions(-) (limited to 'ext') diff --git a/ext/io/wait/io-wait.gemspec b/ext/io/wait/io-wait.gemspec index 1c6c2d5705..ec23699def 100644 --- a/ext/io/wait/io-wait.gemspec +++ b/ext/io/wait/io-wait.gemspec @@ -1,6 +1,8 @@ +_VERSION = "0.2.0" + Gem::Specification.new do |spec| spec.name = "io-wait" - spec.version = "0.1.0" + spec.version = _VERSION spec.authors = ["Nobu Nakada"] spec.email = ["nobu@ruby-lang.org"] @@ -8,7 +10,7 @@ Gem::Specification.new do |spec| spec.description = %q{Waits until IO is readable or writable without blocking.} spec.homepage = "https://github.com/ruby/io-wait" spec.licenses = ["Ruby", "BSD-2-Clause"] - spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0") + spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0") spec.metadata["homepage_uri"] = spec.homepage spec.metadata["source_code_uri"] = spec.homepage @@ -20,6 +22,6 @@ Gem::Specification.new do |spec| end spec.extensions = %w[ext/io/wait/extconf.rb] spec.bindir = "exe" - spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } + spec.executables = [] spec.require_paths = ["lib"] end diff --git a/ext/io/wait/wait.c b/ext/io/wait/wait.c index c5de8967cd..512e4f6a80 100644 --- a/ext/io/wait/wait.c +++ b/ext/io/wait/wait.c @@ -211,7 +211,7 @@ wait_mode_sym(VALUE mode) /* * call-seq: * io.wait(events, timeout) -> event mask or false. - * io.wait(timeout = nil, mode = :read) -> event mask or false (deprecated) + * io.wait(timeout = nil, mode = :read) -> event mask or false. * * Waits until the IO becomes ready for the specified events and returns the * subset of events that become ready, or +false+ when times out. @@ -222,34 +222,32 @@ wait_mode_sym(VALUE mode) * Returns +true+ immediately when buffered data is available. * * Optional parameter +mode+ is one of +:read+, +:write+, or - * +:read_write+ (deprecated). + * +:read_write+. */ static VALUE io_wait(int argc, VALUE *argv, VALUE io) { - VALUE timeout = Qnil; + VALUE timeout = Qundef; rb_io_event_t events = 0; - if (argc < 2 || (argc >= 2 && RB_SYMBOL_P(argv[1]))) { - if (argc > 0) { - timeout = argv[0]; - } - - for (int i = 1; i < argc; i += 1) { - events |= wait_mode_sym(argv[i]); + if (argc != 2 || (RB_SYMBOL_P(argv[0]) || RB_SYMBOL_P(argv[1]))) { + for (int i = 0; i < argc; i += 1) { + if (RB_SYMBOL_P(argv[i])) { + events |= wait_mode_sym(argv[i]); + } + else if (timeout == Qundef) { + rb_time_interval(timeout = argv[i]); + } + else { + rb_raise(rb_eArgError, "timeout given more than once"); + } } + if (timeout == Qundef) timeout = Qnil; } - else if (argc == 2) { + else /* argc == 2 */ { events = RB_NUM2UINT(argv[0]); - - if (argv[1] != Qnil) { - timeout = argv[1]; - } - } - else { - // TODO error - return Qnil; + timeout = argv[1]; } if (events == 0) { -- cgit v1.2.3