1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

readline.c: fix type

* ext/readline/readline.c (getc_body): fix variable type, and
  extract _get_osfhandle.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57769 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-03-04 05:13:18 +00:00
parent 2e97d5bc42
commit 1ec805727e

View file

@ -164,23 +164,24 @@ getc_body(struct getc_struct *p)
#if defined(_WIN32)
{
INPUT_RECORD ir;
int n;
DWORD n;
static int prior_key = '0';
for (;;) {
HANDLE h;
if (prior_key > 0xff) {
prior_key = rl_getc(p->input);
return prior_key;
}
if (PeekConsoleInput((HANDLE)_get_osfhandle(p->fd), &ir, 1, &n)) {
h = (HANDLE)_get_osfhandle(p->fd);
if (PeekConsoleInput(h, &ir, 1, &n)) {
if (n == 1) {
if (ir.EventType == KEY_EVENT && ir.Event.KeyEvent.bKeyDown) {
prior_key = rl_getc(p->input);
return prior_key;
} else {
ReadConsoleInput((HANDLE)_get_osfhandle(p->fd), &ir, 1, &n);
ReadConsoleInput(h, &ir, 1, &n);
}
} else {
HANDLE h = (HANDLE)_get_osfhandle(p->fd);
rb_w32_wait_events(&h, 1, INFINITE);
}
} else {