2014-02-02  Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* 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.


2014-01-18  Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* lib/fopen.c: If ISSLASH is not defined include dosname.h

	* lib/open.c: If ISSLASH is not defined include dosname.h


2013-11-03  Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* lib/spawn_pipe.c [__DJGPP__]: DJGPP specific implementation of create_pipe.

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

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


2013-11-02  Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* src/path.c (include_env_init): If FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX
	is defined check the enironment variable PATH_SEPARATOR to determiante
	the path separator character to be used.  For posix systems the default
	is colon, for DOS/DJGPP the default is semi colon.
	Use CANONICALIZE_PATH to replace DOS-style backslash directory separator
	to unix-style slash directory separtor.

	* src/output.c (make_room_for): Added SET_BINARY. On systems
	that distinguish between text and binary files, tmpfiles are
	opened in binary mode. For all others OS it is a no-op macro.
	Now the SET_BINARY macro is defined by gnulib in /lib/binary-io.h
	and expects a file descriptor as argument.

	* src/m4.h: Added FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX. This macro
	is used to define a serie of macros to parametrize OS specific issues
	like path separators, directory separators, drive letters, etc.
	New macro DOSISH to define a canonical recognition macro for
	MSDOS and DJGPP.  For DJGPP also define UNIX.
	New macro STRIP_FULL_PATH_AND_EXTENSION defined.  For all other systems
	this maccro is a no-op.

	* src/m4.c (usage) [__DJGPP__]: Add DJGPP specific info about M4PATH.
	(main): Use STRIP_FULL_PATH_AND_EXTENSION to strip path and extension
	from argv[0].

	* src/builtin.c: Add MSDOS and DJGPP to the supported platform macros
	list.
	(m4_syscmd, m4_esyscmd): For MSDOS allow command.com as shell as well.

	* lib/tmpdir.c: New macro HAVE_DIFFERENT_TMPDIR.  Value depends on
	if the OS is posix or not.
	(direxists): Use ISSLASH to check for the OS dependent directory
	separator character.  Use HAVE_DIFFERENT_TMPDIR to check for TMP and
	TEMP too, if none of them are defined or do not point to an existing
	directory default to the current directory.

	* lib/tempname.c: New macro HAVE_DIFFERENT_TMPDIR.  Value depends on
	if the OS is posix or not.
	(direxists): Use ISSLASH to check for the OS dependent directory
	separator character.  Use HAVE_DIFFERENT_TMPDIR to check for TMP and
	TEMP too, if none of them are defined or do not point to an existing
	directory default to the current directory.

	* 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.

	* lib/open.c (open): Use ISSLASH to check for the OS dependent
	directory separator character.

	* lib/mkstemp-safer.c [__DJGPP__]: Define macro __need_FILE so that
	libc's stdio.h is included and not the gnulib one that does not
	provide the mkstemp prototype.
	[__DJGPP__]: For djdev203 include <stdio.h> for mkstemp declaration.

	* lib/stdio-impl.h [__DJGPP__]: Include sys/file.h to provide _IOERR
	for fseterr function support.

	* lib/fopen.c (rpl_fopen): Use ISSLASH to check for the OS dependent
	directory separator character.

	* lib/fatal-signal.c [__DJGPP__]: New macro SIGNAL_INDEX used to
	adjust the signal numbers used by DJGPP to fit into the range of
	saved_sigactions.
	(uninstall_handlers): Use SIGNAL_INDEX to access saved_sigactions.
	(install_handlers): Use SIGNAL_INDEX to access saved_sigactions.

	* lib/execute.c [__DJGPP__]: DJGPP specific implementation of execute.

	* lib/djgpp-spawn.h: New file.

	* lib/cloexec.c (set_cloexec_flag) [!MSDOS]: On MSDOS/Windows
	systems always return success.

	* doc/m4.texinfo: Add DJGPP specific info about place where the tmp
	files are stored.
	Add (ENOENT) to error message.
	Add DJGPP specific info about supported M4PATH path separator characters.
	Adjust different tests to DJGPP peculiarities.


2010-09-01  Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* lib/fseeko.c [__DJGPP__]: Include libc/file.h for the definition
	of _IOERR so that SystemV derived implementations, defined in stdio-impl.h,
	are selected for DJGPP.

	* lib/freading.c [__DJGPP__]: Include libc/file.h for the definition
	of _IOERR so that SystemV derived implementations, defined in stdio-impl.h,
	are selected for DJGPP.

	* lib/freadahead.c [__DJGPP__]: Include libc/file.h for the definition
	of _IOERR so that SystemV derived implementations, defined in stdio-impl.h,
	are selected for DJGPP.











diff -aprNU5 gettext-0.18.3.2.orig/gettext-tools/gnulib-lib/djgpp-spawn.h gettext-0.18.3.2/gettext-tools/gnulib-lib/djgpp-spawn.h
--- gettext-0.18.3.2.orig/gettext-tools/gnulib-lib/djgpp-spawn.h	1970-01-01 01:00:00 +0100
+++ gettext-0.18.3.2/gettext-tools/gnulib-lib/djgpp-spawn.h	2014-01-28 23:32:36 +0100
@@ -0,0 +1,153 @@
+#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
+
+
+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/gtXXXXXX");
+  if ((fd = mkstemp(tmp_file_name[pipe_end])) < 0)
+  {
+    strcpy(tmp_file_name[pipe_end], "/dev/env/TMP/gtXXXXXX");
+    if ((fd = mkstemp(tmp_file_name[pipe_end])) < 0)
+    {
+      strcpy(tmp_file_name[pipe_end], "/dev/env/TEMP/gtXXXXXX");
+      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.18.3.2.orig/gettext-tools/gnulib-lib/execute.c gettext-0.18.3.2/gettext-tools/gnulib-lib/execute.c
--- gettext-0.18.3.2.orig/gettext-tools/gnulib-lib/execute.c	2014-01-07 06:15:36 +0100
+++ gettext-0.18.3.2/gettext-tools/gnulib-lib/execute.c	2014-01-28 21:13:40 +0100
@@ -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>
 
@@ -168,10 +174,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.18.3.2.orig/gettext-tools/gnulib-lib/libxml/nanohttp.c gettext-0.18.3.2/gettext-tools/gnulib-lib/libxml/nanohttp.c
--- gettext-0.18.3.2.orig/gettext-tools/gnulib-lib/libxml/nanohttp.c	2013-01-09 04:01:26 +0100
+++ gettext-0.18.3.2/gettext-tools/gnulib-lib/libxml/nanohttp.c	2014-01-13 22:42:30 +0100
@@ -97,12 +97,14 @@
  */
 #ifndef _WINSOCKAPI_
 #ifndef __BEOS__
 #define closesocket(s) close(s)
 #endif
+#ifndef SOCKET
 #define SOCKET int
 #endif
+#endif
 
 #ifdef __BEOS__
 #ifndef PF_INET
 #define PF_INET AF_INET
 #endif
diff -aprNU5 gettext-0.18.3.2.orig/gettext-tools/gnulib-lib/libxml/xmlIO.c gettext-0.18.3.2/gettext-tools/gnulib-lib/libxml/xmlIO.c
--- gettext-0.18.3.2.orig/gettext-tools/gnulib-lib/libxml/xmlIO.c	2013-01-09 04:01:26 +0100
+++ gettext-0.18.3.2/gettext-tools/gnulib-lib/libxml/xmlIO.c	2014-01-13 22:42:30 +0100
@@ -197,10 +197,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
  *
@@ -209,10 +216,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) {
@@ -224,10 +232,11 @@ __xmlIOWin32UTF8ToWChar(const char *u8St
                     wString = NULL;
                 }
             }
         }
     }
+#endif
 
     return wString;
 }
 #endif
 
@@ -680,21 +689,24 @@ static xmlWrapOpenFunc xmlWrapOpen = xml
  */
 static void
 xmlInitPlatformSpecificIo(void)
 {
     static int xmlPlatformIoInitialized = 0;
+#if !defined (__DJGPP__)
     OSVERSIONINFO osvi;
 
     if(xmlPlatformIoInitialized)
       return;
 
     osvi.dwOSVersionInfoSize = sizeof(osvi);
 
     if(GetVersionEx(&osvi) && (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)) {
       xmlWrapStat = xmlWrapStatUtf8;
       xmlWrapOpen = xmlWrapOpenUtf8;
-    } else {
+    } else
+#endif
+    {
       xmlWrapStat = xmlWrapStatNative;
       xmlWrapOpen = xmlWrapOpenNative;
     }
 
     xmlPlatformIoInitialized = 1;
diff -aprNU5 gettext-0.18.3.2.orig/gettext-tools/gnulib-lib/spawn-pipe.c gettext-0.18.3.2/gettext-tools/gnulib-lib/spawn-pipe.c
--- gettext-0.18.3.2.orig/gettext-tools/gnulib-lib/spawn-pipe.c	2014-01-07 06:15:40 +0100
+++ gettext-0.18.3.2/gettext-tools/gnulib-lib/spawn-pipe.c	2014-01-28 21:23:26 +0100
@@ -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>
 
@@ -244,10 +250,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.18.3.2.orig/gettext-tools/gnulib-lib/spawni.c gettext-0.18.3.2/gettext-tools/gnulib-lib/spawni.c
--- gettext-0.18.3.2.orig/gettext-tools/gnulib-lib/spawni.c	2014-01-07 06:15:40 +0100
+++ gettext-0.18.3.2/gettext-tools/gnulib-lib/spawni.c	2014-01-28 21:18:22 +0100
@@ -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.18.3.2.orig/gettext-tools/gnulib-lib/tempname.c gettext-0.18.3.2/gettext-tools/gnulib-lib/tempname.c
--- gettext-0.18.3.2.orig/gettext-tools/gnulib-lib/tempname.c	2014-01-07 06:15:40 +0100
+++ gettext-0.18.3.2/gettext-tools/gnulib-lib/tempname.c	2014-01-13 22:42:30 +0100
@@ -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
@@ -136,30 +142,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.18.3.2.orig/gettext-tools/gnulib-lib/wait-process.c gettext-0.18.3.2/gettext-tools/gnulib-lib/wait-process.c
--- gettext-0.18.3.2.orig/gettext-tools/gnulib-lib/wait-process.c	2014-01-07 06:15:40 +0100
+++ gettext-0.18.3.2/gettext-tools/gnulib-lib/wait-process.c	2014-01-28 23:48:24 +0100
@@ -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.18.3.2.orig/gettext-tools/misc/autopoint.in gettext-0.18.3.2/gettext-tools/misc/autopoint.in
--- gettext-0.18.3.2.orig/gettext-tools/misc/autopoint.in	2013-12-20 03:59:58 +0100
+++ gettext-0.18.3.2/gettext-tools/misc/autopoint.in	2014-02-02 16:32:18 +0100
@@ -37,11 +37,11 @@ gettext_dir="@datadir@/gettext"
 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.18.3.2.orig/gettext-tools/misc/gettextize.in gettext-0.18.3.2/gettext-tools/misc/gettextize.in
--- gettext-0.18.3.2.orig/gettext-tools/misc/gettextize.in	2013-12-20 03:59:58 +0100
+++ gettext-0.18.3.2/gettext-tools/misc/gettextize.in	2014-02-02 16:32:16 +0100
@@ -37,11 +37,11 @@ gettext_dir="@datadir@/gettext"
 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.18.3.2.orig/gnulib-local/lib/libxml/nanohttp.c gettext-0.18.3.2/gnulib-local/lib/libxml/nanohttp.c
--- gettext-0.18.3.2.orig/gnulib-local/lib/libxml/nanohttp.c	2013-01-09 04:01:26 +0100
+++ gettext-0.18.3.2/gnulib-local/lib/libxml/nanohttp.c	2014-01-13 22:42:30 +0100
@@ -97,12 +97,14 @@
  */
 #ifndef _WINSOCKAPI_
 #ifndef __BEOS__
 #define closesocket(s) close(s)
 #endif
+#ifndef SOCKET
 #define SOCKET int
 #endif
+#endif
 
 #ifdef __BEOS__
 #ifndef PF_INET
 #define PF_INET AF_INET
 #endif
diff -aprNU5 gettext-0.18.3.2.orig/gnulib-local/lib/libxml/xmlIO.c gettext-0.18.3.2/gnulib-local/lib/libxml/xmlIO.c
--- gettext-0.18.3.2.orig/gnulib-local/lib/libxml/xmlIO.c	2013-01-09 04:01:26 +0100
+++ gettext-0.18.3.2/gnulib-local/lib/libxml/xmlIO.c	2014-01-13 22:42:30 +0100
@@ -197,10 +197,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
  *
@@ -209,10 +216,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) {
@@ -224,10 +232,11 @@ __xmlIOWin32UTF8ToWChar(const char *u8St
                     wString = NULL;
                 }
             }
         }
     }
+#endif
 
     return wString;
 }
 #endif
 
@@ -680,21 +689,24 @@ static xmlWrapOpenFunc xmlWrapOpen = xml
  */
 static void
 xmlInitPlatformSpecificIo(void)
 {
     static int xmlPlatformIoInitialized = 0;
+#if !defined (__DJGPP__)
     OSVERSIONINFO osvi;
 
     if(xmlPlatformIoInitialized)
       return;
 
     osvi.dwOSVersionInfoSize = sizeof(osvi);
 
     if(GetVersionEx(&osvi) && (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)) {
       xmlWrapStat = xmlWrapStatUtf8;
       xmlWrapOpen = xmlWrapOpenUtf8;
-    } else {
+    } else
+#endif
+    {
       xmlWrapStat = xmlWrapStatNative;
       xmlWrapOpen = xmlWrapOpenNative;
     }
 
     xmlPlatformIoInitialized = 1;
