gcc/gcc/prefix.c

353 lines
8.7 KiB
C
Raw Normal View History

1997-10-19 18:29:32 +02:00
/* Utility to update paths from internal to external forms.
Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
2007, 2011 Free Software Foundation, Inc.
1997-10-19 18:29:32 +02:00
Makefile.in, [...]: replace "GNU CC" with "GCC". * Makefile.in, alias.c, basic-block.h, bb-reorder.c, bitmap.c, bitmap.h, builtin-types.def, builtins.c, builtins.def, c-aux-info.c, c-common.c, c-common.def, c-common.h, c-convert.c, c-decl.c, c-dump.c, c-dump.h, c-errors.c, c-format.c, c-lang.c, c-lex.c, c-lex.h, c-parse.in, c-pragma.c, c-pragma.h, c-semantics.c, c-tree.h, c-typeck.c, caller-save.c, calls.c, collect2.c, collect2.h, combine.c, conditions.h, config.gcc, configure.frag, configure.in, conflict.c, convert.c, convert.h, cppspec.c, crtstuff.c, cse.c, cselib.c, cselib.h, dbxout.c, dbxout.h, defaults.h, dependence.c, df.c, df.h, diagnostic.c, diagnostic.h, doloop.c, dominance.c, dwarf.h, dwarf2.h, dwarf2asm.c, dwarf2asm.h, dwarf2out.c, dwarf2out.h, dwarfout.c, emit-rtl.c, errors.c, errors.h, except.c, except.h, exgettext, explow.c, expmed.c, expr.c, expr.h, final.c, fixproto, flags.h, flow.c, fold-const.c, fp-test.c, function.c, function.h, gbl-ctors.h, gcc.c, gcc.h, gcc.hlp, gccspec.c, gcov-io.h, gcse.c, genattr.c, genattrtab.c, gencheck.c, gencodes.c, genconfig.c, genemit.c, genextract.c, genflags.c, gengenrtl.c, genmultilib, genopinit.c, genoutput.c, genpeep.c, genrecog.c, gensupport.c, gensupport.h, ggc-callbacks.c, ggc-common.c, ggc-none.c, ggc-page.c, ggc-simple.c, ggc.h, global.c, graph.c, graph.h, gthr-aix.h, gthr-dce.h, gthr-posix.h, gthr-rtems.h, gthr-single.h, gthr-solaris.h, gthr-vxworks.h, gthr-win32.h, gthr.h, haifa-sched.c, halfpic.c, halfpic.h, hard-reg-set.h, hwint.h, ifcvt.c, input.h, insn-addr.h, integrate.c, integrate.h, jump.c, lcm.c, libgcc2.c, libgcc2.h, lists.c, local-alloc.c, loop.c, loop.h, machmode.def, machmode.h, main.c, mbchar.c, mbchar.h, mips-tdump.c, mips-tfile.c, mklibgcc.in, mkmap-flat.awk, mkmap-symver.awk, optabs.c, output.h, params.c, params.def, params.h, predict.c, predict.def, predict.h, prefix.c, prefix.h, print-rtl.c, print-tree.c, profile.c, protoize.c, read-rtl.c, real.c, real.h, recog.c, recog.h, reg-stack.c, regclass.c, regmove.c, regrename.c, regs.h, reload.c, reload.h, reload1.c, reorg.c, resource.c, resource.h, rtl.c, rtl.def, rtl.h, rtlanal.c, sbitmap.c, sbitmap.h, sched-deps.c, sched-ebb.c, sched-int.h, sched-rgn.c, sched-vis.c, sdbout.c, sdbout.h, sibcall.c, simplify-rtx.c, ssa-ccp.c, ssa-dce.c, ssa.c, ssa.h, stmt.c, stor-layout.c, stringpool.c, system.h, timevar.c, timevar.def, timevar.h, tlink.c, toplev.c, toplev.h, tree.c, tree.def, tree.h, tsystem.h, unroll.c, unwind-dw2-fde.c, unwind-dw2-fde.h, unwind-dw2.c, unwind-pe.h, unwind-sjlj.c, unwind.h, unwind.inc, varasm.c, varray.c, varray.h, xcoffout.c, xcoffout.h: replace "GNU CC" with "GCC". From-SVN: r45105
2001-08-22 16:35:51 +02:00
This file is part of GCC.
1997-10-19 18:29:32 +02:00
Makefile.in, [...]: replace "GNU CC" with "GCC". * Makefile.in, alias.c, basic-block.h, bb-reorder.c, bitmap.c, bitmap.h, builtin-types.def, builtins.c, builtins.def, c-aux-info.c, c-common.c, c-common.def, c-common.h, c-convert.c, c-decl.c, c-dump.c, c-dump.h, c-errors.c, c-format.c, c-lang.c, c-lex.c, c-lex.h, c-parse.in, c-pragma.c, c-pragma.h, c-semantics.c, c-tree.h, c-typeck.c, caller-save.c, calls.c, collect2.c, collect2.h, combine.c, conditions.h, config.gcc, configure.frag, configure.in, conflict.c, convert.c, convert.h, cppspec.c, crtstuff.c, cse.c, cselib.c, cselib.h, dbxout.c, dbxout.h, defaults.h, dependence.c, df.c, df.h, diagnostic.c, diagnostic.h, doloop.c, dominance.c, dwarf.h, dwarf2.h, dwarf2asm.c, dwarf2asm.h, dwarf2out.c, dwarf2out.h, dwarfout.c, emit-rtl.c, errors.c, errors.h, except.c, except.h, exgettext, explow.c, expmed.c, expr.c, expr.h, final.c, fixproto, flags.h, flow.c, fold-const.c, fp-test.c, function.c, function.h, gbl-ctors.h, gcc.c, gcc.h, gcc.hlp, gccspec.c, gcov-io.h, gcse.c, genattr.c, genattrtab.c, gencheck.c, gencodes.c, genconfig.c, genemit.c, genextract.c, genflags.c, gengenrtl.c, genmultilib, genopinit.c, genoutput.c, genpeep.c, genrecog.c, gensupport.c, gensupport.h, ggc-callbacks.c, ggc-common.c, ggc-none.c, ggc-page.c, ggc-simple.c, ggc.h, global.c, graph.c, graph.h, gthr-aix.h, gthr-dce.h, gthr-posix.h, gthr-rtems.h, gthr-single.h, gthr-solaris.h, gthr-vxworks.h, gthr-win32.h, gthr.h, haifa-sched.c, halfpic.c, halfpic.h, hard-reg-set.h, hwint.h, ifcvt.c, input.h, insn-addr.h, integrate.c, integrate.h, jump.c, lcm.c, libgcc2.c, libgcc2.h, lists.c, local-alloc.c, loop.c, loop.h, machmode.def, machmode.h, main.c, mbchar.c, mbchar.h, mips-tdump.c, mips-tfile.c, mklibgcc.in, mkmap-flat.awk, mkmap-symver.awk, optabs.c, output.h, params.c, params.def, params.h, predict.c, predict.def, predict.h, prefix.c, prefix.h, print-rtl.c, print-tree.c, profile.c, protoize.c, read-rtl.c, real.c, real.h, recog.c, recog.h, reg-stack.c, regclass.c, regmove.c, regrename.c, regs.h, reload.c, reload.h, reload1.c, reorg.c, resource.c, resource.h, rtl.c, rtl.def, rtl.h, rtlanal.c, sbitmap.c, sbitmap.h, sched-deps.c, sched-ebb.c, sched-int.h, sched-rgn.c, sched-vis.c, sdbout.c, sdbout.h, sibcall.c, simplify-rtx.c, ssa-ccp.c, ssa-dce.c, ssa.c, ssa.h, stmt.c, stor-layout.c, stringpool.c, system.h, timevar.c, timevar.def, timevar.h, tlink.c, toplev.c, toplev.h, tree.c, tree.def, tree.h, tsystem.h, unroll.c, unwind-dw2-fde.c, unwind-dw2-fde.h, unwind-dw2.c, unwind-pe.h, unwind-sjlj.c, unwind.h, unwind.inc, varasm.c, varray.c, varray.h, xcoffout.c, xcoffout.h: replace "GNU CC" with "GCC". From-SVN: r45105
2001-08-22 16:35:51 +02:00
GCC 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 3 of the License, or (at
Makefile.in, [...]: replace "GNU CC" with "GCC". * Makefile.in, alias.c, basic-block.h, bb-reorder.c, bitmap.c, bitmap.h, builtin-types.def, builtins.c, builtins.def, c-aux-info.c, c-common.c, c-common.def, c-common.h, c-convert.c, c-decl.c, c-dump.c, c-dump.h, c-errors.c, c-format.c, c-lang.c, c-lex.c, c-lex.h, c-parse.in, c-pragma.c, c-pragma.h, c-semantics.c, c-tree.h, c-typeck.c, caller-save.c, calls.c, collect2.c, collect2.h, combine.c, conditions.h, config.gcc, configure.frag, configure.in, conflict.c, convert.c, convert.h, cppspec.c, crtstuff.c, cse.c, cselib.c, cselib.h, dbxout.c, dbxout.h, defaults.h, dependence.c, df.c, df.h, diagnostic.c, diagnostic.h, doloop.c, dominance.c, dwarf.h, dwarf2.h, dwarf2asm.c, dwarf2asm.h, dwarf2out.c, dwarf2out.h, dwarfout.c, emit-rtl.c, errors.c, errors.h, except.c, except.h, exgettext, explow.c, expmed.c, expr.c, expr.h, final.c, fixproto, flags.h, flow.c, fold-const.c, fp-test.c, function.c, function.h, gbl-ctors.h, gcc.c, gcc.h, gcc.hlp, gccspec.c, gcov-io.h, gcse.c, genattr.c, genattrtab.c, gencheck.c, gencodes.c, genconfig.c, genemit.c, genextract.c, genflags.c, gengenrtl.c, genmultilib, genopinit.c, genoutput.c, genpeep.c, genrecog.c, gensupport.c, gensupport.h, ggc-callbacks.c, ggc-common.c, ggc-none.c, ggc-page.c, ggc-simple.c, ggc.h, global.c, graph.c, graph.h, gthr-aix.h, gthr-dce.h, gthr-posix.h, gthr-rtems.h, gthr-single.h, gthr-solaris.h, gthr-vxworks.h, gthr-win32.h, gthr.h, haifa-sched.c, halfpic.c, halfpic.h, hard-reg-set.h, hwint.h, ifcvt.c, input.h, insn-addr.h, integrate.c, integrate.h, jump.c, lcm.c, libgcc2.c, libgcc2.h, lists.c, local-alloc.c, loop.c, loop.h, machmode.def, machmode.h, main.c, mbchar.c, mbchar.h, mips-tdump.c, mips-tfile.c, mklibgcc.in, mkmap-flat.awk, mkmap-symver.awk, optabs.c, output.h, params.c, params.def, params.h, predict.c, predict.def, predict.h, prefix.c, prefix.h, print-rtl.c, print-tree.c, profile.c, protoize.c, read-rtl.c, real.c, real.h, recog.c, recog.h, reg-stack.c, regclass.c, regmove.c, regrename.c, regs.h, reload.c, reload.h, reload1.c, reorg.c, resource.c, resource.h, rtl.c, rtl.def, rtl.h, rtlanal.c, sbitmap.c, sbitmap.h, sched-deps.c, sched-ebb.c, sched-int.h, sched-rgn.c, sched-vis.c, sdbout.c, sdbout.h, sibcall.c, simplify-rtx.c, ssa-ccp.c, ssa-dce.c, ssa.c, ssa.h, stmt.c, stor-layout.c, stringpool.c, system.h, timevar.c, timevar.def, timevar.h, tlink.c, toplev.c, toplev.h, tree.c, tree.def, tree.h, tsystem.h, unroll.c, unwind-dw2-fde.c, unwind-dw2-fde.h, unwind-dw2.c, unwind-pe.h, unwind-sjlj.c, unwind.h, unwind.inc, varasm.c, varray.c, varray.h, xcoffout.c, xcoffout.h: replace "GNU CC" with "GCC". From-SVN: r45105
2001-08-22 16:35:51 +02:00
your option) any later version.
1997-10-19 18:29:32 +02:00
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 COPYING3. If not see
<http://www.gnu.org/licenses/>. */
1997-10-19 18:29:32 +02:00
/* 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
1997-10-19 18:29:32 +02:00
HKEY_LOCAL_MACHINE\SOFTWARE\Free Software Foundation\<KEY>
1997-10-19 18:29:32 +02:00
if found, that value will be used. <KEY> defaults to GCC version
string, but can be overridden at configuration time.
1997-10-19 18:29:32 +02: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.
1997-10-19 18:29:32 +02:00
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 15:58:42 +01:00
#include "system.h"
#include "coretypes.h"
#if defined(_WIN32) && defined(ENABLE_WIN32_REGISTRY)
1997-10-19 18:29:32 +02:00
#include <windows.h>
#endif
#include "prefix.h"
#include "common/common-target.h"
1997-10-19 18:29:32 +02:00
static const char *std_prefix = PREFIX;
static const char *get_key_value (char *);
static char *translate_name (char *);
static char *save_string (const char *, int);
static void tr (char *, int, int);
1997-10-19 18:29:32 +02:00
#if defined(_WIN32) && defined(ENABLE_WIN32_REGISTRY)
static char *lookup_key (char *);
1997-10-19 18:29:32 +02:00
static HKEY reg_key = (HKEY) INVALID_HANDLE_VALUE;
#endif
/* Given KEY, as above, return its value. */
static const char *
get_key_value (char *key)
1997-10-19 18:29:32 +02:00
{
const char *prefix = 0;
char *temp = 0;
1997-10-19 18:29:32 +02:00
#if defined(_WIN32) && defined(ENABLE_WIN32_REGISTRY)
1997-10-19 18:29:32 +02:00
prefix = lookup_key (key);
#endif
if (prefix == 0)
prefix = getenv (temp = concat (key, "_ROOT", NULL));
1997-10-19 18:29:32 +02:00
if (prefix == 0)
prefix = std_prefix;
free (temp);
1997-10-19 18:29:32 +02:00
return prefix;
}
/* Return a copy of a string that has been placed in the heap. */
static char *
save_string (const char *s, int len)
1997-10-19 18:29:32 +02:00
{
tree-inline.c (copy_body_r): Use explicit cast when converting from void *. * tree-inline.c (copy_body_r): Use explicit cast when converting from void *. (copy_bb): Likewise. (copy_edges_for_bb): Likewise. (remap_decl_1): Likewise. (estimate_num_insns_1): Likewise. * cgraph.c (hash_node): Use explicit cast when converting from void *. (eq_node): Likewise. (cgraph_create_node): Use GGC_CNEW. (cgraph_create_edge): Use GGC_NEW. (cgraph_remove_node): Use explicit cast when converting from void *. (hash_varpool_node): Likewise. (eq_varpool_node): Likewise. (cgraph_varpool_node): Use GGC_CNEW. * lambda.h (lambda_vector_new): Use GGC_CNEWVEC. * tree-scalar-evolution.c (new_scev_info_str): Use XNEW. (eq_scev_info): Use explicit cast when converting from void *. (find_var_scev_info): Likewise. (set_instantiated_value): Likewise. (gather_stats_on_scev_database_1): Likewise. * cfgloop.h (simple_loop_desc): Use explicit cast when converting from void *. * c-pch.c (c_common_write_pch): Use XNEWVEC. (c_common_read_pch): Likewise. * prefix.c (save_string): Use XNEWVEC. (translate_name): Use explicit cast when converting from void *. * c-ppoutput.c (print_line): Use explicit cast when converting from void *. (pp_dir_change): Likewise. * c-cppbuiltin.c (builtin_define_std): Likewise. (builtin_define_with_value): Likewise. (builtin_define_with_value_n): Likewise. (builtin_define_with_int_value): Likewise. (builtin_define_type_max): Likewise. * c-incpath.c (add_env_var_paths): Use XNEWVEC. (add_path): Use XNEW. * c-format.c (check_format_info_main): Use GGC_NEW. (format_type_warning): Use explicit cast when converting from void *. * c-typeck.c (alloc_tagged_tu_seen_cache): Use XNEW instead of xmalloc. (start_init): Likewise. * tree-flow-inline.h (first_referenced_var): Use explicit cast when converting from void *. (next_referenced_var): Likewise. * c-pragma.c (push_alignment): Use GGC_NEW instead of ggc_alloc. * gensupport.c (lookup_predicate): Use explicit cast to convert from void *. (init_predicate_table): Use XCNEW instead of xcalloc. * genpreds.c (process_define_predicate): Likewise. From-SVN: r108723
2005-12-17 21:45:46 +01:00
char *result = XNEWVEC (char, len + 1);
1997-10-19 18:29:32 +02:00
memcpy (result, s, len);
1997-10-19 18:29:32 +02:00
result[len] = 0;
return result;
}
#if defined(_WIN32) && defined(ENABLE_WIN32_REGISTRY)
1997-10-19 18:29:32 +02:00
gcc-version.m4: Delete. config: * gcc-version.m4: Delete. fastjar: * Makefile.am (fastjar_TEXINFOS): Add gcc-vers.texi. (BASEVER, DEVPHASE): New variables. (POD2MAN): Adjust setting of --release option. (fastjar.1, grepjar.1, gcc-vers.texi): New rules. * Makefile.in: Regenerate. * configure.ac: Do not invoke TL_AC_GCC_VERSION. * aclocal.m4, configure: Regenerate. gcc: * BASE-VER, DATESTAMP, DEV-PHASE: New files. * Makefile.in (gcc_version, gcc_version_trigger, ): Delete. (BASEVER, DEVPHASE, DATESTAMP, BASEVER_c, DEVPHASE_c, DATESTAMP_c) (BASEVER_s, DEVPHASE_s, DATESTAMP_s): New variables. (version): Define using $(BASEVER_c). (Makefile, config.status, build/gcov-iov.o): No longer depends on version.c. (version.o): Depend on version files; add custom generation command. (prefix.o): Define BASEVER on command line. (s-iov): Depend on version files; adjust command. (TEXI_CPP_FILES, TEX_IGCC_FILES, TEXI_GCCINT_FILES, TEXI_CPPINT_FILES): Add gcc-vers.texi. (gcc-vers.texi): New rule. (doc/%.info, doc/%.dvi): Add -I . to command line. (doc/gccinstall.dvi): Likewise. (PACKAGE): Delete. All uses replaced with "gcc". * aclocal.m4: Do not include gcc-version.m4. * configure.ac: Do not invoke TL_AC_GCC_VERSION. Do not AC_SUBST nor AC_DEFINE PACKAGE or VERSION. Set is_release based on contents of DEV-PHASE. Set gcc_version based on contents of BASE-VER. Define WIN32_REGISTRY_KEY only if the user overrode the default. * config.in, configure: Regenerate. * gccbug.in: Determine version of GCC in use at runtime. * gcov-iov.c: Get version number and development phase from command line, not by including version.c. * intl.c: Replace all uses of PACKAGE with "gcc". * libada-mk.in: Delete unused "gcc_version" variable. * prefix.c: Default WIN32_REGISTRY_KEY to BASEVER. * version.c: (VERSUFFIX): New hook for redistributors; adjust commentary to match. (version_string): Put together from pieces. * config/alpha/x-vms: Do not use $(gcc_version). * config/i386/t-nwld: Likewise. * doc/include/gcc-common.texi: Include gcc-vers.texi for version-GCC and DEVELOPMENT. gcc/ada: * Make-lang.in (doc/gnat_ugn_unw.info, doc/gnat_rm.info) (doc/gnat_ugn_unw.dvi, doc/gnat_rm.dvi): Add gcc-vers.texi to dependencies. gcc/fortran: * Make-lang.in (GFORTRAN_TEXI): Add gcc-vers.texi. gcc/java: * Make-lang.in (TEXI_JAVA_FILES): Add gcc-vers.texi. gcc/treelang: * Make-lang.in (TEXI_TREELANG_FILES): Add gcc-vers.texi. libstdc++-v3: * include/Makefile.am (c++config.h): Depend on DATESTAMP from gcc subdirectory. Generate #define of __GLIBCXX__ from contents of that file. * include/Makefile.in: Regenerate. * include/bits/c++config: Do not define __GLIBCXX__. maintainer-scripts: * README: Update. * gcc_release: Update gcc/DEV-PHASE if that file exists, instead of gcc/version.c. * update_version: Handle updating gcc/DATESTAMP. * update_web_docs: Generate gcc-vers.texi first. From-SVN: r96549
2005-03-16 07:04:10 +01:00
#ifndef WIN32_REGISTRY_KEY
# define WIN32_REGISTRY_KEY BASEVER
#endif
1997-10-19 18:29:32 +02:00
/* Look up "key" in the registry, as above. */
static char *
lookup_key (char *key)
1997-10-19 18:29:32 +02:00
{
char *dst;
DWORD size;
DWORD type;
LONG res;
if (reg_key == (HKEY) INVALID_HANDLE_VALUE)
{
res = RegOpenKeyExA (HKEY_LOCAL_MACHINE, "SOFTWARE", 0,
KEY_READ, &reg_key);
if (res == ERROR_SUCCESS)
res = RegOpenKeyExA (reg_key, "Free Software Foundation", 0,
KEY_READ, &reg_key);
if (res == ERROR_SUCCESS)
res = RegOpenKeyExA (reg_key, WIN32_REGISTRY_KEY, 0,
KEY_READ, &reg_key);
1997-10-19 18:29:32 +02:00
if (res != ERROR_SUCCESS)
{
reg_key = (HKEY) INVALID_HANDLE_VALUE;
return 0;
}
1997-10-19 18:29:32 +02:00
}
size = 32;
dst = xmalloc (size);
1997-10-19 18:29:32 +02:00
res = RegQueryValueExA (reg_key, key, 0, &type, (LPBYTE) dst, &size);
1997-10-19 18:29:32 +02:00
if (res == ERROR_MORE_DATA && type == REG_SZ)
{
dst = xrealloc (dst, size);
res = RegQueryValueExA (reg_key, key, 0, &type, (LPBYTE) dst, &size);
1997-10-19 18:29:32 +02:00
}
if (type != REG_SZ || res != ERROR_SUCCESS)
{
free (dst);
dst = 0;
}
return dst;
}
#endif
/* If NAME, a malloc-ed string, starts with a '@' or '$', apply the
translation rules above and return a newly malloc-ed name.
Otherwise, return the given name. */
1997-10-19 18:29:32 +02:00
static char *
translate_name (char *name)
1997-10-19 18:29:32 +02:00
{
char code;
char *key, *old_name;
const char *prefix;
1997-10-19 18:29:32 +02:00
int keylen;
for (;;)
{
code = name[0];
if (code != '@' && code != '$')
break;
for (keylen = 0;
(name[keylen + 1] != 0 && !IS_DIR_SEPARATOR (name[keylen + 1]));
keylen++)
;
tree-inline.c (copy_body_r): Use explicit cast when converting from void *. * tree-inline.c (copy_body_r): Use explicit cast when converting from void *. (copy_bb): Likewise. (copy_edges_for_bb): Likewise. (remap_decl_1): Likewise. (estimate_num_insns_1): Likewise. * cgraph.c (hash_node): Use explicit cast when converting from void *. (eq_node): Likewise. (cgraph_create_node): Use GGC_CNEW. (cgraph_create_edge): Use GGC_NEW. (cgraph_remove_node): Use explicit cast when converting from void *. (hash_varpool_node): Likewise. (eq_varpool_node): Likewise. (cgraph_varpool_node): Use GGC_CNEW. * lambda.h (lambda_vector_new): Use GGC_CNEWVEC. * tree-scalar-evolution.c (new_scev_info_str): Use XNEW. (eq_scev_info): Use explicit cast when converting from void *. (find_var_scev_info): Likewise. (set_instantiated_value): Likewise. (gather_stats_on_scev_database_1): Likewise. * cfgloop.h (simple_loop_desc): Use explicit cast when converting from void *. * c-pch.c (c_common_write_pch): Use XNEWVEC. (c_common_read_pch): Likewise. * prefix.c (save_string): Use XNEWVEC. (translate_name): Use explicit cast when converting from void *. * c-ppoutput.c (print_line): Use explicit cast when converting from void *. (pp_dir_change): Likewise. * c-cppbuiltin.c (builtin_define_std): Likewise. (builtin_define_with_value): Likewise. (builtin_define_with_value_n): Likewise. (builtin_define_with_int_value): Likewise. (builtin_define_type_max): Likewise. * c-incpath.c (add_env_var_paths): Use XNEWVEC. (add_path): Use XNEW. * c-format.c (check_format_info_main): Use GGC_NEW. (format_type_warning): Use explicit cast when converting from void *. * c-typeck.c (alloc_tagged_tu_seen_cache): Use XNEW instead of xmalloc. (start_init): Likewise. * tree-flow-inline.h (first_referenced_var): Use explicit cast when converting from void *. (next_referenced_var): Likewise. * c-pragma.c (push_alignment): Use GGC_NEW instead of ggc_alloc. * gensupport.c (lookup_predicate): Use explicit cast to convert from void *. (init_predicate_table): Use XCNEW instead of xcalloc. * genpreds.c (process_define_predicate): Likewise. From-SVN: r108723
2005-12-17 21:45:46 +01:00
key = (char *) alloca (keylen + 1);
strncpy (key, &name[1], keylen);
key[keylen] = 0;
if (code == '@')
{
prefix = get_key_value (key);
if (prefix == 0)
prefix = std_prefix;
}
else
prefix = getenv (key);
1997-10-19 18:29:32 +02:00
if (prefix == 0)
prefix = PREFIX;
1997-10-19 18:29:32 +02: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 18:29:32 +02:00
old_name = name;
name = concat (prefix, &name[keylen + 1], NULL);
free (old_name);
1997-10-19 18:29:32 +02:00
}
return name;
}
1997-10-19 18:29:32 +02:00
/* In a NUL-terminated STRING, replace character C1 with C2 in-place. */
static void
tr (char *string, int c1, int c2)
{
do
{
if (*string == c1)
*string = c2;
}
while (*string++);
1997-10-19 18:29:32 +02:00
}
/* Update PATH using KEY if PATH starts with PREFIX as a directory.
The returned string is always malloc-ed, and the caller is
responsible for freeing it. */
1997-10-19 18:29:32 +02:00
char *
update_path (const char *path, const char *key)
1997-10-19 18:29:32 +02:00
{
char *result, *p;
const int len = strlen (std_prefix);
Changelog c-family/ 2011-03-25 Kai Tietz <ktietz@redhat.com> * c-ada-spec.c (compare_comment): Use filename_cmp instead of strcmp for filename. Changelog fortran/ 2011-03-25 Kai Tietz <ktietz@redhat.com> * scanner.c (preprocessor_line): Use filename_cmp instead of strcmp. Changelog gcc/ 2011-03-25 Kai Tietz <ktietz@redhat.com> * collect2.c (write_c_file_stat): Handle backslash as right-hand directory separator. (resolve_lib_name): Use IS_DIR_SEPARATOR instead of checking just for slash. * coverage.c (coverage_init): Use IS_ABSOLUTE_PATH instead of checking for trailing slash. * gcc.c (record_temp_file): Use filename_cmp instead of strcmp. (do_spec_1): Likewise. (replace_outfile_spec_function): Likewise. (is_directory): Use filename_ncmp instead of strncmp. (print_multilib_info): Likewise. * gcov.c (find_source): Use filename_cmp instead instead of strcmp. (make_gcov_file_name): Fix order of slash/backslash checks. * incpath.c (DIRS_EQ): Use filename_cmp instead of strcmp. (add_standard_paths): Likewise. * mips-tfile.c (saber_stop): Handle backslash. * prefix.c (update_path): Use filename_ncmp instead of strncmp. * profile.c (output_location): Use filename_cmp instead of strcmp. * read-md.c (handle_toplevel_file): Handle backslash. * tlink.c (frob_extension): Likewise. * tree-cfg.c (same_line_p): Use filename_cmp instead of strcmp. * tree-dump.c (dequeue_and_dump): Handle backslash. * tree.c (get_file_function_name): Likewise. * gengtype.c (read_input_list): Likewise. (get_file_realbasename): Likewise. (get_output_file_with_visibility): Use filename_cmp instead of strcmp. ChangeLog java/ 2011-03-25 Kai Tietz <ktietz@redhat.com> * jcf-parse.c (java_read_sourcefilenames): Use filename_cmp instead of strcmp. (set_source_filename): Likewise. * win32-host.c (jcf_open_exact_case): Likewise. ChangeLog lto/ 2011-03-25 Kai Tietz <ktietz@redhat.com> * lto.c (lto_resolution_read): Use filename_cmp instead of strcmp. (lto_read_section_data): Likewise. ChangeLog cp/ 2011-03-25 Kai Tietz <ktietz@redhat.com> * lex.c (interface_strcmp): Handle dos-paths. (handle_pragma_implementation): Use filename_cmp instead of strcmp. (in_main_input_context): Likewise. From-SVN: r171522
2011-03-25 20:20:52 +01:00
if (! filename_ncmp (path, std_prefix, len)
&& (IS_DIR_SEPARATOR(path[len])
|| path[len] == '\0')
&& key != 0)
1997-10-19 18:29:32 +02:00
{
bool free_key = false;
1997-10-19 18:29:32 +02:00
if (key[0] != '$')
{
key = concat ("@", key, NULL);
free_key = true;
}
result = concat (key, &path[len], NULL);
if (free_key)
system.h (CONST_CAST2, [...]): New macros for type-specific casts. * system.h (CONST_CAST2, CONST_CAST_TREE, CONST_CAST_RTX, CONST_CAST_BB): New macros for type-specific casts. (CONST_CAST): Add a TYPE parameter and define it in terms of CONST_CAST2. * c-decl.c (c_make_fname_decl): Supply a TYPE for CONST_CAST. * c-lex.c (cb_ident, lex_string): Likewise, * c-typeck.c (free_all_tagged_tu_seen_up_to): Likewise, * config/i386/i386.c (ix86_function_regparm, ix86_function_sseregparm): Use CONST_CAST_TREE. * config/mmix/mmix.c (mmix_encode_section_info): Supply a TYPE for CONST_CAST. * gcc.c (set_spec, read_specs, for_each_path, execute, do_spec_1, give_switch, set_multilib_dir): Likewise, * gengtype-parse.c (string_seq, typedef_name): Likewise, * gimple-low.c (block_may_fallthru): Use CONST_CAST_TREE. * jump.c (reversed_comparison_code_parts): Use CONST_CAST_RTX. * passes.c (execute_one_pass): Supply a TYPE for CONST_CAST. * prefix.c (update_path): Likewise, * pretty-print.c (pp_base_destroy_prefix): Likewise, * rtlanal.c (keep_with_call_p): Use CONST_CAST_RTX. * tree-cfg.c (tree_can_merge_blocks_p, tree_block_ends_with_condjump_p): Use CONST_CAST_BB. * tree-eh.c (lookup_stmt_eh_region_fn): USe CONST_CAST_TREE. * tree.c (build_string): Supply a TYPE for CONST_CAST. (attribute_list_contained): Use CONST_CAST_TREE. cp: * call.c (name_as_c_string): Supply a TYPE for CONST_CAST. * decl.c (cp_make_fname_decl): Likewise, * parser.c (cp_parser_string_literal): Likewise, * tree.c (pod_type_p, zero_init_p): Use CONST_CAST_TREE. * typeck.c (cp_type_quals, cp_type_readonly, cp_has_mutable_p): Likewise, fortran: * gfortranspec.c (lang_specific_driver): Use CONST_CAST2. * options.c (gfc_post_options): Supply a TYPE for CONST_CAST. * parse.c (parse_omp_structured_block): Likewise, * st.c (gfc_free_statement): Likewise, java: * jcf-parse.c (read_class, java_parse_file): Supply a TYPE for CONST_CAST. * jcf.h (JCF_FINISH): Likewise. From-SVN: r128051
2007-09-03 19:09:20 +02:00
free (CONST_CAST (char *, key));
result = translate_name (result);
1997-10-19 18:29:32 +02:00
}
else
result = xstrdup (path);
p = result;
while (1)
{
char *src, *dest;
p = strchr (p, '.');
if (p == NULL)
break;
/* Look for `/../' */
if (p[1] == '.'
&& IS_DIR_SEPARATOR (p[2])
&& (p != result && IS_DIR_SEPARATOR (p[-1])))
{
*p = 0;
if (!targetm_common.always_strip_dotdot
&& access (result, X_OK) == 0)
{
*p = '.';
break;
}
else
{
/* We can't access the dir, so we won't be able to
access dir/.. either. Strip out `dir/../'. If `dir'
turns out to be `.', strip one more path component. */
dest = p;
do
{
--dest;
while (dest != result && IS_DIR_SEPARATOR (*dest))
--dest;
while (dest != result && !IS_DIR_SEPARATOR (dest[-1]))
--dest;
}
while (dest != result && *dest == '.');
/* If we have something like `./..' or `/..', don't
strip anything more. */
if (*dest == '.' || IS_DIR_SEPARATOR (*dest))
{
*p = '.';
break;
}
src = p + 3;
while (IS_DIR_SEPARATOR (*src))
++src;
p = dest;
while ((*dest++ = *src++) != 0)
;
}
}
else
++p;
}
#ifdef UPDATE_PATH_HOST_CANONICALIZE
/* Perform host dependent canonicalization when needed. */
UPDATE_PATH_HOST_CANONICALIZE (result);
#endif
#ifdef DIR_SEPARATOR_2
/* Convert DIR_SEPARATOR_2 to DIR_SEPARATOR. */
if (DIR_SEPARATOR_2 != DIR_SEPARATOR)
tr (result, DIR_SEPARATOR_2, DIR_SEPARATOR);
#endif
#if defined (DIR_SEPARATOR) && !defined (DIR_SEPARATOR_2)
1997-10-19 18:29:32 +02:00
if (DIR_SEPARATOR != '/')
tr (result, '/', DIR_SEPARATOR);
1997-10-19 18:29:32 +02:00
#endif
return result;
1997-10-19 18:29:32 +02:00
}
/* Reset the standard prefix. */
void
set_std_prefix (const char *prefix, int len)
{
std_prefix = save_string (prefix, len);
}