delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2002/05/09/06:15:01

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-workers-bounces using -f
From: pavenis AT lanet DOT lv
To: Andris Pavenis <pavenis AT latnet DOT lv>, djgpp-workers AT delorie DOT com,
zack AT codesourcery DOT com
Date: Thu, 9 May 2002 13:14:53 +0300
MIME-Version: 1.0
Subject: Re: RFA: Ignore DOS end-of-line characters (ctrl-Z) unless -W
Cc: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>,
Nick Clifton <nickc AT cambridge DOT redhat DOT com>, djgpp-workers AT delorie DOT com,
gcc-patches AT gcc DOT gnu DOT org
Message-ID: <3CDA764D.1410.A1F3EA@localhost>
In-reply-to: <20020508162338.GF20829@codesourcery.com>
References: <200205081853 DOT 11194 DOT pavenis AT latnet DOT lv>
X-mailer: Pegasus Mail for Windows (v4.01)
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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.




- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019