delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2005/04/18/11:47:42

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
From: Andris Pavenis <pavenis AT latnet DOT lv>
To: gcc-patches AT gcc DOT gnu DOT org, djgpp-workers AT delorie DOT com
Subject: [libcpp] [PATCH] Handle DOS EOF character for DJGPP
Date: Mon, 18 Apr 2005 18:46:37 +0300
User-Agent: KMail/1.8
MIME-Version: 1.0
Message-Id: <200504181846.38506.pavenis@latnet.lv>
X-Virus-Scanned: amavisd-new at fgi.fi
Reply-To: djgpp-workers AT delorie DOT com

Here is patch for HEAD branch of GCC for handling DOS EOF character (0x1A, ^Z) 
in libcpp. 

At least I have met situations when DOS EOF character is written at end of file by 
some editors which causes compiler to generate error.

Andris 

2005-04-18  Andris Pavenis  <pavenis AT latnet DOT lv>

 * files.c: Include io.h for DJGPP
 (read_file_guts) Handle DOS EOF character (^Z) for DJGPP
 

Index: gcc/libcpp/files.c
===================================================================
RCS file: /cvs/gcc/gcc/libcpp/files.c,v
retrieving revision 1.9
diff -u -p -3 -r1.9 files.c
--- gcc/libcpp/files.c 14 Feb 2005 14:43:56 -0000 1.9
+++ gcc/libcpp/files.c 18 Apr 2005 15:32:31 -0000
@@ -40,6 +40,7 @@ Foundation, 59 Temple Place - Suite 330,
 #endif
 
 #ifdef __DJGPP__
+#include <io.h>
   /* For DJGPP redirected input is opened in text mode.  */
 #  define set_stdin_to_binary_mode() \
      if (! isatty (0)) setmode (0, O_BINARY)
@@ -573,6 +574,14 @@ read_file_guts (cpp_reader *pfile, _cpp_
     cpp_error (pfile, CPP_DL_WARNING,
         "%s is shorter than expected", file->path);
 
+#ifdef __DJGPP__
+/* For DOS we should handle DOS EOF character (0x1A, ^Z)  */
+  do {
+     uchar * dos_eof = memchr (buf, 0x1A, total);
+     if (dos_eof) total = dos_eof - buf;
+  } while (0);
+#endif
+  
   file->buffer = _cpp_convert_input (pfile, CPP_OPTION (pfile, input_charset),
          buf, size, total, &file->st.st_size);
   file->buffer_valid = true;

- Raw text -


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