m4-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Changes to m4/src/Attic/m4.c,v [branch-1_4]


From: Eric Blake
Subject: Changes to m4/src/Attic/m4.c,v [branch-1_4]
Date: Mon, 24 Jul 2006 20:02:19 +0000

CVSROOT:        /sources/m4
Module name:    m4
Branch:         branch-1_4
Changes by:     Eric Blake <ericb>      06/07/24 20:02:16

Index: src/m4.c
===================================================================
RCS file: /sources/m4/m4/src/Attic/m4.c,v
retrieving revision 1.1.1.1.2.19
retrieving revision 1.1.1.1.2.20
diff -u -b -r1.1.1.1.2.19 -r1.1.1.1.2.20
--- src/m4.c    19 Jul 2006 14:55:53 -0000      1.1.1.1.2.19
+++ src/m4.c    24 Jul 2006 20:02:16 -0000      1.1.1.1.2.20
@@ -24,7 +24,9 @@
 #include <getopt.h>
 #include <signal.h>
 
-static void usage _((int));
+#include "close-stream.h"
+
+static void usage (int);
 
 /* Operate interactively (-e).  */
 static int interactive = 0;
@@ -221,6 +223,9 @@
 mismatch, or whatever value was passed to the m4exit macro.\n\
 ", stdout);
     }
+
+  if (close_stream (stdout) != 0)
+    M4ERROR ((EXIT_FAILURE, errno, "write error"));
   exit (status);
 }
 
@@ -259,6 +264,10 @@
   { 0, 0, 0, 0 },
 };
 
+/* Global catchall for any errors that should affect final error status, but
+   where we try to continue execution in the meantime.  */
+int retcode;
+
 #ifdef ENABLE_CHANGEWORD
 #define OPTSTRING "B:D:EF:GH:I:L:N:PQR:S:T:U:W:d::el:o:st:"
 #else
@@ -268,7 +277,6 @@
 int
 main (int argc, char *const *argv, char *const *envp)
 {
-  int retcode = EXIT_SUCCESS;
   macro_definition *head;      /* head of deferred argument list */
   macro_definition *tail;
   macro_definition *new;
@@ -278,6 +286,7 @@
   FILE *fp;
 
   program_name = argv[0];
+  retcode = EXIT_SUCCESS;
 
   include_init ();
   debug_init ();
@@ -408,6 +417,8 @@
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
 ");
 
+      if (close_stream (stdout) != 0)
+       M4ERROR ((EXIT_FAILURE, errno, "write error"));
       exit (EXIT_SUCCESS);
     }
 
@@ -512,6 +523,10 @@
   while (pop_wrapup ())
     expand_input ();
 
+  /* Change debug stream back to stderr, to force flushing debug stream and
+     detect any errors it might have encountered.  */
+  debug_set_output (NULL);
+
   if (frozen_file_to_write)
     produce_frozen_state (frozen_file_to_write);
   else
@@ -520,5 +535,7 @@
       undivert_all ();
     }
 
+  if (close_stream (stdout) != 0)
+    M4ERROR ((EXIT_FAILURE, errno, "write error"));
   exit (retcode);
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]