From 6ed4bb9a67e3ecc2ab2127d746299537cc9444b0 Mon Sep 17 00:00:00 2001 From: Michael Meissner Date: Fri, 27 Mar 1998 14:20:40 +0000 Subject: [PATCH] Make GCC_EXEC_PREFIX work again From-SVN: r18856 --- gcc/ChangeLog | 13 +++++++++++++ gcc/gcc.c | 15 +++++++++++++++ gcc/prefix.c | 27 +++++++++++++++++++++------ 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2615a60ced2..e5059598bd7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +Fri Mar 27 16:04:49 1998 Michael Meissner + + * gcc.c (set_std_prefix): Add declaration. + (process_command): If GCC_EXEC_PREFIX is set, remove /lib/gcc-lib/ + suffix, and update the standard prefix prefix.c uses. + + * prefix.c (std_prefix): New global to hold default prefix value. + (get_key_value): Change to use std_prefix instead of PREFIX. + (translate_name): Ditto. + (update_path): Ditto. + (get_key_value): Release allocated scratch storage. + (set_std_prefix): New function to reset the standard prefix. + Fri Mar 27 18:08:21 1998 J"orn Rennecke * sh.c (find_barrier): Fix calculations for alignment increase. diff --git a/gcc/gcc.c b/gcc/gcc.c index ab376553a6e..d68f404b273 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -51,6 +51,7 @@ extern int pexecute PROTO ((const char *, char * const *, const char *, const char *, char **, char **, int)); extern int pwait PROTO ((int, int *, int)); extern char *update_path PROTO((char *, char *)); +extern void set_std_prefix PROTO((char *, int)); /* Flag arguments to pexecute. */ #define PEXECUTE_FIRST 1 #define PEXECUTE_LAST 2 @@ -2378,6 +2379,20 @@ process_command (argc, argv) if (gcc_exec_prefix) { + int len = strlen (gcc_exec_prefix); + if (len > sizeof ("/lib/gcc-lib/")-1 + && (gcc_exec_prefix[len-1] == '/' + || gcc_exec_prefix[len-1] == DIR_SEPARATOR)) + { + temp = gcc_exec_prefix + len - sizeof ("/lib/gcc-lib/") + 1; + if ((*temp == '/' || *temp == DIR_SEPARATOR) + && strncmp (temp+1, "lib", 3) == 0 + && (temp[4] == '/' || temp[4] == DIR_SEPARATOR) + && strncmp (temp+5, "gcc-lib", 7) == 0) + len -= sizeof ("/lib/gcc-lib/") - 1; + } + + set_std_prefix (gcc_exec_prefix, len); add_prefix (&exec_prefixes, gcc_exec_prefix, "GCC", 0, 0, NULL_PTR); add_prefix (&startfile_prefixes, gcc_exec_prefix, "GCC", 0, 0, NULL_PTR); } diff --git a/gcc/prefix.c b/gcc/prefix.c index f270172e5fa..c07944764d4 100644 --- a/gcc/prefix.c +++ b/gcc/prefix.c @@ -1,5 +1,5 @@ /* Utility to update paths from internal to external forms. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 1998 Free Software Foundation, Inc. This file is part of GNU CC. @@ -76,6 +76,8 @@ Boston, MA 02111-1307, USA. */ #include "gansidecl.h" +static char *std_prefix = PREFIX; + static char *get_key_value PROTO((char *)); static char *translate_name PROTO((char *)); static char *concat PVPROTO((char *, ...)); @@ -93,16 +95,20 @@ get_key_value (key) char *key; { char *prefix = 0; + char *temp = 0; #ifdef _WIN32 prefix = lookup_key (key); #endif if (prefix == 0) - prefix = getenv (concat (key, "_ROOT", NULL_PTR)); + prefix = getenv (temp = concat (key, "_ROOT", NULL_PTR)); if (prefix == 0) - prefix = PREFIX; + prefix = std_prefix; + + if (temp) + free (temp); return prefix; } @@ -259,7 +265,7 @@ translate_name (name) { prefix = get_key_value (key); if (prefix == 0) - prefix = PREFIX; + prefix = std_prefix; } else { @@ -289,12 +295,12 @@ update_path (path, key) char *path; char *key; { - if (! strncmp (path, PREFIX, strlen (PREFIX)) && key != 0) + if (! strncmp (path, std_prefix, strlen (std_prefix)) && key != 0) { if (key[0] != '$') key = concat ("@", key, NULL_PTR); - path = concat (key, &path[strlen (PREFIX)], NULL_PTR); + path = concat (key, &path[strlen (std_prefix)], NULL_PTR); while (path[0] == '@' || path[0] == '$') path = translate_name (path); @@ -315,3 +321,12 @@ update_path (path, key) return path; } + +/* Reset the standard prefix */ +void +set_std_prefix (prefix, len) + char *prefix; + int len; +{ + std_prefix = save_string (prefix, len); +}