1997-10-19 12:29:32 -04:00
|
|
|
/* Utility to update paths from internal to external forms.
|
2000-01-17 12:16:21 -05:00
|
|
|
Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
|
1997-10-19 12:29:32 -04:00
|
|
|
|
|
|
|
This file is part of GNU CC.
|
|
|
|
|
|
|
|
GNU CC is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
GCC is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
|
|
|
License along with GCC; see the file COPYING. If not, write to the Free
|
|
|
|
Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
Boston, MA 02111-1307, USA. */
|
|
|
|
|
|
|
|
/* This file contains routines to update a path, both to canonicalize
|
|
|
|
the directory format and to handle any prefix translation.
|
|
|
|
|
|
|
|
This file must be compiled with -DPREFIX= to specify the "prefix"
|
|
|
|
value used by configure. If a filename does not begin with this
|
|
|
|
prefix, it will not be affected other than by directory canonicalization.
|
|
|
|
|
|
|
|
Each caller of 'update_path' may specify both a filename and
|
|
|
|
a translation prefix and consist of the name of the package that contains
|
|
|
|
the file ("@GCC", "@BINUTIL", "@GNU", etc).
|
|
|
|
|
|
|
|
If the prefix is not specified, the filename will only undergo
|
|
|
|
directory canonicalization.
|
|
|
|
|
|
|
|
If it is specified, the string given by PREFIX will be replaced
|
|
|
|
by the specified prefix (with a '@' in front unless the prefix begins
|
|
|
|
with a '$') and further translation will be done as follows
|
|
|
|
until none of the two conditions below are met:
|
|
|
|
|
|
|
|
1) If the filename begins with '@', the string between the '@' and
|
|
|
|
the end of the name or the first '/' or directory separator will
|
|
|
|
be considered a "key" and looked up as follows:
|
|
|
|
|
|
|
|
-- If this is a Win32 OS, then the Registry will be examined for
|
|
|
|
an entry of "key" in
|
|
|
|
|
1999-08-14 18:04:44 -04:00
|
|
|
HKEY_LOCAL_MACHINE\SOFTWARE\Free Software Foundation\<KEY>
|
1997-10-19 12:29:32 -04:00
|
|
|
|
1999-08-14 18:04:44 -04:00
|
|
|
if found, that value will be used. <KEY> defaults to GCC version
|
|
|
|
string, but can be overridden at configuration time.
|
1997-10-19 12:29:32 -04:00
|
|
|
|
|
|
|
-- If not found (or not a Win32 OS), the environment variable
|
|
|
|
key_ROOT (the value of "key" concatenated with the constant "_ROOT")
|
|
|
|
is tried. If that fails, then PREFIX (see above) is used.
|
|
|
|
|
|
|
|
2) If the filename begins with a '$', the rest of the string up
|
|
|
|
to the end or the first '/' or directory separator will be used
|
|
|
|
as an environment variable, whose value will be returned.
|
|
|
|
|
|
|
|
Once all this is done, any '/' will be converted to DIR_SEPARATOR,
|
|
|
|
if they are different.
|
|
|
|
|
|
|
|
NOTE: using resolve_keyed_path under Win32 requires linking with
|
|
|
|
advapi32.dll. */
|
|
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
Major cutover to using system.h:
* Makefile.in (alias.o, bitmap.o, c-aux-info.o, c-common.o,
c-decl.o, c-iterate.o, c-lang.o, c-lex.o, c-pragma.o, c-typeck.o,
caller-save.o, calls.o, collect2.o, combine.o, cse.o, dbxout.o,
dwarf2out.o, dwarfout.o, emit-rtl.o, except.o, explow.o, expmed.o,
expr.o, final.o, flow.o, function.o, getpwd.o, global.o,
integrate.o, jump.o, local-alloc.o, loop.o, optabs.o, pexecute.o,
prefix.o, print-rtl.o, print-tree.o, profile.o, real.o, recog.o,
reg-stack.o, regclass.o, regmove.o, reload.o, reload1.o, reorg.o,
rtl.o, rtlanal.o, sdbout.o, stmt.o, stor-layout.o, stupid.o,
tlink.o, toplev.o, tree.o, unroll.o, varasm.o, xcoffout.o): Depend
on system.h.
* alias.c, bitmap.c, c-aux-info.c, c-common.c, c-decl.c,
c-iterate.c, c-lang.c, c-lex.c, c-pragma.c, c-typeck.c,
caller-save.c, calls.c, collect2.c, combine.c, cse.c, dbxout.c,
dwarf2out.c, dwarfout.c, emit-rtl.c, except.c, explow.c, expmed.c,
expr.c, final.c, flow.c, function.c, gcc.c, getpwd.c, global.c,
integrate.c, jump.c, local-alloc.c, loop.c, optabs.c, pexecute.c,
prefix.c, print-rtl.c, print-tree.c, profile.c, real.c, recog.c,
reg-stack.c, regclass.c, regmove.c, reload.c, reload1.c, reorg.c,
rtl.c, rtlanal.c, sched.c, sdbout.c, stmt.c, stor-layout.c,
stupid.c, tlink.c, toplev.c, tree.c, unroll.c, varasm.c,
xcoffout.c: Include system.h. Organize include ordering so
that stdarg/varargs comes before other system headers. Remove
spurious casts of functions assured of a prototype in system.h.
From-SVN: r18726
1998-03-20 09:58:42 -05:00
|
|
|
#include "system.h"
|
1999-08-14 18:04:44 -04:00
|
|
|
#if defined(_WIN32) && defined(ENABLE_WIN32_REGISTRY)
|
1997-10-19 12:29:32 -04:00
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
Makefile.in (gcc.o, [...]): Depend on prefix.h.
* Makefile.in (gcc.o, prefix.o, cccp.o, cpplib.o): Depend on prefix.h.
* cccp.c: Include prefix.h, don't prototype prefix.c functions.
(new_include_prefix): Constify char* parameters.
* cppfiles.c (read_name_map): Likewise.
(append_include_chain): Likewise. Also, use a writable char* copy
of parameter `dir' which we then modify, rather than using the
parameter itself to store the new writable string.
(remap_filename): Constify some variables. Also, use a writable
char* to store an allocated string which we will be modifying.
* cpplib.c: Include prefix.h, don't prototype prefix.c functions.
(cpp_start_read): Constify variable `str'.
* cpplib.h (append_include_chain): Constify a char* parameter.
* gcc.c Include prefix.h, don't prototype prefix.c functions.
(add_prefix, save_string): Constify char* parameters.
(fatal, error): Add ATTRIBUTE_PRINTF_1 to prototypes.
* prefix.c: Include prefix.h.
(get_key_value, translate_name, save_string, update_path,
set_std_prefix): Constify various char* parameters and variables.
(save_string): Use xmalloc, not malloc.
(translate_name): Use a writable temporary variable to create and
modify a string before setting it to a const char*.
* prefix.h: New file to prototype functions exported from prefix.c.
From-SVN: r24498
1999-01-05 14:11:22 -05:00
|
|
|
#include "prefix.h"
|
1997-10-19 12:29:32 -04:00
|
|
|
|
Makefile.in (gcc.o, [...]): Depend on prefix.h.
* Makefile.in (gcc.o, prefix.o, cccp.o, cpplib.o): Depend on prefix.h.
* cccp.c: Include prefix.h, don't prototype prefix.c functions.
(new_include_prefix): Constify char* parameters.
* cppfiles.c (read_name_map): Likewise.
(append_include_chain): Likewise. Also, use a writable char* copy
of parameter `dir' which we then modify, rather than using the
parameter itself to store the new writable string.
(remap_filename): Constify some variables. Also, use a writable
char* to store an allocated string which we will be modifying.
* cpplib.c: Include prefix.h, don't prototype prefix.c functions.
(cpp_start_read): Constify variable `str'.
* cpplib.h (append_include_chain): Constify a char* parameter.
* gcc.c Include prefix.h, don't prototype prefix.c functions.
(add_prefix, save_string): Constify char* parameters.
(fatal, error): Add ATTRIBUTE_PRINTF_1 to prototypes.
* prefix.c: Include prefix.h.
(get_key_value, translate_name, save_string, update_path,
set_std_prefix): Constify various char* parameters and variables.
(save_string): Use xmalloc, not malloc.
(translate_name): Use a writable temporary variable to create and
modify a string before setting it to a const char*.
* prefix.h: New file to prototype functions exported from prefix.c.
From-SVN: r24498
1999-01-05 14:11:22 -05:00
|
|
|
static const char *std_prefix = PREFIX;
|
1998-03-27 09:20:40 -05:00
|
|
|
|
2000-01-17 10:37:04 -05:00
|
|
|
static const char *get_key_value PARAMS ((char *));
|
|
|
|
static const char *translate_name PARAMS ((const char *));
|
|
|
|
static char *save_string PARAMS ((const char *, int));
|
1997-10-19 12:29:32 -04:00
|
|
|
|
1999-08-14 18:04:44 -04:00
|
|
|
#if defined(_WIN32) && defined(ENABLE_WIN32_REGISTRY)
|
2000-01-17 10:37:04 -05:00
|
|
|
static char *lookup_key PARAMS ((char *));
|
1997-10-19 12:29:32 -04:00
|
|
|
static HKEY reg_key = (HKEY) INVALID_HANDLE_VALUE;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Given KEY, as above, return its value. */
|
|
|
|
|
Makefile.in (gcc.o, [...]): Depend on prefix.h.
* Makefile.in (gcc.o, prefix.o, cccp.o, cpplib.o): Depend on prefix.h.
* cccp.c: Include prefix.h, don't prototype prefix.c functions.
(new_include_prefix): Constify char* parameters.
* cppfiles.c (read_name_map): Likewise.
(append_include_chain): Likewise. Also, use a writable char* copy
of parameter `dir' which we then modify, rather than using the
parameter itself to store the new writable string.
(remap_filename): Constify some variables. Also, use a writable
char* to store an allocated string which we will be modifying.
* cpplib.c: Include prefix.h, don't prototype prefix.c functions.
(cpp_start_read): Constify variable `str'.
* cpplib.h (append_include_chain): Constify a char* parameter.
* gcc.c Include prefix.h, don't prototype prefix.c functions.
(add_prefix, save_string): Constify char* parameters.
(fatal, error): Add ATTRIBUTE_PRINTF_1 to prototypes.
* prefix.c: Include prefix.h.
(get_key_value, translate_name, save_string, update_path,
set_std_prefix): Constify various char* parameters and variables.
(save_string): Use xmalloc, not malloc.
(translate_name): Use a writable temporary variable to create and
modify a string before setting it to a const char*.
* prefix.h: New file to prototype functions exported from prefix.c.
From-SVN: r24498
1999-01-05 14:11:22 -05:00
|
|
|
static const char *
|
1997-10-19 12:29:32 -04:00
|
|
|
get_key_value (key)
|
|
|
|
char *key;
|
|
|
|
{
|
Makefile.in (gcc.o, [...]): Depend on prefix.h.
* Makefile.in (gcc.o, prefix.o, cccp.o, cpplib.o): Depend on prefix.h.
* cccp.c: Include prefix.h, don't prototype prefix.c functions.
(new_include_prefix): Constify char* parameters.
* cppfiles.c (read_name_map): Likewise.
(append_include_chain): Likewise. Also, use a writable char* copy
of parameter `dir' which we then modify, rather than using the
parameter itself to store the new writable string.
(remap_filename): Constify some variables. Also, use a writable
char* to store an allocated string which we will be modifying.
* cpplib.c: Include prefix.h, don't prototype prefix.c functions.
(cpp_start_read): Constify variable `str'.
* cpplib.h (append_include_chain): Constify a char* parameter.
* gcc.c Include prefix.h, don't prototype prefix.c functions.
(add_prefix, save_string): Constify char* parameters.
(fatal, error): Add ATTRIBUTE_PRINTF_1 to prototypes.
* prefix.c: Include prefix.h.
(get_key_value, translate_name, save_string, update_path,
set_std_prefix): Constify various char* parameters and variables.
(save_string): Use xmalloc, not malloc.
(translate_name): Use a writable temporary variable to create and
modify a string before setting it to a const char*.
* prefix.h: New file to prototype functions exported from prefix.c.
From-SVN: r24498
1999-01-05 14:11:22 -05:00
|
|
|
const char *prefix = 0;
|
1998-03-27 09:20:40 -05:00
|
|
|
char *temp = 0;
|
1997-10-19 12:29:32 -04:00
|
|
|
|
1999-08-14 18:04:44 -04:00
|
|
|
#if defined(_WIN32) && defined(ENABLE_WIN32_REGISTRY)
|
1997-10-19 12:29:32 -04:00
|
|
|
prefix = lookup_key (key);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (prefix == 0)
|
1998-03-27 09:20:40 -05:00
|
|
|
prefix = getenv (temp = concat (key, "_ROOT", NULL_PTR));
|
1997-10-19 12:29:32 -04:00
|
|
|
|
|
|
|
if (prefix == 0)
|
1998-03-27 09:20:40 -05:00
|
|
|
prefix = std_prefix;
|
|
|
|
|
|
|
|
if (temp)
|
|
|
|
free (temp);
|
1997-10-19 12:29:32 -04:00
|
|
|
|
|
|
|
return prefix;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Concatenate a sequence of strings, returning the result.
|
|
|
|
|
|
|
|
This function is based on the one in libiberty. */
|
|
|
|
|
1998-11-27 05:09:17 -05:00
|
|
|
char *
|
2000-01-17 10:37:04 -05:00
|
|
|
concat VPARAMS ((const char *first, ...))
|
1997-10-19 12:29:32 -04:00
|
|
|
{
|
|
|
|
register int length;
|
|
|
|
register char *newstr;
|
|
|
|
register char *end;
|
1998-11-27 05:09:17 -05:00
|
|
|
register const char *arg;
|
1997-10-19 12:29:32 -04:00
|
|
|
va_list args;
|
gansidecl.h: Prepend a "G" to the macro wrapping this file (to distinguish it from the macro...
* gansidecl.h: Prepend a "G" to the macro wrapping this file
(to distinguish it from the macro wrapping ansidecl.h.)
Include libiberty's ansidecl.h. Remove all redundant definitions.
Define the PROTO() style macros in terms of the PARAMS() ones.
* calls.c (emit_library_call): Switch on ANSI_PROTOTYPES, not
__STDC__, when deciding whether to use ANSI variable args.
(emit_library_call_value): Likewise.
* cccp.c (error): Likewise.
(warning): Likewise.
(error_with_line): Likewise.
(warning_with_line): Likewise.
(pedwarn): Likewise.
(pedwarn_with_line): Likewise.
(pedwarn_with_file_and_line): Likewise.
(fatal): Likewise.
* cexp.y (error): Likewise.
(pedwarn): Likewise.
(warning): Likewise.
* collect2.c (fatal_perror): Likewise.
(fatal): Likewise.
(error): Likewise.
* combine.c (gen_rtx_combine): Likewise.
* cpperror.c (cpp_message): Likewise.
(cpp_fatal): Likewise.
* cpplib.c (cpp_error): Likewise.
(cpp_warning): Likewise.
(cpp_pedwarn): Likewise.
(cpp_error_with_line): Likewise.
(cpp_warning_with_line): Likewise.
(cpp_pedwarn_with_line): Likewise.
(cpp_pedwarn_with_file_and_line): Likewise.
* cpplib.h: Don't define PARAMS() macro.
* demangle.h: Likewise.
* doprint.c (checkit): Switch on ANSI_PROTOTYPES, not __STDC__,
when deciding whether to use ANSI variable args.
* emit-rtl.c (gen_rtx): Likewise.
(gen_rtvec): Likewise.
* final.c (asm_fprintf): Likewise.
* fix-header.c (cpp_message): Likewise.
(fatal): Likewise.
(cpp_fatal): Likewise.
* gcc.c (concat): Likewise.
(fatal): Likewise.
(error): Likewise.
* genattr.c (fatal): Likewise.
* genattrtab.c (attr_rtx): Likewise.
(attr_printf): Likewise.
(fatal): Likewise.
* gencodes.c (fatal): Likewise.
* genconfig.c (fatal): Likewise.
* genemit.c (fatal): Likewise.
* genextract.c (fatal): Likewise.
* genflags.c (fatal): Likewise.
* genopinit.c (fatal): Likewise.
* genoutput.c (fatal): Likewise.
(error): Likewise.
* genpeep.c (fatal): Likewise.
* genrecog.c (fatal): Likewise.
* halfpic.h: Switch on ANSI_PROTOTYPES, not __STDC__, when
deciding whether to declare `tree_node' and `rtx_def'.
* hash.h: Don't define stuff we get from gansidecl.h.
* mips-tfile.c: Likewise. Define __proto() in terms of PARAMS().
(fatal): Switch on ANSI_PROTOTYPES, not __STDC__, when deciding
whether to use ANSI variable args.
(error): Likewise.
* prefix.c (concat): Likewise.
* scan.h: Likewise.
* system.h: Likewise.
* toplev.c (error_with_file_and_line): Likewise.
(error_with_decl): Likewise.
(error_for_asm): Likewise.
(error): Likewise.
(fatal): Likewise.
(warning_with_file_and_line): Likewise.
(warning_with_decl): Likewise.
(warning_for_asm): Likewise.
(warning): Likewise.
(pedwarn): Likewise.
(pedwarn_with_decl): Likewise.
(pedwarn_with_file_and_line): Likewise.
(sorry): Likewise.
(really_sorry): Likewise.
* toplev.h: Switch on ANSI_PROTOTYPES, not __STDC__, when deciding
whether to declare `tree_node' and `rtx_def'.
* tree.c (build): Switch on ANSI_PROTOTYPES, not __STDC__, when
deciding whether to use ANSI variable args.
(build_nt): Likewise.
(build_parse_node): Likewise.
From-SVN: r23577
1998-11-08 10:10:24 -05:00
|
|
|
#ifndef ANSI_PROTOTYPES
|
1998-11-27 05:09:17 -05:00
|
|
|
const char *first;
|
1997-10-19 12:29:32 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* First compute the size of the result and get sufficient memory. */
|
|
|
|
|
|
|
|
VA_START (args, first);
|
gansidecl.h: Prepend a "G" to the macro wrapping this file (to distinguish it from the macro...
* gansidecl.h: Prepend a "G" to the macro wrapping this file
(to distinguish it from the macro wrapping ansidecl.h.)
Include libiberty's ansidecl.h. Remove all redundant definitions.
Define the PROTO() style macros in terms of the PARAMS() ones.
* calls.c (emit_library_call): Switch on ANSI_PROTOTYPES, not
__STDC__, when deciding whether to use ANSI variable args.
(emit_library_call_value): Likewise.
* cccp.c (error): Likewise.
(warning): Likewise.
(error_with_line): Likewise.
(warning_with_line): Likewise.
(pedwarn): Likewise.
(pedwarn_with_line): Likewise.
(pedwarn_with_file_and_line): Likewise.
(fatal): Likewise.
* cexp.y (error): Likewise.
(pedwarn): Likewise.
(warning): Likewise.
* collect2.c (fatal_perror): Likewise.
(fatal): Likewise.
(error): Likewise.
* combine.c (gen_rtx_combine): Likewise.
* cpperror.c (cpp_message): Likewise.
(cpp_fatal): Likewise.
* cpplib.c (cpp_error): Likewise.
(cpp_warning): Likewise.
(cpp_pedwarn): Likewise.
(cpp_error_with_line): Likewise.
(cpp_warning_with_line): Likewise.
(cpp_pedwarn_with_line): Likewise.
(cpp_pedwarn_with_file_and_line): Likewise.
* cpplib.h: Don't define PARAMS() macro.
* demangle.h: Likewise.
* doprint.c (checkit): Switch on ANSI_PROTOTYPES, not __STDC__,
when deciding whether to use ANSI variable args.
* emit-rtl.c (gen_rtx): Likewise.
(gen_rtvec): Likewise.
* final.c (asm_fprintf): Likewise.
* fix-header.c (cpp_message): Likewise.
(fatal): Likewise.
(cpp_fatal): Likewise.
* gcc.c (concat): Likewise.
(fatal): Likewise.
(error): Likewise.
* genattr.c (fatal): Likewise.
* genattrtab.c (attr_rtx): Likewise.
(attr_printf): Likewise.
(fatal): Likewise.
* gencodes.c (fatal): Likewise.
* genconfig.c (fatal): Likewise.
* genemit.c (fatal): Likewise.
* genextract.c (fatal): Likewise.
* genflags.c (fatal): Likewise.
* genopinit.c (fatal): Likewise.
* genoutput.c (fatal): Likewise.
(error): Likewise.
* genpeep.c (fatal): Likewise.
* genrecog.c (fatal): Likewise.
* halfpic.h: Switch on ANSI_PROTOTYPES, not __STDC__, when
deciding whether to declare `tree_node' and `rtx_def'.
* hash.h: Don't define stuff we get from gansidecl.h.
* mips-tfile.c: Likewise. Define __proto() in terms of PARAMS().
(fatal): Switch on ANSI_PROTOTYPES, not __STDC__, when deciding
whether to use ANSI variable args.
(error): Likewise.
* prefix.c (concat): Likewise.
* scan.h: Likewise.
* system.h: Likewise.
* toplev.c (error_with_file_and_line): Likewise.
(error_with_decl): Likewise.
(error_for_asm): Likewise.
(error): Likewise.
(fatal): Likewise.
(warning_with_file_and_line): Likewise.
(warning_with_decl): Likewise.
(warning_for_asm): Likewise.
(warning): Likewise.
(pedwarn): Likewise.
(pedwarn_with_decl): Likewise.
(pedwarn_with_file_and_line): Likewise.
(sorry): Likewise.
(really_sorry): Likewise.
* toplev.h: Switch on ANSI_PROTOTYPES, not __STDC__, when deciding
whether to declare `tree_node' and `rtx_def'.
* tree.c (build): Switch on ANSI_PROTOTYPES, not __STDC__, when
deciding whether to use ANSI variable args.
(build_nt): Likewise.
(build_parse_node): Likewise.
From-SVN: r23577
1998-11-08 10:10:24 -05:00
|
|
|
#ifndef ANSI_PROTOTYPES
|
1998-11-27 05:09:17 -05:00
|
|
|
first = va_arg (args, const char *);
|
1997-10-19 12:29:32 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
arg = first;
|
|
|
|
length = 0;
|
|
|
|
|
|
|
|
while (arg != 0)
|
|
|
|
{
|
|
|
|
length += strlen (arg);
|
1998-11-27 05:09:17 -05:00
|
|
|
arg = va_arg (args, const char *);
|
1997-10-19 12:29:32 -04:00
|
|
|
}
|
|
|
|
|
2000-02-13 14:59:29 -05:00
|
|
|
newstr = (char *) xmalloc (length + 1);
|
1997-10-19 12:29:32 -04:00
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
/* Now copy the individual pieces to the result string. */
|
|
|
|
|
|
|
|
VA_START (args, first);
|
gansidecl.h: Prepend a "G" to the macro wrapping this file (to distinguish it from the macro...
* gansidecl.h: Prepend a "G" to the macro wrapping this file
(to distinguish it from the macro wrapping ansidecl.h.)
Include libiberty's ansidecl.h. Remove all redundant definitions.
Define the PROTO() style macros in terms of the PARAMS() ones.
* calls.c (emit_library_call): Switch on ANSI_PROTOTYPES, not
__STDC__, when deciding whether to use ANSI variable args.
(emit_library_call_value): Likewise.
* cccp.c (error): Likewise.
(warning): Likewise.
(error_with_line): Likewise.
(warning_with_line): Likewise.
(pedwarn): Likewise.
(pedwarn_with_line): Likewise.
(pedwarn_with_file_and_line): Likewise.
(fatal): Likewise.
* cexp.y (error): Likewise.
(pedwarn): Likewise.
(warning): Likewise.
* collect2.c (fatal_perror): Likewise.
(fatal): Likewise.
(error): Likewise.
* combine.c (gen_rtx_combine): Likewise.
* cpperror.c (cpp_message): Likewise.
(cpp_fatal): Likewise.
* cpplib.c (cpp_error): Likewise.
(cpp_warning): Likewise.
(cpp_pedwarn): Likewise.
(cpp_error_with_line): Likewise.
(cpp_warning_with_line): Likewise.
(cpp_pedwarn_with_line): Likewise.
(cpp_pedwarn_with_file_and_line): Likewise.
* cpplib.h: Don't define PARAMS() macro.
* demangle.h: Likewise.
* doprint.c (checkit): Switch on ANSI_PROTOTYPES, not __STDC__,
when deciding whether to use ANSI variable args.
* emit-rtl.c (gen_rtx): Likewise.
(gen_rtvec): Likewise.
* final.c (asm_fprintf): Likewise.
* fix-header.c (cpp_message): Likewise.
(fatal): Likewise.
(cpp_fatal): Likewise.
* gcc.c (concat): Likewise.
(fatal): Likewise.
(error): Likewise.
* genattr.c (fatal): Likewise.
* genattrtab.c (attr_rtx): Likewise.
(attr_printf): Likewise.
(fatal): Likewise.
* gencodes.c (fatal): Likewise.
* genconfig.c (fatal): Likewise.
* genemit.c (fatal): Likewise.
* genextract.c (fatal): Likewise.
* genflags.c (fatal): Likewise.
* genopinit.c (fatal): Likewise.
* genoutput.c (fatal): Likewise.
(error): Likewise.
* genpeep.c (fatal): Likewise.
* genrecog.c (fatal): Likewise.
* halfpic.h: Switch on ANSI_PROTOTYPES, not __STDC__, when
deciding whether to declare `tree_node' and `rtx_def'.
* hash.h: Don't define stuff we get from gansidecl.h.
* mips-tfile.c: Likewise. Define __proto() in terms of PARAMS().
(fatal): Switch on ANSI_PROTOTYPES, not __STDC__, when deciding
whether to use ANSI variable args.
(error): Likewise.
* prefix.c (concat): Likewise.
* scan.h: Likewise.
* system.h: Likewise.
* toplev.c (error_with_file_and_line): Likewise.
(error_with_decl): Likewise.
(error_for_asm): Likewise.
(error): Likewise.
(fatal): Likewise.
(warning_with_file_and_line): Likewise.
(warning_with_decl): Likewise.
(warning_for_asm): Likewise.
(warning): Likewise.
(pedwarn): Likewise.
(pedwarn_with_decl): Likewise.
(pedwarn_with_file_and_line): Likewise.
(sorry): Likewise.
(really_sorry): Likewise.
* toplev.h: Switch on ANSI_PROTOTYPES, not __STDC__, when deciding
whether to declare `tree_node' and `rtx_def'.
* tree.c (build): Switch on ANSI_PROTOTYPES, not __STDC__, when
deciding whether to use ANSI variable args.
(build_nt): Likewise.
(build_parse_node): Likewise.
From-SVN: r23577
1998-11-08 10:10:24 -05:00
|
|
|
#ifndef ANSI_PROTOTYPES
|
1997-10-19 12:29:32 -04:00
|
|
|
first = va_arg (args, char *);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
end = newstr;
|
|
|
|
arg = first;
|
|
|
|
while (arg != 0)
|
|
|
|
{
|
|
|
|
while (*arg)
|
|
|
|
*end++ = *arg++;
|
1998-11-27 05:09:17 -05:00
|
|
|
arg = va_arg (args, const char *);
|
1997-10-19 12:29:32 -04:00
|
|
|
}
|
|
|
|
*end = '\000';
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
return (newstr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return a copy of a string that has been placed in the heap. */
|
|
|
|
|
|
|
|
static char *
|
|
|
|
save_string (s, len)
|
Makefile.in (gcc.o, [...]): Depend on prefix.h.
* Makefile.in (gcc.o, prefix.o, cccp.o, cpplib.o): Depend on prefix.h.
* cccp.c: Include prefix.h, don't prototype prefix.c functions.
(new_include_prefix): Constify char* parameters.
* cppfiles.c (read_name_map): Likewise.
(append_include_chain): Likewise. Also, use a writable char* copy
of parameter `dir' which we then modify, rather than using the
parameter itself to store the new writable string.
(remap_filename): Constify some variables. Also, use a writable
char* to store an allocated string which we will be modifying.
* cpplib.c: Include prefix.h, don't prototype prefix.c functions.
(cpp_start_read): Constify variable `str'.
* cpplib.h (append_include_chain): Constify a char* parameter.
* gcc.c Include prefix.h, don't prototype prefix.c functions.
(add_prefix, save_string): Constify char* parameters.
(fatal, error): Add ATTRIBUTE_PRINTF_1 to prototypes.
* prefix.c: Include prefix.h.
(get_key_value, translate_name, save_string, update_path,
set_std_prefix): Constify various char* parameters and variables.
(save_string): Use xmalloc, not malloc.
(translate_name): Use a writable temporary variable to create and
modify a string before setting it to a const char*.
* prefix.h: New file to prototype functions exported from prefix.c.
From-SVN: r24498
1999-01-05 14:11:22 -05:00
|
|
|
const char *s;
|
|
|
|
int len;
|
1997-10-19 12:29:32 -04:00
|
|
|
{
|
Makefile.in (gcc.o, [...]): Depend on prefix.h.
* Makefile.in (gcc.o, prefix.o, cccp.o, cpplib.o): Depend on prefix.h.
* cccp.c: Include prefix.h, don't prototype prefix.c functions.
(new_include_prefix): Constify char* parameters.
* cppfiles.c (read_name_map): Likewise.
(append_include_chain): Likewise. Also, use a writable char* copy
of parameter `dir' which we then modify, rather than using the
parameter itself to store the new writable string.
(remap_filename): Constify some variables. Also, use a writable
char* to store an allocated string which we will be modifying.
* cpplib.c: Include prefix.h, don't prototype prefix.c functions.
(cpp_start_read): Constify variable `str'.
* cpplib.h (append_include_chain): Constify a char* parameter.
* gcc.c Include prefix.h, don't prototype prefix.c functions.
(add_prefix, save_string): Constify char* parameters.
(fatal, error): Add ATTRIBUTE_PRINTF_1 to prototypes.
* prefix.c: Include prefix.h.
(get_key_value, translate_name, save_string, update_path,
set_std_prefix): Constify various char* parameters and variables.
(save_string): Use xmalloc, not malloc.
(translate_name): Use a writable temporary variable to create and
modify a string before setting it to a const char*.
* prefix.h: New file to prototype functions exported from prefix.c.
From-SVN: r24498
1999-01-05 14:11:22 -05:00
|
|
|
register char *result = xmalloc (len + 1);
|
1997-10-19 12:29:32 -04:00
|
|
|
|
alpha.c (check_float_value): Use memcpy, not bcopy.
* alpha.c (check_float_value): Use memcpy, not bcopy.
* arm.c (output_move_double): Likewise.
* arm.md: Likewise.
* m88k.c (legitimize_operand): Likewise.
* m88k.h (ORDER_REGS_FOR_LOCAL_ALLOC): Likewise.
* m88k.md: Likewise.
* mips.c (override_options): Likewise.
* mips.md: Likewise.
* romp.c (output_fpops): Likewise.
* rs6000.c (rs6000_override_options): Likewise.
* sh.md: Likewise.
* vax.c (check_float_value): Likewise.
* emit-rtl.c (copy_rtx_if_shared, init_emit_once): Likewise.
* expmed.c (synth_mult): Likewise.
* final.c (add_bb_string): Likewise.
* genattr.c (main): Likewise.
* genattrtab.c (attr_string, simplify_cond, copy_rtx_unchanging):
Likewise.
* jump.c (thread_jumps): Likewise.
* prefix.c (save_string): Likewise.
* real.h (REAL_VALUE_FROM_CONST_DOUBLE): Likewise.
* regclass.c (init_reg_sets, init_reg_sets_1): Likewise.
* reload1.c (reload, eliminate_regs): Likewise.
cp:
* decl.c (grokdeclarator, save_function_data): Use memcpy, not bcopy.
* lex.c (copy_lang_decl): Likewise.
java:
* decl.c (copy_lang_decl): Use memcpy, not bcopy.
* jcf-parse.c (jcf_figure_file_type): Likewise.
From-SVN: r37367
2000-11-10 11:01:28 -05:00
|
|
|
memcpy (result, s, len);
|
1997-10-19 12:29:32 -04:00
|
|
|
result[len] = 0;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1999-08-14 18:04:44 -04:00
|
|
|
#if defined(_WIN32) && defined(ENABLE_WIN32_REGISTRY)
|
1997-10-19 12:29:32 -04:00
|
|
|
|
|
|
|
/* Look up "key" in the registry, as above. */
|
|
|
|
|
|
|
|
static char *
|
|
|
|
lookup_key (key)
|
|
|
|
char *key;
|
|
|
|
{
|
|
|
|
char *dst;
|
|
|
|
DWORD size;
|
|
|
|
DWORD type;
|
|
|
|
LONG res;
|
|
|
|
|
|
|
|
if (reg_key == (HKEY) INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
res = RegOpenKeyExA (HKEY_LOCAL_MACHINE, "SOFTWARE", 0,
|
|
|
|
KEY_READ, ®_key);
|
|
|
|
|
|
|
|
if (res == ERROR_SUCCESS)
|
|
|
|
res = RegOpenKeyExA (reg_key, "Free Software Foundation", 0,
|
|
|
|
KEY_READ, ®_key);
|
|
|
|
|
1999-08-14 18:04:44 -04:00
|
|
|
if (res == ERROR_SUCCESS)
|
|
|
|
res = RegOpenKeyExA (reg_key, WIN32_REGISTRY_KEY, 0,
|
|
|
|
KEY_READ, ®_key);
|
|
|
|
|
1997-10-19 12:29:32 -04:00
|
|
|
if (res != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
reg_key = (HKEY) INVALID_HANDLE_VALUE;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
size = 32;
|
2000-02-13 14:59:29 -05:00
|
|
|
dst = (char *) xmalloc (size);
|
1997-10-19 12:29:32 -04:00
|
|
|
|
|
|
|
res = RegQueryValueExA (reg_key, key, 0, &type, dst, &size);
|
|
|
|
if (res == ERROR_MORE_DATA && type == REG_SZ)
|
|
|
|
{
|
2000-02-13 14:59:29 -05:00
|
|
|
dst = (char *) xrealloc (dst, size);
|
1997-10-19 12:29:32 -04:00
|
|
|
res = RegQueryValueExA (reg_key, key, 0, &type, dst, &size);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type != REG_SZ || res != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
free (dst);
|
|
|
|
dst = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* If NAME starts with a '@' or '$', apply the translation rules above
|
|
|
|
and return a new name. Otherwise, return the given name. */
|
|
|
|
|
Makefile.in (gcc.o, [...]): Depend on prefix.h.
* Makefile.in (gcc.o, prefix.o, cccp.o, cpplib.o): Depend on prefix.h.
* cccp.c: Include prefix.h, don't prototype prefix.c functions.
(new_include_prefix): Constify char* parameters.
* cppfiles.c (read_name_map): Likewise.
(append_include_chain): Likewise. Also, use a writable char* copy
of parameter `dir' which we then modify, rather than using the
parameter itself to store the new writable string.
(remap_filename): Constify some variables. Also, use a writable
char* to store an allocated string which we will be modifying.
* cpplib.c: Include prefix.h, don't prototype prefix.c functions.
(cpp_start_read): Constify variable `str'.
* cpplib.h (append_include_chain): Constify a char* parameter.
* gcc.c Include prefix.h, don't prototype prefix.c functions.
(add_prefix, save_string): Constify char* parameters.
(fatal, error): Add ATTRIBUTE_PRINTF_1 to prototypes.
* prefix.c: Include prefix.h.
(get_key_value, translate_name, save_string, update_path,
set_std_prefix): Constify various char* parameters and variables.
(save_string): Use xmalloc, not malloc.
(translate_name): Use a writable temporary variable to create and
modify a string before setting it to a const char*.
* prefix.h: New file to prototype functions exported from prefix.c.
From-SVN: r24498
1999-01-05 14:11:22 -05:00
|
|
|
static const char *
|
1997-10-19 12:29:32 -04:00
|
|
|
translate_name (name)
|
Makefile.in (gcc.o, [...]): Depend on prefix.h.
* Makefile.in (gcc.o, prefix.o, cccp.o, cpplib.o): Depend on prefix.h.
* cccp.c: Include prefix.h, don't prototype prefix.c functions.
(new_include_prefix): Constify char* parameters.
* cppfiles.c (read_name_map): Likewise.
(append_include_chain): Likewise. Also, use a writable char* copy
of parameter `dir' which we then modify, rather than using the
parameter itself to store the new writable string.
(remap_filename): Constify some variables. Also, use a writable
char* to store an allocated string which we will be modifying.
* cpplib.c: Include prefix.h, don't prototype prefix.c functions.
(cpp_start_read): Constify variable `str'.
* cpplib.h (append_include_chain): Constify a char* parameter.
* gcc.c Include prefix.h, don't prototype prefix.c functions.
(add_prefix, save_string): Constify char* parameters.
(fatal, error): Add ATTRIBUTE_PRINTF_1 to prototypes.
* prefix.c: Include prefix.h.
(get_key_value, translate_name, save_string, update_path,
set_std_prefix): Constify various char* parameters and variables.
(save_string): Use xmalloc, not malloc.
(translate_name): Use a writable temporary variable to create and
modify a string before setting it to a const char*.
* prefix.h: New file to prototype functions exported from prefix.c.
From-SVN: r24498
1999-01-05 14:11:22 -05:00
|
|
|
const char *name;
|
1997-10-19 12:29:32 -04:00
|
|
|
{
|
|
|
|
char code = name[0];
|
Makefile.in (gcc.o, [...]): Depend on prefix.h.
* Makefile.in (gcc.o, prefix.o, cccp.o, cpplib.o): Depend on prefix.h.
* cccp.c: Include prefix.h, don't prototype prefix.c functions.
(new_include_prefix): Constify char* parameters.
* cppfiles.c (read_name_map): Likewise.
(append_include_chain): Likewise. Also, use a writable char* copy
of parameter `dir' which we then modify, rather than using the
parameter itself to store the new writable string.
(remap_filename): Constify some variables. Also, use a writable
char* to store an allocated string which we will be modifying.
* cpplib.c: Include prefix.h, don't prototype prefix.c functions.
(cpp_start_read): Constify variable `str'.
* cpplib.h (append_include_chain): Constify a char* parameter.
* gcc.c Include prefix.h, don't prototype prefix.c functions.
(add_prefix, save_string): Constify char* parameters.
(fatal, error): Add ATTRIBUTE_PRINTF_1 to prototypes.
* prefix.c: Include prefix.h.
(get_key_value, translate_name, save_string, update_path,
set_std_prefix): Constify various char* parameters and variables.
(save_string): Use xmalloc, not malloc.
(translate_name): Use a writable temporary variable to create and
modify a string before setting it to a const char*.
* prefix.h: New file to prototype functions exported from prefix.c.
From-SVN: r24498
1999-01-05 14:11:22 -05:00
|
|
|
char *key;
|
|
|
|
const char *prefix = 0;
|
1997-10-19 12:29:32 -04:00
|
|
|
int keylen;
|
|
|
|
|
|
|
|
if (code != '@' && code != '$')
|
|
|
|
return name;
|
|
|
|
|
|
|
|
for (keylen = 0;
|
1999-04-10 00:27:16 -04:00
|
|
|
(name[keylen + 1] != 0 && !IS_DIR_SEPARATOR (name[keylen + 1]));
|
1997-10-19 12:29:32 -04:00
|
|
|
keylen++)
|
|
|
|
;
|
|
|
|
|
1998-08-17 05:08:32 -04:00
|
|
|
key = (char *) alloca (keylen + 1);
|
1997-10-19 12:29:32 -04:00
|
|
|
strncpy (key, &name[1], keylen);
|
|
|
|
key[keylen] = 0;
|
|
|
|
|
|
|
|
name = &name[keylen + 1];
|
|
|
|
|
|
|
|
if (code == '@')
|
|
|
|
{
|
|
|
|
prefix = get_key_value (key);
|
|
|
|
if (prefix == 0)
|
1998-03-27 09:20:40 -05:00
|
|
|
prefix = std_prefix;
|
1997-10-19 12:29:32 -04:00
|
|
|
}
|
|
|
|
else
|
1998-04-04 08:32:39 -05:00
|
|
|
prefix = getenv (key);
|
|
|
|
|
|
|
|
if (prefix == 0)
|
|
|
|
prefix = PREFIX;
|
1997-10-19 12:29:32 -04:00
|
|
|
|
2000-08-04 13:02:51 -04:00
|
|
|
/* We used to strip trailing DIR_SEPARATORs here, but that can
|
|
|
|
sometimes yield a result with no separator when one was coded
|
|
|
|
and intended by the user, causing two path components to run
|
|
|
|
together. */
|
1997-10-19 12:29:32 -04:00
|
|
|
|
|
|
|
return concat (prefix, name, NULL_PTR);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update PATH using KEY if PATH starts with PREFIX. */
|
|
|
|
|
Makefile.in (gcc.o, [...]): Depend on prefix.h.
* Makefile.in (gcc.o, prefix.o, cccp.o, cpplib.o): Depend on prefix.h.
* cccp.c: Include prefix.h, don't prototype prefix.c functions.
(new_include_prefix): Constify char* parameters.
* cppfiles.c (read_name_map): Likewise.
(append_include_chain): Likewise. Also, use a writable char* copy
of parameter `dir' which we then modify, rather than using the
parameter itself to store the new writable string.
(remap_filename): Constify some variables. Also, use a writable
char* to store an allocated string which we will be modifying.
* cpplib.c: Include prefix.h, don't prototype prefix.c functions.
(cpp_start_read): Constify variable `str'.
* cpplib.h (append_include_chain): Constify a char* parameter.
* gcc.c Include prefix.h, don't prototype prefix.c functions.
(add_prefix, save_string): Constify char* parameters.
(fatal, error): Add ATTRIBUTE_PRINTF_1 to prototypes.
* prefix.c: Include prefix.h.
(get_key_value, translate_name, save_string, update_path,
set_std_prefix): Constify various char* parameters and variables.
(save_string): Use xmalloc, not malloc.
(translate_name): Use a writable temporary variable to create and
modify a string before setting it to a const char*.
* prefix.h: New file to prototype functions exported from prefix.c.
From-SVN: r24498
1999-01-05 14:11:22 -05:00
|
|
|
const char *
|
1997-10-19 12:29:32 -04:00
|
|
|
update_path (path, key)
|
Makefile.in (gcc.o, [...]): Depend on prefix.h.
* Makefile.in (gcc.o, prefix.o, cccp.o, cpplib.o): Depend on prefix.h.
* cccp.c: Include prefix.h, don't prototype prefix.c functions.
(new_include_prefix): Constify char* parameters.
* cppfiles.c (read_name_map): Likewise.
(append_include_chain): Likewise. Also, use a writable char* copy
of parameter `dir' which we then modify, rather than using the
parameter itself to store the new writable string.
(remap_filename): Constify some variables. Also, use a writable
char* to store an allocated string which we will be modifying.
* cpplib.c: Include prefix.h, don't prototype prefix.c functions.
(cpp_start_read): Constify variable `str'.
* cpplib.h (append_include_chain): Constify a char* parameter.
* gcc.c Include prefix.h, don't prototype prefix.c functions.
(add_prefix, save_string): Constify char* parameters.
(fatal, error): Add ATTRIBUTE_PRINTF_1 to prototypes.
* prefix.c: Include prefix.h.
(get_key_value, translate_name, save_string, update_path,
set_std_prefix): Constify various char* parameters and variables.
(save_string): Use xmalloc, not malloc.
(translate_name): Use a writable temporary variable to create and
modify a string before setting it to a const char*.
* prefix.h: New file to prototype functions exported from prefix.c.
From-SVN: r24498
1999-01-05 14:11:22 -05:00
|
|
|
const char *path;
|
|
|
|
const char *key;
|
1997-10-19 12:29:32 -04:00
|
|
|
{
|
1998-03-27 09:20:40 -05:00
|
|
|
if (! strncmp (path, std_prefix, strlen (std_prefix)) && key != 0)
|
1997-10-19 12:29:32 -04:00
|
|
|
{
|
|
|
|
if (key[0] != '$')
|
|
|
|
key = concat ("@", key, NULL_PTR);
|
|
|
|
|
1998-03-27 09:20:40 -05:00
|
|
|
path = concat (key, &path[strlen (std_prefix)], NULL_PTR);
|
1997-10-19 12:29:32 -04:00
|
|
|
|
|
|
|
while (path[0] == '@' || path[0] == '$')
|
|
|
|
path = translate_name (path);
|
|
|
|
}
|
1999-04-10 00:27:16 -04:00
|
|
|
|
2000-08-04 12:19:19 -04:00
|
|
|
#ifdef UPDATE_PATH_HOST_CANONICALIZE
|
|
|
|
/* Perform host dependant canonicalization when needed. */
|
|
|
|
UPDATE_PATH_HOST_CANONICALIZE (path, key);
|
|
|
|
#endif
|
|
|
|
|
1999-04-10 00:27:16 -04:00
|
|
|
#ifdef DIR_SEPARATOR_2
|
|
|
|
/* Convert DIR_SEPARATOR_2 to DIR_SEPARATOR. */
|
|
|
|
if (DIR_SEPARATOR != DIR_SEPARATOR_2)
|
|
|
|
{
|
c-aux-info.c (concat): Don't define.
* c-aux-info.c (concat): Don't define.
* cccp.c (my_strerror): Likewise. All callers changed to use
xstrerror instead.
(do_include): Call xstrdup, not xmalloc/strcpy.
(grow_outbuf): Don't check if xrealloc returns NULL, it can't.
(xmalloc, xrealloc, xcalloc, xstrdup): Don't define.
* collect2.c (my_strsignal): Likewise. All callers changed to use
strsignal instead.
(locatelib): Call xstrdup, not xmalloc/strcpy.
* 1750a.h (ASM_OUTPUT_INTERNAL_LABEL): Call xmalloc, not malloc.
* dsp16xx.c (override_options): Call xstrdup, not xmalloc/strcpy.
* i370.h (ASM_DECLARE_FUNCTION_NAME): Call xmalloc, not malloc.
* mips.c (build_mips16_call_stub): Call xstrdup, not xmalloc/strcpy.
* cppinit.c (cpp_options_init): Call xcalloc, not xmalloc/bzero.
* dwarfout.c (dwarfout_init): Call concat, not xmalloc/strcpy/...
* except.c (new_eh_region_entry): Call xmalloc/xrealloc, not
malloc/realloc.
(find_all_handler_type_matches): Likewise. Don't check return
value.
(get_new_handler, init_insn_eh_region, process_nestinfo): Call
xmalloc, not malloc.
(init_eh_nesting_info): Likewise. Call xcalloc, not xmalloc/bzero.
* gcc.c (xstrerror, xmalloc, xrealloc): Don't define.
(init_spec): Call xcalloc, not xmalloc/bzero.
(set_spec): Call xstrdup, not save_string.
(record_temp_file): Call xstrdup, not xmalloc/strcpy.
(find_a_file): Call xstrdup, not xmalloc/strcpy.
(process_command): Call xstrdup, not save_string.
(main): Call xcalloc, not xmalloc/bzero.
* gcov.c (xmalloc): Don't define.
(create_program_flow_graph): Call xcalloc, not xmalloc/bzero.
(scan_for_source_files): Call xstrdup, not xmalloc/strcpy.
(output_data): Call xcalloc, not xmalloc/bzero.
* haifa-sched.c (schedule_insns): Call xcalloc, not xmalloc/bzero.
* mips-tdump.c (xmalloc): Don't define.
(print_symbol): Call xmalloc, not malloc.
(read_tfile): Call xcalloc, not calloc.
* mips-tfile.c (xfree, my_strsignal, xmalloc, xcalloc, xrealloc):
Don't define. All callers of xfree/my_strsignal changed to use
free/strsignal instead.
(allocate_cluster): Call xcalloc, not calloc.
* objc/objc-act.c (lang_init): Call concat, not xmalloc/strcpy/...
Fix memory leak, free allocated memory.
* prefix.c (translate_name): Call xstrdup, not save_string.
(update_path): Likewise.
* profile.c (branch_prob): Call xstrdup, not xmalloc/strcpy.
* protoize.c (xstrerror, xmalloc, xrealloc, xfree, savestring2):
Don't define. Callers of xfree/savestring2 changed to use
free/concat instead.
* reload1.c (reload): Call xcalloc, not xmalloc/bzero.
(init_elim_table): Likewise.
* resource.c (init_resource_info): Likewise.
* stupid.c (stupid_life_analysis): Likewise.
* toplev.c (xmalloc, xcalloc, xrealloc, xstrdup): Don't define.
(open_dump_file): Call concat, not xmalloc/strcpy/...
(clean_dump_file): Likewise.
(compile_file): Call xstrdup, not xmalloc/strcpy.
From-SVN: r29148
1999-09-06 22:36:41 -04:00
|
|
|
char *new_path = xstrdup (path);
|
1999-04-10 00:27:16 -04:00
|
|
|
path = new_path;
|
c-aux-info.c (concat): Don't define.
* c-aux-info.c (concat): Don't define.
* cccp.c (my_strerror): Likewise. All callers changed to use
xstrerror instead.
(do_include): Call xstrdup, not xmalloc/strcpy.
(grow_outbuf): Don't check if xrealloc returns NULL, it can't.
(xmalloc, xrealloc, xcalloc, xstrdup): Don't define.
* collect2.c (my_strsignal): Likewise. All callers changed to use
strsignal instead.
(locatelib): Call xstrdup, not xmalloc/strcpy.
* 1750a.h (ASM_OUTPUT_INTERNAL_LABEL): Call xmalloc, not malloc.
* dsp16xx.c (override_options): Call xstrdup, not xmalloc/strcpy.
* i370.h (ASM_DECLARE_FUNCTION_NAME): Call xmalloc, not malloc.
* mips.c (build_mips16_call_stub): Call xstrdup, not xmalloc/strcpy.
* cppinit.c (cpp_options_init): Call xcalloc, not xmalloc/bzero.
* dwarfout.c (dwarfout_init): Call concat, not xmalloc/strcpy/...
* except.c (new_eh_region_entry): Call xmalloc/xrealloc, not
malloc/realloc.
(find_all_handler_type_matches): Likewise. Don't check return
value.
(get_new_handler, init_insn_eh_region, process_nestinfo): Call
xmalloc, not malloc.
(init_eh_nesting_info): Likewise. Call xcalloc, not xmalloc/bzero.
* gcc.c (xstrerror, xmalloc, xrealloc): Don't define.
(init_spec): Call xcalloc, not xmalloc/bzero.
(set_spec): Call xstrdup, not save_string.
(record_temp_file): Call xstrdup, not xmalloc/strcpy.
(find_a_file): Call xstrdup, not xmalloc/strcpy.
(process_command): Call xstrdup, not save_string.
(main): Call xcalloc, not xmalloc/bzero.
* gcov.c (xmalloc): Don't define.
(create_program_flow_graph): Call xcalloc, not xmalloc/bzero.
(scan_for_source_files): Call xstrdup, not xmalloc/strcpy.
(output_data): Call xcalloc, not xmalloc/bzero.
* haifa-sched.c (schedule_insns): Call xcalloc, not xmalloc/bzero.
* mips-tdump.c (xmalloc): Don't define.
(print_symbol): Call xmalloc, not malloc.
(read_tfile): Call xcalloc, not calloc.
* mips-tfile.c (xfree, my_strsignal, xmalloc, xcalloc, xrealloc):
Don't define. All callers of xfree/my_strsignal changed to use
free/strsignal instead.
(allocate_cluster): Call xcalloc, not calloc.
* objc/objc-act.c (lang_init): Call concat, not xmalloc/strcpy/...
Fix memory leak, free allocated memory.
* prefix.c (translate_name): Call xstrdup, not save_string.
(update_path): Likewise.
* profile.c (branch_prob): Call xstrdup, not xmalloc/strcpy.
* protoize.c (xstrerror, xmalloc, xrealloc, xfree, savestring2):
Don't define. Callers of xfree/savestring2 changed to use
free/concat instead.
* reload1.c (reload): Call xcalloc, not xmalloc/bzero.
(init_elim_table): Likewise.
* resource.c (init_resource_info): Likewise.
* stupid.c (stupid_life_analysis): Likewise.
* toplev.c (xmalloc, xcalloc, xrealloc, xstrdup): Don't define.
(open_dump_file): Call concat, not xmalloc/strcpy/...
(clean_dump_file): Likewise.
(compile_file): Call xstrdup, not xmalloc/strcpy.
From-SVN: r29148
1999-09-06 22:36:41 -04:00
|
|
|
do {
|
|
|
|
if (*new_path == DIR_SEPARATOR_2)
|
|
|
|
*new_path = DIR_SEPARATOR;
|
|
|
|
} while (*new_path++);
|
1999-04-10 00:27:16 -04:00
|
|
|
}
|
|
|
|
#endif
|
1997-10-19 12:29:32 -04:00
|
|
|
|
1999-04-10 00:27:16 -04:00
|
|
|
#if defined (DIR_SEPARATOR) && !defined (DIR_SEPARATOR_2)
|
1997-10-19 12:29:32 -04:00
|
|
|
if (DIR_SEPARATOR != '/')
|
|
|
|
{
|
c-aux-info.c (concat): Don't define.
* c-aux-info.c (concat): Don't define.
* cccp.c (my_strerror): Likewise. All callers changed to use
xstrerror instead.
(do_include): Call xstrdup, not xmalloc/strcpy.
(grow_outbuf): Don't check if xrealloc returns NULL, it can't.
(xmalloc, xrealloc, xcalloc, xstrdup): Don't define.
* collect2.c (my_strsignal): Likewise. All callers changed to use
strsignal instead.
(locatelib): Call xstrdup, not xmalloc/strcpy.
* 1750a.h (ASM_OUTPUT_INTERNAL_LABEL): Call xmalloc, not malloc.
* dsp16xx.c (override_options): Call xstrdup, not xmalloc/strcpy.
* i370.h (ASM_DECLARE_FUNCTION_NAME): Call xmalloc, not malloc.
* mips.c (build_mips16_call_stub): Call xstrdup, not xmalloc/strcpy.
* cppinit.c (cpp_options_init): Call xcalloc, not xmalloc/bzero.
* dwarfout.c (dwarfout_init): Call concat, not xmalloc/strcpy/...
* except.c (new_eh_region_entry): Call xmalloc/xrealloc, not
malloc/realloc.
(find_all_handler_type_matches): Likewise. Don't check return
value.
(get_new_handler, init_insn_eh_region, process_nestinfo): Call
xmalloc, not malloc.
(init_eh_nesting_info): Likewise. Call xcalloc, not xmalloc/bzero.
* gcc.c (xstrerror, xmalloc, xrealloc): Don't define.
(init_spec): Call xcalloc, not xmalloc/bzero.
(set_spec): Call xstrdup, not save_string.
(record_temp_file): Call xstrdup, not xmalloc/strcpy.
(find_a_file): Call xstrdup, not xmalloc/strcpy.
(process_command): Call xstrdup, not save_string.
(main): Call xcalloc, not xmalloc/bzero.
* gcov.c (xmalloc): Don't define.
(create_program_flow_graph): Call xcalloc, not xmalloc/bzero.
(scan_for_source_files): Call xstrdup, not xmalloc/strcpy.
(output_data): Call xcalloc, not xmalloc/bzero.
* haifa-sched.c (schedule_insns): Call xcalloc, not xmalloc/bzero.
* mips-tdump.c (xmalloc): Don't define.
(print_symbol): Call xmalloc, not malloc.
(read_tfile): Call xcalloc, not calloc.
* mips-tfile.c (xfree, my_strsignal, xmalloc, xcalloc, xrealloc):
Don't define. All callers of xfree/my_strsignal changed to use
free/strsignal instead.
(allocate_cluster): Call xcalloc, not calloc.
* objc/objc-act.c (lang_init): Call concat, not xmalloc/strcpy/...
Fix memory leak, free allocated memory.
* prefix.c (translate_name): Call xstrdup, not save_string.
(update_path): Likewise.
* profile.c (branch_prob): Call xstrdup, not xmalloc/strcpy.
* protoize.c (xstrerror, xmalloc, xrealloc, xfree, savestring2):
Don't define. Callers of xfree/savestring2 changed to use
free/concat instead.
* reload1.c (reload): Call xcalloc, not xmalloc/bzero.
(init_elim_table): Likewise.
* resource.c (init_resource_info): Likewise.
* stupid.c (stupid_life_analysis): Likewise.
* toplev.c (xmalloc, xcalloc, xrealloc, xstrdup): Don't define.
(open_dump_file): Call concat, not xmalloc/strcpy/...
(clean_dump_file): Likewise.
(compile_file): Call xstrdup, not xmalloc/strcpy.
From-SVN: r29148
1999-09-06 22:36:41 -04:00
|
|
|
char *new_path = xstrdup (path);
|
1999-04-10 00:27:16 -04:00
|
|
|
path = new_path;
|
c-aux-info.c (concat): Don't define.
* c-aux-info.c (concat): Don't define.
* cccp.c (my_strerror): Likewise. All callers changed to use
xstrerror instead.
(do_include): Call xstrdup, not xmalloc/strcpy.
(grow_outbuf): Don't check if xrealloc returns NULL, it can't.
(xmalloc, xrealloc, xcalloc, xstrdup): Don't define.
* collect2.c (my_strsignal): Likewise. All callers changed to use
strsignal instead.
(locatelib): Call xstrdup, not xmalloc/strcpy.
* 1750a.h (ASM_OUTPUT_INTERNAL_LABEL): Call xmalloc, not malloc.
* dsp16xx.c (override_options): Call xstrdup, not xmalloc/strcpy.
* i370.h (ASM_DECLARE_FUNCTION_NAME): Call xmalloc, not malloc.
* mips.c (build_mips16_call_stub): Call xstrdup, not xmalloc/strcpy.
* cppinit.c (cpp_options_init): Call xcalloc, not xmalloc/bzero.
* dwarfout.c (dwarfout_init): Call concat, not xmalloc/strcpy/...
* except.c (new_eh_region_entry): Call xmalloc/xrealloc, not
malloc/realloc.
(find_all_handler_type_matches): Likewise. Don't check return
value.
(get_new_handler, init_insn_eh_region, process_nestinfo): Call
xmalloc, not malloc.
(init_eh_nesting_info): Likewise. Call xcalloc, not xmalloc/bzero.
* gcc.c (xstrerror, xmalloc, xrealloc): Don't define.
(init_spec): Call xcalloc, not xmalloc/bzero.
(set_spec): Call xstrdup, not save_string.
(record_temp_file): Call xstrdup, not xmalloc/strcpy.
(find_a_file): Call xstrdup, not xmalloc/strcpy.
(process_command): Call xstrdup, not save_string.
(main): Call xcalloc, not xmalloc/bzero.
* gcov.c (xmalloc): Don't define.
(create_program_flow_graph): Call xcalloc, not xmalloc/bzero.
(scan_for_source_files): Call xstrdup, not xmalloc/strcpy.
(output_data): Call xcalloc, not xmalloc/bzero.
* haifa-sched.c (schedule_insns): Call xcalloc, not xmalloc/bzero.
* mips-tdump.c (xmalloc): Don't define.
(print_symbol): Call xmalloc, not malloc.
(read_tfile): Call xcalloc, not calloc.
* mips-tfile.c (xfree, my_strsignal, xmalloc, xcalloc, xrealloc):
Don't define. All callers of xfree/my_strsignal changed to use
free/strsignal instead.
(allocate_cluster): Call xcalloc, not calloc.
* objc/objc-act.c (lang_init): Call concat, not xmalloc/strcpy/...
Fix memory leak, free allocated memory.
* prefix.c (translate_name): Call xstrdup, not save_string.
(update_path): Likewise.
* profile.c (branch_prob): Call xstrdup, not xmalloc/strcpy.
* protoize.c (xstrerror, xmalloc, xrealloc, xfree, savestring2):
Don't define. Callers of xfree/savestring2 changed to use
free/concat instead.
* reload1.c (reload): Call xcalloc, not xmalloc/bzero.
(init_elim_table): Likewise.
* resource.c (init_resource_info): Likewise.
* stupid.c (stupid_life_analysis): Likewise.
* toplev.c (xmalloc, xcalloc, xrealloc, xstrdup): Don't define.
(open_dump_file): Call concat, not xmalloc/strcpy/...
(clean_dump_file): Likewise.
(compile_file): Call xstrdup, not xmalloc/strcpy.
From-SVN: r29148
1999-09-06 22:36:41 -04:00
|
|
|
do {
|
|
|
|
if (*new_path == '/')
|
|
|
|
*new_path = DIR_SEPARATOR;
|
2000-01-06 17:00:02 -05:00
|
|
|
} while (*new_path++);
|
1997-10-19 12:29:32 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
1998-03-27 09:20:40 -05:00
|
|
|
|
|
|
|
/* Reset the standard prefix */
|
|
|
|
void
|
|
|
|
set_std_prefix (prefix, len)
|
Makefile.in (gcc.o, [...]): Depend on prefix.h.
* Makefile.in (gcc.o, prefix.o, cccp.o, cpplib.o): Depend on prefix.h.
* cccp.c: Include prefix.h, don't prototype prefix.c functions.
(new_include_prefix): Constify char* parameters.
* cppfiles.c (read_name_map): Likewise.
(append_include_chain): Likewise. Also, use a writable char* copy
of parameter `dir' which we then modify, rather than using the
parameter itself to store the new writable string.
(remap_filename): Constify some variables. Also, use a writable
char* to store an allocated string which we will be modifying.
* cpplib.c: Include prefix.h, don't prototype prefix.c functions.
(cpp_start_read): Constify variable `str'.
* cpplib.h (append_include_chain): Constify a char* parameter.
* gcc.c Include prefix.h, don't prototype prefix.c functions.
(add_prefix, save_string): Constify char* parameters.
(fatal, error): Add ATTRIBUTE_PRINTF_1 to prototypes.
* prefix.c: Include prefix.h.
(get_key_value, translate_name, save_string, update_path,
set_std_prefix): Constify various char* parameters and variables.
(save_string): Use xmalloc, not malloc.
(translate_name): Use a writable temporary variable to create and
modify a string before setting it to a const char*.
* prefix.h: New file to prototype functions exported from prefix.c.
From-SVN: r24498
1999-01-05 14:11:22 -05:00
|
|
|
const char *prefix;
|
|
|
|
int len;
|
1998-03-27 09:20:40 -05:00
|
|
|
{
|
|
|
|
std_prefix = save_string (prefix, len);
|
|
|
|
}
|