m4-commit
[Top][All Lists]
Advanced

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

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


From: Eric Blake
Subject: Changes to m4/src/Attic/output.c,v [branch-1_4]
Date: Wed, 08 Nov 2006 05:08:28 +0000

CVSROOT:        /sources/m4
Module name:    m4
Branch:         branch-1_4
Changes by:     Eric Blake <ericb>      06/11/08 05:08:26

Index: src/output.c
===================================================================
RCS file: /sources/m4/m4/src/Attic/output.c,v
retrieving revision 1.1.1.1.2.14
retrieving revision 1.1.1.1.2.15
diff -u -b -r1.1.1.1.2.14 -r1.1.1.1.2.15
--- src/output.c        1 Nov 2006 22:29:08 -0000       1.1.1.1.2.14
+++ src/output.c        8 Nov 2006 05:08:26 -0000       1.1.1.1.2.15
@@ -106,13 +106,39 @@
   output_unused = 0;
 }
 
+void
+output_exit (void)
+{
+  free (diversion_table);
+  diversion_table = NULL;
+}
+
 /* Clean up any temporary directory.  Designed for use as an atexit
    handler, where it is not safe to call exit() recursively; so this
    calls _exit if a problem is encountered.  */
 static void
 cleanup_tmpfile (void)
 {
+  /* Close any open diversions.  */
+  int divnum;
+  struct diversion *diversion;
+  bool fail = false;
+
+  if (diversion_table)
+    for (divnum = 1; divnum < diversions; divnum++)
+      {
+       diversion = diversion_table + divnum;
+       if (diversion->file && close_stream_temp (diversion->file) != 0)
+         {
+           M4ERROR ((0, errno, "cannot clean temporary file for diversion"));
+           fail = true;
+         }
+      }
+
+  /* Clean up the temporary directory.  */
   if (cleanup_temp_dir (output_temp_dir) != 0)
+    fail = true;
+  if (fail)
     _exit (exit_failure);
 }
 
@@ -531,7 +557,8 @@
 
   if (diversion->file)
     {
-      close_stream_temp (diversion->file);
+      if (close_stream_temp (diversion->file) != 0)
+       M4ERROR ((0, errno, "cannot clean temporary file for diversion"));
       diversion->file = NULL;
     }
   else if (diversion->buffer)




reply via email to

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