This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFA: Ignore DOS end-of-line characters (ctrl-Z) unless -W
- 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
- 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
- Date: Thu, 9 May 2002 13:14:53 +0300
- Subject: Re: RFA: Ignore DOS end-of-line characters (ctrl-Z) unless -W
- References: <200205081853.11194.pavenis@latnet.lv>
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.