ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2002/05/08/11:54:26

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-workers-bounces using -f
From: Andris Pavenis <pavenis AT latnet DOT lv>
To: Zack Weinberg <zack AT codesourcery DOT com>, Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
Subject: Re: RFA: Ignore DOS end-of-line characters (ctrl-Z) unless -W
Date: Wed, 8 May 2002 18:53:11 +0300
User-Agent: KMail/1.4.1
Cc: Nick Clifton <nickc AT cambridge DOT redhat DOT com>, djgpp-workers AT delorie DOT com,
gcc-patches AT gcc DOT gnu DOT org
References: <Pine DOT LNX DOT 4 DOT 21 DOT 0205081655590 DOT 26648-100000 AT gulbis DOT latnet DOT lv> <Pine DOT SUN DOT 3 DOT 91 DOT 1020508170644 DOT 25387K-100000 AT is> <20020508153338 DOT GE20829 AT codesourcery DOT com>
In-Reply-To: <20020508153338.GE20829@codesourcery.com>
MIME-Version: 1.0
Message-Id: <200205081853.11194.pavenis@latnet.lv>
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id g48FsPQ13489
Reply-To: djgpp-workers AT delorie DOT com

On Wednesday 08 May 2002 18:33, Zack Weinberg wrote:
> On Wed, May 08, 2002 at 05:09:20PM +0300, Eli Zaretskii wrote:
> > On Wed, 8 May 2002, Andris Pavenis wrote:
> > > Original message (and patch) was due to a different reason: use of
> > > source files originated from DOS under other systems (unfortunatelly
> > > read initial message not too carefully ...)
> >
> > For other systems, I guess a warning under -W is okay.
>
> With or without truncating the input file?

I don't know. For DJGPP one needs that as I have seen source files ending ^Z 
generated while building some packages. Also some text editors writes it at 
the end of file. I don't know what GCC should  do on other systems

>
> Is ^Z to be honored wherever it appears, or only immediately after a
> newline sequence?

Here is what I have in patchset for DJGPP

--- cppfiles.c.orig     Fri Jan 18 15:40:28 2002
+++ cppfiles.c  Tue May  7 12:24:48 2002
@@ -414,6 +414,12 @@
        {
          buf = (U_CHAR *) xmalloc (size + 1);
          offset = 0;
+#ifdef __DJGPP__
+          /* For DJGPP redirected input is opened with O_TEXT by default
+             change it to O_BINARY  */
+         if (inc->fd==0)
+            setmode (inc->fd, O_BINARY);
+#endif
          while (offset < size)
            {
              count = read (inc->fd, buf + offset, size - offset);
@@ -469,6 +475,20 @@
       inc->st.st_size = offset;
     }

+#ifdef __DJGPP__
+/* For DOS we should handle DOS EOF character (0x1A, ^Z)  */
+  do {
+    U_CHAR * dos_eof = memchr (buf, 0x1A, offset);
+    if (dos_eof) {
+      offset = dos_eof - buf;
+      buf = xrealloc (buf, offset + 1);
+      /* The lexer requires that the buffer be NUL-terminated.  */
+      buf[offset] = '\0';
+      inc->st.st_size = offset;
+    }
+  } while (0);
+#endif
+
   inc->buffer = buf;
   return 0;


>
> > > It reads in binary mode.
> >
> > I hope only when the input comes from a file, not from a terminal.
>
> It makes no distinction.  What goes wrong when one reads from a
> terminal in binary mode under DOS?
>
> (I'm not sure how to open a file in text mode using open(),
> incidentally)

Andris

- Raw text -


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