Subject: RE: Huge bug with C read() function for DOS text files
From: [email-masked] (Sergey Okhapkin)

3 May 1998 03:39:21 -0700
Message-ID: <01BD767A.787B8310.cygnus.gnu-win32@sos>
To: "[email-masked]" <[email-masked]>,
        "[email-masked]'"
	 <[email-masked]>

Daniel Sands wrote:
> I noticed while trying to modify BASH that there is a huge problem
> introduced when reading a text file which was formatted for DOS.  The
> problem is with the .DEF compiler in Bash's builtins directory.  Here's
> what happens:
>
>    1) It stats the file to get the size
>    2) It opens for text mode and reads the entire file into a buffer
>
> The read line looks like this:
>   if (read (fd, buffer, finfo.st_size) < finfo.st_size/2)
>
> The C function reads finfo.st_size bytes from the file, but then removes
> #CR bytes (the number of CR's).
>

Some time ago I sent a patch to bash maintainers to fix translation mode 
problems when reading shell scripts. The fix is included into current 
bash-2.02 release. This release is available on prep.ai.mit.edu/pub/gnu. 
The sourses are ready to compile with cygwin (including forced text mode 
for pipes :-), readline library has additional cygwin-specific command 
"paste from windows clipboard" as suggested by Chuck Bogorad.

--
Sergey Okhapkin, http://www.lexa.ru/sos
Moscow, Russia

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".