CVSROOT: /sources/m4 Module name: m4 Changes by: Eric Blake <ericb> 07/04/12 16:27:20
Index: src/main.c =================================================================== RCS file: /sources/m4/m4/src/main.c,v retrieving revision 1.111 retrieving revision 1.112 diff -u -b -r1.111 -r1.112 --- src/main.c 2 Apr 2007 12:06:23 -0000 1.111 +++ src/main.c 12 Apr 2007 16:27:20 -0000 1.112 @@ -26,7 +26,7 @@ #include "m4.h" #include "close-stream.h" -#include "closeout.h" +#include "closein.h" #include "configmake.h" #include "getopt.h" #include "version-etc.h" @@ -298,15 +298,11 @@ /* Process a command line file NAME, and return true only if it was stdin. */ -static bool +static void process_file (m4 *context, const char *name) { - bool result = false; if (strcmp (name, "-") == 0) - { m4_push_file (context, stdin, "stdin", false); - result = true; - } else { char *full_name; @@ -314,13 +310,12 @@ if (fp == NULL) { m4_error (context, 0, errno, _("cannot open file `%s'"), name); - return false; + return; } m4_push_file (context, fp, full_name, true); free (full_name); } m4_macro_expand_input (context); - return result; } @@ -334,7 +329,6 @@ int optchar; /* option character */ size_t size; /* for parsing numeric option arguments */ - bool read_stdin = false; /* true iff we have read from stdin */ bool import_environment = false; /* true to import environment */ bool seen_file = false; const char *debugfile = NULL; @@ -348,7 +342,7 @@ /* Initialize gnulib error module. */ m4_set_program_name (argv[0]); - atexit (close_stdout); + atexit (close_stdin); setlocale (LC_ALL, ""); #ifdef ENABLE_NLS @@ -702,7 +696,7 @@ break; case '\1': - read_stdin |= process_file (context, arg); + process_file (context, arg); break; case POPDEF_OPTION: @@ -743,10 +737,10 @@ and the input read. */ if (optind == argc && !seen_file) - read_stdin = process_file (context, "-"); + process_file (context, "-"); else for (; optind < argc; optind++) - read_stdin |= process_file (context, argv[optind]); + process_file (context, argv[optind]); /* Now handle wrapup text. FIXME - when -F is in effect, should wrapped text be frozen? */ @@ -772,11 +766,9 @@ m4_input_exit (); /* 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. */ + stream and detect any errors it might have encountered. The + three standard streams are closed by close_stdin. */ m4_debug_set_output (context, NULL); - if (read_stdin && close_stream (stdin) == EOF) - m4_error (context, 0, errno, _("error closing stdin")); exit_status = m4_get_exit_status (context); m4_delete (context);