From: dnsands AT sandia DOT gov (Daniel Sands) Subject: Huge bug with C read() function for DOS text files 1 May 1998 18:33:33 -0700 Message-ID: <354A1E6C.95D.cygnus.gnu-win32@sandia.gov> Reply-To: dnsands AT sandia DOT gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: gnu-win32 AT cygnus DOT com 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 AT cygnus DOT com" with one line of text: "help".