diff options
author | Benjamin Chausse <benjamin@chausse.xyz> | 2024-08-09 14:11:50 -0400 |
---|---|---|
committer | Benjamin Chausse <benjamin@chausse.xyz> | 2024-08-09 14:11:50 -0400 |
commit | 5857d82e8e596d6fda406a0c4d8d68ca7a03c124 (patch) | |
tree | 553916894dee907825360580c5d9a05c82c5af16 /sfeed_twtxt.c | |
parent | 3574e3cbf9d99546e868aeb995ce2c171cdc36a6 (diff) | |
parent | 19957bc272e745af7b56b79fa648e8b6b77113b1 (diff) |
Diffstat (limited to 'sfeed_twtxt.c')
-rw-r--r-- | sfeed_twtxt.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/sfeed_twtxt.c b/sfeed_twtxt.c index 6107fc7..1bb9d3b 100644 --- a/sfeed_twtxt.c +++ b/sfeed_twtxt.c @@ -1,5 +1,3 @@ -#include <sys/types.h> - #include <stdio.h> #include <string.h> #include <time.h> @@ -17,7 +15,8 @@ printfeed(FILE *fp, const char *feedname) time_t parsedtime; ssize_t linelen; - 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); @@ -54,17 +53,20 @@ 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'); + checkfileerror(stdout, "<stdout>", 'w'); fclose(fp); } } + checkfileerror(stdout, "<stdout>", 'w'); + return 0; } |