]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Cygwin portability.
authorBruno Haible <bruno@clisp.org>
Mon, 5 Dec 2005 12:06:30 +0000 (12:06 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:12:57 +0000 (12:12 +0200)
20 files changed:
ChangeLog
autoconf-lib-link/ChangeLog
autoconf-lib-link/configure.ac
build-aux/install-reloc
gettext-runtime/ChangeLog
gettext-runtime/configure.ac
gettext-runtime/intl/ChangeLog
gettext-runtime/intl/relocatable.c
gettext-runtime/libasprintf/ChangeLog
gettext-runtime/libasprintf/configure.ac
gettext-runtime/m4/ChangeLog
gettext-runtime/m4/Makefile.am
gettext-tools/ChangeLog
gettext-tools/configure.ac
gettext-tools/lib/ChangeLog
gettext-tools/lib/progreloc.c
gettext-tools/lib/relocatable.c
gettext-tools/lib/relocwrapper.c
gettext-tools/m4/ChangeLog
gettext-tools/m4/relocatable.m4

index c40c0a532b68624046ff58c710f83e4c17929630..b4ab07d70d41eb0133a3c410374f70d1edbddcf2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-11-23  Bruno Haible  <bruno@clisp.org>
+
+       Cygwin portability.
+       * build-aux/install-reloc: Expect additional exeext argument. On
+       Cygwin, use suffix ".bin.exe" instead of just ".bin".
+
 2005-09-18  Bruno Haible  <bruno@clisp.org>
 
        * build-aux/ltmain.sh: Upgrade to libtool-1.5.20.
index 465fd71a287292406538bee058183bc1b184b883..63400081e864b7410685c68c93577ad80db94445 100644 (file)
@@ -1,3 +1,8 @@
+2005-11-23  Bruno Haible  <bruno@clisp.org>
+
+       Cygwin portability.
+       * configure.ac: Invoke gl_WOE32_DLL.
+
 2005-09-18  Bruno Haible  <bruno@clisp.org>
 
        * config.rpath: Upgrade to libtool-1.5.20.
index 24afbf0b4f7cf905b4efa9677ea07875ed2974b1..db8705ef5eb528da354d3e16759d55605055c8d4 100644 (file)
@@ -38,6 +38,7 @@ AC_OBJEXT
 AC_EXEEXT
 
 dnl Check for build configuration.
+gl_WOE32_DLL
 AC_LIBTOOL_WIN32_DLL
 AC_PROG_LIBTOOL
 
index cbec00791fd956e4f930e58f2e03568a682f7a80..55ec38cc8696459e6ede3c3b22a745afb53a8500 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 # install-reloc - install a program including a relocating wrapper
-# Copyright (C) 2003 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2005 Free Software Foundation, Inc.
 # Written by Bruno Haible <bruno@clisp.org>, 2003.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -18,7 +18,7 @@
 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
 # Usage:
-#   install-reloc library_path_var library_path_value prefix compile_command srcdir config_h_dir install_command... destprog
+#   install-reloc library_path_var library_path_value prefix compile_command srcdir config_h_dir exeext install_command... destprog
 # where
 #   - library_path_var is the platform dependent runtime library path variable
 #   - library_path_value is a colon separated list of directories that contain
@@ -29,6 +29,7 @@
 #   - builddir is the directory where to find built dependencies (namely,
 #     alloca.h and stdbool.h)
 #   - config_h_dir is the directory where to find config.h
+#   - exeext is platform dependent suffix of executables
 #   - install-command is the install command line, excluding the final destprog
 #   - destprog is the destination program name
 # install-reloc renames destprog to destprog.bin and installs a relocating
@@ -45,6 +46,7 @@ if test $# -eq 2; then
   srcdir=$RELOC_SRCDIR
   builddir=$RELOC_BUILDDIR
   config_h_dir=$RELOC_CONFIG_H_DIR
+  exeext=$RELOC_EXEEXT
   install_prog=$RELOC_INSTALL_PROG # including the "-c" option
 else
   if test $# -ge 9; then
@@ -56,7 +58,9 @@ else
     srcdir=$5
     builddir=$6
     config_h_dir=$7
-    install_prog=$8 # maybe not including the "-c" option
+    exeext=$8
+    install_prog=$9 # maybe not including the "-c" option
+    shift
     shift
     shift
     shift
@@ -66,7 +70,7 @@ else
     shift
     shift
   else
-    echo "Usage: $0 library_path_var library_path_value prefix compile_command srcdir builddir config_h_dir install_command... destprog" 1>&2
+    echo "Usage: $0 library_path_var library_path_value prefix compile_command srcdir builddir config_h_dir exeext install_command... destprog" 1>&2
     exit 1
   fi
 fi
@@ -77,6 +81,11 @@ for arg
 do
   destprog=$arg
 done
+# Remove trailing $exeext, if present.
+if test -n "$exeext"; then
+  sedexpr='s|'`echo "$exeext" | sed -e 's,\.,\\\.,g'`'$||'
+  destprog=`echo "$destprog" | sed -e "$sedexpr"`
+fi
 
 # Outputs a command and runs it.
 func_verbose ()
@@ -110,10 +119,10 @@ test -n "$libdirs" || exit 0
 
 # Compile wrapper.
 installdir=`echo "$destprog" | sed -e 's,/[^/]*$,,'`
-func_verbose $compile_command -I"$builddir" -I"$srcdir" -I"$config_h_dir" -DHAVE_CONFIG_H -DNO_XMALLOC -D"INSTALLPREFIX=\"$prefix\"" -D"INSTALLDIR=\"$installdir\"" -D"LIBPATHVAR=\"$library_path_var\"" -D"LIBDIRS=$libdirs" "$srcdir"/relocwrapper.c "$srcdir"/progname.c "$srcdir"/progreloc.c "$srcdir"/xreadlink.c "$srcdir"/readlink.c "$srcdir"/canonicalize.c "$srcdir"/allocsa.c "$srcdir"/relocatable.c "$srcdir"/setenv.c "$srcdir"/strerror.c -o $destprog.wrapper || exit $?
+func_verbose $compile_command -I"$builddir" -I"$srcdir" -I"$config_h_dir" -DHAVE_CONFIG_H -DNO_XMALLOC -D"INSTALLPREFIX=\"$prefix\"" -D"INSTALLDIR=\"$installdir\"" -D"LIBPATHVAR=\"$library_path_var\"" -D"LIBDIRS=$libdirs" -D"EXEEXT=\"$exeext\"" "$srcdir"/relocwrapper.c "$srcdir"/progname.c "$srcdir"/progreloc.c "$srcdir"/xreadlink.c "$srcdir"/readlink.c "$srcdir"/canonicalize.c "$srcdir"/allocsa.c "$srcdir"/relocatable.c "$srcdir"/setenv.c "$srcdir"/strerror.c -o "$destprog.wrapper$exeext" || exit $?
 
 # Rename $destprog.wrapper -> $destprog -> $destprog.bin.
-ln -f $destprog $destprog.bin || exit 1
-mv $destprog.wrapper $destprog || exit 1
+ln -f "$destprog$exeext" "$destprog.bin$exeext" || exit 1
+mv "$destprog.wrapper$exeext" "$destprog$exeext" || exit 1
 
 exit 0
index 4eee768ec7362aa3011a002e90d7a0a08b8aa6e4..7ca1fe4d18f5479f6cdf0476af98164e416c055f 100644 (file)
@@ -1,3 +1,8 @@
+2005-11-23  Bruno Haible  <bruno@clisp.org>
+
+       Cygwin portability.
+       * configure.ac: Invoke gl_WOE32_DLL.
+
 2005-11-24  Bruno Haible  <bruno@clisp.org>
 
        * Makefile.am (config.h_vms, config.h.msvc): Treat HAVE_FWPRINTF like
index f98f32a0bec2b350911df1618d64454dbb83e502..1e957ac554e62af4caf6ddf18e63d7e5f9877901 100644 (file)
@@ -69,6 +69,7 @@ AC_GNU_SOURCE
 gl_USE_SYSTEM_EXTENSIONS
 
 dnl Check for build configuration.
+gl_WOE32_DLL
 AC_LIBTOOL_WIN32_DLL
 AC_PROG_LIBTOOL
 
index c712708d1a9e085a0fefbaceb0a724feeddbe461..5d5a268e61c904fd1c4b2ca7d2331c0f3bab3c78 100644 (file)
@@ -1,3 +1,11 @@
+2005-12-04  Bruno Haible  <bruno@clisp.org>
+
+       Cygwin portability.
+       * relocatable.c: Include <windows.h> also on Cygwin.
+       (DllMain): Add support for Cygwin.
+       (get_shared_library_fullname): Update.
+       Patches partially from Charles Wilson <cygwin@cwilson.fastmail.fm>.
+
 2005-10-09  Bruno Haible  <bruno@clisp.org>
 2002-07-24  Ulrich Drepper  <drepper@redhat.com>
 
index 5b43d12994d8bf831fc12f1557093385d25d30e3..7cc8daf77cc6a88f82d2e24bfc5a046aa60d6de6 100644 (file)
@@ -1,5 +1,5 @@
 /* Provide relocatable packages.
-   Copyright (C) 2003-2004 Free Software Foundation, Inc.
+   Copyright (C) 2003-2005 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
@@ -45,7 +45,7 @@
 # include "xalloc.h"
 #endif
 
-#if defined _WIN32 || defined __WIN32__
+#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__
 # define WIN32_LEAN_AND_MEAN
 # include <windows.h>
 #endif
@@ -234,6 +234,9 @@ compute_curr_prefix (const char *orig_installprefix,
                  same = true;
                break;
              }
+           /* Do case-insensitive comparison if the filesystem is always or
+              often case-insensitive.  It's better to accept the comparison
+              if the difference is only in case, rather than to fail.  */
 #if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
            /* Win32, Cygwin, OS/2, DOS - case insignificant filesystem */
            if ((*rpi >= 'a' && *rpi <= 'z' ? *rpi - 'a' + 'A' : *rpi)
@@ -280,7 +283,7 @@ compute_curr_prefix (const char *orig_installprefix,
 /* Full pathname of shared library, or NULL.  */
 static char *shared_library_fullname;
 
-#if defined _WIN32 || defined __WIN32__
+#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__
 
 /* Determine the full pathname of the shared library when it is loaded.  */
 
@@ -302,13 +305,31 @@ DllMain (HINSTANCE module_handle, DWORD event, LPVOID reserved)
        /* Shouldn't happen.  */
        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;
 }
 
-#else /* Unix */
+#else /* Unix except Cygwin */
 
 static void
 find_shared_library_fullname ()
@@ -359,15 +380,15 @@ find_shared_library_fullname ()
 #endif
 }
 
-#endif /* WIN32 / Unix */
+#endif /* (WIN32 or Cygwin) / (Unix except Cygwin) */
 
 /* Return the full pathname of the current shared library.
    Return NULL if unknown.
-   Guaranteed to work only on Linux and Woe32.  */
+   Guaranteed to work only on Linux, Cygwin and Woe32.  */
 static char *
 get_shared_library_fullname ()
 {
-#if !(defined _WIN32 || defined __WIN32__)
+#if !(defined _WIN32 || defined __WIN32__ || defined __CYGWIN__)
   static bool tried_find_shared_library_fullname;
   if (!tried_find_shared_library_fullname)
     {
index 86ba909dcd0cd11a0e211fe8b8449d431030798a..1a8397e27b0c86a0bf27b8ba03c803175154d11f 100644 (file)
@@ -1,3 +1,8 @@
+2005-11-23  Bruno Haible  <bruno@clisp.org>
+
+       Cygwin portability.
+       * configure.ac: Invoke gl_WOE32_DLL.
+
 2005-07-07  Bruno Haible  <bruno@clisp.org>
 
        Add ability to create shared library on BeOS.
index eee24c9f58d5ee6767273780f188c815aca28b5f..b536bfe4e4cba79f0458e57e66250fcffb1f6dba 100644 (file)
@@ -37,6 +37,7 @@ AC_OBJEXT
 AC_EXEEXT
 
 dnl Check for build configuration.
+gl_WOE32_DLL
 AC_LIBTOOL_WIN32_DLL
 AC_PROG_LIBTOOL
 case "$host_os" in
index 12d0002c30cbc5a546c221bb2849452ad7a19171..d37b725fce79f1622556c97057cdc486ac243c2d 100644 (file)
@@ -1,3 +1,9 @@
+2005-11-23  Bruno Haible  <bruno@clisp.org>
+
+       Cygwin portability.
+       * woe32-dll.m4: New file.
+       * Makefile.am (EXTRA_DIST): Add it.
+
 2005-11-21  Bruno Haible  <bruno@clisp.org>
 
        * gettext.m4 (AM_INTL_SUBDIR): Invoke gt_LC_MESSAGES always, since we
index 3b45d07dc5234339203669774a4ca3e6a6ff18d3..e091e83254959cb5ac152a8d0e9df4f85e2682a2 100644 (file)
@@ -31,4 +31,5 @@ ulonglong.m4 \
 visibility.m4 \
 wchar_t.m4 \
 wint_t.m4 \
+woe32-dll.m4 \
 xsize.m4
index 855894a8e54fe8f27fb79e3283c34932927e0fb0..b7f285d7c0eb3fe59de85805d19754c414f055ba 100644 (file)
@@ -1,3 +1,8 @@
+2005-11-23  Bruno Haible  <bruno@clisp.org>
+
+       Cygwin portability.
+       * configure.ac: Invoke gl_WOE32_DLL.
+
 2005-11-24  Bruno Haible  <bruno@clisp.org>
 
        * Makefile.am (config.h_vms, config.h.msvc): Treat HAVE_FWPRINTF like
index 5130b20ca0437a5226df89f3a8b810886964a466..f42667c8d0b7550996800609da6e3010b7550e6f 100644 (file)
@@ -94,6 +94,7 @@ AC_GNU_SOURCE
 gl_USE_SYSTEM_EXTENSIONS
 
 dnl Check for build configuration.
+gl_WOE32_DLL
 AC_LIBTOOL_WIN32_DLL
 AC_PROG_LIBTOOL
 case "$host_os" in
index 03df93d2bdaf94ce84cb46da85eaf83a6c5851b0..70b9ecd88fd63a23aee98619a16f28e3e3d2f26a 100644 (file)
@@ -1,3 +1,17 @@
+2005-12-04  Bruno Haible  <bruno@clisp.org>
+
+       Cygwin portability.
+       * progreloc.c: Include <windows.h> also on Cygwin.
+       (find_executable): Add support for Cygwin.
+       (set_program_name_and_installdir): Handle also platforms with nonempty
+       EXEEXT.
+       * relocatable.c: Include <windows.h> also on Cygwin.
+       (DllMain): Add support for Cygwin.
+       (get_shared_library_fullname): Update.
+       * relocwrapper.c (add_dotbin): Handle also platforms with nonempty
+       EXEEXT.
+       Patches partially from Charles Wilson <cygwin@cwilson.fastmail.fm>.
+
 2005-10-09  Bruno Haible  <bruno@clisp.org>
 
        * c-strcasestr.h: New file.
index 3f56a22a9d3bef55b8b00c7cdcd6391fdbcd53dd..acf9488bea29444ec97cd58f2531edf0e579fe5e 100644 (file)
@@ -1,5 +1,5 @@
 /* Provide relocatable programs.
-   Copyright (C) 2003-2004 Free Software Foundation, Inc.
+   Copyright (C) 2003-2005 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
@@ -40,7 +40,7 @@
 # define WIN32
 #endif
 
-#ifdef WIN32
+#if defined WIN32 || defined __CYGWIN__
 # define WIN32_LEAN_AND_MEAN
 # include <windows.h>
 #endif
@@ -126,16 +126,39 @@ maybe_executable (const char *filename)
 static char *
 find_executable (const char *argv0)
 {
-#ifdef WIN32
-  char buf[1024];
-  int length = GetModuleFileName (NULL, buf, sizeof (buf));
+#if defined WIN32 || defined __CYGWIN__
+  char location[MAX_PATH];
+  int length = GetModuleFileName (NULL, location, sizeof (location));
   if (length < 0)
     return NULL;
-  if (!IS_PATH_WITH_DIR (buf))
+  if (!IS_PATH_WITH_DIR (location))
     /* Shouldn't happen.  */
     return NULL;
-  return xstrdup (buf);
-#else /* Unix */
+  {
+#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__
   /* The executable is accessible as /proc/<pid>/exe.  In newer Linux
      versions, also as /proc/self/exe.  Linux >= 2.1 provides a symlink
@@ -260,20 +283,48 @@ set_program_name_and_installdir (const char *argv0,
 {
   const char *argv0_stripped = argv0;
 
-  /* Relocatable programs are renamed to .bin by install-reloc.  Remove
-     this suffix here.  */
+  /* Relocatable programs are renamed to .bin by install-reloc.  Or, more
+     generally, their suffix is changed from $exeext to .bin$exeext.
+     Remove the ".bin" here.  */
   {
     size_t argv0_len = strlen (argv0);
-    if (argv0_len > 4 && memcmp (argv0 + argv0_len - 4, ".bin", 4) == 0)
-      {
-       char *shorter = (char *) xmalloc (argv0_len - 4 + 1);
+    const size_t exeext_len = sizeof (EXEEXT) - sizeof ("");
+    if (argv0_len > 4 + exeext_len)
+      if (memcmp (argv0 + argv0_len - exeext_len - 4, ".bin", 4) == 0)
+       {
+         if (sizeof (EXEEXT) > sizeof (""))
+           {
+             /* Compare using an inlined copy of c_strncasecmp(), because
+                the filenames may have undergone a case conversion since
+                they were packaged.  In other words, EXEEXT may be ".exe"
+                on one system and ".EXE" on another.  */
+             static const char exeext[] = EXEEXT;
+             const char *s1 = argv0 + argv0_len - exeext_len;
+             const char *s2 = exeext;
+             for (; *s1 != '\0'; s1++, s2++)
+               {
+                 unsigned char c1 = *s1;
+                 unsigned char c2 = *s2;
+                 if ((c1 >= 'A' && c1 <= 'Z' ? c1 - 'A' + 'a' : c1)
+                     != (c2 >= 'A' && c2 <= 'Z' ? c2 - 'A' + 'a' : c2))
+                   goto done_stripping;
+               }
+           }
+         /* Remove ".bin" before EXEEXT or its equivalent.  */
+         {
+           char *shorter = (char *) xmalloc (argv0_len - 4 + 1);
 #ifdef NO_XMALLOC
-       if (shorter != NULL)
+           if (shorter != NULL)
 #endif
-         {
-           memcpy (shorter, argv0, argv0_len - 4);
-           shorter[argv0_len - 4] = '\0';
-           argv0_stripped = shorter;
+             {
+               memcpy (shorter, argv0, argv0_len - exeext_len - 4);
+               if (sizeof (EXEEXT) > sizeof (""))
+                 memcpy (shorter + argv0_len - exeext_len - 4,
+                         argv0 + argv0_len - exeext_len - 4,
+                         exeext_len);
+               shorter[argv0_len - 4] = '\0';
+               argv0_stripped = shorter;
+             }
          }
       }
   }
index 5b43d12994d8bf831fc12f1557093385d25d30e3..7cc8daf77cc6a88f82d2e24bfc5a046aa60d6de6 100644 (file)
@@ -1,5 +1,5 @@
 /* Provide relocatable packages.
-   Copyright (C) 2003-2004 Free Software Foundation, Inc.
+   Copyright (C) 2003-2005 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
@@ -45,7 +45,7 @@
 # include "xalloc.h"
 #endif
 
-#if defined _WIN32 || defined __WIN32__
+#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__
 # define WIN32_LEAN_AND_MEAN
 # include <windows.h>
 #endif
@@ -234,6 +234,9 @@ compute_curr_prefix (const char *orig_installprefix,
                  same = true;
                break;
              }
+           /* Do case-insensitive comparison if the filesystem is always or
+              often case-insensitive.  It's better to accept the comparison
+              if the difference is only in case, rather than to fail.  */
 #if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
            /* Win32, Cygwin, OS/2, DOS - case insignificant filesystem */
            if ((*rpi >= 'a' && *rpi <= 'z' ? *rpi - 'a' + 'A' : *rpi)
@@ -280,7 +283,7 @@ compute_curr_prefix (const char *orig_installprefix,
 /* Full pathname of shared library, or NULL.  */
 static char *shared_library_fullname;
 
-#if defined _WIN32 || defined __WIN32__
+#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__
 
 /* Determine the full pathname of the shared library when it is loaded.  */
 
@@ -302,13 +305,31 @@ DllMain (HINSTANCE module_handle, DWORD event, LPVOID reserved)
        /* Shouldn't happen.  */
        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;
 }
 
-#else /* Unix */
+#else /* Unix except Cygwin */
 
 static void
 find_shared_library_fullname ()
@@ -359,15 +380,15 @@ find_shared_library_fullname ()
 #endif
 }
 
-#endif /* WIN32 / Unix */
+#endif /* (WIN32 or Cygwin) / (Unix except Cygwin) */
 
 /* Return the full pathname of the current shared library.
    Return NULL if unknown.
-   Guaranteed to work only on Linux and Woe32.  */
+   Guaranteed to work only on Linux, Cygwin and Woe32.  */
 static char *
 get_shared_library_fullname ()
 {
-#if !(defined _WIN32 || defined __WIN32__)
+#if !(defined _WIN32 || defined __WIN32__ || defined __CYGWIN__)
   static bool tried_find_shared_library_fullname;
   if (!tried_find_shared_library_fullname)
     {
index 81127d11e148f55251ac9a6030bf10948d1ff4b9..aae6ea4bb398c7e171bbaf01fb9fb3016fa25836 100644 (file)
@@ -1,5 +1,5 @@
 /* Relocating wrapper program.
-   Copyright (C) 2003 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2005 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2003.
 
    This program is free software; you can redistribute it and/or modify
@@ -58,7 +58,8 @@
 #include "relocatable.h"
 #include "setenv.h"
 
-/* Return a copy of the filename, with an extra ".bin" at the end.  */
+/* Return a copy of the filename, with an extra ".bin" at the end.
+   More generally, it replaces "${EXEEXT}" at the end with ".bin${EXEEXT}".  */
 static char *
 add_dotbin (const char *filename)
 {
@@ -67,6 +68,38 @@ add_dotbin (const char *filename)
 
   if (result != NULL)
     {
+      if (sizeof (EXEEXT) > sizeof (""))
+       {
+         /* EXEEXT handling.  */
+         const size_t exeext_len = sizeof (EXEEXT) - sizeof ("");
+         static const char exeext[] = EXEEXT;
+         if (filename_len > exeext_len)
+           {
+             /* Compare using an inlined copy of c_strncasecmp(), because
+                the filenames may have undergone a case conversion since
+                they were packaged.  In other words, EXEEXT may be ".exe"
+                on one system and ".EXE" on another.  */
+             const char *s1 = filename + filename_len - exeext_len;
+             const char *s2 = exeext;
+             for (; *s1 != '\0'; s1++, s2++)
+               {
+                 unsigned char c1 = *s1;
+                 unsigned char c2 = *s2;
+                 if ((c1 >= 'A' && c1 <= 'Z' ? c1 - 'A' + 'a' : c1)
+                     != (c2 >= 'A' && c2 <= 'Z' ? c2 - 'A' + 'a' : c2))
+                   goto simple_append;
+               }
+             /* Insert ".bin" before EXEEXT or its equivalent.  */
+             memcpy (result, filename, filename_len - exeext_len);
+             memcpy (result + filename_len - exeext_len, ".bin", 4);
+             memcpy (result + filename_len - exeext_len + 4,
+                     filename + filename_len - exeext_len,
+                     exeext_len + 1);
+             return result;
+           }
+       }
+     simple_append:
+      /* Simply append ".bin".  */
       memcpy (result, filename, filename_len);
       memcpy (result + filename_len, ".bin", 4 + 1);
       return result;
index e9282f34e97c28fa5af0d6faf71a5a886ef923ea..e80342bd330bf1507047653237e067a5a474180c 100644 (file)
@@ -1,3 +1,9 @@
+2005-11-24  Bruno Haible  <bruno@clisp.org>
+
+       Cygwin portability.
+       * relocatable.m4 (AC_RELOCATABLE): Require AC_EXEEXT. Arrange to set
+       RELOC_EXEEXT while invoking install-reloc.
+
 2005-09-20  Bruno Haible  <bruno@clisp.org>
 
        * bison-i18n.m4: New file, from bison-2.1.
index cf05dcf66e59a2ded498bf85138271634ae37833..40910a16b98b9c71dc960fee7b7fa932835bc6ca 100644 (file)
@@ -1,4 +1,4 @@
-# relocatable.m4 serial 3 (gettext-0.15)
+# relocatable.m4 serial 4 (gettext-0.15)
 dnl Copyright (C) 2003, 2005 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -13,6 +13,7 @@ AC_DEFUN([AC_RELOCATABLE],
   AC_BEFORE([AC_PROG_INSTALL],[AC_RELOCATABLE])
   AC_REQUIRE([AC_LIB_LIBPATH])
   AC_REQUIRE([AC_RELOCATABLE_LIBRARY])
+  AC_REQUIRE([AC_EXEEXT])
   is_noop=no
   use_elf_origin_trick=no
   if test $RELOCATABLE = yes; then
@@ -40,7 +41,7 @@ AC_DEFUN([AC_RELOCATABLE],
         dnl consisting of more than one word - libtool doesn't support this.
         dnl So we abuse the INSTALL_PROGRAM_ENV hook, originally meant for the
         dnl 'install-strip' target.
-        SET_RELOCATABLE="INSTALL_PROGRAM_ENV = RELOC_LIBRARY_PATH_VAR=\"$shlibpath_var\" RELOC_LIBRARY_PATH_VALUE=\"\$(RELOCATABLE_LIBRARY_PATH)\" RELOC_PREFIX=\"\$(prefix)\" RELOC_COMPILE_COMMAND=\"\$(CC) \$(CPPFLAGS) \$(CFLAGS) \$(LDFLAGS)\" RELOC_SRCDIR=\"\$(RELOCATABLE_SRC_DIR)\" RELOC_BUILDDIR=\"\$(RELOCATABLE_BUILD_DIR)\" RELOC_CONFIG_H_DIR=\"\$(RELOCATABLE_CONFIG_H_DIR)\" RELOC_INSTALL_PROG=\"$INSTALL_PROGRAM\""
+        SET_RELOCATABLE="INSTALL_PROGRAM_ENV = RELOC_LIBRARY_PATH_VAR=\"$shlibpath_var\" RELOC_LIBRARY_PATH_VALUE=\"\$(RELOCATABLE_LIBRARY_PATH)\" RELOC_PREFIX=\"\$(prefix)\" RELOC_COMPILE_COMMAND=\"\$(CC) \$(CPPFLAGS) \$(CFLAGS) \$(LDFLAGS)\" RELOC_SRCDIR=\"\$(RELOCATABLE_SRC_DIR)\" RELOC_BUILDDIR=\"\$(RELOCATABLE_BUILD_DIR)\" RELOC_CONFIG_H_DIR=\"\$(RELOCATABLE_CONFIG_H_DIR)\" RELOC_EXEEXT=\"\$(EXEEXT)\" RELOC_INSTALL_PROG=\"$INSTALL_PROGRAM\""
         case "$ac_aux_dir" in
           /*) INSTALL_PROGRAM="$ac_aux_dir/install-reloc" ;;
           *) INSTALL_PROGRAM="\$(top_builddir)/$ac_aux_dir/install-reloc" ;;