aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorPaul Eggert <[email protected]>2011-02-25 21:36:51 -0800
committerPaul Eggert <[email protected]>2011-02-25 21:36:51 -0800
commita4fe4e890af466aea88b4e069d176b8e7da94c80 (patch)
tree9a8dadf8c794aaa025220e851cb5d0205f134655 /lib-src
parent70279bd1cbd56a16b39cb09ac0b47b564db6949b (diff)
* 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.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/ChangeLog8
-rw-r--r--lib-src/fakemail.c13
2 files changed, 18 insertions, 3 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index ed6162bc99..c57ee2ff98 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -1,5 +1,13 @@
2011-02-26 Paul Eggert <[email protected]>
+ * 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.
All callers changed. This is cleaner, and avoids GCC warnings about
passing NULL to fputs.
diff --git a/lib-src/fakemail.c b/lib-src/fakemail.c
index 26375a6165..780a104b40 100644
--- a/lib-src/fakemail.c
+++ b/lib-src/fakemail.c
@@ -62,6 +62,8 @@ main ()
/* This is to declare cuserid. */
#include <unistd.h>
+
+#include <ignore-value.h>
/* Type definitions */
@@ -405,8 +407,8 @@ close_the_streams (void)
for (rem = the_streams;
rem != ((stream_list) NULL);
rem = rem->rest_streams)
- no_problems = (no_problems &&
- ((*rem->action) (rem->handle) == 0));
+ if (no_problems && (*rem->action) (rem->handle) != 0)
+ error ("output error", NULL);
the_streams = ((stream_list) NULL);
return (no_problems ? EXIT_SUCCESS : EXIT_FAILURE);
}
@@ -427,6 +429,8 @@ my_fclose (FILE *the_file)
{
putc ('\n', the_file);
fflush (the_file);
+ if (ferror (the_file))
+ return EOF;
return fclose (the_file);
}
@@ -496,7 +500,7 @@ put_line (const char *string)
}
}
/* 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;
/* Skip whitespace and prepare to print more addresses. */
@@ -729,6 +733,9 @@ main (int argc, char **argv)
put_string (buf);
}
+ if (no_problems && (ferror (stdin) || fclose (stdin) != 0))
+ error ("input error", NULL);
+
exit (close_the_streams ());
}