2005-01-29  Juan Manuel Guerrero  <juan.guerrero@igd.fhg.de>

	* djgpp/xp-config.bat: Use included popen.c file instead of the brocken
	popen() and pclose() function from djdev204 beta1 (2003-11-30).

	* djgpp/makefile.sed: The same reason.

	* djgpp/popen.c: From djdev204 cvs tree (2004-12-09).

	Files djgpp/xp-config.bat, djgpp/makefile.sed and djgpp/popen.c will
	be removed as soon as they are no longer needed.



diff -apruNU3 texinfo-4.8.orig/djgpp/makefile.sed texinfo-4.8/djgpp/makefile.sed
--- texinfo-4.8.orig/djgpp/makefile.sed	1970-01-01 00:00:00.000000000 +0000
+++ texinfo-4.8/djgpp/makefile.sed	2005-01-29 01:20:48.000000000 +0000
@@ -0,0 +1,7 @@
+# Additional editing of lib/Makefiles for DJGPP
+
+/^am_libtxi_a_OBJECTS[ 	]=/ s,= ,= popen.$(OBJEXT) ,
+/^libtxi\.a:/ i\
+\
+popen.$(OBJEXT): $(top_srcdir)/djgpp/popen.c\
+	$(COMPILE) -c $<
diff -apruNU3 texinfo-4.8.orig/djgpp/popen.c texinfo-4.8/djgpp/popen.c
--- texinfo-4.8.orig/djgpp/popen.c	1970-01-01 00:00:00.000000000 +0000
+++ texinfo-4.8/djgpp/popen.c	2004-12-09 21:53:38.000000000 +0000
@@ -0,0 +1,254 @@
+/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
+/* Copyright (C) 1998 DJ Delorie, see COPYING.DJ for details */
+/* Copyright (C) 1997 DJ Delorie, see COPYING.DJ for details */
+/* Copyright (C) 1996 DJ Delorie, see COPYING.DJ for details */
+/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
+/*
+   This is popen() and pclose() for MSDOS.  They were developed using
+   Microsoft C, but should port easily to DOS C any compiler.
+   
+   Original author: pacetti@fl-ngnet.army.mil
+
+   These routines are hacks, that is they SIMULATE their UNIX
+   counterparts.  Since MSDOS and won't allow concurrent process spawning,
+   you can't really pipe.  I came up with this nearly stupid way around
+   piping because I wanted to have some portability between UNIX and MSDOS.
+   I'm probably not the first person to have this idea or implement it, but
+   I think I'm the first to give it away for free (no points?!).
+
+   The functions simulate popen() and pclose() by redirecting stdin or
+   stdout, then spawning a child process via system().
+
+   If you popen() for read, the stdout is redirected to a temporary
+   file, and the child is spawned.  The stdout is reopened via dup2(), the
+   temporary file is opened for read and a file pointer to it is returned.
+
+   If you popen() for write, a temporary file is opened for write, and
+   a file pointer to it is returned.  When you pclose(), the stdin is
+   redirected to the temporary file and the child is spawned.
+
+   In both cases, pclose() closes and unlinks the temporary file.
+
+   A static linked list of C structures is built to store necessary
+   info for all popen()ed files so you can popen() more than one file at
+   a time.
+
+   The popen() function will return NULL on an error, or a valid FILE
+   *pointer on a successful open.  The pclose() function will return
+   negative one (-1) on an error or zero (0) on a successful close.
+
+   The function prototypes are:
+
+   FILE *popen(command, mode)
+        char *command, char *mode;
+
+   int pclose(pp)
+       FILE *pp;
+
+   Where command is a character string equivilant to a MSDOS command
+   line, mode is "r" for read or "w" for write, and pp is a pointer to a
+   file opened through popen().
+ */
+
+#include <libc/stubs.h>
+#include <io.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <libc/file.h>
+
+/* hold file pointer, command, mode, and the status of the command */
+struct pipe_list {
+  FILE *fp;
+  int exit_status;
+  char *command, mode[10];
+  struct pipe_list *next;
+};
+
+/* static, global list pointer */
+static struct pipe_list *pl = NULL;
+
+FILE *popen(const char *cm, const char *md) /* program name, pipe mode */
+{
+  struct pipe_list *l1;
+  char *temp_name;
+
+  /* make new node */
+  if ((l1 = malloc(sizeof(*l1))) == NULL)
+    return NULL;
+
+  /* if empty list - just grab new node */
+  l1->next = pl;
+  pl = l1;
+
+  /* stick in elements we know already */
+  l1->command = NULL;
+
+  if ((temp_name = malloc(L_tmpnam)) == NULL)
+    goto error;
+
+  if (tmpnam(temp_name) == NULL)
+    goto error;
+
+  strcpy(l1->mode, md);
+
+  if (l1->mode[0] == 'r')
+  /* caller wants to read */
+  {
+    int fd;
+
+    /* dup stdout */
+    if ((fd = dup(fileno(stdout))) == -1)
+      goto error;
+
+    /* redirect stdout */
+    if (!freopen(temp_name, "wb", stdout))
+      goto error;
+
+    /* make sure file is removed on abnormal exit */
+    stdout->_flag |= _IORMONCL;
+    stdout->_name_to_remove = temp_name;
+
+    /* execute command */
+    l1->exit_status = system(cm);
+
+    /* don't remove file */
+    stdout->_flag &= ~_IORMONCL;
+    stdout->_name_to_remove = NULL;
+
+    /* flush file just in case */
+    fflush(stdout);
+
+    /* reopen real stdout */
+    if (dup2(fd, fileno(stdout)) == -1)
+      goto error;
+
+    /* close duplicate stdout */
+    close(fd);
+
+    /* if cmd couldn't be run, make sure we return NULL */
+    if (l1->exit_status == -1)
+      goto error;
+  }
+  else if (l1->mode[0] == 'w')
+  /* caller wants to write */
+  {
+    /* if can save the program name, build temp file */
+    if (!(l1->command = malloc(strlen(cm) + 1)))
+      goto error;
+
+    strcpy(l1->command, cm);
+  }
+  else
+    /* unknown mode */
+    goto error;
+
+  /* open file for caller */
+  l1->fp = fopen(temp_name, l1->mode);
+
+  /* make sure file is removed on abnormal exit */
+  l1->fp->_flag |= _IORMONCL;
+  l1->fp->_name_to_remove = temp_name;
+
+  return l1->fp;
+
+ error:
+
+  if (temp_name)
+    free(temp_name);
+
+  pl = l1->next;
+  free(l1);
+
+  return NULL;
+}
+
+int pclose(FILE *pp)
+{
+  struct pipe_list *l1, **l2;	/* list pointers */
+  char *temp_name;		/* file name */
+  int retval = -1;		/* function return value */
+
+  for (l2 = &pl; *l2; l2 = &(*l2)->next)
+    if ((*l2)->fp == pp)
+      break;
+
+  if (!*l2)
+    return -1;
+
+  l1 = *l2;
+  *l2 = l1->next;
+
+  if (!(l1->fp->_flag & _IORMONCL))
+    /* file wasn't popen()ed */
+    return -1;
+  else
+    temp_name = l1->fp->_name_to_remove;
+
+  /* if pipe was opened to write */
+  if (l1->mode[0] == 'w')
+  {
+    int fd;
+
+    /* don't remove file while closing */
+    l1->fp->_flag &= ~_IORMONCL;
+    l1->fp->_name_to_remove = NULL;
+
+    /* close the (hopefully) popen()ed file */
+    fclose(l1->fp);
+
+    /* dup stdin */
+    if ((fd = dup(fileno(stdin))) == -1)
+      goto exit;
+
+    /* redirect stdin */
+    if (!freopen(temp_name, "rb", stdin))
+      goto exit;
+
+    /* make sure file is removed on abnormal exit */
+    stdin->_flag |= _IORMONCL;
+    stdin->_name_to_remove = temp_name;
+
+    /* execute command */
+    retval = system(l1->command);
+
+    /* don't remove file */
+    stdin->_flag &= ~_IORMONCL;
+    stdin->_name_to_remove = NULL;
+
+    /* close and remove file */
+    close(fileno(stdin));
+    remove(temp_name);
+
+    /* reopen real stdin */
+    if (dup2(fd, fileno(stdin)) == -1)
+    {
+      retval = -1;
+      goto exit;
+    }
+
+    /* close duplicate stdin */
+    close(fd);
+
+  exit:
+
+    free(l1->command);
+  }
+  /* if pipe was opened to read, return the exit status we saved */
+  else if (l1->mode[0] == 'r')
+  {
+    retval = l1->exit_status;
+
+    /* close and remove file */
+    fclose(l1->fp);
+  }
+  else
+    /* invalid mode */
+    retval = -1;
+
+  free(l1);
+
+  return retval;
+}
diff -apruNU3 texinfo-4.8.orig/djgpp/xp-config.bat texinfo-4.8/djgpp/xp-config.bat
--- texinfo-4.8.orig/djgpp/xp-config.bat	1970-01-01 00:00:00.000000000 +0000
+++ texinfo-4.8/djgpp/xp-config.bat	2005-01-29 01:20:48.000000000 +0000
@@ -0,0 +1,251 @@
+@echo off
+
+echo Configuring GNU Texinfo for DJGPP v2.x...
+
+Rem The small_env tests protect against fixed and too small size
+Rem of the environment in stock DOS shell.
+
+Rem Find out if NLS is wanted or not, if dependency-tracking is
+Rem wanted or not, if cache is wanted or not, and where the sources are.
+set ARGS=
+set NLS=disabled
+if not "%NLS%" == "disabled" goto small_env
+set CACHE=enabled
+if not "%CACHE%" == "enabled" goto small_env
+set DEPTRAK=disabled
+if not "%DEPTRAK%" == "disabled" goto small_env
+set XSRC=.
+if not "%XSRC%" == "." goto small_env
+
+Rem Loop over all arguments.
+Rem Special arguments are: NLS, XSRC CACHE and DEPS.
+Rem All other arguments are stored into ARGS.
+:arg_loop
+set SPECARG=0
+if not "%SPECARG%" == "0" goto small_env
+if not "%1" == "NLS" if not "%1" == "nls" goto cache_opt
+if "%1" == "nls" set NLS=enabled
+if "%1" == "NLS" set NLS=enabled
+if not "%NLS%" == "enabled" goto small_env
+set SPECARG=1
+if not "%SPECARG%" == "1" goto small_env
+shift
+:cache_opt
+set SPECARG=0
+if not "%SPECARG%" == "0" goto small_env
+if "%1" == "no-cache" goto cache_off
+if "%1" == "no-CACHE" goto cache_off
+if not "%1" == "NO-CACHE" goto dependency_opt
+:cache_off
+if "%1" == "no-cache" set CACHE=disabled
+if "%1" == "no-CACHE" set CACHE=disabled
+if "%1" == "NO-CACHE" set CACHE=disabled
+if not "%CACHE%" == "disabled" goto small_env
+set SPECARG=1
+if not "%SPECARG%" == "1" goto small_env
+shift
+:dependency_opt
+set SPECARG=0
+if not "%SPECARG%" == "0" goto small_env
+if "%1" == "dep" goto dep_off
+if not "%1" == "DEP" goto src_dir_opt
+:dep_off
+if "%1" == "dep" set DEPTRAK=enabled
+if "%1" == "DEP" set DEPTRAK=enabled
+if not "%DEPTRAK%" == "enabled" goto small_env
+set SPECARG=1
+if not "%SPECARG%" == "1" goto small_env
+shift
+:src_dir_opt
+set SPECARG=0
+if not "%SPECARG%" == "0" goto small_env
+echo %1 | grep -q "/"
+if errorlevel 1 goto collect_arg
+set XSRC=%1
+if not "%XSRC%" == "%1" goto small_env
+set SPECARG=1
+if not "%SPECARG%" == "1" goto small_env
+:collect_arg
+if "%SPECARG%" == "0" set _ARGS=%ARGS% %1
+if "%SPECARG%" == "0" if not "%_ARGS%" == "%ARGS% %1" goto small_env
+echo %_ARGS% | grep -q "[^ ]"
+if not errorlevel 0 set ARGS=%_ARGS%
+set _ARGS=
+shift
+if not "%1" == "" goto arg_loop
+set SPECARG=
+
+Rem Create a response file for the configure script.
+echo --srcdir=%XSRC% > arguments
+if "%CACHE%" == "enabled"    echo --config-cache >>arguments
+if "%DEPTRAK%" == "enabled"  echo --enable-dependency-tracking >>arguments
+if "%DEPTRAK%" == "disabled" echo --disable-dependency-tracking >>arguments
+if not "%ARGS%" == ""        echo %ARGS% >>arguments
+set ARGS=
+set CACHE=
+set DEPTRAK=
+
+if "%XSRC%" == "." goto in_place
+
+:not_in_place
+redir -e /dev/null update %XSRC%/configure.orig ./configure
+test -f ./configure
+if errorlevel 1 update %XSRC%/configure ./configure
+
+:in_place
+Rem Update configuration files
+echo Updating configuration scripts...
+test -f ./configure.orig
+if errorlevel 1 update configure configure.orig
+sed -f %XSRC%/djgpp/config.sed configure.orig > configure
+if errorlevel 1 goto sed_error
+
+Rem Make sure they have a config.site file
+set CONFIG_SITE=%XSRC%/djgpp/config.site
+if not "%CONFIG_SITE%" == "%XSRC%/djgpp/config.site" goto small_env
+
+Rem Make sure crucial file names are not munged by unpacking
+test -f %XSRC%/m4/inttypes-pri.m4
+if not errorlevel 1 mv -f %XSRC%/m4/inttypes-pri.m4 %XSRC%/m4/inttype-pri.m4
+test -f %XSRC%/m4/inttypes_h.m4
+if not errorlevel 1 mv -f %XSRC%/m4/inttypes_h.m4 %XSRC%/m4/inttype_h.m4
+test -f %XSRC%/m4/onceonly_2_57.m4
+if not errorlevel 1 mv -f %XSRC%/m4/onceonly_2_57.m4 %XSRC%/m4/2_57_onceonly.m4
+test -f %XSRC%/po/Makefile.in.in
+if not errorlevel 1 mv -f %XSRC%/po/Makefile.in.in %XSRC%/po/Makefile.in-in
+test -f %XSRC%/po/Makefile.am.in
+if not errorlevel 1 mv -f %XSRC%/po/Makefile.am.in %XSRC%/po/Makefile.am-in
+
+Rem This is required because DOS/Windows are case-insensitive
+Rem to file names, and "make install" will do nothing if Make
+Rem finds a file called `install'.
+if exist INSTALL ren INSTALL INSTALL.txt
+
+Rem Set HOME to a sane default so configure stops complaining.
+if not "%HOME%" == "" goto host_name
+set HOME=%XSRC%/djgpp
+if not "%HOME%" == "%XSRC%/djgpp" goto small_env
+echo No HOME found in the environment, using default value
+
+:host_name
+Rem Set HOSTNAME so it shows in config.status
+if not "%HOSTNAME%" == "" goto hostdone
+if "%windir%" == "" goto msdos
+set OS=MS-Windows
+if not "%OS%" == "MS-Windows" goto small_env
+goto haveos
+:msdos
+set OS=MS-DOS
+if not "%OS%" == "MS-DOS" goto small_env
+:haveos
+if not "%USERNAME%" == "" goto haveuname
+if not "%USER%" == "" goto haveuser
+echo No USERNAME and no USER found in the environment, using default values
+set HOSTNAME=Unknown PC
+if not "%HOSTNAME%" == "Unknown PC" goto small_env
+goto userdone
+:haveuser
+set HOSTNAME=%USER%'s PC
+if not "%HOSTNAME%" == "%USER%'s PC" goto small_env
+goto userdone
+:haveuname
+set HOSTNAME=%USERNAME%'s PC
+if not "%HOSTNAME%" == "%USERNAME%'s PC" goto small_env
+:userdone
+set _HOSTNAME=%HOSTNAME%, %OS%
+if not "%_HOSTNAME%" == "%HOSTNAME%, %OS%" goto small_env
+set HOSTNAME=%_HOSTNAME%
+:hostdone
+set _HOSTNAME=
+set OS=
+
+Rem install-sh is required by the configure script but clashes with the
+Rem various Makefile install-foo targets, so we MUST have it before the
+Rem script runs and rename it afterwards
+test -f %XSRC%/install-sh
+if not errorlevel 1 goto no_ren0
+test -f %XSRC%/install-sh.sh
+if not errorlevel 1 mv -f %XSRC%/install-sh.sh %XSRC%/install-sh
+:no_ren0
+
+if "%NLS%" == "disabled" goto without_NLS
+
+:with_NLS
+Rem Check for the needed libraries and binaries.
+test -x /dev/env/DJDIR/bin/msgfmt.exe
+if not errorlevel 0 goto missing_NLS_tools
+test -x /dev/env/DJDIR/bin/xgettext.exe
+if not errorlevel 0 goto missing_NLS_tools
+test -f /dev/env/DJDIR/include/libcharset.h
+if not errorlevel 0 goto missing_NLS_tools
+test -f /dev/env/DJDIR/lib/libcharset.a
+if not errorlevel 0 goto missing_NLS_tools
+test -f /dev/env/DJDIR/include/iconv.h
+if not errorlevel 0 goto missing_NLS_tools
+test -f /dev/env/DJDIR/lib/libiconv.a
+if not errorlevel 0 goto missing_NLS_tools
+test -f /dev/env/DJDIR/include/libintl.h
+if not errorlevel 0 goto missing_NLS_tools
+test -f /dev/env/DJDIR/lib/libintl.a
+if not errorlevel 0 goto missing_NLS_tools
+
+Rem Recreate the files in the %XSRC%/po subdir with our ported tools.
+redir -e /dev/null rm %XSRC%/po/*.gmo
+redir -e /dev/null rm %XSRC%/po/diffutil*.pot
+redir -e /dev/null rm %XSRC%/po/cat-id-tbl.c
+redir -e /dev/null rm %XSRC%/po/stamp-cat-id
+
+Rem Update the arguments file for the configure script.
+Rem We prefer without-included-gettext because libintl.a from gettext package
+Rem is the only one that is guaranteed to have been ported to DJGPP.
+echo --enable-nls --without-included-gettext >> arguments
+goto configure_package
+
+:missing_NLS_tools
+echo Needed libs/tools for NLS not found.  Configuring without NLS.
+:without_NLS
+Rem Update the arguments file for the configure script.
+echo --disable-nls >> arguments
+
+:configure_package
+echo Running the ./configure script...
+sh ./configure @arguments
+if errorlevel 1 goto cfg_error
+rm arguments
+sed -f %XSRC%/djgpp/makefile.sed lib/Makefile > Makefile.lib
+if errorlevel 1 goto sed_error0
+mv Makefile.lib lib/Makefile
+echo Done.
+goto End
+
+:sed_error0
+echo lib/Makefile editing failed!
+goto End
+
+:sed_error
+echo ./configure script editing failed!
+goto End
+
+:cfg_error
+echo ./configure script exited abnormally!
+goto End
+
+:small_env
+echo Your environment size is too small.  Enlarge it and run me again.
+echo Configuration NOT done!
+
+:End
+test -f %XSRC%/install-sh.sh
+if not errorlevel 1 goto no_ren1
+test -f %XSRC%/install-sh
+if not errorlevel 1 mv -f %XSRC%/install-sh %XSRC%/install-sh.sh
+:no_ren1
+redir -e /dev/null rm ./co*.tmp
+if "%HOME%" == "%XSRC%/djgpp" set HOME=
+set ARGS=
+set CONFIG_SITE=
+set HOSTNAME=
+set NLS=
+set CACHE=
+set DEPTRAK=
+set XSRC=
