Commit a4fe4e89 authored by Paul Eggert's avatar Paul Eggert

* fakemail.c: Include <ignore-value.h>.

(put_line): Explicitly ignore fwrite return value, for benefit of
recent glibc + gcc.
(close_the_streams): Diagnose output errors instead of merely
exiting with nonzero status.
(my_fclose, main): Diagnose input errors, and exit with nonzero status.
Formerly, input errors were silently ignored.
parent 70279bd1
2011-02-26 Paul Eggert <eggert@cs.ucla.edu> 2011-02-26 Paul Eggert <eggert@cs.ucla.edu>
* fakemail.c: Include <ignore-value.h>.
(put_line): Explicitly ignore fwrite return value, for benefit of
recent glibc + gcc.
(close_the_streams): Diagnose output errors instead of merely
exiting with nonzero status.
(my_fclose, main): Diagnose input errors, and exit with nonzero status.
Formerly, input errors were silently ignored.
* ebrowse.c (putstr): Rename from PUTSTR and turn into a function. * ebrowse.c (putstr): Rename from PUTSTR and turn into a function.
All callers changed. This is cleaner, and avoids GCC warnings about All callers changed. This is cleaner, and avoids GCC warnings about
passing NULL to fputs. passing NULL to fputs.
......
...@@ -62,6 +62,8 @@ main () ...@@ -62,6 +62,8 @@ main ()
/* This is to declare cuserid. */ /* This is to declare cuserid. */
#include <unistd.h> #include <unistd.h>
#include <ignore-value.h>
/* Type definitions */ /* Type definitions */
...@@ -405,8 +407,8 @@ close_the_streams (void) ...@@ -405,8 +407,8 @@ close_the_streams (void)
for (rem = the_streams; for (rem = the_streams;
rem != ((stream_list) NULL); rem != ((stream_list) NULL);
rem = rem->rest_streams) rem = rem->rest_streams)
no_problems = (no_problems && if (no_problems && (*rem->action) (rem->handle) != 0)
((*rem->action) (rem->handle) == 0)); error ("output error", NULL);
the_streams = ((stream_list) NULL); the_streams = ((stream_list) NULL);
return (no_problems ? EXIT_SUCCESS : EXIT_FAILURE); return (no_problems ? EXIT_SUCCESS : EXIT_FAILURE);
} }
...@@ -427,6 +429,8 @@ my_fclose (FILE *the_file) ...@@ -427,6 +429,8 @@ my_fclose (FILE *the_file)
{ {
putc ('\n', the_file); putc ('\n', the_file);
fflush (the_file); fflush (the_file);
if (ferror (the_file))
return EOF;
return fclose (the_file); return fclose (the_file);
} }
...@@ -496,7 +500,7 @@ put_line (const char *string) ...@@ -496,7 +500,7 @@ put_line (const char *string)
} }
} }
/* Output that much, then break the line. */ /* Output that much, then break the line. */
fwrite (s, 1, breakpos - s, rem->handle); ignore_value (fwrite (s, 1, breakpos - s, rem->handle));
column = 8; column = 8;
/* Skip whitespace and prepare to print more addresses. */ /* Skip whitespace and prepare to print more addresses. */
...@@ -729,6 +733,9 @@ main (int argc, char **argv) ...@@ -729,6 +733,9 @@ main (int argc, char **argv)
put_string (buf); put_string (buf);
} }
if (no_problems && (ferror (stdin) || fclose (stdin) != 0))
error ("input error", NULL);
exit (close_the_streams ()); exit (close_the_streams ());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment