X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Frelocatable.c;h=fa730984479269f70559af2514d88174927fb7f5;hb=79a3d2d10ebf29fb4e73716ae1b72fc5d20486a5;hp=f0ac6d1058bc5fd852ac0f8265dd617228a5013b;hpb=fc06be3f71756ab695008854af0643e75c78999f;p=gnulib.git diff --git a/lib/relocatable.c b/lib/relocatable.c index f0ac6d105..fa7309844 100644 --- a/lib/relocatable.c +++ b/lib/relocatable.c @@ -1,21 +1,19 @@ /* Provide relocatable packages. - Copyright (C) 2003-2006, 2008-2010 Free Software Foundation, Inc. + Copyright (C) 2003-2006, 2008-2011 Free Software Foundation, Inc. Written by Bruno Haible , 2003. - This program 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, or (at your option) - any later version. + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. 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 - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. */ + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ /* Tell glibc's to provide a prototype for getline(). @@ -25,6 +23,7 @@ # define _GNU_SOURCE 1 #endif +#define _GL_USE_STDLIB_ALLOC 1 #include /* Specification. */ @@ -43,7 +42,7 @@ # include "xalloc.h" #endif -#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ +#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ # define WIN32_LEAN_AND_MEAN # include #endif @@ -70,8 +69,8 @@ ISSLASH(C) tests whether C is a directory separator character. IS_PATH_WITH_DIR(P) tests whether P contains a directory specification. */ -#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ - /* Win32, Cygwin, OS/2, DOS */ +#if ((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__) || defined __EMX__ || defined __DJGPP__ + /* Win32, OS/2, DOS */ # define ISSLASH(C) ((C) == '/' || (C) == '\\') # define HAS_DEVICE(P) \ ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \ @@ -86,9 +85,6 @@ # define FILE_SYSTEM_PREFIX_LEN(P) 0 #endif -/* Use the system functions, not the gnulib overrides in this file. */ -#undef malloc - /* Original installation prefix. */ static char *orig_prefix; static size_t orig_prefix_len; @@ -293,7 +289,12 @@ compute_curr_prefix (const char *orig_installprefix, /* Full pathname of shared library, or NULL. */ static char *shared_library_fullname; -#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ +#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ +/* Native Win32 only. + On Cygwin, it is better to use the Cygwin provided /proc interface, than + to use native Win32 API and cygwin_conv_to_posix_path, because it supports + longer file names + (see ). */ /* Determine the full pathname of the shared library when it is loaded. */ @@ -315,37 +316,21 @@ DllMain (HINSTANCE module_handle, DWORD event, LPVOID reserved) /* Shouldn't happen. */ return FALSE; - { -#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 - } + shared_library_fullname = strdup (location); } return TRUE; } -#else /* Unix except Cygwin */ +#else /* Unix */ static void find_shared_library_fullname () { -#if defined __linux__ && __GLIBC__ >= 2 - /* Linux has /proc/self/maps. glibc 2 has the getline() function. */ +#if (defined __linux__ && (__GLIBC__ >= 2 || defined __UCLIBC__)) || defined __CYGWIN__ + /* 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. */ FILE *fp; /* Open the current process' maps file. It describes one VMA per line. */ @@ -390,7 +375,7 @@ find_shared_library_fullname () #endif } -#endif /* (WIN32 or Cygwin) / (Unix except Cygwin) */ +#endif /* WIN32 / Unix */ /* Return the full pathname of the current shared library. Return NULL if unknown. @@ -398,7 +383,7 @@ find_shared_library_fullname () static char * get_shared_library_fullname () { -#if !(defined _WIN32 || defined __WIN32__ || defined __CYGWIN__) +#if !((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__) static bool tried_find_shared_library_fullname; if (!tried_find_shared_library_fullname) {