sfeed

simple feed reader - forked from git.codemadness.org/sfeed
git clone git://src.gearsix.net/sfeed
Log | Files | Refs | Atom | README | LICENSE

commit 389af9187013e76036e48369276582c55bcbc849
parent e9b8b6c62ac1a37f795259c979fa5fce4dd8ffdb
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sun, 10 Apr 2016 13:55:07 +0200

strtotime: improve

use long long: atleast 32-bit, but now time_t (real) to 32-bit or
64-bit is supported. Long long is C99 though, but that is fine.

check errno, it can have ERANGE.

Diffstat:
Msfeed.c | 2+-
Mutil.c | 6+++---
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/sfeed.c b/sfeed.c @@ -529,7 +529,7 @@ printfields(void) if (ctx.fields[FeedFieldTime].str.data) r = parsetime(ctx.fields[FeedFieldTime].str.data, &t); if (r != -1) - printf("%ld", (long)t); + printf("%lld", (long long)t); putchar(FieldSeparator); string_print_trimmed(&ctx.fields[FeedFieldTitle].str); putchar(FieldSeparator); diff --git a/util.c b/util.c @@ -218,12 +218,12 @@ parseline(char *line, char *fields[FieldLast]) int strtotime(const char *s, time_t *t) { - long l; + long long l; char *e; errno = 0; - l = strtol(s, &e, 10); - if (*s == '\0' || *e != '\0') + l = strtoll(s, &e, 10); + if (errno || *s == '\0' || *e) return -1; if (t) *t = (time_t)l;