Diff for /embedaddon/libiconv/srclib/relocatable.c between versions 1.1 and 1.1.1.3

version 1.1, 2012/02/21 22:57:48 version 1.1.1.3, 2021/03/17 13:38:46
Line 1 Line 1
 /* Provide relocatable packages.  /* Provide relocatable packages.
   Copyright (C) 2003-2006, 2008 Free Software Foundation, Inc.   Copyright (C) 2003-2006, 2008-2019 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2003.     Written by Bruno Haible <bruno@clisp.org>, 2003.
   
   This program is free software; you can redistribute it and/or modify it   This program is free software: you can redistribute it and/or modify
   under the terms of the GNU General Public License as published   it under the terms of the GNU General Public License as published by
   by the Free Software Foundation; either version 3, or (at your option)   the Free Software Foundation; either version 3 of the License, or
   any later version.   (at your option) any later version.
   
    This program is distributed in the hope that it will be useful,     This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of     but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   Library General Public License for more details.   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public   You should have received a copy of the GNU General Public License
   License along with this program; if not, write to the Free Software   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 
   USA.  */ 
   
   
 /* Tell glibc's <stdio.h> to provide a prototype for getline().  /* Tell glibc's <stdio.h> to provide a prototype for getline().
    This must come before <config.h> because <config.h> may include     This must come before <config.h> because <config.h> may include
    <features.h>, and once <features.h> has been included, it's too late.  */     <features.h>, and once <features.h> has been included, it's too late.  */
 #ifndef _GNU_SOURCE  #ifndef _GNU_SOURCE
# define _GNU_SOURCE    1# define _GNU_SOURCE 1
 #endif  #endif
   
   #define _GL_USE_STDLIB_ALLOC 1
 #include <config.h>  #include <config.h>
   
 /* Specification.  */  /* Specification.  */
Line 43 Line 42
 # include "xalloc.h"  # include "xalloc.h"
 #endif  #endif
   
#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__#if defined _WIN32 && !defined __CYGWIN__
 # define WIN32_LEAN_AND_MEAN  # define WIN32_LEAN_AND_MEAN
 # include <windows.h>  # include <windows.h>
 #endif  #endif
   
   #ifdef __EMX__
   # define INCL_DOS
   # include <os2.h>
   
   # define strcmp  stricmp
   # define strncmp strnicmp
   #endif
   
 #if DEPENDS_ON_LIBCHARSET  #if DEPENDS_ON_LIBCHARSET
 # include <libcharset.h>  # include <libcharset.h>
 #endif  #endif
Line 70 Line 77
    ISSLASH(C)           tests whether C is a directory separator character.     ISSLASH(C)           tests whether C is a directory separator character.
    IS_PATH_WITH_DIR(P)  tests whether P contains a directory specification.     IS_PATH_WITH_DIR(P)  tests whether P contains a directory specification.
  */   */
#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__#if (defined _WIN32 && !defined __CYGWIN__) || defined __EMX__ || defined __DJGPP__
  /* Win32, Cygwin, OS/2, DOS */  /* Native Windows, OS/2, DOS */
 # define ISSLASH(C) ((C) == '/' || (C) == '\\')  # define ISSLASH(C) ((C) == '/' || (C) == '\\')
 # define HAS_DEVICE(P) \  # define HAS_DEVICE(P) \
     ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \      ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \
Line 86 Line 93
 # define FILE_SYSTEM_PREFIX_LEN(P) 0  # define FILE_SYSTEM_PREFIX_LEN(P) 0
 #endif  #endif
   
   /* Whether to enable the more costly support for relocatable libraries.
      It allows libraries to be have been installed with a different original
      prefix than the program.  But it is quite costly, especially on Cygwin
      platforms, see below.  Therefore we enable it by default only on native
      Windows platforms.  */
   #ifndef ENABLE_COSTLY_RELOCATABLE
   # if defined _WIN32 && !defined __CYGWIN__
   #  define ENABLE_COSTLY_RELOCATABLE 1
   # else
   #  define ENABLE_COSTLY_RELOCATABLE 0
   # endif
   #endif
   
 /* Original installation prefix.  */  /* Original installation prefix.  */
 static char *orig_prefix;  static char *orig_prefix;
 static size_t orig_prefix_len;  static size_t orig_prefix_len;
Line 102  static size_t curr_prefix_len; Line 122  static size_t curr_prefix_len;
    instead of "/").  */     instead of "/").  */
 static void  static void
 set_this_relocation_prefix (const char *orig_prefix_arg,  set_this_relocation_prefix (const char *orig_prefix_arg,
                            const char *curr_prefix_arg)                            const char *curr_prefix_arg)
 {  {
   if (orig_prefix_arg != NULL && curr_prefix_arg != NULL    if (orig_prefix_arg != NULL && curr_prefix_arg != NULL
       /* Optimization: if orig_prefix and curr_prefix are equal, the        /* Optimization: if orig_prefix and curr_prefix are equal, the
         relocation is a nop.  */         relocation is a nop.  */
       && strcmp (orig_prefix_arg, curr_prefix_arg) != 0)        && strcmp (orig_prefix_arg, curr_prefix_arg) != 0)
     {      {
       /* Duplicate the argument strings.  */        /* Duplicate the argument strings.  */
Line 118  set_this_relocation_prefix (const char *orig_prefix_ar Line 138  set_this_relocation_prefix (const char *orig_prefix_ar
 #ifdef NO_XMALLOC  #ifdef NO_XMALLOC
       if (memory != NULL)        if (memory != NULL)
 #endif  #endif
        {        {
          memcpy (memory, orig_prefix_arg, orig_prefix_len + 1);          memcpy (memory, orig_prefix_arg, orig_prefix_len + 1);
          orig_prefix = memory;          orig_prefix = memory;
          memory += orig_prefix_len + 1;          memory += orig_prefix_len + 1;
          memcpy (memory, curr_prefix_arg, curr_prefix_len + 1);          memcpy (memory, curr_prefix_arg, curr_prefix_len + 1);
          curr_prefix = memory;          curr_prefix = memory;
          return;          return;
        }        }
     }      }
   orig_prefix = NULL;    orig_prefix = NULL;
   curr_prefix = NULL;    curr_prefix = NULL;
Line 155  set_relocation_prefix (const char *orig_prefix_arg, co Line 175  set_relocation_prefix (const char *orig_prefix_arg, co
 #endif  #endif
 }  }
   
#if !defined IN_LIBRARY || (defined PIC && defined INSTALLDIR)#if !defined IN_LIBRARY || (defined PIC && defined INSTALLDIR && ENABLE_COSTLY_RELOCATABLE)
   
 /* Convenience function:  /* Convenience function:
    Computes the current installation prefix, based on the original     Computes the current installation prefix, based on the original
Line 168  static Line 188  static
 #endif  #endif
 char *  char *
 compute_curr_prefix (const char *orig_installprefix,  compute_curr_prefix (const char *orig_installprefix,
                     const char *orig_installdir,                     const char *orig_installdir,
                     const char *curr_pathname)                     const char *curr_pathname)
 {  {
   char *curr_installdir;    char *curr_installdir;
   const char *rel_installdir;    const char *rel_installdir;
Line 194  compute_curr_prefix (const char *orig_installprefix, Line 214  compute_curr_prefix (const char *orig_installprefix,
   
     while (p > p_base)      while (p > p_base)
       {        {
        p--;        p--;
        if (ISSLASH (*p))        if (ISSLASH (*p))
          break;          break;
       }        }
   
     q = (char *) xmalloc (p - curr_pathname + 1);      q = (char *) xmalloc (p - curr_pathname + 1);
Line 219  compute_curr_prefix (const char *orig_installprefix, Line 239  compute_curr_prefix (const char *orig_installprefix,
   
     while (rp > rel_installdir && cp > cp_base)      while (rp > rel_installdir && cp > cp_base)
       {        {
        bool same = false;        bool same = false;
        const char *rpi = rp;        const char *rpi = rp;
        const char *cpi = cp;        const char *cpi = cp;
   
        while (rpi > rel_installdir && cpi > cp_base)        while (rpi > rel_installdir && cpi > cp_base)
          {          {
            rpi--;            rpi--;
            cpi--;            cpi--;
            if (ISSLASH (*rpi) || ISSLASH (*cpi))            if (ISSLASH (*rpi) || ISSLASH (*cpi))
              {              {
                if (ISSLASH (*rpi) && ISSLASH (*cpi))                if (ISSLASH (*rpi) && ISSLASH (*cpi))
                  same = true;                  same = true;
                break;                break;
              }              }
            /* Do case-insensitive comparison if the filesystem is always or            /* Do case-insensitive comparison if the file system is always or
               often case-insensitive.  It's better to accept the comparison               often case-insensitive.  It's better to accept the comparison
               if the difference is only in case, rather than to fail.  */               if the difference is only in case, rather than to fail.  */
#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__#if defined _WIN32 || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
            /* Win32, Cygwin, OS/2, DOS - case insignificant filesystem */            /* Native Windows, Cygwin, OS/2, DOS - case insignificant file system */
            if ((*rpi >= 'a' && *rpi <= 'z' ? *rpi - 'a' + 'A' : *rpi)            if ((*rpi >= 'a' && *rpi <= 'z' ? *rpi - 'a' + 'A' : *rpi)
                != (*cpi >= 'a' && *cpi <= 'z' ? *cpi - 'a' + 'A' : *cpi))                != (*cpi >= 'a' && *cpi <= 'z' ? *cpi - 'a' + 'A' : *cpi))
              break;              break;
 #else  #else
            if (*rpi != *cpi)            if (*rpi != *cpi)
              break;              break;
 #endif  #endif
          }          }
        if (!same)        if (!same)
          break;          break;
        /* The last pathname component was the same.  opi and cpi now point        /* The last pathname component was the same.  rpi and cpi now point
           to the slash before it.  */           to the slash before it.  */
        rp = rpi;        rp = rpi;
        cp = cpi;        cp = cpi;
       }        }
   
     if (rp > rel_installdir)      if (rp > rel_installdir)
       {        {
        /* Unexpected: The curr_installdir does not end with rel_installdir.  */        /* Unexpected: The curr_installdir does not end with rel_installdir.  */
        free (curr_installdir);        free (curr_installdir);
        return NULL;        return NULL;
       }        }
   
     {      {
      size_t curr_prefix_len = cp - curr_installdir;      size_t computed_curr_prefix_len = cp - curr_installdir;
      char *curr_prefix;      char *computed_curr_prefix;
   
      curr_prefix = (char *) xmalloc (curr_prefix_len + 1);      computed_curr_prefix = (char *) xmalloc (computed_curr_prefix_len + 1);
 #ifdef NO_XMALLOC  #ifdef NO_XMALLOC
      if (curr_prefix == NULL)      if (computed_curr_prefix == NULL)
        {        {
          free (curr_installdir);          free (curr_installdir);
          return NULL;          return NULL;
        }        }
 #endif  #endif
      memcpy (curr_prefix, curr_installdir, curr_prefix_len);      memcpy (computed_curr_prefix, curr_installdir, computed_curr_prefix_len);
      curr_prefix[curr_prefix_len] = '\0';      computed_curr_prefix[computed_curr_prefix_len] = '\0';
   
       free (curr_installdir);        free (curr_installdir);
   
      return curr_prefix;      return computed_curr_prefix;
     }      }
   }    }
 }  }
   
 #endif /* !IN_LIBRARY || PIC */  #endif /* !IN_LIBRARY || PIC */
   
#if defined PIC && defined INSTALLDIR#if defined PIC && defined INSTALLDIR && ENABLE_COSTLY_RELOCATABLE
   
 /* Full pathname of shared library, or NULL.  */  /* Full pathname of shared library, or NULL.  */
 static char *shared_library_fullname;  static char *shared_library_fullname;
   
#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__#if defined _WIN32 && !defined __CYGWIN__
 /* Native Windows only.
    On Cygwin, it is better to use the Cygwin provided /proc interface, than
    to use native Windows API and cygwin_conv_to_posix_path, because it
    supports longer file names
    (see <https://cygwin.com/ml/cygwin/2011-01/msg00410.html>).  */
   
 /* Determine the full pathname of the shared library when it is loaded.  */  /* Determine the full pathname of the shared library when it is loaded.  */
   
Line 305  DllMain (HINSTANCE module_handle, DWORD event, LPVOID  Line 330  DllMain (HINSTANCE module_handle, DWORD event, LPVOID 
       static char location[MAX_PATH];        static char location[MAX_PATH];
   
       if (!GetModuleFileName (module_handle, location, sizeof (location)))        if (!GetModuleFileName (module_handle, location, sizeof (location)))
        /* Shouldn't happen.  */        /* Shouldn't happen.  */
        return FALSE;        return FALSE;
   
       if (!IS_PATH_WITH_DIR (location))        if (!IS_PATH_WITH_DIR (location))
        /* Shouldn't happen.  */        /* Shouldn't happen.  */
        return FALSE;        return FALSE;
   
      {      shared_library_fullname = strdup (location);
#if defined __CYGWIN__ 
        /* On Cygwin, we need to convert paths coming from Win32 system calls 
           to the Unix-like slashified notation.  */ 
        static char location_as_posix_path[2 * MAX_PATH]; 
        /* There's no error return defined for cygwin_conv_to_posix_path. 
           See cygwin-api/func-cygwin-conv-to-posix-path.html. 
           Does it overflow the buffer of expected size MAX_PATH or does it 
           truncate the path?  I don't know.  Let's catch both.  */ 
        cygwin_conv_to_posix_path (location, location_as_posix_path); 
        location_as_posix_path[MAX_PATH - 1] = '\0'; 
        if (strlen (location_as_posix_path) >= MAX_PATH - 1) 
          /* A sign of buffer overflow or path truncation.  */ 
          return FALSE; 
        shared_library_fullname = strdup (location_as_posix_path); 
#else 
        shared_library_fullname = strdup (location); 
#endif 
      } 
     }      }
   
   return TRUE;    return TRUE;
 }  }
   
#else /* Unix except Cygwin */#elif defined __EMX__
   
   extern int  _CRT_init (void);
   extern void _CRT_term (void);
   extern void __ctordtorInit (void);
   extern void __ctordtorTerm (void);
   
   unsigned long _System
   _DLL_InitTerm (unsigned long hModule, unsigned long ulFlag)
   {
     static char location[CCHMAXPATH];
   
     switch (ulFlag)
       {
         case 0:
           if (_CRT_init () == -1)
             return 0;
   
           __ctordtorInit();
   
           /* See http://cyberkinetica.homeunix.net/os2tk45/cp1/1247_L2H_DosQueryModuleNameSy.html
              for specification of DosQueryModuleName(). */
           if (DosQueryModuleName (hModule, sizeof (location), location))
             return 0;
   
           _fnslashify (location);
           shared_library_fullname = strdup (location);
           break;
   
         case 1:
           __ctordtorTerm();
   
           _CRT_term ();
           break;
       }
   
     return 1;
   }
   
   #else /* Unix */
   
 static void  static void
 find_shared_library_fullname ()  find_shared_library_fullname ()
 {  {
#if defined __linux__ && __GLIBC__ >= 2#if (defined __linux__ && (__GLIBC__ >= 2 || defined __UCLIBC__)) || defined __CYGWIN__
  /* Linux has /proc/self/maps. glibc 2 has the getline() function.  */  /* Linux has /proc/self/maps. glibc 2 and uClibc have the getline()
      function.
      Cygwin >= 1.5 has /proc/self/maps and the getline() function too.
      But it is costly: ca. 0.3 ms on Linux, 3 ms on Cygwin 1.5, and 5 ms on
      Cygwin 1.7.  */
   FILE *fp;    FILE *fp;
   
   /* Open the current process' maps file.  It describes one VMA per line.  */    /* Open the current process' maps file.  It describes one VMA per line.  */
Line 351  find_shared_library_fullname () Line 401  find_shared_library_fullname ()
     {      {
       unsigned long address = (unsigned long) &find_shared_library_fullname;        unsigned long address = (unsigned long) &find_shared_library_fullname;
       for (;;)        for (;;)
        {        {
          unsigned long start, end;          unsigned long start, end;
          int c;          int c;
   
          if (fscanf (fp, "%lx-%lx", &start, &end) != 2)          if (fscanf (fp, "%lx-%lx", &start, &end) != 2)
            break;            break;
          if (address >= start && address <= end - 1)          if (address >= start && address <= end - 1)
            {            {
              /* Found it.  Now see if this line contains a filename.  */              /* Found it.  Now see if this line contains a filename.  */
              while (c = getc (fp), c != EOF && c != '\n' && c != '/')              while (c = getc (fp), c != EOF && c != '\n' && c != '/')
                continue;                continue;
              if (c == '/')              if (c == '/')
                {                {
                  size_t size;                  size_t size;
                  int len;                  int len;
   
                  ungetc (c, fp);                  ungetc (c, fp);
                  shared_library_fullname = NULL; size = 0;                  shared_library_fullname = NULL; size = 0;
                  len = getline (&shared_library_fullname, &size, fp);                  len = getline (&shared_library_fullname, &size, fp);
                  if (len >= 0)                  if (len >= 0)
                    {                    {
                      /* Success: filled shared_library_fullname.  */                      /* Success: filled shared_library_fullname.  */
                      if (len > 0 && shared_library_fullname[len - 1] == '\n')                      if (len > 0 && shared_library_fullname[len - 1] == '\n')
                        shared_library_fullname[len - 1] = '\0';                        shared_library_fullname[len - 1] = '\0';
                    }                    }
                }                }
              break;              break;
            }            }
          while (c = getc (fp), c != EOF && c != '\n')          while (c = getc (fp), c != EOF && c != '\n')
            continue;            continue;
        }        }
       fclose (fp);        fclose (fp);
     }      }
 #endif  #endif
 }  }
   
#endif /* (WIN32 or Cygwin) / (Unix except Cygwin) */#endif /* Native Windows / EMX / Unix */
   
 /* Return the full pathname of the current shared library.  /* Return the full pathname of the current shared library.
    Return NULL if unknown.     Return NULL if unknown.
   Guaranteed to work only on Linux, Cygwin and Woe32.  */   Guaranteed to work only on Linux, EMX, Cygwin, and native Windows.  */
 static char *  static char *
 get_shared_library_fullname ()  get_shared_library_fullname ()
 {  {
#if !(defined _WIN32 || defined __WIN32__ || defined __CYGWIN__)#if !(defined _WIN32 && !defined __CYGWIN__) && !defined __EMX__
   static bool tried_find_shared_library_fullname;    static bool tried_find_shared_library_fullname;
   if (!tried_find_shared_library_fullname)    if (!tried_find_shared_library_fullname)
     {      {
Line 415  get_shared_library_fullname () Line 465  get_shared_library_fullname ()
 const char *  const char *
 relocate (const char *pathname)  relocate (const char *pathname)
 {  {
#if defined PIC && defined INSTALLDIR#if defined PIC && defined INSTALLDIR && ENABLE_COSTLY_RELOCATABLE
   static int initialized;    static int initialized;
   
   /* Initialization code for a shared library.  */    /* Initialization code for a shared library.  */
   if (!initialized)    if (!initialized)
     {      {
       /* At this point, orig_prefix and curr_prefix likely have already been        /* At this point, orig_prefix and curr_prefix likely have already been
         set through the main program's set_program_name_and_installdir         set through the main program's set_program_name_and_installdir
         function.  This is sufficient in the case that the library has         function.  This is sufficient in the case that the library has
         initially been installed in the same orig_prefix.  But we can do         initially been installed in the same orig_prefix.  But we can do
         better, to also cover the cases that 1. it has been installed         better, to also cover the cases that 1. it has been installed
         in a different prefix before being moved to orig_prefix and (later)         in a different prefix before being moved to orig_prefix and (later)
         to curr_prefix, 2. unlike the program, it has not moved away from         to curr_prefix, 2. unlike the program, it has not moved away from
         orig_prefix.  */         orig_prefix.  */
       const char *orig_installprefix = INSTALLPREFIX;        const char *orig_installprefix = INSTALLPREFIX;
       const char *orig_installdir = INSTALLDIR;        const char *orig_installdir = INSTALLDIR;
       char *curr_prefix_better;        char *curr_prefix_better;
   
       curr_prefix_better =        curr_prefix_better =
        compute_curr_prefix (orig_installprefix, orig_installdir,        compute_curr_prefix (orig_installprefix, orig_installdir,
                             get_shared_library_fullname ());                             get_shared_library_fullname ());
   
       set_relocation_prefix (orig_installprefix,        set_relocation_prefix (orig_installprefix,
                             curr_prefix_better != NULL                             curr_prefix_better != NULL
                             ? curr_prefix_better                             ? curr_prefix_better
                             : curr_prefix);                             : curr_prefix);
   
       if (curr_prefix_better != NULL)        if (curr_prefix_better != NULL)
        free (curr_prefix_better);        free (curr_prefix_better);
   
       initialized = 1;        initialized = 1;
     }      }
 #endif  #endif
   
   /* Note: It is not necessary to perform case insensitive comparison here,    /* Note: It is not necessary to perform case insensitive comparison here,
     even for DOS-like filesystems, because the pathname argument was     even for DOS-like file systems, because the pathname argument was
      typically created from the same Makefile variable as orig_prefix came       typically created from the same Makefile variable as orig_prefix came
      from.  */       from.  */
   if (orig_prefix != NULL && curr_prefix != NULL    if (orig_prefix != NULL && curr_prefix != NULL
       && strncmp (pathname, orig_prefix, orig_prefix_len) == 0)        && strncmp (pathname, orig_prefix, orig_prefix_len) == 0)
     {      {
       if (pathname[orig_prefix_len] == '\0')        if (pathname[orig_prefix_len] == '\0')
        {        {
          /* pathname equals orig_prefix.  */          /* pathname equals orig_prefix.  */
          char *result = (char *) xmalloc (strlen (curr_prefix) + 1);          char *result = (char *) xmalloc (strlen (curr_prefix) + 1);
   
 #ifdef NO_XMALLOC  #ifdef NO_XMALLOC
          if (result != NULL)          if (result != NULL)
 #endif  #endif
            {            {
              strcpy (result, curr_prefix);              strcpy (result, curr_prefix);
              return result;              return result;
            }            }
        }        }
       else if (ISSLASH (pathname[orig_prefix_len]))        else if (ISSLASH (pathname[orig_prefix_len]))
        {        {
          /* pathname starts with orig_prefix.  */          /* pathname starts with orig_prefix.  */
          const char *pathname_tail = &pathname[orig_prefix_len];          const char *pathname_tail = &pathname[orig_prefix_len];
          char *result =          char *result =
            (char *) xmalloc (curr_prefix_len + strlen (pathname_tail) + 1);            (char *) xmalloc (curr_prefix_len + strlen (pathname_tail) + 1);
   
 #ifdef NO_XMALLOC  #ifdef NO_XMALLOC
          if (result != NULL)          if (result != NULL)
 #endif  #endif
            {            {
              memcpy (result, curr_prefix, curr_prefix_len);              memcpy (result, curr_prefix, curr_prefix_len);
              strcpy (result + curr_prefix_len, pathname_tail);              strcpy (result + curr_prefix_len, pathname_tail);
              return result;              return result;
            }            }
        }        }
     }      }
   
   #ifdef __EMX__
   # ifdef __KLIBC__
   #  undef strncmp
   
     if (strncmp (pathname, "/@unixroot", 10) == 0
         && (pathname[10] == '\0' || ISSLASH (pathname[10])))
       {
         /* kLIBC itself processes /@unixroot prefix */
         return pathname;
       }
     else
   # endif
     if (ISSLASH (pathname[0]))
       {
         const char *unixroot = getenv ("UNIXROOT");
   
         if (unixroot && HAS_DEVICE (unixroot) && unixroot[2] == '\0')
           {
             char *result = (char *) xmalloc (2 + strlen (pathname) + 1);
   #ifdef NO_XMALLOC
             if (result != NULL)
   #endif
               {
                 memcpy (result, unixroot, 2);
                 strcpy (result + 2, pathname);
                 return result;
               }
           }
       }
   #endif
   
   /* Nothing to relocate.  */    /* Nothing to relocate.  */
   return pathname;    return pathname;
   }
   
   /* Returns the pathname, relocated according to the current installation
      directory.
      This function sets *ALLOCATEDP to the allocated memory, or to NULL if
      no memory allocation occurs.  So that, after you're done with the return
      value, to reclaim allocated memory, you can do: free (*ALLOCATEDP).  */
   const char *
   relocate2 (const char *pathname, char **allocatedp)
   {
     const char *result = relocate (pathname);
     *allocatedp = (result != pathname ? (char *) result : NULL);
     return result;
 }  }
   
 #endif  #endif

Removed from v.1.1  
changed lines
  Added in v.1.1.1.3


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>