GCC Middle and Back End API Reference
prefix.c File Reference


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)
static char * lookup_key (char *)
static const char * get_key_value ()
static char * save_string ()
static char * lookup_key ()
static char * translate_name ()
static void tr ()
char * update_path ()
void set_std_prefix ()


static const char * std_prefix = PREFIX

Function Documentation

static const char* get_key_value ( char *  )

Referenced by translate_name().

static const char* get_key_value ( )
   Given KEY, as above, return its value.  
static char* lookup_key ( char *  )
static char* lookup_key ( )
   Look up "key" in the registry, as above.  

References reg_key.

static char* save_string ( const char *  ,
static char* save_string ( )
   Return a copy of a string that has been placed in the heap.  
void set_std_prefix ( )
   Reset the standard prefix.  
static void tr ( char *  ,
int  ,
static void tr ( )
   In a NUL-terminated STRING, replace character C1 with C2 in-place.  
static char* translate_name ( char *  )

Referenced by update_path().

static char* translate_name ( )
   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.  
         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

References free(), get_key_value(), getenv(), and std_prefix.

char* update_path ( )
   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.  
         Look for `/../'  
                 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.  
                 If we have something like `./..' or `/..', don't
                 strip anything more.  
     Perform host dependent canonicalization when needed.  

References free(), and translate_name().

Variable Documentation


Referenced by lookup_key().

const char* std_prefix = PREFIX

Utility to update paths from internal to external forms. Copyright (C) 1997-2013 Free Software Foundation, Inc.

This file is part of GCC.

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 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 COPYING3. If not see http://www.gnu.org/licenses/.

   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

      HKEY_LOCAL_MACHINE\SOFTWARE\Free Software Foundation\<KEY>

      if found, that value will be used. <KEY> defaults to GCC version
      string, but can be overridden at configuration time.

   -- 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

Referenced by translate_name().