From b232db436b7b9343c336ef941c47cf8b107d1f7e Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Sun, 24 Dec 2017 12:58:44 +0100 Subject: format programs: ignore fields with an invalid time this makes sure tail -f with multiple files ignores the ==> file <== lines too. --- sfeed_frames.c | 3 ++- sfeed_gph.c | 3 ++- sfeed_html.c | 3 ++- sfeed_mbox.c | 3 ++- sfeed_plain.c | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/sfeed_frames.c b/sfeed_frames.c index 7df8528..34d6d4e 100644 --- a/sfeed_frames.c +++ b/sfeed_frames.c @@ -145,7 +145,8 @@ printfeed(FILE *fpitems, FILE *fpin, struct feed *f) break; parsedtime = 0; - strtotime(fields[FieldUnixTimestamp], &parsedtime); + if (strtotime(fields[FieldUnixTimestamp], &parsedtime)) + continue; if (!(tm = localtime(&parsedtime))) err(1, "localtime"); diff --git a/sfeed_gph.c b/sfeed_gph.c index addb457..df2b5b2 100644 --- a/sfeed_gph.c +++ b/sfeed_gph.c @@ -95,7 +95,8 @@ printfeed(FILE *fp, const char *feedname) break; parsedtime = 0; - strtotime(fields[FieldUnixTimestamp], &parsedtime); + if (strtotime(fields[FieldUnixTimestamp], &parsedtime)) + continue; if (!(tm = localtime(&parsedtime))) err(1, "localtime"); diff --git a/sfeed_html.c b/sfeed_html.c index 9ddc44f..bdeb3dc 100644 --- a/sfeed_html.c +++ b/sfeed_html.c @@ -39,7 +39,8 @@ printfeed(FILE *fp, struct feed *f) break; parsedtime = 0; - strtotime(fields[FieldUnixTimestamp], &parsedtime); + if (strtotime(fields[FieldUnixTimestamp], &parsedtime)) + continue; if (!(tm = localtime(&parsedtime))) err(1, "localtime"); diff --git a/sfeed_mbox.c b/sfeed_mbox.c index 9b9b5cf..995890b 100644 --- a/sfeed_mbox.c +++ b/sfeed_mbox.c @@ -125,7 +125,8 @@ printfeed(FILE *fp, const char *feedname) if (!parseline(line, fields)) break; parsedtime = 0; - strtotime(fields[FieldUnixTimestamp], &parsedtime); + if (strtotime(fields[FieldUnixTimestamp], &parsedtime)) + continue; /* can't convert: default to formatted time for time_t 0. */ if (!gmtime_r(&parsedtime, &tm) || !strftime(timebuf, sizeof(timebuf), diff --git a/sfeed_plain.c b/sfeed_plain.c index b88a776..b2f5236 100644 --- a/sfeed_plain.c +++ b/sfeed_plain.c @@ -27,7 +27,8 @@ printfeed(FILE *fp, const char *feedname) break; parsedtime = 0; - strtotime(fields[FieldUnixTimestamp], &parsedtime); + if (strtotime(fields[FieldUnixTimestamp], &parsedtime)) + continue; if (!(tm = localtime(&parsedtime))) err(1, "localtime"); -- cgit v1.2.3