summaryrefslogtreecommitdiff
path: root/sfeed_plain.c
diff options
context:
space:
mode:
Diffstat (limited to 'sfeed_plain.c')
-rw-r--r--sfeed_plain.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/sfeed_plain.c b/sfeed_plain.c
index df93a5a..adeefdb 100644
--- a/sfeed_plain.c
+++ b/sfeed_plain.c
@@ -1,5 +1,3 @@
-#include <sys/types.h>
-
#include <locale.h>
#include <stdio.h>
#include <string.h>
@@ -19,7 +17,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);
@@ -62,24 +61,24 @@ main(int argc, char *argv[])
if (pledge(argc == 1 ? "stdio" : "stdio rpath", NULL) == -1)
err(1, "pledge");
- if ((comparetime = time(NULL)) == -1)
- err(1, "time");
- /* 1 day is old news */
- comparetime -= 86400;
+ if ((comparetime = getcomparetime()) == (time_t)-1)
+ errx(1, "getcomparetime");
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;
}