]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
msginit: Fix invocation of helper programs on Windows.
authorBruno Haible <bruno@clisp.org>
Wed, 1 May 2019 20:58:28 +0000 (22:58 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 1 May 2019 20:58:28 +0000 (22:58 +0200)
Reported by Michele Locati <michele@locati.it>
in <https://lists.gnu.org/archive/html/bug-gettext/2019-04/msg00058.html>.

* autogen.sh (GNULIB_MODULES_TOOLS_FOR_SRC): Add configmake.
* gettext-tools/src/msginit.c: Include configmake.h.
(main): Add BINDIR to the PATH.

autogen.sh
gettext-tools/src/msginit.c

index a0f4ece2c4480aed1925b401cb1842cff1833c7e..1f03930af29e5489671f578717ac3e69d1649715 100755 (executable)
@@ -130,6 +130,7 @@ if ! $skip_gnulib; then
     clean-temp
     closedir
     closeout
+    configmake
     copy-file
     csharpcomp
     csharpexec
index 1d90717fe38beb8bea9874a4dbf3d0f9b4029a43..8b599abd69f8dbd04d9140cb37ef593ab0cf1176 100644 (file)
@@ -51,6 +51,9 @@
 
 #include <textstyle.h>
 
+/* Get BINDIR.  */
+#include "configmake.h"
+
 #include "closeout.h"
 #include "error.h"
 #include "error-progname.h"
@@ -334,6 +337,48 @@ the output .po file through the --output-file option.\n"),
   /* Read input file.  */
   result = read_catalog_file (input_file, input_syntax);
 
+#if defined _WIN32 || defined __CYGWIN__
+  /* The function fill_header invokes, directly or indirectly, some programs
+     that are installed in ${libdir}/gettext:
+       - hostname, invoked indirectly through 'user-email'.
+       - urlget, invoked indirectly through 'team-address'.
+       - cldr-plurals, invoked directly.
+     These programs depend on libintl.  In installations with shared libraries,
+     we need to guarantee that the programs find the DLL, which is installed
+     in ${bindir}, not in ${libdir}/gettext.  The preferred way to do so is to
+     extend $PATH, so that it contains ${bindir}.  */
+  {
+    const char *orig_path;
+    size_t orig_path_len;
+    char separator;
+    const char *bindir;
+    size_t bindir_len;
+    char *augmented_path;
+
+    orig_path = getenv ("PATH");
+    if (orig_path == NULL)
+      orig_path = "";
+    orig_path_len = strlen (orig_path);
+
+    #if defined __CYGWIN__
+    separator = ':';
+    #else /* native Windows */
+    separator = ';';
+    #endif
+
+    bindir = BINDIR;
+    bindir_len = strlen (bindir);
+
+    /* Concatenate bindir, separator, orig_path.  */
+    augmented_path = XNMALLOC (bindir_len + 1 + orig_path_len + 1, char);
+    memcpy (augmented_path, bindir, bindir_len);
+    augmented_path[bindir_len] = separator;
+    memcpy (augmented_path + bindir_len + 1, orig_path, orig_path_len + 1);
+
+    xsetenv ("PATH", augmented_path, 1);
+  }
+#endif
+
   /* Fill the header entry.  */
   result = fill_header (result);