Module Name: src Committed By: christos Date: Thu Jan 12 14:27:14 UTC 2017
Modified Files: src/usr.bin/cvslatest: cvslatest.c Log Message: give the absolute path for the error message. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.bin/cvslatest/cvslatest.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/cvslatest/cvslatest.c diff -u src/usr.bin/cvslatest/cvslatest.c:1.4 src/usr.bin/cvslatest/cvslatest.c:1.5 --- src/usr.bin/cvslatest/cvslatest.c:1.4 Mon Dec 26 09:53:17 2016 +++ src/usr.bin/cvslatest/cvslatest.c Thu Jan 12 09:27:14 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: cvslatest.c,v 1.4 2016/12/26 14:53:17 christos Exp $ */ +/* $NetBSD: cvslatest.c,v 1.5 2017/01/12 14:27:14 christos Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ #endif #include <sys/cdefs.h> -__RCSID("$NetBSD: cvslatest.c,v 1.4 2016/12/26 14:53:17 christos Exp $"); +__RCSID("$NetBSD: cvslatest.c,v 1.5 2017/01/12 14:27:14 christos Exp $"); /* * Find the latest timestamp in a set of CVS trees, by examining the @@ -67,37 +67,39 @@ printlat(const struct latest *lat) } static void -getrepo(const char *path, char *repo, size_t maxrepo) +getrepo(const FTSENT *e, char *repo, size_t maxrepo) { FILE *fp; - char name[MAXPATHLEN]; + char name[MAXPATHLEN], ename[MAXPATHLEN]; char *ptr; - snprintf(name, sizeof(name), "%s/Repository", path); + snprintf(name, sizeof(name), "%s/Repository", e->fts_accpath); + snprintf(ename, sizeof(ename), "%s/Repository", e->fts_path); if ((fp = fopen(name, "r")) == NULL) - err(EXIT_FAILURE, "Can't open `%s'", name); + err(EXIT_FAILURE, "Can't open `%s'", ename); if (fgets(repo, (int)maxrepo, fp) == NULL) - err(EXIT_FAILURE, "Can't read `%s'", name); + err(EXIT_FAILURE, "Can't read `%s'", ename); if ((ptr = strchr(repo, '\n')) == NULL) - errx(EXIT_FAILURE, "Malformed line in `%s'", name); + errx(EXIT_FAILURE, "Malformed line in `%s'", ename); *ptr = '\0'; fclose(fp); } static void -getlatest(const char *path, const char *repo, struct latest *lat) +getlatest(const FTSENT *e, const char *repo, struct latest *lat) { static const char fmt[] = "%a %b %d %H:%M:%S %Y"; - char name[MAXPATHLEN]; + char name[MAXPATHLEN], ename[MAXPATHLEN]; char entry[MAXPATHLEN * 2]; char *fn, *dt, *p; time_t t; struct tm tm; FILE *fp; - snprintf(name, sizeof(name), "%s/Entries", path); + snprintf(name, sizeof(name), "%s/Entries", e->fts_accpath); + snprintf(ename, sizeof(ename), "%s/Entries", e->fts_path); if ((fp = fopen(name, "r")) == NULL) - err(EXIT_FAILURE, "Can't open `%s'", name); + err(EXIT_FAILURE, "Can't open `%s'", ename); while (fgets(entry, (int)sizeof(entry), fp) != NULL) { if (entry[0] != '/') @@ -109,14 +111,14 @@ getlatest(const char *path, const char * if ((dt = strtok(NULL, "/")) == NULL) goto mal; if ((p = strptime(dt, fmt, &tm)) == NULL || *p) { - warnx("Malformed time `%s' in `%s'", dt, name); + warnx("Malformed time `%s' in `%s'", dt, ename); if (!ignore) exit(EXIT_FAILURE); } tm.tm_isdst = 0; // We are in GMT anyway if ((t = mktime(&tm)) == (time_t)-1) errx(EXIT_FAILURE, "Time conversion `%s' in `%s'", - dt, name); + dt, ename); if (lat->time == 0 || lat->time < t) { lat->time = t; snprintf(lat->path, sizeof(lat->path), @@ -130,7 +132,7 @@ getlatest(const char *path, const char * return; mal: - errx(EXIT_FAILURE, "Malformed line in `%s'", name); + errx(EXIT_FAILURE, "Malformed line in `%s'", ename); } static void @@ -153,8 +155,8 @@ cvsscan(char **pathv, const char *name, if (strcmp(entry->fts_name, name) != 0) continue; - getrepo(entry->fts_accpath, repo, sizeof(repo)); - getlatest(entry->fts_accpath, repo, lat); + getrepo(entry, repo, sizeof(repo)); + getlatest(entry, repo, lat); } (void)fts_close(dh);