delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1998/12/02/21:42:42

From: DJ Delorie <dj AT delorie DOT com>
Subject: Re: B20 patch: CR handling in fhandler_console
02 Dec 1998 21:42:42 -0500 :
Message-ID: <3665FAA2.EC99192F@delorie.com>
References: <3665D672 DOT A1722461 DOT cygnus DOT cygwin32 DOT developers AT cityweb DOT de>
Mime-Version: 1.0
X-Mailer: Mozilla 4.5 [en] (X11; I; Linux 2.1.126 i586)
X-Accept-Language: en

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.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019