2018-01-07  Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* gettext-runtime/gnulib-lib/progname.c [MSDOS]: Define new macro
	GET_LAST_SLASH to find the last directory separator character.  On
	DOS-Like systems these are slash, backslash or colon.  For POSIX
	this is simple a slash.

	* gettext-tools/gnulib-lib/execute.c [__DJGPP__]: DJGPP specific
	implementation of execute.

	* gettext-tools/gnulib-lib/djgpp-spawn.h: New file.  Implements DJGPP
	specific stuff.

	* gettext-tools/gnulib-lib/libxml/nanohttp.c: Define SOCKET to int if
	not defined.

	* gettext-tools/gnulib-lib/libxml/xmlIO.c: For DJGPP define _wfopen,
	_wopen and _wstat as NO-OPs.
	(__xmlIOWin32UTF8ToWChar): For DJGPP return always NULL.
	(xmlInitPlatformSpecificIo): For DJGPP return native format of stat
	and open instead of UTF8 version.

	* gettext-tools/gnulib-lib/libxml/libxml.h [PIC, NOLIBTOOL]: Define
	LIBXML_STATIC only if not already defined.

	* gettext-tools/gnulib-lib/libgettextpo/progname.c [MSDOS]: Define new
	macro GET_LAST_SLASH to find the last directory separator character.
	On DOS-Like systems these are slash, backslash or colon.  For POSIX
	this is simple a slash.

	* gettext-tools/gnulib-lib/progname.c [MSDOS]: Define new macro
	GET_LAST_SLASH to find the last directory separator character.  On
	DOS-Like systems these are slash, backslash or colon.  For POSIX
	this is simple a slash.

	* gettext-tools/gnulib-lib/spawn-pipe.c: DJGPP specific implementation
	of create_pipe.

	* gettext-tools/gnulib-lib/spawni.c [__DJGPP__]: DJGPP specific
	implementation of __spawni.  Still not implemented; returns ENOSYS.

	* gettext-tools/gnulib-lib/tempname.c (__path_search): For DJGPP try
	TMP and TEMP also if TMPDIR does not exist or does not point to an
	existing directory.

	* gettext-tools/gnulib-lib/wait-process.c[__DJGPP__]: Include
	djgpp-spawn.h.
	(wait_subprocess): DJGPP specific implementation of wait_subprocess.
	Removes the tmp files used to implement the pipe.

	* gettext-tools/misc/autopoint.in: Appart of TMPDIR support TMP and
	TEMP also and default to the current working directory if neither is
	set.

	* gettext-tools/misc/gettextize.in: Appart of TMPDIR support TMP and
	TEMP also and default to the current working directory if neither is
	set.

	* gnulib-local/lib/libxml/nanohttp.c: Define SOCKET to int if not
	defined.

	* gnulib-local/lib/libxml/xmlIO.c: For DJGPP define _wfopen, _wopen
	and _wstat as NO-OPs.
	(__xmlIOWin32UTF8ToWChar): For DJGPP return always NULL.
	(xmlInitPlatformSpecificIo): For DJGPP return native format of stat
	and open instead of UTF8 version.

	* gnulib-local/lib/libxml/libxml.h [PIC, NOLIBTOOL]: Define
	LIBXML_STATIC only if not already defined.











diff -aprNU5 gettext-0.19.8.1.orig/gettext-runtime/gnulib-lib/progname.c gettext-0.19.8.1/gettext-runtime/gnulib-lib/progname.c
--- gettext-0.19.8.1.orig/gettext-runtime/gnulib-lib/progname.c	2016-05-30 02:52:18 +0000
+++ gettext-0.19.8.1/gettext-runtime/gnulib-lib/progname.c	2018-01-29 09:54:02 +0000
@@ -25,10 +25,44 @@
 #include <errno.h> /* get program_invocation_name declaration */
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
+/* MS-DOS and similar non-Posix systems have some peculiarities:
+    - they use both `/' and `\\' as directory separator in file names;
+    - they can have a drive letter X: prepended to a file name;
+   These are all parameterized here.  */
+
+#ifdef MSDOS
+# if defined (__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
+#  define __gnuc_extension__  __extension__
+# else
+#  define __gnuc_extension__
+# endif
+# include <libc/unconst.h>
+# undef  IS_SLASH
+# define IS_SLASH(c)  ((c) == '/' || (c) == '\\' || (c) == ':')
+# define GET_LAST_SLASH(filename)              \
+  (__gnuc_extension__                          \
+    ({                                         \
+      char *_slash = NULL;                     \
+      if ((filename))                          \
+      {                                        \
+        _slash = unconst((filename), char *);  \
+        while (*_slash++)                      \
+          ;                                    \
+        while ((--_slash - (filename)))        \
+          if (IS_SLASH(*_slash))               \
+            break;                             \
+      }                                        \
+      _slash;                                  \
+    })                                         \
+  )
+#else
+# define GET_LAST_SLASH(filename)  (strrchr((filename), '/'))
+#endif
+
 
 /* String containing name the program is called with.
    To be initialized by main().  */
 const char *program_name = NULL;
 
@@ -54,13 +88,21 @@ set_program_name (const char *argv0)
       fputs ("A NULL argv[0] was passed through an exec system call.\n",
              stderr);
       abort ();
     }
 
-  slash = strrchr (argv0, '/');
+  slash = GET_LAST_SLASH (argv0);
   base = (slash != NULL ? slash + 1 : argv0);
-  if (base - argv0 >= 7 && strncmp (base - 7, "/.libs/", 7) == 0)
+  if (base - argv0 >= 7 && (strncmp (base - 7, "/.libs/", 7) == 0
+#ifdef MSDOS
+     || strncmp (base - 7, "\\.libs/", 7) == 0
+     || strncmp (base - 7, "\\.libs\\", 7) == 0
+     || strncmp (base - 7, "/_libs/", 7) == 0
+     || strncmp (base - 7, "\\_libs/", 7) == 0
+     || strncmp (base - 7, "\\_libs\\", 7) == 0
+#endif
+     ))
     {
       argv0 = base;
       if (strncmp (base, "lt-", 3) == 0)
         {
           argv0 = base + 3;
diff -aprNU5 gettext-0.19.8.1.orig/gettext-tools/gnulib-lib/djgpp-spawn.h gettext-0.19.8.1/gettext-tools/gnulib-lib/djgpp-spawn.h
--- gettext-0.19.8.1.orig/gettext-tools/gnulib-lib/djgpp-spawn.h	1970-01-01 00:00:00 +0000
+++ gettext-0.19.8.1/gettext-tools/gnulib-lib/djgpp-spawn.h	2018-01-29 09:54:02 +0000
@@ -0,0 +1,155 @@
+#include <config.h>
+#include <stdio.h>
+#include "cloexec.h"
+#include "xalloc.h"
+
+#define prepare_spawn(argv)                                        \
+(__gnuc_extension__                                                \
+  ({                                                               \
+     size_t _argc;                                                 \
+     char **_new_argv;                                             \
+                                                                   \
+     for (_argc = 0; (argv)[_argc]; _argc++)                       \
+       ;                                                           \
+                                                                   \
+     _new_argv = xmalloc((1 + _argc + 1) * sizeof(_new_argv[0]));  \
+     *_new_argv++ = "/dev/env/DJDIR/bin/sh";                       \
+                                                                   \
+     for (_argc = 0; (_new_argv[_argc] = argv[_argc]); _argc++)    \
+       ;                                                           \
+                                                                   \
+     _new_argv;                                                    \
+  })                                                               \
+)
+
+
+#define PIPE_STDIN   0
+#define PIPE_STDOUT  1
+
+#define PIPE_END_FILE_NAME_PATTERN  "gtXXXXXX"
+
+
+char tmp_file_name[2][L_tmpnam];  /*  0: pipe stdin, 1: pipe stdout.  */
+
+
+#define remove_tmp_file(name)                                                \
+(__gnuc_extension__                                                          \
+  ({                                                                         \
+     if ((name))                                                             \
+     {                                                                       \
+       if (unlink((name)))                                                   \
+         error(exit_on_error ? EXIT_FAILURE : 0, errno,                      \
+               _("removing of `%s' failed"), (name));                        \
+     }                                                                       \
+     else                                                                    \
+     {                                                                       \
+       if (tmp_file_name[PIPE_STDIN][0])                                     \
+       {                                                                     \
+         if (unlink(tmp_file_name[PIPE_STDIN]))                              \
+           error(exit_on_error ? EXIT_FAILURE : 0, errno,                    \
+                 _("removing of `%s' failed"), tmp_file_name[PIPE_STDIN]);   \
+       }                                                                     \
+       if (tmp_file_name[PIPE_STDOUT][0])                                    \
+       {                                                                     \
+         if (unlink(tmp_file_name[PIPE_STDOUT]))                             \
+           error(exit_on_error ? EXIT_FAILURE : 0, errno,                    \
+                 _("removing of `%s' failed"), tmp_file_name[PIPE_STDOUT]);  \
+       }                                                                     \
+     }                                                                       \
+  })                                                                         \
+)
+
+
+/* Duplicates a file handle, making the copy uninheritable.
+   Returns -1 for a file handle that is equivalent to closed.  */
+static int
+dup_noinherit(int fd)
+{
+  fd = dup_cloexec(fd);
+  if (fd < 0 && errno == EMFILE)
+    error(EXIT_FAILURE, errno, _("fcntl failed"));
+
+  return fd;
+}
+
+/* Returns a file descriptor equivalent to FD, except that the resulting file
+   descriptor is none of STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO.
+   FD must be open and non-inheritable.  The result will be non-inheritable as
+   well.
+   If FD < 0, FD itself is returned.  */
+static int
+fd_safer_noinherit(int fd)
+{
+  if (STDIN_FILENO <= fd && fd <= STDERR_FILENO)
+  {
+    /* The recursion depth is at most 3.  */
+    int nfd = fd_safer_noinherit(dup_noinherit(fd));
+    int saved_errno = errno;
+    close(fd);
+    errno = saved_errno;
+    return nfd;
+  }
+  return fd;
+}
+
+/* Duplicates a file handle, making the copy uninheritable and ensuring the
+   result is none of STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO.
+   Returns -1 for a file handle that is equivalent to closed.  */
+static int
+dup_safer_noinherit(int fd)
+{
+  return fd_safer_noinherit(dup_noinherit(fd));
+}
+
+/* Undoes the effect of TEMPFD = dup_safer_noinherit (ORIGFD);  */
+static void
+undup_safer_noinherit(int tempfd, int origfd)
+{
+  if (tempfd >= 0)
+  {
+    if (dup2(tempfd, origfd) < 0)
+      error(EXIT_FAILURE, errno, _("cannot restore fd %d: dup2 failed"), origfd);
+    close(tempfd);
+  }
+  else
+  {
+    /* origfd was closed or open to no handle at all.  Set it to a closed
+       state.  This is (nearly) equivalent to the original state.  */
+    close(origfd);
+  }
+}
+
+#ifdef _SPAWN_PIPE_H
+static int
+djgpp_pipe(int pipe_fd[2], int pipe_end)
+{
+  int fd;
+
+  strcpy(tmp_file_name[pipe_end], "/dev/env/TMPDIR/"PIPE_END_FILE_NAME_PATTERN);
+  if ((fd = mkstemp(tmp_file_name[pipe_end])) < 0)
+  {
+    strcpy(tmp_file_name[pipe_end], "/dev/env/TMP/"PIPE_END_FILE_NAME_PATTERN);
+    if ((fd = mkstemp(tmp_file_name[pipe_end])) < 0)
+    {
+      strcpy(tmp_file_name[pipe_end], "/dev/env/TEMP/"PIPE_END_FILE_NAME_PATTERN);
+      if ((fd = mkstemp(tmp_file_name[pipe_end])) < 0)
+        return -1;
+    }
+  }
+
+  if (pipe_end == PIPE_STDIN)
+  {
+    pipe_fd[PIPE_STDIN] = fd;
+    pipe_fd[PIPE_STDOUT] = -1;
+    tmp_file_name[PIPE_STDOUT][0] = '\0';
+  }
+  else if (pipe_end == PIPE_STDOUT)
+  {
+    pipe_fd[PIPE_STDOUT] = fd;
+    pipe_fd[PIPE_STDIN] = -1;
+    tmp_file_name[PIPE_STDIN][0] = '\0';
+  }
+
+  return 0;
+}
+#endif
diff -aprNU5 gettext-0.19.8.1.orig/gettext-tools/gnulib-lib/execute.c gettext-0.19.8.1/gettext-tools/gnulib-lib/execute.c
--- gettext-0.19.8.1.orig/gettext-tools/gnulib-lib/execute.c	2016-05-30 02:52:46 +0000
+++ gettext-0.19.8.1/gettext-tools/gnulib-lib/execute.c	2018-01-29 09:54:02 +0000
@@ -39,10 +39,16 @@
 
 /* Native Windows API.  */
 # include <process.h>
 # include "w32spawn.h"
 
+#elif defined __DJGPP__
+
+/* DJGPP API.  */
+# include <process.h>
+# include "djgpp-spawn.h"
+
 #else
 
 /* Unix API.  */
 # include <spawn.h>
 
@@ -170,10 +176,96 @@ execute (const char *progname,
     }
   if (nulloutfd >= 0)
     close (nulloutfd);
   if (nullinfd >= 0)
     close (nullinfd);
+
+  /* Restore standard file handles of parent process.  */
+  if (null_stderr)
+    undup_safer_noinherit (orig_stderr, STDERR_FILENO);
+  if (null_stdout)
+    undup_safer_noinherit (orig_stdout, STDOUT_FILENO);
+  if (null_stdin)
+    undup_safer_noinherit (orig_stdin, STDIN_FILENO);
+
+  if (termsigp != NULL)
+    *termsigp = 0;
+
+  if (exitcode == -1)
+    {
+      if (exit_on_error || !null_stderr)
+        error (exit_on_error ? EXIT_FAILURE : 0, errno,
+               _("%s subprocess failed"), progname);
+      return 127;
+    }
+
+  return exitcode;
+
+#elif defined __DJGPP__
+
+  int orig_stdin;
+  int orig_stdout;
+  int orig_stderr;
+  int exitcode;
+  int nullinfd;
+  int nulloutfd;
+
+  /* Add an element upfront that can be used when argv[0] turns out to be a
+     script, not a program.  */
+  char **new_prog_argv = prepare_spawn (prog_argv);
+
+  /* Save standard file handles of parent process.  */
+ if (null_stdin)
+    orig_stdin = dup_safer_noinherit (STDIN_FILENO);
+  if (null_stdout)
+    orig_stdout = dup_safer_noinherit (STDOUT_FILENO);
+  if (null_stderr)
+    orig_stderr = dup_safer_noinherit (STDERR_FILENO);
+  exitcode = -1;
+
+  /* Create standard file handles of child process.  */
+  nullinfd = -1;
+  nulloutfd = -1;
+  if ((!null_stdin
+       || ((nullinfd = open ("/dev/null", O_RDONLY | O_BINARY, 0)) >= 0
+           && (nullinfd == STDIN_FILENO
+               || (dup2 (nullinfd, STDIN_FILENO) >= 0
+                   && close (nullinfd) >= 0))))
+      && (!(null_stdout || null_stderr)
+          || ((nulloutfd = open ("/dev/null", O_RDWR | O_BINARY, 0)) >= 0
+              && (!null_stdout
+                  || nulloutfd == STDOUT_FILENO
+                  || dup2 (nulloutfd, STDOUT_FILENO) >= 0)
+              && (!null_stderr
+                  || nulloutfd == STDERR_FILENO
+                  || dup2 (nulloutfd, STDERR_FILENO) >= 0)
+              && ((null_stdout && nulloutfd == STDOUT_FILENO)
+                  || (null_stderr && nulloutfd == STDERR_FILENO)
+                  || close (nulloutfd) >= 0))))
+    /* Use spawnvpe and pass the environment explicitly.  This is needed if
+       the program has modified the environment using putenv() or [un]setenv().
+       On Windows, programs have two environments, one in the "environment
+       block" of the process and managed through SetEnvironmentVariable(), and
+       one inside the process, in the location retrieved by the 'environ'
+       macro.  When using spawnvp() without 'e', the child process inherits a
+       copy of the environment block - ignoring the effects of putenv() and
+       [un]setenv().  */
+    {
+      exitcode = spawnvpe (P_WAIT, prog_path, new_prog_argv, environ);
+      if (--new_prog_argv, exitcode < 0 && errno == ENOEXEC)
+        {
+          /* prog is not an native executable.  Try to execute it as a
+             shell script.  Note that prepare_spawn() has already prepended
+             a hidden element "/dev/env/DJDIR/bin/sh" to new_prog_argv.  */
+          exitcode = spawnvpe (P_WAIT, new_prog_argv[0], new_prog_argv, environ);
+        }
+      free (new_prog_argv);
+    }
+  if (nulloutfd >= 0)
+    close (nulloutfd);
+  if (nullinfd >= 0)
+    close (nullinfd);
 
   /* Restore standard file handles of parent process.  */
   if (null_stderr)
     undup_safer_noinherit (orig_stderr, STDERR_FILENO);
   if (null_stdout)
diff -aprNU5 gettext-0.19.8.1.orig/gettext-tools/gnulib-lib/libxml/libxml.h gettext-0.19.8.1/gettext-tools/gnulib-lib/libxml/libxml.h
--- gettext-0.19.8.1.orig/gettext-tools/gnulib-lib/libxml/libxml.h	2015-12-10 21:01:14 +0000
+++ gettext-0.19.8.1/gettext-tools/gnulib-lib/libxml/libxml.h	2018-01-29 09:55:36 +0000
@@ -104,9 +104,9 @@ int xmlNop(void);
 #endif
 #endif
 #endif
 #endif
 #endif
-#if !defined(PIC) && !defined(NOLIBTOOL)
+#if !defined(PIC) && !defined(NOLIBTOOL) && !defined(LIBXML_STATIC)
 #  define LIBXML_STATIC
 #endif
 #endif /* ! __XML_LIBXML_H__ */
diff -aprNU5 gettext-0.19.8.1.orig/gettext-tools/gnulib-lib/libxml/nanohttp.c gettext-0.19.8.1/gettext-tools/gnulib-lib/libxml/nanohttp.c
--- gettext-0.19.8.1.orig/gettext-tools/gnulib-lib/libxml/nanohttp.c	2015-12-10 21:01:14 +0000
+++ gettext-0.19.8.1/gettext-tools/gnulib-lib/libxml/nanohttp.c	2018-01-29 09:54:02 +0000
@@ -97,11 +97,13 @@
  */
 #ifndef _WINSOCKAPI_
 #if !defined(__BEOS__) || defined(__HAIKU__)
 #define closesocket(s) close(s)
 #endif
+#ifndef SOCKET
 #define SOCKET int
+#endif
 #define INVALID_SOCKET (-1)
 #endif
 
 #ifdef __BEOS__
 #ifndef PF_INET
diff -aprNU5 gettext-0.19.8.1.orig/gettext-tools/gnulib-lib/libxml/xmlIO.c gettext-0.19.8.1/gettext-tools/gnulib-lib/libxml/xmlIO.c
--- gettext-0.19.8.1.orig/gettext-tools/gnulib-lib/libxml/xmlIO.c	2015-12-10 21:01:14 +0000
+++ gettext-0.19.8.1/gettext-tools/gnulib-lib/libxml/xmlIO.c	2018-01-29 09:54:02 +0000
@@ -210,10 +210,17 @@ static const char *IOerr[] = {
     "adddress in use",		/* EADDRINUSE */
     "already in use",		/* EALREADY */
     "unknown address familly",	/* EAFNOSUPPORT */
 };
 
+#if defined (__DJGPP__)
+/*  I/O function that expect UTF-8 strings as arguments are not supported by DJGPP.  */
+# define _wfopen(filename, mode)  (NULL)
+# define _wopen(filename, omode)  (-1)
+# define _wstat(path, buffer)     (-1)
+#endif
+
 #if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
 /**
  * __xmlIOWin32UTF8ToWChar:
  * @u8String:  uft-8 string
  *
@@ -222,10 +229,11 @@ static const char *IOerr[] = {
 static wchar_t *
 __xmlIOWin32UTF8ToWChar(const char *u8String)
 {
     wchar_t *wString = NULL;
 
+#if !defined (__DJGPP__)
     if (u8String) {
         int wLen =
             MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, u8String,
                                 -1, NULL, 0);
         if (wLen) {
@@ -237,10 +245,11 @@ __xmlIOWin32UTF8ToWChar(const char *u8St
                     wString = NULL;
                 }
             }
         }
     }
+#endif
 
     return wString;
 }
 #endif
 
@@ -724,10 +733,11 @@ static xmlWrapGzOpenFunc xmlWrapGzOpen =
  */
 static void
 xmlInitPlatformSpecificIo(void)
 {
     static int xmlPlatformIoInitialized = 0;
+#if !defined (__DJGPP__)
     OSVERSIONINFO osvi;
 
     if(xmlPlatformIoInitialized)
       return;
 
@@ -737,11 +747,13 @@ xmlInitPlatformSpecificIo(void)
       xmlWrapStat = xmlWrapStatUtf8;
       xmlWrapOpen = xmlWrapOpenUtf8;
 #ifdef HAVE_ZLIB_H
       xmlWrapGzOpen = xmlWrapGzOpenUtf8;
 #endif
-    } else {
+    } else
+#endif  /* !__DJGPP__ */
+    {
       xmlWrapStat = xmlWrapStatNative;
       xmlWrapOpen = xmlWrapOpenNative;
 #ifdef HAVE_ZLIB_H
       xmlWrapGzOpen = gzopen;
 #endif
diff -aprNU5 gettext-0.19.8.1.orig/gettext-tools/gnulib-lib/progname.c gettext-0.19.8.1/gettext-tools/gnulib-lib/progname.c
--- gettext-0.19.8.1.orig/gettext-tools/gnulib-lib/progname.c	2016-05-30 02:52:48 +0000
+++ gettext-0.19.8.1/gettext-tools/gnulib-lib/progname.c	2018-01-29 09:54:02 +0000
@@ -25,10 +25,44 @@
 #include <errno.h> /* get program_invocation_name declaration */
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
+/* MS-DOS and similar non-Posix systems have some peculiarities:
+    - they use both `/' and `\\' as directory separator in file names;
+    - they can have a drive letter X: prepended to a file name;
+   These are all parameterized here.  */
+
+#ifdef MSDOS
+# if defined (__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
+#  define __gnuc_extension__  __extension__
+# else
+#  define __gnuc_extension__
+# endif
+# include <libc/unconst.h>
+# undef  IS_SLASH
+# define IS_SLASH(c)  ((c) == '/' || (c) == '\\' || (c) == ':')
+# define GET_LAST_SLASH(filename)              \
+  (__gnuc_extension__                          \
+    ({                                         \
+      char *_slash = NULL;                     \
+      if ((filename))                          \
+      {                                        \
+        _slash = unconst((filename), char *);  \
+        while (*_slash++)                      \
+          ;                                    \
+        while ((--_slash - (filename)))        \
+          if (IS_SLASH(*_slash))               \
+            break;                             \
+      }                                        \
+      _slash;                                  \
+    })                                         \
+  )
+#else
+# define GET_LAST_SLASH(filename)  (strrchr((filename), '/'))
+#endif
+
 
 /* String containing name the program is called with.
    To be initialized by main().  */
 const char *program_name = NULL;
 
@@ -54,13 +88,21 @@ set_program_name (const char *argv0)
       fputs ("A NULL argv[0] was passed through an exec system call.\n",
              stderr);
       abort ();
     }
 
-  slash = strrchr (argv0, '/');
+  slash = GET_LAST_SLASH (argv0);
   base = (slash != NULL ? slash + 1 : argv0);
-  if (base - argv0 >= 7 && strncmp (base - 7, "/.libs/", 7) == 0)
+  if (base - argv0 >= 7 && (strncmp (base - 7, "/.libs/", 7) == 0
+#ifdef MSDOS
+     || strncmp (base - 7, "\\.libs/", 7) == 0
+     || strncmp (base - 7, "\\.libs\\", 7) == 0
+     || strncmp (base - 7, "/_libs/", 7) == 0
+     || strncmp (base - 7, "\\_libs/", 7) == 0
+     || strncmp (base - 7, "\\_libs\\", 7) == 0
+#endif
+     ))
     {
       argv0 = base;
       if (strncmp (base, "lt-", 3) == 0)
         {
           argv0 = base + 3;
diff -aprNU5 gettext-0.19.8.1.orig/gettext-tools/gnulib-lib/spawn-pipe.c gettext-0.19.8.1/gettext-tools/gnulib-lib/spawn-pipe.c
--- gettext-0.19.8.1.orig/gettext-tools/gnulib-lib/spawn-pipe.c	2016-05-30 02:52:48 +0000
+++ gettext-0.19.8.1/gettext-tools/gnulib-lib/spawn-pipe.c	2018-01-29 09:54:02 +0000
@@ -40,10 +40,16 @@
 
 /* Native Windows API.  */
 # include <process.h>
 # include "w32spawn.h"
 
+#elif defined __DJGPP__
+
+/* DJGPP API.  */
+# include <process.h>
+# include "djgpp-spawn.h"
+
 #else
 
 /* Unix API.  */
 # include <spawn.h>
 
@@ -248,10 +254,135 @@ create_pipe (const char *progname,
     fd[0] = ifd[0];
   if (pipe_stdin)
     fd[1] = ofd[1];
   return child;
 
+#elif defined  __DJGPP__
+
+  /* DJGPP API.  */
+  int ifd[2];
+  int ofd[2];
+  int orig_stdin;
+  int orig_stdout;
+  int orig_stderr;
+  int child;
+  int nulloutfd;
+  int stdinfd;
+  int stdoutfd;
+  int saved_errno;
+
+  /* Add an element upfront that can be used when argv[0] turns out to be a
+     script, not a program.  */
+  char **new_prog_argv = prepare_spawn (prog_argv);
+
+  if (pipe_stdout)
+    if (djgpp_pipe (ifd, PIPE_STDOUT) < 0)
+      error (EXIT_FAILURE, errno, _("cannot create pipe"));
+  if (pipe_stdin)
+    if (djgpp_pipe (ofd, PIPE_STDIN) < 0)
+      error (EXIT_FAILURE, errno, _("cannot create pipe"));
+/* Data flow diagram:
+ *
+ *           write        system         read
+ *    parent  ->   ofd[1]   ->   ofd[0]   ->   child       if pipe_stdin
+ *    parent  <-   ifd[0]   <-   ifd[1]   <-   child       if pipe_stdout
+ *           read         system         write
+ *
+ */
+
+  /* Save standard file handles of parent process.  */
+  if (pipe_stdin || prog_stdin != NULL)
+    orig_stdin = dup_safer_noinherit (STDIN_FILENO);
+  if (pipe_stdout || prog_stdout != NULL)
+    orig_stdout = dup_safer_noinherit (STDOUT_FILENO);
+  if (null_stderr)
+    orig_stderr = dup_safer_noinherit (STDERR_FILENO);
+  child = -1;
+
+  /* Create standard file handles of child process.  */
+  nulloutfd = -1;
+  stdinfd = -1;
+  stdoutfd = -1;
+  if ((!pipe_stdin || dup2 (ofd[0], STDIN_FILENO) >= 0)
+      && (!pipe_stdout || dup2 (ifd[1], STDOUT_FILENO) >= 0)
+      && (!null_stderr
+	  || ((nulloutfd = open ("/dev/null", O_RDWR, 0)) >= 0
+	      && (nulloutfd == STDERR_FILENO
+		  || (dup2 (nulloutfd, STDERR_FILENO) >= 0
+		      && close (nulloutfd) >= 0))))
+      && (pipe_stdin
+	  || prog_stdin == NULL
+	  || ((stdinfd = open (prog_stdin, O_RDONLY, 0)) >= 0
+	      && (stdinfd == STDIN_FILENO
+		  || (dup2 (stdinfd, STDIN_FILENO) >= 0
+		      && close (stdinfd) >= 0))))
+      && (pipe_stdout
+	  || prog_stdout == NULL
+	  || ((stdoutfd = open (prog_stdout, O_WRONLY, 0)) >= 0
+	      && (stdoutfd == STDOUT_FILENO
+		  || (dup2 (stdoutfd, STDOUT_FILENO) >= 0
+		      && close (stdoutfd) >= 0)))))
+    /* The child process doesn't inherit ifd[0], ifd[1], ofd[0], ofd[1],
+       but it inherits all open()ed or dup2()ed file handles (which is what
+       we want in the case of STD*_FILENO) and also orig_stdin,
+       orig_stdout, orig_stderr (which is not explicitly wanted but
+       harmless).  */
+    /* Use spawnvpe and pass the environment explicitly.  This is needed if
+       the program has modified the environment using putenv() or [un]setenv().
+       On Windows, programs have two environments, one in the "environment
+       block" of the process and managed through SetEnvironmentVariable(), and
+       one inside the process, in the location retrieved by the 'environ'
+       macro.  When using spawnvp() without 'e', the child process inherits a
+       copy of the environment block - ignoring the effects of putenv() and
+       [un]setenv().  */
+    {
+      child = spawnvpe (P_WAIT, prog_path, prog_argv, environ);
+      if (child < 0 && errno == ENOEXEC)
+	{
+	  /* prog is not an native executable.  Try to execute it as a
+	     shell script.  Note that prepare_spawn() has already prepended
+	     a hidden element "sh.exe" to prog_argv.  */
+	  --prog_argv;
+	  child = spawnvpe (P_WAIT, prog_argv[0], prog_argv, environ);
+	}
+    }
+  if (child == -1)
+    saved_errno = errno;
+  if (stdinfd >= 0)
+    close (stdinfd);
+  if (stdoutfd >= 0)
+    close (stdoutfd);
+  if (nulloutfd >= 0)
+    close (nulloutfd);
+
+  /* Restore standard file handles of parent process.  */
+  if (null_stderr)
+    dup2 (orig_stderr, STDERR_FILENO), close (orig_stderr);
+  if (pipe_stdout || prog_stdout != NULL)
+    dup2 (orig_stdout, STDOUT_FILENO), close (orig_stdout);
+  if (pipe_stdin || prog_stdin != NULL)
+    dup2 (orig_stdin, STDIN_FILENO), close (orig_stdin);
+
+  if (pipe_stdin)
+    close (ofd[0]);
+  if (pipe_stdout)
+    close (ifd[1]);
+  if (child == -1)
+    {
+      if (exit_on_error || !null_stderr)
+	error (exit_on_error ? EXIT_FAILURE : 0, errno,
+	       _("%s subprocess failed"), progname);
+      errno = saved_errno;
+      return -1;
+    }
+
+  if (pipe_stdout)
+    fd[0] = open (tmp_file_name[PIPE_STDOUT], O_RDONLY, S_IRUSR);
+  if (pipe_stdin)
+    fd[1] = open (tmp_file_name[PIPE_STDIN], O_WRONLY | O_CREAT | O_TRUNC, S_IWUSR);
+  return child;
+
 #else
 
   /* Unix API.  */
   int ifd[2];
   int ofd[2];
diff -aprNU5 gettext-0.19.8.1.orig/gettext-tools/gnulib-lib/spawni.c gettext-0.19.8.1/gettext-tools/gnulib-lib/spawni.c
--- gettext-0.19.8.1.orig/gettext-tools/gnulib-lib/spawni.c	2016-05-30 02:52:50 +0000
+++ gettext-0.19.8.1/gettext-tools/gnulib-lib/spawni.c	2018-01-29 09:54:02 +0000
@@ -38,10 +38,17 @@
 #include <signal.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
+#ifdef __DJGPP__
+/*  Provide DJGPP specific prototypes of setresgid and setresuid.
+    These are placebos and do nothing but are required for porting.  */
+int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
+int setresuid(uid_t ruid, uid_t euid, uid_t suid);
+#endif
+
 #if _LIBC
 # include <not-cancel.h>
 #else
 # define close_not_cancel close
 # define open_not_cancel open
@@ -100,10 +107,23 @@ __spawni (pid_t *pid, const char *file,
 {
   /* Not yet implemented.  */
   return ENOSYS;
 }
 
+#elif defined __DJGPP__
+
+/* MSDOS/DJGPP API.  */
+int
+__spawni (pid_t *pid, const char *file,
+	  const posix_spawn_file_actions_t *file_actions,
+	  const posix_spawnattr_t *attrp, char *const argv[],
+	  char *const envp[], int use_path)
+{
+  /* Not yet implemented.  */
+  return ENOSYS;
+}
+
 #else
 
 
 /* The file is accessible but it is not an executable file.  Invoke
    the shell to interpret it as a script.  */
diff -aprNU5 gettext-0.19.8.1.orig/gettext-tools/gnulib-lib/tempname.c gettext-0.19.8.1/gettext-tools/gnulib-lib/tempname.c
--- gettext-0.19.8.1.orig/gettext-tools/gnulib-lib/tempname.c	2016-05-30 02:52:50 +0000
+++ gettext-0.19.8.1/gettext-tools/gnulib-lib/tempname.c	2018-01-29 09:54:02 +0000
@@ -28,10 +28,16 @@
 #include <errno.h>
 #ifndef __set_errno
 # define __set_errno(Val) errno = (Val)
 #endif
 
+#ifdef MSDOS
+# define HAVE_DIFFERENT_TMPDIR  1
+#else
+# define HAVE_DIFFERENT_TMPDIR  0
+#endif
+
 #include <stdio.h>
 #ifndef P_tmpdir
 # define P_tmpdir "/tmp"
 #endif
 #ifndef TMP_MAX
@@ -137,30 +143,41 @@ __path_search (char *tmpl, size_t tmpl_l
   if (try_tmpdir)
     {
       d = __secure_getenv ("TMPDIR");
       if (d != NULL && direxists (d))
         dir = d;
+#if HAVE_DIFFERENT_TMPDIR
+      else if ((d = __secure_getenv ("TMP")) && direxists (d))
+	dir = d;
+      else if ((d = __secure_getenv ("TEMP")) && direxists (d))
+	dir = d;
+#endif
       else if (dir != NULL && direxists (dir))
         /* nothing */ ;
       else
         dir = NULL;
     }
   if (dir == NULL)
     {
       if (direxists (P_tmpdir))
         dir = P_tmpdir;
+#if !HAVE_DIFFERENT_TMPDIR
       else if (strcmp (P_tmpdir, "/tmp") != 0 && direxists ("/tmp"))
         dir = "/tmp";
+#else
+      else if (strcmp (P_tmpdir, ".") != 0 && direxists ("."))
+	dir = "./";
+#endif
       else
         {
           __set_errno (ENOENT);
           return -1;
         }
     }
 
   dlen = strlen (dir);
-  while (dlen > 1 && dir[dlen - 1] == '/')
+  while (dlen > 1 && ISSLASH (dir[dlen - 1]))
     dlen--;                     /* remove trailing slashes */
 
   /* check we have room for "${dir}/${pfx}XXXXXX\0" */
   if (tmpl_len < dlen + 1 + plen + 6 + 1)
     {
diff -aprNU5 gettext-0.19.8.1.orig/gettext-tools/gnulib-lib/wait-process.c gettext-0.19.8.1/gettext-tools/gnulib-lib/wait-process.c
--- gettext-0.19.8.1.orig/gettext-tools/gnulib-lib/wait-process.c	2016-05-30 02:52:50 +0000
+++ gettext-0.19.8.1/gettext-tools/gnulib-lib/wait-process.c	2018-01-29 09:54:04 +0000
@@ -46,10 +46,14 @@
 
 /* The return value of spawnvp() is really a process handle as returned
    by CreateProcess().  Therefore we can kill it using TerminateProcess.  */
 #define kill(pid,sig) TerminateProcess ((HANDLE) (pid), sig)
 
+#elif defined __DJGPP__
+
+# include "djgpp-spawn.h"
+
 #endif
 
 
 /* Type of an entry in the slaves array.
    The 'used' bit determines whether this entry is currently in use.
@@ -291,10 +295,25 @@ wait_subprocess (pid_t child, const char
   int status;
 
   if (termsigp != NULL)
     *termsigp = 0;
   status = 0;
+# ifdef __DJGPP__
+  /* Child process already finished.  */
+
+  remove_tmp_file(NULL);
+  if (child == -1)
+    {
+      if (exit_on_error || !null_stderr)
+        error (exit_on_error ? EXIT_FAILURE : 0, errno,
+               _("%s subprocess failed"), progname);
+      return 127;
+    }
+
+  return WEXITSTATUS (child);
+
+# else
   for (;;)
     {
       int result = waitpid (child, &status, 0);
 
       if (result != child)
@@ -355,7 +374,8 @@ wait_subprocess (pid_t child, const char
         error (exit_on_error ? EXIT_FAILURE : 0, 0,
                _("%s subprocess failed"), progname);
       return 127;
     }
   return WEXITSTATUS (status);
+# endif
 #endif
 }
diff -aprNU5 gettext-0.19.8.1.orig/gettext-tools/libgettextpo/progname.c gettext-0.19.8.1/gettext-tools/libgettextpo/progname.c
--- gettext-0.19.8.1.orig/gettext-tools/libgettextpo/progname.c	2016-05-30 02:53:22 +0000
+++ gettext-0.19.8.1/gettext-tools/libgettextpo/progname.c	2018-01-29 09:54:04 +0000
@@ -25,10 +25,44 @@
 #include <errno.h> /* get program_invocation_name declaration */
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
+/* MS-DOS and similar non-Posix systems have some peculiarities:
+    - they use both `/' and `\\' as directory separator in file names;
+    - they can have a drive letter X: prepended to a file name;
+   These are all parameterized here.  */
+
+#ifdef MSDOS
+# if defined (__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
+#  define __gnuc_extension__  __extension__
+# else
+#  define __gnuc_extension__
+# endif
+# include <libc/unconst.h>
+# undef  IS_SLASH
+# define IS_SLASH(c)  ((c) == '/' || (c) == '\\' || (c) == ':')
+# define GET_LAST_SLASH(filename)              \
+  (__gnuc_extension__                          \
+    ({                                         \
+      char *_slash = NULL;                     \
+      if ((filename))                          \
+      {                                        \
+        _slash = unconst((filename), char *);  \
+        while (*_slash++)                      \
+          ;                                    \
+        while ((--_slash - (filename)))        \
+          if (IS_SLASH(*_slash))               \
+            break;                             \
+      }                                        \
+      _slash;                                  \
+    })                                         \
+  )
+#else
+# define GET_LAST_SLASH(filename)  (strrchr((filename), '/'))
+#endif
+
 
 /* String containing name the program is called with.
    To be initialized by main().  */
 const char *program_name = NULL;
 
@@ -54,13 +88,21 @@ set_program_name (const char *argv0)
       fputs ("A NULL argv[0] was passed through an exec system call.\n",
              stderr);
       abort ();
     }
 
-  slash = strrchr (argv0, '/');
+  slash = GET_LAST_SLASH (argv0);
   base = (slash != NULL ? slash + 1 : argv0);
-  if (base - argv0 >= 7 && strncmp (base - 7, "/.libs/", 7) == 0)
+  if (base - argv0 >= 7 && (strncmp (base - 7, "/.libs/", 7) == 0
+#ifdef MSDOS
+     || strncmp (base - 7, "\\.libs/", 7) == 0
+     || strncmp (base - 7, "\\.libs\\", 7) == 0
+     || strncmp (base - 7, "/_libs/", 7) == 0
+     || strncmp (base - 7, "\\_libs/", 7) == 0
+     || strncmp (base - 7, "\\_libs\\", 7) == 0
+#endif
+     ))
     {
       argv0 = base;
       if (strncmp (base, "lt-", 3) == 0)
         {
           argv0 = base + 3;
diff -aprNU5 gettext-0.19.8.1.orig/gettext-tools/misc/autopoint.in gettext-0.19.8.1/gettext-tools/misc/autopoint.in
--- gettext-0.19.8.1.orig/gettext-tools/misc/autopoint.in	2016-05-28 12:48:48 +0000
+++ gettext-0.19.8.1/gettext-tools/misc/autopoint.in	2018-01-29 09:54:04 +0000
@@ -39,11 +39,11 @@ datarootdir="@datarootdir@"
 func_tmpdir ()
 {
   # Use the environment variable TMPDIR, falling back to /tmp. This allows
   # users to specify a different temporary directory, for example, if their
   # /tmp is filled up or too small.
-  : ${TMPDIR=/tmp}
+  : ${TMPDIR=${TMP=${TEMP=.}}}
   {
     # Use the mktemp program if available. If not available, hide the error
     # message.
     tmp=`(umask 077 && mktemp -d "$TMPDIR/gtXXXXXX") 2>/dev/null` &&
     test -n "$tmp" && test -d "$tmp"
diff -aprNU5 gettext-0.19.8.1.orig/gettext-tools/misc/gettextize.in gettext-0.19.8.1/gettext-tools/misc/gettextize.in
--- gettext-0.19.8.1.orig/gettext-tools/misc/gettextize.in	2016-03-07 21:30:40 +0000
+++ gettext-0.19.8.1/gettext-tools/misc/gettextize.in	2018-01-29 09:54:04 +0000
@@ -39,11 +39,11 @@ datarootdir="@datarootdir@"
 func_tmpdir ()
 {
   # Use the environment variable TMPDIR, falling back to /tmp. This allows
   # users to specify a different temporary directory, for example, if their
   # /tmp is filled up or too small.
-  : ${TMPDIR=/tmp}
+  : ${TMPDIR=${TMP=${TEMP=.}}}
   {
     # Use the mktemp program if available. If not available, hide the error
     # message.
     tmp=`(umask 077 && mktemp -d "$TMPDIR/gtXXXXXX") 2>/dev/null` &&
     test -n "$tmp" && test -d "$tmp"
diff -aprNU5 gettext-0.19.8.1.orig/gnulib-local/lib/libxml/libxml.h gettext-0.19.8.1/gnulib-local/lib/libxml/libxml.h
--- gettext-0.19.8.1.orig/gnulib-local/lib/libxml/libxml.h	2015-12-10 21:01:14 +0000
+++ gettext-0.19.8.1/gnulib-local/lib/libxml/libxml.h	2018-01-29 09:55:36 +0000
@@ -104,9 +104,9 @@ int xmlNop(void);
 #endif
 #endif
 #endif
 #endif
 #endif
-#if !defined(PIC) && !defined(NOLIBTOOL)
+#if !defined(PIC) && !defined(NOLIBTOOL) && !defined(LIBXML_STATIC)
 #  define LIBXML_STATIC
 #endif
 #endif /* ! __XML_LIBXML_H__ */
diff -aprNU5 gettext-0.19.8.1.orig/gnulib-local/lib/libxml/nanohttp.c gettext-0.19.8.1/gnulib-local/lib/libxml/nanohttp.c
--- gettext-0.19.8.1.orig/gnulib-local/lib/libxml/nanohttp.c	2015-12-10 21:01:14 +0000
+++ gettext-0.19.8.1/gnulib-local/lib/libxml/nanohttp.c	2018-01-29 09:54:04 +0000
@@ -97,11 +97,13 @@
  */
 #ifndef _WINSOCKAPI_
 #if !defined(__BEOS__) || defined(__HAIKU__)
 #define closesocket(s) close(s)
 #endif
+#ifndef SOCKET
 #define SOCKET int
+#endif
 #define INVALID_SOCKET (-1)
 #endif
 
 #ifdef __BEOS__
 #ifndef PF_INET
diff -aprNU5 gettext-0.19.8.1.orig/gnulib-local/lib/libxml/xmlIO.c gettext-0.19.8.1/gnulib-local/lib/libxml/xmlIO.c
--- gettext-0.19.8.1.orig/gnulib-local/lib/libxml/xmlIO.c	2015-12-10 21:01:14 +0000
+++ gettext-0.19.8.1/gnulib-local/lib/libxml/xmlIO.c	2018-01-29 09:54:04 +0000
@@ -210,10 +210,17 @@ static const char *IOerr[] = {
     "adddress in use",		/* EADDRINUSE */
     "already in use",		/* EALREADY */
     "unknown address familly",	/* EAFNOSUPPORT */
 };
 
+#if defined (__DJGPP__)
+/*  I/O function that expect UTF-8 strings as arguments are not supported by DJGPP.  */
+# define _wfopen(filename, mode)  (NULL)
+# define _wopen(filename, omode)  (-1)
+# define _wstat(path, buffer)     (-1)
+#endif
+
 #if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
 /**
  * __xmlIOWin32UTF8ToWChar:
  * @u8String:  uft-8 string
  *
@@ -222,10 +229,11 @@ static const char *IOerr[] = {
 static wchar_t *
 __xmlIOWin32UTF8ToWChar(const char *u8String)
 {
     wchar_t *wString = NULL;
 
+#if !defined (__DJGPP__)
     if (u8String) {
         int wLen =
             MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, u8String,
                                 -1, NULL, 0);
         if (wLen) {
@@ -237,10 +245,11 @@ __xmlIOWin32UTF8ToWChar(const char *u8St
                     wString = NULL;
                 }
             }
         }
     }
+#endif
 
     return wString;
 }
 #endif
 
@@ -724,10 +733,11 @@ static xmlWrapGzOpenFunc xmlWrapGzOpen =
  */
 static void
 xmlInitPlatformSpecificIo(void)
 {
     static int xmlPlatformIoInitialized = 0;
+#if !defined (__DJGPP__)
     OSVERSIONINFO osvi;
 
     if(xmlPlatformIoInitialized)
       return;
 
@@ -737,11 +747,13 @@ xmlInitPlatformSpecificIo(void)
       xmlWrapStat = xmlWrapStatUtf8;
       xmlWrapOpen = xmlWrapOpenUtf8;
 #ifdef HAVE_ZLIB_H
       xmlWrapGzOpen = xmlWrapGzOpenUtf8;
 #endif
-    } else {
+    } else
+#endif  /* !__DJGPP__ */
+    {
       xmlWrapStat = xmlWrapStatNative;
       xmlWrapOpen = xmlWrapOpenNative;
 #ifdef HAVE_ZLIB_H
       xmlWrapGzOpen = gzopen;
 #endif
