m4-commit
[Top][All Lists]
Advanced

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

Changes to m4/src/main.c,v


From: Eric Blake
Subject: Changes to m4/src/main.c,v
Date: Thu, 07 Sep 2006 23:53:06 +0000

CVSROOT:        /sources/m4
Module name:    m4
Changes by:     Eric Blake <ericb>      06/09/07 23:53:04

Index: src/main.c
===================================================================
RCS file: /sources/m4/m4/src/main.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -b -r1.79 -r1.80
--- src/main.c  5 Sep 2006 23:16:40 -0000       1.79
+++ src/main.c  7 Sep 2006 23:53:04 -0000       1.80
@@ -236,6 +236,7 @@
   macro_definition *defines;
   FILE *fp;
   char *filename;
+  bool read_stdin = false;     /* true iff we have read from stdin */
 
   m4 *context;
 
@@ -549,14 +550,18 @@
   exit_status = EXIT_SUCCESS;
   if (optind == argc)
     {
-      m4_push_file (context, stdin, "stdin");
+      m4_push_file (context, stdin, "stdin", false);
+      read_stdin = true;
       m4_macro_expand_input (context);
     }
   else
     for (; optind < argc; optind++)
       {
        if (strcmp (argv[optind], "-") == 0)
-         m4_push_file (context, stdin, "stdin");
+         {
+           m4_push_file (context, stdin, "stdin", false);
+           read_stdin = true;
+         }
        else
          {
            fp = m4_path_search (context, argv[optind], &filename);
@@ -568,7 +573,7 @@
              }
            else
              {
-               m4_push_file (context, fp, filename);
+               m4_push_file (context, fp, filename, true);
                free (filename);
              }
          }
@@ -576,10 +581,16 @@
       }
 
   /* Now handle wrapup text.  */
-
   while (m4_pop_wrapup ())
     m4_macro_expand_input (context);
 
+  /* Change debug stream back to stderr, to force flushing the debug
+     stream and detect any errors it might have encountered.  Close
+     stdin if we read from it, to detect any errors.  */
+  m4_debug_set_output (context, NULL);
+  if (read_stdin && fclose (stdin) == EOF)
+    m4_error (context, 0, errno, _("error closing stdin"));
+
   if (frozen_file_to_write)
     produce_frozen_state (context, frozen_file_to_write);
   else




reply via email to

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