dag

Djmoch's Auto Generator
git clone git://git.danielmoch.com/dag.git
Log | Files | Refs | README | LICENSE

commit 52bc15ac170019d624d8ab1934fe1c2a68ad8fe7
parent a6a94c246b19a4197ce13e42bda86d64a049b7fe
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Sun, 14 Nov 2021 07:35:58 -0500

Fix date detection

Diffstat:
Mdagindex.c | 6++++++
Mdb.c | 4++--
2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/dagindex.c b/dagindex.c @@ -2,6 +2,7 @@ #include <err.h> #include <errno.h> #include <libgen.h> +#include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -85,8 +86,13 @@ populate_time(char *time_str) { struct tm time_tm; time_t time = 0; + char *ep; if (time_str) { + time = strtoll(time_str, &ep, 10); + if (time_str[0] != '\0' && *ep == '\0') { + return time; + } if (strptime(time_str, "%F %T UTC%z", &time_tm) == NULL) { err(ERR_TIME, "call to strptime failed"); } diff --git a/db.c b/db.c @@ -48,8 +48,8 @@ db_index_open(const char *db_path) goto exit; } - if (sb.st_mode | S_IFDIR) { - errx("%s is a directory", db_path); + if (sb.st_mode & S_IFDIR) { + errx(1, "%s is a directory", db_path); } if ((cur_entry = getentry(fp)) == NULL) {