summaryrefslogtreecommitdiff
path: root/ext/io/console
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-10-10 21:58:07 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-10-11 02:00:26 +0900
commit37259e878f05db4106b67a9fc9cdc426d174282c (patch)
tree08a4262eb445980976de2fd27ce0bf751d42742e /ext/io/console
parenta79966743c346bfc588022db29229b79bee51d45 (diff)
[ruby/io-console] Relaxed min: option warning
When `min: 0` is given to `IO#getch` with `time:` option, it is expected to return nil if timed out, and needed for source code the compatibility with unixen platforms. https://github.com/ruby/io-console/commit/a2afbe72bd
Diffstat (limited to 'ext/io/console')
-rw-r--r--ext/io/console/console.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/ext/io/console/console.c b/ext/io/console/console.c
index 11ce699..7d5181c 100644
--- a/ext/io/console/console.c
+++ b/ext/io/console/console.c
@@ -537,7 +537,13 @@ console_getch(int argc, VALUE *argv, VALUE io)
timeout = rb_scheduler_timeout(&tv);
# endif
}
- if (optp->vmin != 1) {
+ switch (optp->vmin) {
+ case 1: /* default */
+ break;
+ case 0: /* return nil when timed out */
+ if (optp->vtime) break;
+ /* fallthru */
+ default:
rb_warning("min option ignored");
}
if (optp->intr) {