Here is the patch that fixes the problem. For some unknown reason,
an extra '\n' was being inserted into the stream when switching
from line mode to char-by-char mode on Win9x, and thus terminating
getChar and getLine. However:

getChar >> getLine >>= print

"works", because the first getChar would throw away the extra '\n'.

diff -C2 -r1.5 machdep.c
*** machdep.c   1999/09/13 11:01:03     1.5
--- machdep.c   1999/10/26 03:04:20
***************
*** 951,955 ****
        GetConsoleMode(hIn, &mo);
        SetConsoleMode(hIn, mo & ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT));
!       c = getc(stdin);

        /* Same as it ever was - revert back state of stdin. */
--- 951,962 ----
        GetConsoleMode(hIn, &mo);
        SetConsoleMode(hIn, mo & ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT));
!       /*
!        * On Win9x, the first time you change the mode (as above) a
!        * raw '\n' is inserted.  Since enter maps to a raw '\r', and we
!        * map this (below) to '\n', we can just ignore all *raw* '\n's.
!        */
!       do {
!         c = getc(stdin);
!       } while (c == '\n');

        /* Same as it ever was - revert back state of stain. */

Reply via email to