This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
Huge bug with C read() function for DOS text files
- To: gnu-win32 at cygnus dot com
- Subject: Huge bug with C read() function for DOS text files
- From: Daniel Sands <dnsands at sandia dot gov>
- Date: Fri, 01 May 1998 13:11:40 -0600
- Organization: Sandia National Laboratories
- Reply-To: dnsands at sandia dot gov
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).
The bug: Even though it removed #CR bytes, it still returns that it
read finfo.st_size bytes, and includes the #CR bytes at the end which
should have been completely thrown out. Because of this, MKBUILTINS.C
writes extra junk to the .C file that it creates, causing a CPP error.
This is probably the reason that so many text programs do not work
anymore.
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".