aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMumit Khan <khan@xraylith.wisc.edu>2000-04-24 23:57:46 +0000
committerJeff Law <law@gcc.gnu.org>2000-04-24 17:57:46 -0600
commitb633b6c0947aa4201a31fb17869fb5157471f58f (patch)
treeb2fc748df5fcea1eac4240247d3d1656aef106fd /gcc
parent03bf1c28ac17199533dcab43432f1f0532ecfaaa (diff)
downloadgcc-b633b6c0947aa4201a31fb17869fb5157471f58f.zip
gcc-b633b6c0947aa4201a31fb17869fb5157471f58f.tar.gz
gcc-b633b6c0947aa4201a31fb17869fb5157471f58f.tar.bz2
gcc.c (load_specs): New static function.
* gcc.c (load_specs): New static function. (read_specs): Use it. From-SVN: r33395
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog3
-rw-r--r--gcc/gcc.c67
2 files changed, 56 insertions, 14 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 71ebba4..a4bb170 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/gcc.c b/gcc/gcc.c
index d8dd563..7730482 100644
--- 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);
}
-/* 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)