This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
RE: Huge bug with C read() function for DOS text files
- To: "gnu-win32 at cygnus dot com" <gnu-win32 at cygnus dot com>, "'dnsands at sandia dot gov'" <dnsands at sandia dot gov>
- Subject: RE: Huge bug with C read() function for DOS text files
- From: Sergey Okhapkin <sos at buggy dot prospect dot com dot ru>
- Date: Sun, 3 May 1998 10:01:40 +0400
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
"gnu-win32-request@cygnus.com" with one line of text: "help".