From 389af9187013e76036e48369276582c55bcbc849 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Sun, 10 Apr 2016 13:55:07 +0200 Subject: 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. --- util.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'util.c') diff --git a/util.c b/util.c index 535e012..b75c88c 100644 --- 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; -- cgit v1.2.3