From 44a3eaeba04ef78835ca741592c376428ada5f71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sat, 2 Dec 2017 10:30:25 +0100 Subject: New upstream version 0.9.8 --- lib/relocatable.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'lib/relocatable.c') diff --git a/lib/relocatable.c b/lib/relocatable.c index 810f19b..9c27296 100644 --- a/lib/relocatable.c +++ b/lib/relocatable.c @@ -1,5 +1,5 @@ /* Provide relocatable packages. - Copyright (C) 2003-2006, 2008-2016 Free Software Foundation, Inc. + Copyright (C) 2003-2006, 2008-2017 Free Software Foundation, Inc. Written by Bruno Haible , 2003. This program is free software: you can redistribute it and/or @@ -19,10 +19,10 @@ This program 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 Lesser General Public License for more details. + GNU General Public License for more details. - You should have received a copy of the GNU Lesser General Public License - along with this program. If not, see . */ + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ /* Tell glibc's to provide a prototype for getline(). @@ -324,7 +324,7 @@ static char *shared_library_fullname; 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 ). */ + (see ). */ /* Determine the full pathname of the shared library when it is loaded. */ @@ -551,27 +551,26 @@ relocate (const char *pathname) # ifdef __KLIBC__ # undef strncmp - if (pathname && strncmp (pathname, "/@unixroot", 10) == 0 - && (pathname[10] == '\0' || pathname[10] == '/' || pathname[10] == '\\')) + if (strncmp (pathname, "/@unixroot", 10) == 0 + && (pathname[10] == '\0' || ISSLASH (pathname[10]))) { /* kLIBC itself processes /@unixroot prefix */ - return pathname; } else # endif - if (pathname && ISSLASH (pathname[0])) + if (ISSLASH (pathname[0])) { const char *unixroot = getenv ("UNIXROOT"); - if (unixroot && HAS_DEVICE (unixroot) && !unixroot[2]) + if (unixroot && HAS_DEVICE (unixroot) && unixroot[2] == '\0') { char *result = (char *) xmalloc (2 + strlen (pathname) + 1); #ifdef NO_XMALLOC if (result != NULL) #endif { - strcpy (result, unixroot); + memcpy (result, unixroot, 2); strcpy (result + 2, pathname); return result; } @@ -583,4 +582,17 @@ relocate (const char *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 -- cgit v1.2.3