This is the mail archive of the cygwin-developers mailing list for the Cygwin project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On Oct 14 02:09, Charles Wilson wrote:[[ SIDE NOTE: even though our official libintl is built without --enable-relocate, its Makefile is *hardcoded* to define ENABLE_RELOCATABLE. Therefore the libintl_relocate() function IS present, and IS called -- but because the compile-time prefix (/usr) was the same as the installed prefix, it very expensively did a no-op. With Bruno's recent change, it will do a cheap -- but not entirely free -- no-op. ]] [...]
First of all, the blatant bug which sets the locale depending on the Windows settings is much more important and *pressing* IMHO. This is what's really necessary, the relocation stuff not so much.
I had a look into gettext-runtime/intl/setlocale.c and it drives me nuts. I told Bruno back in January already not to use Windowisms on Cygwin.
Cygwin's setlocale and nl_langinfo functions do everything libintl needs. And it's especially annoying to use an encoding which doesn't match the rest of the system, because libintl fetches "ISO-8859-1" from Windows (strange enough), rather than using UTF-8 as requested by $LANG.
Therefore, can we get an intermediate libintl8 which fixes this bug
and just disables ENABLE_RELOCATABLE in the Makefile, until the relocation problem is settled?
But the key bit is that the libfoo_relocate() function needs to be able to determine the current runtime path of the-module-which-contains-'libfoo_relocate()' (well, technically, the module which contains a specific static (private) copy of find_shared_library_fullname).
Well, if that's really necessary, then, for heaven's sake, let them use the code in gettext-runtime/gnulib-lib/relocatable.c, but with a good tweak:
- Call GetModuleFileNameW instead of GetModuleFileName.
- Call cygwin_create_path instead of cygwin_conv_to_posix_path.
The reason is not so much the longer filenames, rather than the conversion of the path into the correct current encoding. Here's an untested patch relative to the original sources from gettext-0.18.1.1.tar.gz:
-- Chuck
Attachment:
setlocale.ii
Description: Text document
diff -urN old/gettext-0.18.1.1/gettext-runtime/gnulib-lib/relocatable.c new/gettext-0.18.1.1/gettext-runtime/gnulib-lib/relocatable.c --- old/gettext-0.18.1.1/gettext-runtime/gnulib-lib/relocatable.c 2010-02-16 16:31:28.000000000 -0500 +++ new/gettext-0.18.1.1/gettext-runtime/gnulib-lib/relocatable.c 2011-08-28 00:25:34.933000000 -0400 @@ -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 <bruno@clisp.org>, 2003. - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 3, 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 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 <http://www.gnu.org/licenses/>. */ /* Tell glibc's <stdio.h> to provide a prototype for getline(). @@ -25,6 +23,7 @@ # define _GNU_SOURCE 1 #endif +#define _GL_USE_STDLIB_ALLOC 1 #include <config.h> /* 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 <windows.h> #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')) \ @@ -290,7 +289,12 @@ /* 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 <http://cygwin.com/ml/cygwin/2011-01/msg00410.html>). */ /* Determine the full pathname of the shared library when it is loaded. */ @@ -312,37 +316,21 @@ /* 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. */ @@ -387,7 +375,7 @@ #endif } -#endif /* (WIN32 or Cygwin) / (Unix except Cygwin) */ +#endif /* WIN32 / Unix */ /* Return the full pathname of the current shared library. Return NULL if unknown. @@ -395,7 +383,7 @@ 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) { diff -urN old/gettext-0.18.1.1/gettext-runtime/intl/relocatable.c new/gettext-0.18.1.1/gettext-runtime/intl/relocatable.c --- old/gettext-0.18.1.1/gettext-runtime/intl/relocatable.c 2010-06-06 08:49:57.000000000 -0400 +++ new/gettext-0.18.1.1/gettext-runtime/intl/relocatable.c 2011-08-28 00:25:34.933000000 -0400 @@ -1,21 +1,19 @@ /* Provide relocatable packages. - Copyright (C) 2003-2006, 2008-2009 Free Software Foundation, Inc. + Copyright (C) 2003-2006, 2008-2011 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 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 <http://www.gnu.org/licenses/>. */ /* Tell glibc's <stdio.h> to provide a prototype for getline(). @@ -25,6 +23,7 @@ # define _GNU_SOURCE 1 #endif +#define _GL_USE_STDLIB_ALLOC 1 #include <config.h> /* 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 <windows.h> #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')) \ @@ -290,7 +289,12 @@ /* 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 <http://cygwin.com/ml/cygwin/2011-01/msg00410.html>). */ /* Determine the full pathname of the shared library when it is loaded. */ @@ -312,37 +316,21 @@ /* 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. */ @@ -387,7 +375,7 @@ #endif } -#endif /* (WIN32 or Cygwin) / (Unix except Cygwin) */ +#endif /* WIN32 / Unix */ /* Return the full pathname of the current shared library. Return NULL if unknown. @@ -395,7 +383,7 @@ 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) { diff -urN old/gettext-0.18.1.1/gettext-tools/gnulib-lib/relocatable.c new/gettext-0.18.1.1/gettext-tools/gnulib-lib/relocatable.c --- old/gettext-0.18.1.1/gettext-tools/gnulib-lib/relocatable.c 2010-05-24 05:42:46.000000000 -0400 +++ new/gettext-0.18.1.1/gettext-tools/gnulib-lib/relocatable.c 2011-08-28 00:25:34.933000000 -0400 @@ -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 <bruno@clisp.org>, 2003. - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 3, 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 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 <http://www.gnu.org/licenses/>. */ /* Tell glibc's <stdio.h> to provide a prototype for getline(). @@ -25,6 +23,7 @@ # define _GNU_SOURCE 1 #endif +#define _GL_USE_STDLIB_ALLOC 1 #include <config.h> /* 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 <windows.h> #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')) \ @@ -290,7 +289,12 @@ /* 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 <http://cygwin.com/ml/cygwin/2011-01/msg00410.html>). */ /* Determine the full pathname of the shared library when it is loaded. */ @@ -312,37 +316,21 @@ /* 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. */ @@ -387,7 +375,7 @@ #endif } -#endif /* (WIN32 or Cygwin) / (Unix except Cygwin) */ +#endif /* WIN32 / Unix */ /* Return the full pathname of the current shared library. Return NULL if unknown. @@ -395,7 +383,7 @@ 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) { diff -urN old/gettext-0.18.1.1/gettext-tools/libgettextpo/relocatable.c new/gettext-0.18.1.1/gettext-tools/libgettextpo/relocatable.c --- old/gettext-0.18.1.1/gettext-tools/libgettextpo/relocatable.c 2010-02-16 16:33:15.000000000 -0500 +++ new/gettext-0.18.1.1/gettext-tools/libgettextpo/relocatable.c 2011-08-28 00:25:34.933000000 -0400 @@ -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 <bruno@clisp.org>, 2003. - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 3, 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 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 <http://www.gnu.org/licenses/>. */ /* Tell glibc's <stdio.h> to provide a prototype for getline(). @@ -25,6 +23,7 @@ # define _GNU_SOURCE 1 #endif +#define _GL_USE_STDLIB_ALLOC 1 #include <config.h> /* 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 <windows.h> #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')) \ @@ -290,7 +289,12 @@ /* 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 <http://cygwin.com/ml/cygwin/2011-01/msg00410.html>). */ /* Determine the full pathname of the shared library when it is loaded. */ @@ -312,37 +316,21 @@ /* 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. */ @@ -387,7 +375,7 @@ #endif } -#endif /* (WIN32 or Cygwin) / (Unix except Cygwin) */ +#endif /* WIN32 / Unix */ /* Return the full pathname of the current shared library. Return NULL if unknown. @@ -395,7 +383,7 @@ 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) { diff -urN old/gettext-0.18.1.1/gettext-runtime/gnulib-lib/progreloc.c new/gettext-0.18.1.1/gettext-runtime/gnulib-lib/progreloc.c --- old/gettext-0.18.1.1/gettext-runtime/gnulib-lib/progreloc.c 2010-02-16 16:31:28.000000000 -0500 +++ new/gettext-0.18.1.1/gettext-runtime/gnulib-lib/progreloc.c 2011-08-28 00:25:34.783000000 -0400 @@ -1,5 +1,5 @@ /* Provide relocatable programs. - Copyright (C) 2003-2010 Free Software Foundation, Inc. + Copyright (C) 2003-2011 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2003. This program is free software: you can redistribute it and/or modify @@ -16,6 +16,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#define _GL_USE_STDLIB_ALLOC 1 #include <config.h> /* Specification. */ @@ -34,11 +35,11 @@ # include <mach-o/dyld.h> #endif -#if defined _WIN32 || defined __WIN32__ +#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ # define WIN32_NATIVE #endif -#if defined WIN32_NATIVE || defined __CYGWIN__ +#ifdef WIN32_NATIVE # define WIN32_LEAN_AND_MEAN # include <windows.h> #endif @@ -59,6 +60,10 @@ # include "xalloc.h" #endif +#ifndef O_EXEC +# define O_EXEC O_RDONLY /* This is often close enough in older systems. */ +#endif + /* Declare canonicalize_file_name. The <stdlib.h> included above may be the system's one, not the gnulib one. */ @@ -68,8 +73,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')) \ @@ -89,12 +94,15 @@ #undef open #undef close +/* Use the system functions, not the gnulib overrides in this file. */ +#undef sprintf + #undef set_program_name #if ENABLE_RELOCATABLE -#ifdef __linux__ +#if defined __linux__ || defined __CYGWIN__ /* File descriptor of the executable. (Only used to verify that we find the correct executable.) */ static int executable_fd = -1; @@ -104,12 +112,13 @@ static bool maybe_executable (const char *filename) { - /* Woe32 lacks the access() function, but Cygwin doesn't. */ -#if !(defined WIN32_NATIVE && !defined __CYGWIN__) + /* Woe32 lacks the access() function. */ +#if !defined WIN32_NATIVE if (access (filename, X_OK) < 0) return false; +#endif -#ifdef __linux__ +#if defined __linux__ || defined __CYGWIN__ if (executable_fd >= 0) { /* If we already have an executable_fd, check that filename points to @@ -128,7 +137,6 @@ } } #endif -#endif return true; } @@ -140,7 +148,12 @@ static char * find_executable (const char *argv0) { -#if defined WIN32_NATIVE || defined __CYGWIN__ +#if defined WIN32_NATIVE + /* 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 <http://cygwin.com/ml/cygwin/2011-01/msg00410.html>). */ char location[MAX_PATH]; int length = GetModuleFileName (NULL, location, sizeof (location)); if (length < 0) @@ -148,32 +161,9 @@ if (!IS_PATH_WITH_DIR (location)) /* Shouldn't happen. */ return NULL; - { -#if defined __CYGWIN__ - /* cygwin-1.5.13 (2005-03-01) or newer would also allow a Linux-like - implementation: readlink of "/proc/self/exe". But using the - result of the Win32 system call is simpler and is consistent with the - code in relocatable.c. */ - /* 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 NULL; - /* Call canonicalize_file_name, because Cygwin supports symbolic links. */ - return canonicalize_file_name (location_as_posix_path); -#else - return xstrdup (location); -#endif - } -#else /* Unix && !Cygwin */ -#ifdef __linux__ + return xstrdup (location); +#else /* Unix */ +# ifdef __linux__ /* The executable is accessible as /proc/<pid>/exe. In newer Linux versions, also as /proc/self/exe. Linux >= 2.1 provides a symlink to the true pathname; older Linux versions give only device and ino, @@ -185,7 +175,7 @@ if (link != NULL && link[0] != '[') return link; if (executable_fd < 0) - executable_fd = open ("/proc/self/exe", O_RDONLY, 0); + executable_fd = open ("/proc/self/exe", O_EXEC, 0); { char buf[6+10+5]; @@ -194,11 +184,24 @@ if (link != NULL && link[0] != '[') return link; if (executable_fd < 0) - executable_fd = open (buf, O_RDONLY, 0); + executable_fd = open (buf, O_EXEC, 0); } } -#endif -#if HAVE_MACH_O_DYLD_H && HAVE__NSGETEXECUTABLEPATH +# endif +# ifdef __CYGWIN__ + /* The executable is accessible as /proc/<pid>/exe, at least in + Cygwin >= 1.5. */ + { + char *link; + + link = xreadlink ("/proc/self/exe"); + if (link != NULL) + return link; + if (executable_fd < 0) + executable_fd = open ("/proc/self/exe", O_EXEC, 0); + } +# endif +# if HAVE_MACH_O_DYLD_H && HAVE__NSGETEXECUTABLEPATH /* On MacOS X 10.2 or newer, the function int _NSGetExecutablePath (char *buf, uint32_t *bufsize); can be used to retrieve the executable's full path. */ @@ -207,7 +210,7 @@ if (_NSGetExecutablePath (location, &length) == 0 && location[0] == '/') return canonicalize_file_name (location); -#endif +# endif /* Guess the executable's full path. We assume the executable has been called via execlp() or execvp() with properly set up argv[0]. The login(1) convention to add a '-' prefix to argv[0] is not supported. */ @@ -248,10 +251,10 @@ /* We have a path item at p, of length p_len. Now concatenate the path item and argv0. */ concat_name = (char *) xmalloc (p_len + strlen (argv0) + 2); -#ifdef NO_XMALLOC +# ifdef NO_XMALLOC if (concat_name == NULL) return NULL; -#endif +# endif if (p_len == 0) /* An empty PATH element designates the current directory. */ strcpy (concat_name, argv0); diff -urN old/gettext-0.18.1.1/gettext-tools/gnulib-lib/progreloc.c new/gettext-0.18.1.1/gettext-tools/gnulib-lib/progreloc.c --- old/gettext-0.18.1.1/gettext-tools/gnulib-lib/progreloc.c 2010-05-24 05:42:46.000000000 -0400 +++ new/gettext-0.18.1.1/gettext-tools/gnulib-lib/progreloc.c 2011-08-28 00:25:34.783000000 -0400 @@ -1,5 +1,5 @@ /* Provide relocatable programs. - Copyright (C) 2003-2010 Free Software Foundation, Inc. + Copyright (C) 2003-2011 Free Software Foundation, Inc. Written by Bruno Haible <bruno@clisp.org>, 2003. This program is free software: you can redistribute it and/or modify @@ -16,6 +16,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#define _GL_USE_STDLIB_ALLOC 1 #include <config.h> /* Specification. */ @@ -34,11 +35,11 @@ # include <mach-o/dyld.h> #endif -#if defined _WIN32 || defined __WIN32__ +#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ # define WIN32_NATIVE #endif -#if defined WIN32_NATIVE || defined __CYGWIN__ +#ifdef WIN32_NATIVE # define WIN32_LEAN_AND_MEAN # include <windows.h> #endif @@ -59,6 +60,10 @@ # include "xalloc.h" #endif +#ifndef O_EXEC +# define O_EXEC O_RDONLY /* This is often close enough in older systems. */ +#endif + /* Declare canonicalize_file_name. The <stdlib.h> included above may be the system's one, not the gnulib one. */ @@ -68,8 +73,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')) \ @@ -89,12 +94,15 @@ #undef open #undef close +/* Use the system functions, not the gnulib overrides in this file. */ +#undef sprintf + #undef set_program_name #if ENABLE_RELOCATABLE -#ifdef __linux__ +#if defined __linux__ || defined __CYGWIN__ /* File descriptor of the executable. (Only used to verify that we find the correct executable.) */ static int executable_fd = -1; @@ -104,12 +112,13 @@ static bool maybe_executable (const char *filename) { - /* Woe32 lacks the access() function, but Cygwin doesn't. */ -#if !(defined WIN32_NATIVE && !defined __CYGWIN__) + /* Woe32 lacks the access() function. */ +#if !defined WIN32_NATIVE if (access (filename, X_OK) < 0) return false; +#endif -#ifdef __linux__ +#if defined __linux__ || defined __CYGWIN__ if (executable_fd >= 0) { /* If we already have an executable_fd, check that filename points to @@ -128,7 +137,6 @@ } } #endif -#endif return true; } @@ -140,7 +148,12 @@ static char * find_executable (const char *argv0) { -#if defined WIN32_NATIVE || defined __CYGWIN__ +#if defined WIN32_NATIVE + /* 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 <http://cygwin.com/ml/cygwin/2011-01/msg00410.html>). */ char location[MAX_PATH]; int length = GetModuleFileName (NULL, location, sizeof (location)); if (length < 0) @@ -148,32 +161,9 @@ if (!IS_PATH_WITH_DIR (location)) /* Shouldn't happen. */ return NULL; - { -#if defined __CYGWIN__ - /* cygwin-1.5.13 (2005-03-01) or newer would also allow a Linux-like - implementation: readlink of "/proc/self/exe". But using the - result of the Win32 system call is simpler and is consistent with the - code in relocatable.c. */ - /* 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 NULL; - /* Call canonicalize_file_name, because Cygwin supports symbolic links. */ - return canonicalize_file_name (location_as_posix_path); -#else - return xstrdup (location); -#endif - } -#else /* Unix && !Cygwin */ -#ifdef __linux__ + return xstrdup (location); +#else /* Unix */ +# ifdef __linux__ /* The executable is accessible as /proc/<pid>/exe. In newer Linux versions, also as /proc/self/exe. Linux >= 2.1 provides a symlink to the true pathname; older Linux versions give only device and ino, @@ -185,7 +175,7 @@ if (link != NULL && link[0] != '[') return link; if (executable_fd < 0) - executable_fd = open ("/proc/self/exe", O_RDONLY, 0); + executable_fd = open ("/proc/self/exe", O_EXEC, 0); { char buf[6+10+5]; @@ -194,11 +184,24 @@ if (link != NULL && link[0] != '[') return link; if (executable_fd < 0) - executable_fd = open (buf, O_RDONLY, 0); + executable_fd = open (buf, O_EXEC, 0); } } -#endif -#if HAVE_MACH_O_DYLD_H && HAVE__NSGETEXECUTABLEPATH +# endif +# ifdef __CYGWIN__ + /* The executable is accessible as /proc/<pid>/exe, at least in + Cygwin >= 1.5. */ + { + char *link; + + link = xreadlink ("/proc/self/exe"); + if (link != NULL) + return link; + if (executable_fd < 0) + executable_fd = open ("/proc/self/exe", O_EXEC, 0); + } +# endif +# if HAVE_MACH_O_DYLD_H && HAVE__NSGETEXECUTABLEPATH /* On MacOS X 10.2 or newer, the function int _NSGetExecutablePath (char *buf, uint32_t *bufsize); can be used to retrieve the executable's full path. */ @@ -207,7 +210,7 @@ if (_NSGetExecutablePath (location, &length) == 0 && location[0] == '/') return canonicalize_file_name (location); -#endif +# endif /* Guess the executable's full path. We assume the executable has been called via execlp() or execvp() with properly set up argv[0]. The login(1) convention to add a '-' prefix to argv[0] is not supported. */ @@ -248,10 +251,10 @@ /* We have a path item at p, of length p_len. Now concatenate the path item and argv0. */ concat_name = (char *) xmalloc (p_len + strlen (argv0) + 2); -#ifdef NO_XMALLOC +# ifdef NO_XMALLOC if (concat_name == NULL) return NULL; -#endif +# endif if (p_len == 0) /* An empty PATH element designates the current directory. */ strcpy (concat_name, argv0);
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |