This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFA: Ignore DOS end-of-line characters (ctrl-Z) unless -W


On 8 May 2002 at 9:23, Zack Weinberg wrote:

> This should be done in open_file():
> 
>   /* ...
> 
>      O_BINARY tells some runtime libraries (notably DJGPP) not to do
>      newline translation; we can handle DOS line breaks just fine
>      ourselves.
> 
>      Special case: the empty string is translated to stdin.  */
> 
>   if (filename[0] == '\0')
>     file->fd = 0;
>   else
>     file->fd = open (file->name, O_RDONLY | O_NOCTTY | O_BINARY, 0666);
> 
> A tested patch that does that and nothing else is preapproved.

OK. Here it is (tested for DJGPP with 3.1 branch)

--- cppfiles.c~1	Thu May  9 10:32:46 2002
+++ cppfiles.c	Thu May  9 12:57:10 2002
@@ -270,7 +270,13 @@
      Special case: the empty string is translated to stdin.  */
 
   if (filename[0] == '\0')
-    file->fd = 0;
+    {
+      file->fd = 0;
+#ifdef __DJGPP__
+      if (!isatty(file->fd))
+        setmode (file->fd, O_BINARY);
+#endif
+    }
   else
     file->fd = open (file->name, O_RDONLY | O_NOCTTY | O_BINARY, 0666);
 


Andris

PS. I'm also keeping my other patch for handling ^Z for DJGPP in cppfiles.c   
      before it's handled in other place.





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]