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

	* djgpp/subpipe.c: Exit/termination logic changed.
	(end_of_output_subpipe): If spawn returns -1 or m4 is interrupted
	by user, then exit.  If m4 returns with exit code greater 0 continue.
	(reap_subpipe): If m4's exit code is greater than 0, then exit.
	(remove_remaining_tmp_files): Remove tmp files at exit.


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

	* djgpp/README.in: Documentation updated.

	* djgpp/config.sed: Entry for scan-code-c.c added.
	Do not run AUTOM4TE to regenerate testsuite.

	* djgpp/fnchange.lst: Entry for scan-code-c.c added.








diff -aprNU5 bison-2.4.1.orig/djgpp/README.in bison-2.4.1/djgpp/README.in
--- bison-2.4.1.orig/djgpp/README.in	2008-11-03 18:54:12 +0000
+++ bison-2.4.1/djgpp/README.in	2010-01-09 00:26:18 +0000
@@ -108,30 +108,30 @@ along with this program.  If not, see <h
 
 	If the distribution comes as a .tar.bz2 archive, and your version of
 	`djtar' doesn't support bzip2 decompression, you need to unpack it as
 	follows:
 
-	  bnzip2 bison-@VERSION@.tar.bz2
+	  bunzip2 bison-@VERSION@.tar.bz2
 	  djtar -x -p -o bison-@VERSION@/djgpp/djunpack.bat bison-@VERSION@.tar > djunpack.bat
 	  djunpack bison-@VERSION@.tar
 
 3.3.:   To build the binaries you will need the following binary packages:
 	  djdev203.zip (or a later but NOT a prior version)
-	  bsh204b.zip  (or a later but NOT a prior version)
+	  bsh205bbr3.zip  (or a later but NOT a prior version)
           gccNNNb.zip, gppNNN.zip, bnuNNNb.zip, makNNNb.zip, filNNNb.zip,
           perlNNNb.zip, shlNNNb.zip, txtNNNb.zip, txiNNNb.zip, grepNNNb.zip,
           sedNNNb.zip and m4NNN.zip
 
 	If you want to run the check you will need also:
 	  difNNNb.zip
 
 	NNN represents the latest version number of the binary packages. All
 	this packages can be found in the /v2gnu directory of any
 	ftp.delorie.com mirror.
-	You will need bsh204b.zip or later and *NOT* a prior version or
+	You will need bsh205bbr3.zip or later and *NOT* a prior version or
 	the build will fail.  The same applies to djdev203.zip.  Please note
-	that Bison requires m4-144b.zip or later to work properly.
+	that Bison requires m4-1413b.zip or later to work properly.
 
 3.4.:   If for some reason you want to reconfigure the package cd into the top
 	srcdir (bison-@TREE_VERSION@) and run the following commands:
 	  del djgpp\config.cache
 	  make clean
diff -aprNU5 bison-2.4.1.orig/djgpp/config.sed bison-2.4.1/djgpp/config.sed
--- bison-2.4.1.orig/djgpp/config.sed	2008-11-03 18:54:12 +0000
+++ bison-2.4.1/djgpp/config.sed	2010-01-10 02:39:04 +0000
@@ -34,10 +34,11 @@ s,\\.old\\.,_old.,g\
 s,\\.tab\\.,_tab.,g\
 s,c++\\.at,cxx.at,g\
 s,c++\\.m4,cxx.m4,g\
 s,c++-skel\\.m4,cxx-skel.m4,g\
 s,calc++,calcxx,g\
+s,scan-code-c,c-scan-code,g\
 s,scan-gram-c,c-scan-gram,g\
 s,scan-skel-c,c-scan-skel,g\
 s,inttypes_,_inttypes,g\
 s,javacomp\\.sh\\.in,javacomp.sh-in,g\
 s,javaexec\\.sh\\.in,javaexec.sh-in,g\
@@ -61,10 +62,16 @@ yacc.bat:\\\\\
 	echo "bison\\$(EXEEXT) -y %1 %2 %3 %4 %5 %6 %7 %8 %9" >\\$@\
 /^bin_SCRIPTS =/s/$/ yacc.bat/\
 /^MOSTLYCLEANFILES = yacc/s/$/ yacc.bat/\
 /cross-options.texi:/,/^$/ s|bison|&.exe|g\
 /^\\.x\\.1:/,/^$/ s|\\$program|&.exe|g\
+/^\\$(TESTSUITE)[ 	]*:/,/^$/ {\
+  s/^	/#&/\
+}\
+/^\.x\.1[	 ]*:/,/^$/ {\
+  s/^	/#&/\
+}\
 eof_djgpp\
 sed -f "\$tmp/subs-djgpp.sed" \$tmp/out > \$tmp/out.djgpp\
 mv -f \$tmp/out.djgpp \$tmp/out
 }
 
diff -aprNU5 bison-2.4.1.orig/djgpp/fnchange.lst bison-2.4.1/djgpp/fnchange.lst
--- bison-2.4.1.orig/djgpp/fnchange.lst	2008-11-03 18:54:12 +0000
+++ bison-2.4.1/djgpp/fnchange.lst	2010-01-09 00:26:18 +0000
@@ -20,8 +20,9 @@
 @V@/examples/calc++/calc++-parser.stamp   @V@/examples/calcxx/calcxx-parser.stamp
 @V@/examples/calc++/calc++-parser.yy      @V@/examples/calcxx/calcxx-parser.yy
 @V@/examples/calc++/test                  @V@/examples/calcxx/test
 @V@/po/Makefile.in.in                     @V@/po/Makefile.in-in
 @V@/runtime-po/Makefile.in.in             @V@/runtime-po/Makefile.in-in
+@V@/src/scan-code-c.c                     @V@/src/c-scan-code.c
 @V@/src/scan-gram-c.c                     @V@/src/c-scan-gram.c
 @V@/src/scan-skel-c.c                     @V@/src/c-scan-skel.c
 @V@/tests/c++.at                          @V@/tests/cxx.at
diff -aprNU5 bison-2.4.1.orig/djgpp/subpipe.c bison-2.4.1/djgpp/subpipe.c
--- bison-2.4.1.orig/djgpp/subpipe.c	2008-11-03 18:54:12 +0000
+++ bison-2.4.1/djgpp/subpipe.c	2010-01-10 00:56:44 +0000
@@ -1,8 +1,8 @@
 /* Subprocesses with pipes.
 
-   Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
@@ -29,10 +29,11 @@
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <sys/wait.h>
 #include "xalloc.h"
 
 
 #ifndef STDIN_FILENO
 # define STDIN_FILENO 0
@@ -53,19 +54,40 @@
 
 static int old_stdin;
 static int old_stdout;
 static char **arguments;
 static char tmp_file_name[2][L_tmpnam];
+static int spawn_status;
 
-#define remove_tmp_file(fd, name)                                     \
-  do {                                                                \
-    close ((fd));                                                     \
-    if (unlink ((name)))                                              \
-      error (EXIT_FAILURE, 0, _("removing of `%s' failed"), (name));  \
+
+#define remove_tmp_file(fd, name)                                       \
+  do {                                                                  \
+    if (!close((fd)))                                                   \
+    {                                                                   \
+      if (unlink ((name)))                                              \
+        error (EXIT_FAILURE, 0, _("removing of `%s' failed"), (name));  \
+      (name)[0] = '\0';                                                 \
+    }                                                                   \
   } while (0)
 
 
+static void
+remove_remaining_tmp_files(void)
+{
+  /*
+   *  On MSDOS/Windows it is always necessary to close()
+   *  a file before remove() or unlink() it.  The tmp files
+   *  used to simulate the pipe are always connected to STDIN
+   *  and STDOUT.
+   */
+  close(STDIN_FILENO);
+  close(STDOUT_FILENO);
+  unlink(tmp_file_name[0]);
+  unlink(tmp_file_name[1]);
+}
+
+
 void
 init_subpipe(void)
 {
   char *tmpdir;
   int fd;
@@ -89,10 +111,12 @@ init_subpipe(void)
   strcat(tmp_file_name[1], "/bnXXXXXX");
   fd = mkstemp(tmp_file_name[1]);
   if (fd < 0)
     error(EXIT_FAILURE, 0, _("creation of a temporary file failed"));
   close (fd);
+
+  atexit(remove_remaining_tmp_files);
 }
 
 
 /* Create a subprocess that is run as a filter.  ARGV is the
    NULL-terminated argument vector for the subprocess.  Store read and
@@ -225,25 +249,35 @@ end_of_output_subpipe(pid_t pid, int fd[
   child_interrupted = 0;
   errno = 0;
   previous_handler = signal(SIGINT, signal_catcher);
   status = spawnvp(P_WAIT, program, arguments);
   signal(SIGINT, previous_handler);
+
+  spawn_status = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
   if (child_interrupted)
   {
     remove_tmp_file(STDIN_FILENO, tmp_file_name[0]);
     remove_tmp_file(STDOUT_FILENO, tmp_file_name[1]);
     error(EXIT_FAILURE, 0, _("subsidiary program `%s' interrupted"), program);
   }
-  if (status)
+  if (spawn_status == -1)
   {
+    /*
+     *  - spawn returns -1 if m4 can not be invoked or executed.
+     *  - If m4 could be executed, then spawn returns m4's exit
+     *    code in the lower 8 bits of status.
+     *  - m4's exit codes are at least: 0, 1 and 63.
+     *
+     *  If m4 returns with exit code greater than 0 bison will
+     *  get the chance to examinate m4's output and terminated
+     *  itself in reap_subpipe() if necessary.
+     */
     remove_tmp_file(STDIN_FILENO, tmp_file_name[0]);
     remove_tmp_file(STDOUT_FILENO, tmp_file_name[1]);
     error(EXIT_FAILURE, 0, _(errno == ENOENT
-			     ? "subsidiary program `%s' not found"
-			     : status < 1
-			     ? "subsidiary program `%s' failed"
-			     : "subsidiary program `%s' failed (status=%i, errno=%i)"), program, status, errno);
+                             ? "subsidiary program `%s' not found"
+                             : "subsidiary program `%s' could not be invoked (status=%i, errno=%i)"), program, spawn_status, errno);
   }
 
 
   /*
    *  Redirect m4's output to bison's stdin.
@@ -274,20 +308,28 @@ end_of_output_subpipe(pid_t pid, int fd[
 /* Free resources, unlink temporary files and restore stdin and stdout. */
 
 void
 reap_subpipe(pid_t pid, char const *program)
 {
-  int argc;
+  if (spawn_status)
+  {
+    /*  m4 returned with exit code > 0.  Terminate bison.   */
+    error(EXIT_FAILURE, 0, _("subsidiary program `%s' failed (status=%i, errno=%i)"), program, spawn_status, errno);
+  }
+  else
+  {
+    int argc;
 
-  for (argc = 0; arguments[argc]; argc++)
-    free(arguments[argc]);
-  free(arguments);
-
-  if (unlink(tmp_file_name[0]))
-    error(EXIT_FAILURE, 0, _("removing of `%s' failed"), tmp_file_name[0]);
-  if (unlink(tmp_file_name[1]))
-    error(EXIT_FAILURE, 0, _("removing of `%s' failed"), tmp_file_name[1]);
-
-  if (dup2(old_stdin, STDIN_FILENO) < 0)
-    error(EXIT_FAILURE, 0, "restore of bison's stdin failed");
-  close(old_stdin);
+    for (argc = 0; arguments[argc]; argc++)
+      free(arguments[argc]);
+    free(arguments);
+
+    if (unlink(tmp_file_name[0]))
+      error(EXIT_FAILURE, 0, _("removing of `%s' failed"), tmp_file_name[0]);
+    if (unlink(tmp_file_name[1]))
+      error(EXIT_FAILURE, 0, _("removing of `%s' failed"), tmp_file_name[1]);
+
+    if (dup2(old_stdin, STDIN_FILENO) < 0)
+      error(EXIT_FAILURE, 0, "restore of bison's stdin failed");
+    close(old_stdin);
+  }
 }
