kernel32: ReadConsoleW should wait for at least one character before returning.

This commit is contained in:
Kirill K. Smirnov 2007-12-18 19:38:50 +03:00 committed by Alexandre Julliard
parent 979a43e49d
commit c9700896fe
1 changed files with 4 additions and 1 deletions

View File

@ -1359,17 +1359,20 @@ BOOL WINAPI ReadConsoleW(HANDLE hConsoleInput, LPVOID lpBuffer,
/* FIXME: should we read at least 1 char? The SDK does not say */ /* FIXME: should we read at least 1 char? The SDK does not say */
/* wait for at least one available input record (it doesn't mean we'll have /* wait for at least one available input record (it doesn't mean we'll have
* chars stored in xbuf...) * chars stored in xbuf...)
*
* Although SDK doc keeps silence about 1 char, SDK examples assume
* that we should wait for at least one character (not key). --KS
*/ */
charsread = 0; charsread = 0;
do do
{ {
if (read_console_input(hConsoleInput, &ir, timeout) != rci_gotone) break; if (read_console_input(hConsoleInput, &ir, timeout) != rci_gotone) break;
timeout = 0;
if (ir.EventType == KEY_EVENT && ir.Event.KeyEvent.bKeyDown && if (ir.EventType == KEY_EVENT && ir.Event.KeyEvent.bKeyDown &&
ir.Event.KeyEvent.uChar.UnicodeChar && ir.Event.KeyEvent.uChar.UnicodeChar &&
!(ir.Event.KeyEvent.dwControlKeyState & ENHANCED_KEY)) !(ir.Event.KeyEvent.dwControlKeyState & ENHANCED_KEY))
{ {
xbuf[charsread++] = ir.Event.KeyEvent.uChar.UnicodeChar; xbuf[charsread++] = ir.Event.KeyEvent.uChar.UnicodeChar;
timeout = 0;
} }
} while (charsread < nNumberOfCharsToRead); } while (charsread < nNumberOfCharsToRead);
/* nothing has been read */ /* nothing has been read */