Mail Archives: cygwin-developers/1999/01/11/08:31:42
While you are in fhandler_console.cc:
@@ -1234,7 +1226,7 @@
else
buf[copied_chars++] = input_rec.Event.KeyEvent.uChar.AsciiChar;
}
- if (copied_chars ||
+ if (copied_chars >= lenin ||
WaitForSingleObject (hndl, 0) != WAIT_OBJECT_0)
break;
}
ReadConsoleInput() already blocks and there is no reason to wait if there
are already characters read. This patch fixes the problem where pasted
characters fail to show up until a key is pressed. It also fixes some
console mode peculiarities where an extra key press is required.
Kevin
> -----Original Message-----
> From: Christopher Faylor [mailto:cgf AT cygnus DOT com]
> Sent: Monday, January 11, 1999 9:18 AM
> To: Kazuhiro Fujieda; cygwin32-developers AT cygnus DOT com
> Subject: Re: fhandler_console bug
>
>
> I've added code to fhandler_console.cc which specifically handles EOF.
> It will be in the next snapshot.
>
> Thanks for finding this.
>
> -chris
>
> On Mon, Jan 11, 1999 at 09:16:00PM +0900, Kazuhiro Fujieda wrote:
> >The following program is hanged up when Return and ^Z are typed
> >continuously in notty mode on Win95.
> >
> >#include <stdio.h>
> >main()
> >{
> > int ch;
> > while ((ch = fgetc(stdin)) != EOF) {
> > printf("ch = %02x\n", ch);
> > }
> >}
> >
> >The reason of it is in fhandler_console.cc:1143-1157.
> >
> >1142: copied_chars = 0x12345678;
> >1143: if ((res = ReadFile (hndl, buf, lenin,
> &copied_chars, NULL)) &&
> >1144: copied_chars == 0x12345678)
> >
> >When ^Z is typed, ReadFile catch the EOF and set copied_char is 0.
> >But the succeeding code take no account of this case. On Win95,
> >ReadFile doesn't modify the contents of buf in this case, so
> >buf[0] is still '\n' and the program is crushed by the following
> >code.
> >
> >1153: if (!looped++ && buf[0] == '\n')
> >1154: {
> >1155: if (!--copied_chars)
> >1156: continue;
> >1157: memcpy (buf, buf + 1, copied_chars);
> >____
> > | AIST Kazuhiro Fujieda <fujieda AT jaist DOT ac DOT jp>
> > | HOKURIKU School of Information Science
> >o_/ 1990 Japan Advanced Institute of Science and Technology
> >
>
> --
> cgf AT cygnus DOT com
> http://www.cygnus.com/
>
- Raw text -