diff options
| author | Paul Eggert | 2011-02-25 21:36:51 -0800 |
|---|---|---|
| committer | Paul Eggert | 2011-02-25 21:36:51 -0800 |
| commit | a4fe4e890af466aea88b4e069d176b8e7da94c80 (patch) | |
| tree | 9a8dadf8c794aaa025220e851cb5d0205f134655 /lib-src | |
| parent | 70279bd1cbd56a16b39cb09ac0b47b564db6949b (diff) | |
| download | emacs-a4fe4e890af466aea88b4e069d176b8e7da94c80.tar.gz emacs-a4fe4e890af466aea88b4e069d176b8e7da94c80.zip | |
* 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/ChangeLog | 8 | ||||
| -rw-r--r-- | lib-src/fakemail.c | 13 |
2 files changed, 18 insertions, 3 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index ed6162bc997..c57ee2ff98c 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog | |||
| @@ -1,5 +1,13 @@ | |||
| 1 | 2011-02-26 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2011-02-26 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | * fakemail.c: Include <ignore-value.h>. | ||
| 4 | (put_line): Explicitly ignore fwrite return value, for benefit of | ||
| 5 | recent glibc + gcc. | ||
| 6 | (close_the_streams): Diagnose output errors instead of merely | ||
| 7 | exiting with nonzero status. | ||
| 8 | (my_fclose, main): Diagnose input errors, and exit with nonzero status. | ||
| 9 | Formerly, input errors were silently ignored. | ||
| 10 | |||
| 3 | * ebrowse.c (putstr): Rename from PUTSTR and turn into a function. | 11 | * ebrowse.c (putstr): Rename from PUTSTR and turn into a function. |
| 4 | All callers changed. This is cleaner, and avoids GCC warnings about | 12 | All callers changed. This is cleaner, and avoids GCC warnings about |
| 5 | passing NULL to fputs. | 13 | passing NULL to fputs. |
diff --git a/lib-src/fakemail.c b/lib-src/fakemail.c index 26375a61654..780a104b405 100644 --- a/lib-src/fakemail.c +++ b/lib-src/fakemail.c | |||
| @@ -62,6 +62,8 @@ main () | |||
| 62 | 62 | ||
| 63 | /* This is to declare cuserid. */ | 63 | /* This is to declare cuserid. */ |
| 64 | #include <unistd.h> | 64 | #include <unistd.h> |
| 65 | |||
| 66 | #include <ignore-value.h> | ||
| 65 | 67 | ||
| 66 | /* Type definitions */ | 68 | /* Type definitions */ |
| 67 | 69 | ||
| @@ -405,8 +407,8 @@ close_the_streams (void) | |||
| 405 | for (rem = the_streams; | 407 | for (rem = the_streams; |
| 406 | rem != ((stream_list) NULL); | 408 | rem != ((stream_list) NULL); |
| 407 | rem = rem->rest_streams) | 409 | rem = rem->rest_streams) |
| 408 | no_problems = (no_problems && | 410 | if (no_problems && (*rem->action) (rem->handle) != 0) |
| 409 | ((*rem->action) (rem->handle) == 0)); | 411 | error ("output error", NULL); |
| 410 | the_streams = ((stream_list) NULL); | 412 | the_streams = ((stream_list) NULL); |
| 411 | return (no_problems ? EXIT_SUCCESS : EXIT_FAILURE); | 413 | return (no_problems ? EXIT_SUCCESS : EXIT_FAILURE); |
| 412 | } | 414 | } |
| @@ -427,6 +429,8 @@ my_fclose (FILE *the_file) | |||
| 427 | { | 429 | { |
| 428 | putc ('\n', the_file); | 430 | putc ('\n', the_file); |
| 429 | fflush (the_file); | 431 | fflush (the_file); |
| 432 | if (ferror (the_file)) | ||
| 433 | return EOF; | ||
| 430 | return fclose (the_file); | 434 | return fclose (the_file); |
| 431 | } | 435 | } |
| 432 | 436 | ||
| @@ -496,7 +500,7 @@ put_line (const char *string) | |||
| 496 | } | 500 | } |
| 497 | } | 501 | } |
| 498 | /* Output that much, then break the line. */ | 502 | /* Output that much, then break the line. */ |
| 499 | fwrite (s, 1, breakpos - s, rem->handle); | 503 | ignore_value (fwrite (s, 1, breakpos - s, rem->handle)); |
| 500 | column = 8; | 504 | column = 8; |
| 501 | 505 | ||
| 502 | /* Skip whitespace and prepare to print more addresses. */ | 506 | /* Skip whitespace and prepare to print more addresses. */ |
| @@ -729,6 +733,9 @@ main (int argc, char **argv) | |||
| 729 | put_string (buf); | 733 | put_string (buf); |
| 730 | } | 734 | } |
| 731 | 735 | ||
| 736 | if (no_problems && (ferror (stdin) || fclose (stdin) != 0)) | ||
| 737 | error ("input error", NULL); | ||
| 738 | |||
| 732 | exit (close_the_streams ()); | 739 | exit (close_the_streams ()); |
| 733 | } | 740 | } |
| 734 | 741 | ||