From b633b6c0947aa4201a31fb17869fb5157471f58f Mon Sep 17 00:00:00 2001 From: Mumit Khan Date: Mon, 24 Apr 2000 23:57:46 +0000 Subject: [PATCH] gcc.c (load_specs): New static function. * gcc.c (load_specs): New static function. (read_specs): Use it. From-SVN: r33395 --- gcc/ChangeLog | 3 +++ gcc/gcc.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++------------- 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 + * 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) -- 2.7.4