io/console: support getch timeout on Windows

This commit is contained in:
Nobuyoshi Nakada 2019-05-14 14:21:46 +09:00
Родитель 6d733565c2
Коммит 456586bb23
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4BC7D6DF58D8DF60
1 изменённых файлов: 9 добавлений и 1 удалений

Просмотреть файл

@ -419,7 +419,15 @@ console_getch(int argc, VALUE *argv, VALUE io)
GetOpenFile(io, fptr);
if (optp) {
rb_warning("option ignored");
struct timeval *to = NULL, tv;
if (optp->vtime) {
to = &tv;
tv.tv_sec = optp->vtime / 10;
tv.tv_usec = (optp->vtime % 10) * 100000;
}
if (optp->vmin) {
rb_warning("min option ignored");
}
}
w = rb_wait_for_single_fd(fptr->fd, RB_WAITFD_IN, NULL);
if (w < 0) rb_eof_error();