Skip to content

Commit a2afbe7

Browse files
committed
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.
1 parent 3bdfaf6 commit a2afbe7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ext/io/console/console.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,13 @@ console_getch(int argc, VALUE *argv, VALUE io)
537537
timeout = rb_scheduler_timeout(&tv);
538538
# endif
539539
}
540-
if (optp->vmin != 1) {
540+
switch (optp->vmin) {
541+
case 1: /* default */
542+
break;
543+
case 0: /* return nil when timed out */
544+
if (optp->vtime) break;
545+
/* fallthru */
546+
default:
541547
rb_warning("min option ignored");
542548
}
543549
if (optp->intr) {

0 commit comments

Comments
 (0)