Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/cvslatest give the absolute path for the error message.



details:   https://anonhg.NetBSD.org/src/rev/be77607f78fb
branches:  trunk
changeset: 820615:be77607f78fb
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Jan 12 14:27:14 2017 +0000

description:
give the absolute path for the error message.

diffstat:

 usr.bin/cvslatest/cvslatest.c |  36 +++++++++++++++++++-----------------
 1 files changed, 19 insertions(+), 17 deletions(-)

diffs (105 lines):

diff -r 5ea08d06c0ac -r be77607f78fb usr.bin/cvslatest/cvslatest.c
--- a/usr.bin/cvslatest/cvslatest.c     Thu Jan 12 14:24:53 2017 +0000
+++ b/usr.bin/cvslatest/cvslatest.c     Thu Jan 12 14:27:14 2017 +0000
@@ -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 @@
 }
 
 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 @@
                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 @@
        return;
                        
 mal:
-       errx(EXIT_FAILURE, "Malformed line in `%s'", name);
+       errx(EXIT_FAILURE, "Malformed line in `%s'", ename);
 }
 
 static void
@@ -153,8 +155,8 @@
                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);



Home | Main Index | Thread Index | Old Index