summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sfeed_frames.c22
-rw-r--r--sfeed_gopher.c31
-rw-r--r--sfeed_html.c24
-rw-r--r--sfeed_plain.c24
-rw-r--r--sfeed_twtxt.c16
5 files changed, 59 insertions, 58 deletions
diff --git a/sfeed_frames.c b/sfeed_frames.c
index 972f9ce..bb55c31 100644
--- a/sfeed_frames.c
+++ b/sfeed_frames.c
@@ -41,19 +41,19 @@ printfeed(FILE *fpitems, FILE *fpin, struct feed *f)
parseline(line, fields);
parsedtime = 0;
- if (strtotime(fields[FieldUnixTimestamp], &parsedtime))
- continue;
- if (!(tm = localtime(&parsedtime)))
- err(1, "localtime");
-
- isnew = (parsedtime >= comparetime) ? 1 : 0;
- totalnew += isnew;
- f->totalnew += isnew;
+ if (!strtotime(fields[FieldUnixTimestamp], &parsedtime) &&
+ (tm = localtime(&parsedtime))) {
+ isnew = (parsedtime >= comparetime) ? 1 : 0;
+ totalnew += isnew;
+ f->totalnew += isnew;
+ fprintf(fpitems, "%04d-%02d-%02d %02d:%02d ",
+ tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
+ tm->tm_hour, tm->tm_min);
+ } else {
+ fputs(" ", fpitems);
+ }
f->total++;
- fprintf(fpitems, "%04d-%02d-%02d %02d:%02d ",
- tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
- tm->tm_hour, tm->tm_min);
if (fields[FieldLink][0]) {
fputs("<a href=\"", fpitems);
xmlencode(fields[FieldLink], fpitems);
diff --git a/sfeed_gopher.c b/sfeed_gopher.c
index 74c0a71..0d5b0c9 100644
--- a/sfeed_gopher.c
+++ b/sfeed_gopher.c
@@ -55,16 +55,6 @@ printfeed(FILE *fpitems, FILE *fpin, struct feed *f)
line[--linelen] = '\0';
parseline(line, fields);
- parsedtime = 0;
- if (strtotime(fields[FieldUnixTimestamp], &parsedtime))
- continue;
- if (!(tm = localtime(&parsedtime)))
- err(1, "localtime");
-
- isnew = (parsedtime >= comparetime) ? 1 : 0;
- f->totalnew += isnew;
- f->total++;
-
itemhost = host;
itemport = port;
itemtype = 'i';
@@ -89,11 +79,22 @@ printfeed(FILE *fpitems, FILE *fpin, struct feed *f)
}
}
- fprintf(fpitems, "%c%c %04d-%02d-%02d %02d:%02d ",
- itemtype,
- isnew ? 'N' : ' ',
- tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
- tm->tm_hour, tm->tm_min);
+ parsedtime = 0;
+ if (!strtotime(fields[FieldUnixTimestamp], &parsedtime) &&
+ (tm = localtime(&parsedtime))) {
+ isnew = (parsedtime >= comparetime) ? 1 : 0;
+ f->totalnew += isnew;
+
+ fprintf(fpitems, "%c%c %04d-%02d-%02d %02d:%02d ",
+ itemtype,
+ isnew ? 'N' : ' ',
+ tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
+ tm->tm_hour, tm->tm_min);
+ } else {
+ fprintf(fpitems, "%c ", itemtype);
+ }
+ f->total++;
+
gophertext(fpitems, fields[FieldTitle]);
fputs("\t", fpitems);
if (itemtype == 'h' && fields[FieldLink] == itempath)
diff --git a/sfeed_html.c b/sfeed_html.c
index 97318af..42e6572 100644
--- a/sfeed_html.c
+++ b/sfeed_html.c
@@ -41,20 +41,20 @@ printfeed(FILE *fp, struct feed *f)
parseline(line, fields);
parsedtime = 0;
- if (strtotime(fields[FieldUnixTimestamp], &parsedtime))
- continue;
- if (!(tm = localtime(&parsedtime)))
- err(1, "localtime");
-
- isnew = (parsedtime >= comparetime) ? 1 : 0;
- totalnew += isnew;
- f->totalnew += isnew;
+ if (!strtotime(fields[FieldUnixTimestamp], &parsedtime) &&
+ (tm = localtime(&parsedtime))) {
+ isnew = (parsedtime >= comparetime) ? 1 : 0;
+ totalnew += isnew;
+ f->totalnew += isnew;
+
+ fprintf(stdout, "%04d-%02d-%02d&nbsp;%02d:%02d ",
+ tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
+ tm->tm_hour, tm->tm_min);
+ } else {
+ fputs(" ", stdout);
+ }
f->total++;
- fprintf(stdout, "%04d-%02d-%02d&nbsp;%02d:%02d ",
- tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
- tm->tm_hour, tm->tm_min);
-
if (fields[FieldLink][0]) {
fputs("<a href=\"", stdout);
xmlencode(fields[FieldLink], stdout);
diff --git a/sfeed_plain.c b/sfeed_plain.c
index 6dd3d5e..42f9626 100644
--- a/sfeed_plain.c
+++ b/sfeed_plain.c
@@ -26,19 +26,19 @@ printfeed(FILE *fp, const char *feedname)
parseline(line, fields);
parsedtime = 0;
- if (strtotime(fields[FieldUnixTimestamp], &parsedtime))
- continue;
- if (!(tm = localtime(&parsedtime)))
- err(1, "localtime");
-
- if (parsedtime >= comparetime)
- fputs("N ", stdout);
- else
- fputs(" ", stdout);
+ if (!strtotime(fields[FieldUnixTimestamp], &parsedtime) &&
+ (tm = localtime(&parsedtime))) {
+ if (parsedtime >= comparetime)
+ fputs("N ", stdout);
+ else
+ fputs(" ", stdout);
+ fprintf(stdout, "%04d-%02d-%02d %02d:%02d ",
+ tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
+ tm->tm_hour, tm->tm_min);
+ } else {
+ fputs(" ", stdout);
+ }
- fprintf(stdout, "%04d-%02d-%02d %02d:%02d ",
- tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
- tm->tm_hour, tm->tm_min);
if (feedname[0]) {
printutf8pad(stdout, feedname, 15, ' ');
fputs(" ", stdout);
diff --git a/sfeed_twtxt.c b/sfeed_twtxt.c
index 52281d2..2b171ba 100644
--- a/sfeed_twtxt.c
+++ b/sfeed_twtxt.c
@@ -24,14 +24,14 @@ printfeed(FILE *fp, const char *feedname)
parseline(line, fields);
parsedtime = 0;
- if (strtotime(fields[FieldUnixTimestamp], &parsedtime))
- continue;
- if (!(tm = gmtime(&parsedtime)))
- err(1, "gmtime");
-
- fprintf(stdout, "%04d-%02d-%02dT%02d:%02d:%02dZ\t",
- tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
- tm->tm_hour, tm->tm_min, tm->tm_sec);
+ if (!strtotime(fields[FieldUnixTimestamp], &parsedtime) &&
+ (tm = gmtime(&parsedtime))) {
+ fprintf(stdout, "%04d-%02d-%02dT%02d:%02d:%02dZ\t",
+ tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
+ tm->tm_hour, tm->tm_min, tm->tm_sec);
+ } else {
+ fputs("\t", stdout);
+ }
if (feedname[0])
printf("[%s] ", feedname);
fputs(fields[FieldTitle], stdout);