From: cgf AT cygnus DOT com (Christopher Faylor) Subject: Re: B20 patch: CR handling in fhandler_console 2 Dec 1998 19:32:19 -0800 Message-ID: <19981202220732.A6801.cygnus.cygwin32.developers@cygnus.com> References: <3665D672 DOT A1722461 DOT cygnus DOT cygwin32 DOT developers AT cityweb DOT de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii To: DJ Delorie , cygwin32-developers AT cygnus DOT com On Wed, Dec 02, 1998 at 09:42:42PM -0500, DJ Delorie wrote: >Corinna Vinschen wrote: >> in fhandler_console::read1() a short piece of code >> ignores CR if it is the one and only char in console input. >> >> I have found no circumstance, in which this code makes sense. > >Be careful. If the console is in text mode, the \r character >will be stripped (i.e. crlf->nl conversion). If the user >asked to read one character, and it is stripped, the function >will report that zero characters were read. This is an EOF >indicator, even though it is not really EOF. > >What the code should do is *if* the \r would be stripped, >it should read the following \n. If it can tell that >the \r is alone (no \n) but would be stripped, it should >probably change it to a \n. If the console is in binary >mode (no stripping), it can safely return a \r character. At that point in the function, the console is *guaranteed* to be in cooked mode. If it sees a \r, then it should be ignored. I think the code is correct, but then I would, because I wrote it. -- cgf AT cygnus DOT com http://www.cygnus.com/