gcc.c (load_specs): New static function.
authorMumit Khan <khan@xraylith.wisc.edu>
Mon, 24 Apr 2000 23:57:46 +0000 (23:57 +0000)
committerJeff Law <law@gcc.gnu.org>
Mon, 24 Apr 2000 23:57:46 +0000 (17:57 -0600)
        * gcc.c (load_specs): New static function.
        (read_specs): Use it.

From-SVN: r33395

gcc/ChangeLog
gcc/gcc.c

index 71ebba4..a4bb170 100644 (file)
@@ -1,5 +1,8 @@
 Mon Apr 24 17:34:18 2000  Mumit Khan  <khan@xraylith.wisc.edu>
 
+       * gcc.c (load_specs): New static function.
+       (read_specs): Use it.
+
        * gcc.c (lookup_compiler): Make multiple passes for case
        insensitive filesystems.
 
index d8dd563..7730482 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -1451,27 +1451,21 @@ store_arg (arg, delete_always, delete_failure)
     record_temp_file (arg, delete_always, delete_failure);
 }
 \f
-/* Read compilation specs from a file named FILENAME,
-   replacing the default ones.
+/* Load specs from a file name named FILENAME, replacing occurances of
+   various different types of line-endings, \r\n, \n\r and just \r, with 
+   a single \n.  */
 
-   A suffix which starts with `*' is a definition for
-   one of the machine-specific sub-specs.  The "suffix" should be
-   *asm, *cc1, *cpp, *link, *startfile, *signed_char, etc.
-   The corresponding spec is stored in asm_spec, etc.,
-   rather than in the `compilers' vector.
-
-   Anything invalid in the file is a fatal error.  */
-
-static void
-read_specs (filename, main_p)
+static char*
+load_specs (filename)
      const char *filename;
-     int main_p;
 {
   int desc;
   int readlen;
   struct stat statbuf;
   char *buffer;
-  register char *p;
+  char *buffer_p;
+  char *specs;
+  char *specs_p;
 
   if (verbose_flag)
     notice ("Reading specs from %s\n", filename);
@@ -1491,6 +1485,51 @@ read_specs (filename, main_p)
   buffer[readlen] = 0;
   close (desc);
 
+  specs = xmalloc (readlen + 1);
+  specs_p = specs;
+  for (buffer_p = buffer; buffer_p && *buffer_p; buffer_p++)
+    {
+      int skip = 0;
+      char c = *buffer_p;
+      if (c == '\r')
+        {
+         if (buffer_p > buffer && *(buffer_p-1) == '\n')       /* \n\r */
+           skip = 1;
+         else if (*(buffer_p+1) == '\n')                       /* \r\n */
+           skip = 1;
+         else                                                  /* \r */
+           c = '\n';
+       }
+      if (! skip)
+       *specs_p++ = c;
+    }
+  *specs_p = '\0';
+
+  free (buffer);
+  return (specs);
+}
+
+/* Read compilation specs from a file named FILENAME,
+   replacing the default ones.
+
+   A suffix which starts with `*' is a definition for
+   one of the machine-specific sub-specs.  The "suffix" should be
+   *asm, *cc1, *cpp, *link, *startfile, *signed_char, etc.
+   The corresponding spec is stored in asm_spec, etc.,
+   rather than in the `compilers' vector.
+
+   Anything invalid in the file is a fatal error.  */
+
+static void
+read_specs (filename, main_p)
+     const char *filename;
+     int main_p;
+{
+  char *buffer;
+  register char *p;
+
+  buffer = load_specs (filename);
+
   /* Scan BUFFER for specs, putting them in the vector.  */
   p = buffer;
   while (1)