diff options
Diffstat (limited to 'sfeed_atom.c')
-rw-r--r-- | sfeed_atom.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sfeed_atom.c b/sfeed_atom.c index 2aea54e..07c34cd 100644 --- a/sfeed_atom.c +++ b/sfeed_atom.c @@ -43,7 +43,8 @@ printfeed(FILE *fp, const char *feedname) ssize_t linelen; int c; - while ((linelen = getline(&line, &linesize, fp)) > 0) { + while ((linelen = getline(&line, &linesize, fp)) > 0 && + !ferror(stdout)) { if (line[linelen - 1] == '\n') line[--linelen] = '\0'; parseline(line, fields); @@ -141,19 +142,21 @@ main(int argc, char *argv[]) if (argc == 1) { printfeed(stdin, ""); + checkfileerror(stdin, "<stdin>", 'r'); } else { for (i = 1; i < argc; i++) { if (!(fp = fopen(argv[i], "r"))) err(1, "fopen: %s", argv[i]); name = ((name = strrchr(argv[i], '/'))) ? name + 1 : argv[i]; printfeed(fp, name); - if (ferror(fp)) - err(1, "ferror: %s", argv[i]); + checkfileerror(fp, argv[i], 'r'); fclose(fp); } } fputs("</feed>\n", stdout); + checkfileerror(stdout, "<stdout>", 'w'); + return 0; } |