dag

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

commit 26c02c827de83b4505cbd26acc95f2695fd68d0c
parent 295660af94b1caa0729fe16a554f464faa674a4b
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Sun, 18 Sep 2022 06:32:44 -0400

Use err/x correctly

Diffstat:
Mdag.c | 6++----
Mdagfile.c | 4++--
Mdagindex.c | 6+++---
3 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/dag.c b/dag.c @@ -80,12 +80,10 @@ main(int argc, char **argv) } #endif if ((df = fopen(path, "r")) == NULL) { - fprintf(stderr, "%s: error opening %s\n", argv0, path); - exit(ERR_FILE); + errx(ERR_FILE, "%s: error opening %s", argv0, path); } if ((dagfile = parse_dagfile(df)) == NULL) { - fprintf(stderr, "%s: error parsing %s\n", argv0, path); - exit(ERR_PARSE); + errx(ERR_PARSE, "%s: error parsing %s", argv0, path); } fclose(df); if (verbose) { diff --git a/dagfile.c b/dagfile.c @@ -42,7 +42,7 @@ process_dagfile(struct dagfile *df) while (src != NULL && path[0] != NULL) { src_tree = fts_open(path, FTS_LOGICAL, NULL); if (src_tree == NULL) { - err(1, "call to fts_open() failed -- %d\n", errno); + err(errno, "call to fts_open() failed:"); } while ((entry = fts_read(src_tree)) != NULL) { @@ -52,7 +52,7 @@ process_dagfile(struct dagfile *df) } if (errno != 0) { - err(1, "error occurred walking file tree -- %d\n", errno); + err(errno, "error occurred walking file tree:"); } fts_close(src_tree); diff --git a/dagindex.c b/dagindex.c @@ -95,12 +95,12 @@ populate_time(char *time_str) 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"); + if (strptime(time_str, "%Y-%m-%d %T", &time_tm) == NULL) { + errx(ERR_TIME, "call to strptime failed"); } if ((time = mktime(&time_tm)) == -1) { - err(ERR_TIME, "call to mktime failed"); + errx(ERR_TIME, "call to mktime failed"); } }