CVS commit: src/usr.bin/cvslatest

2023-12-16 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Dec 16 14:32:33 UTC 2023

Modified Files:
src/usr.bin/cvslatest: cvslatest.1

Log Message:
cvslatest(1): remove RETURN VALUES

Pages in section one should use EXIT STATUS instead (which this one
already provides).

Closes PR 57778 by Kouichi Hashikawa


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/cvslatest/cvslatest.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/cvslatest

2023-12-16 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Dec 16 14:32:33 UTC 2023

Modified Files:
src/usr.bin/cvslatest: cvslatest.1

Log Message:
cvslatest(1): remove RETURN VALUES

Pages in section one should use EXIT STATUS instead (which this one
already provides).

Closes PR 57778 by Kouichi Hashikawa


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/cvslatest/cvslatest.1

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.1
diff -u src/usr.bin/cvslatest/cvslatest.1:1.1 src/usr.bin/cvslatest/cvslatest.1:1.2
--- src/usr.bin/cvslatest/cvslatest.1:1.1	Sun Jan 24 17:08:16 2016
+++ src/usr.bin/cvslatest/cvslatest.1	Sat Dec 16 14:32:33 2023
@@ -1,4 +1,4 @@
-.\" $NetBSD: cvslatest.1,v 1.1 2016/01/24 17:08:16 christos Exp $
+.\" $NetBSD: cvslatest.1,v 1.2 2023/12/16 14:32:33 wiz Exp $
 .\" Copyright (C) 2015 Thomas Klausner
 .\"
 .\" Redistribution and use in source and binary forms, with or without
@@ -23,7 +23,7 @@
 .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd January 7, 2016
+.Dd December 16, 2023
 .Dt CVSLATEST 1
 .Os
 .Sh NAME
@@ -70,7 +70,5 @@ information directory.
 .Sh SEE ALSO
 .Xr cvs 1 ,
 .Xr date 1
-.Sh RETURN VALUES
-.Ex -std
 .Sh AUTHORS
 .An Christos Zoulas Aq Mt chris...@netbsd.org



CVS commit: src/usr.bin/cvslatest

2023-03-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Mar  7 21:24:19 UTC 2023

Modified Files:
src/usr.bin/cvslatest: cvslatest.c

Log Message:
simplify previous


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 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.10 src/usr.bin/cvslatest/cvslatest.c:1.11
--- src/usr.bin/cvslatest/cvslatest.c:1.10	Wed Feb 15 12:00:24 2023
+++ src/usr.bin/cvslatest/cvslatest.c	Tue Mar  7 16:24:19 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: cvslatest.c,v 1.10 2023/02/15 17:00:24 martin Exp $	*/
+/*	$NetBSD: cvslatest.c,v 1.11 2023/03/07 21:24:19 christos Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: cvslatest.c,v 1.10 2023/02/15 17:00:24 martin Exp $");
+__RCSID("$NetBSD: cvslatest.c,v 1.11 2023/03/07 21:24:19 christos Exp $");
 
 /*
  * Find the latest timestamp in a set of CVS trees, by examining the
@@ -92,6 +92,13 @@ getrepo(const FTSENT *e, char *repo, siz
 }
 
 static void
+notimestamp(const char *fn, const char *ename, int uncommitted)
+{
+	warnx("Can't get timestamp from %s file `%s' in `%s'",
+	uncommitted ? "uncommitted" : "locally modified", fn, ename);
+}
+
+static void
 getlatest(const FTSENT *e, const char *repo, struct latest *lat)
 {
 	static const char fmt[] = "%a %b %d %H:%M:%S %Y";
@@ -117,28 +124,14 @@ getlatest(const FTSENT *e, const char *r
 			goto mal;
 		if ((dt = strtok(NULL, "/")) == NULL)
 			goto mal;
-		if (strcmp(dt, "dummy timestamp") == 0) {
-			warnx("Can't get timestamp from uncommitted file %s in `%s'",
-			fn, ename);
-			if (!ignore)
-exit(EXIT_FAILURE);
-			continue;
-		}
-		/*
-		 * This may not be visible in real world, but the cvs code
-		 * has paths that would create this string (mabe server
-		 * side only?)
-		 */
-		if (strcmp(dt, "dummy timestamp from new-entry") == 0) {
-			warnx("Can't get timestamp from uncommitted file %s in `%s'",
-			fn, ename);
+		if (strncmp(dt, "dummy timestamp", 14) == 0) {
+			notimestamp(fn, ename, 1);
 			if (!ignore)
 exit(EXIT_FAILURE);
 			continue;
 		}
 		if (strcmp(dt, "Result of merge") == 0) {
-			warnx("Can't get cvs timestamp for localy modified file %s in `%s', using modification time.",
-			fn, ename);
+			notimestamp(fn, ename, 0);
 			if (fstat(fileno(fp), ) == 0) {
 t = sb.st_mtime;
 goto compare;



CVS commit: src/usr.bin/cvslatest

2023-03-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Mar  7 21:24:19 UTC 2023

Modified Files:
src/usr.bin/cvslatest: cvslatest.c

Log Message:
simplify previous


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 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.



CVS commit: src/usr.bin/cvslatest

2023-02-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 15 17:00:24 UTC 2023

Modified Files:
src/usr.bin/cvslatest: cvslatest.c

Log Message:
While this is not intended to be used on unclean checkouts, improve
diagnostics if it happens.
Add another variant of a "new entry" dummy timestamp found in the
cvs code (but not seen in checkouts in the wild).


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 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.



CVS commit: src/usr.bin/cvslatest

2023-02-15 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Feb 15 17:00:24 UTC 2023

Modified Files:
src/usr.bin/cvslatest: cvslatest.c

Log Message:
While this is not intended to be used on unclean checkouts, improve
diagnostics if it happens.
Add another variant of a "new entry" dummy timestamp found in the
cvs code (but not seen in checkouts in the wild).


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 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.9 src/usr.bin/cvslatest/cvslatest.c:1.10
--- src/usr.bin/cvslatest/cvslatest.c:1.9	Tue Nov  3 22:21:43 2020
+++ src/usr.bin/cvslatest/cvslatest.c	Wed Feb 15 17:00:24 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: cvslatest.c,v 1.9 2020/11/03 22:21:43 christos Exp $	*/
+/*	$NetBSD: cvslatest.c,v 1.10 2023/02/15 17:00:24 martin Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: cvslatest.c,v 1.9 2020/11/03 22:21:43 christos Exp $");
+__RCSID("$NetBSD: cvslatest.c,v 1.10 2023/02/15 17:00:24 martin Exp $");
 
 /*
  * Find the latest timestamp in a set of CVS trees, by examining the
@@ -47,6 +47,7 @@ __RCSID("$NetBSD: cvslatest.c,v 1.9 2020
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -99,6 +100,7 @@ getlatest(const FTSENT *e, const char *r
 	char *fn, *dt, *p;
 	time_t t;
 	struct tm tm;
+	struct stat sb;
 	FILE *fp;
 
 	snprintf(name, sizeof(name), "%s/Entries", e->fts_accpath);
@@ -116,8 +118,31 @@ getlatest(const FTSENT *e, const char *r
 		if ((dt = strtok(NULL, "/")) == NULL)
 			goto mal;
 		if (strcmp(dt, "dummy timestamp") == 0) {
-			warnx("Can't get timestamp from uncommitted file `%s'",
-			ename);
+			warnx("Can't get timestamp from uncommitted file %s in `%s'",
+			fn, ename);
+			if (!ignore)
+exit(EXIT_FAILURE);
+			continue;
+		}
+		/*
+		 * This may not be visible in real world, but the cvs code
+		 * has paths that would create this string (mabe server
+		 * side only?)
+		 */
+		if (strcmp(dt, "dummy timestamp from new-entry") == 0) {
+			warnx("Can't get timestamp from uncommitted file %s in `%s'",
+			fn, ename);
+			if (!ignore)
+exit(EXIT_FAILURE);
+			continue;
+		}
+		if (strcmp(dt, "Result of merge") == 0) {
+			warnx("Can't get cvs timestamp for localy modified file %s in `%s', using modification time.",
+			fn, ename);
+			if (fstat(fileno(fp), ) == 0) {
+t = sb.st_mtime;
+goto compare;
+			}
 			if (!ignore)
 exit(EXIT_FAILURE);
 			continue;
@@ -132,6 +157,7 @@ getlatest(const FTSENT *e, const char *r
 		if ((t = mktime()) == (time_t)-1)
 			errx(EXIT_FAILURE, "Time conversion `%s' in `%s'",
 			dt, ename);
+compare:
 		if (lat->time == 0 || lat->time < t) {
 			lat->time = t;
 			snprintf(lat->path, sizeof(lat->path),



CVS commit: src/usr.bin/cvslatest

2020-11-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Nov  3 22:21:44 UTC 2020

Modified Files:
src/usr.bin/cvslatest: cvslatest.c

Log Message:
Handle dummy timestamp better and check for I/O errors. From khorben@


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 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.



CVS commit: src/usr.bin/cvslatest

2020-11-03 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Nov  3 22:21:44 UTC 2020

Modified Files:
src/usr.bin/cvslatest: cvslatest.c

Log Message:
Handle dummy timestamp better and check for I/O errors. From khorben@


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 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.8 src/usr.bin/cvslatest/cvslatest.c:1.9
--- src/usr.bin/cvslatest/cvslatest.c:1.8	Sat Mar  9 11:18:22 2019
+++ src/usr.bin/cvslatest/cvslatest.c	Tue Nov  3 17:21:43 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cvslatest.c,v 1.8 2019/03/09 16:18:22 christos Exp $	*/
+/*	$NetBSD: cvslatest.c,v 1.9 2020/11/03 22:21:43 christos Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: cvslatest.c,v 1.8 2019/03/09 16:18:22 christos Exp $");
+__RCSID("$NetBSD: cvslatest.c,v 1.9 2020/11/03 22:21:43 christos Exp $");
 
 /*
  * Find the latest timestamp in a set of CVS trees, by examining the
@@ -115,10 +115,18 @@ getlatest(const FTSENT *e, const char *r
 			goto mal;
 		if ((dt = strtok(NULL, "/")) == NULL)
 			goto mal;
+		if (strcmp(dt, "dummy timestamp") == 0) {
+			warnx("Can't get timestamp from uncommitted file `%s'",
+			ename);
+			if (!ignore)
+exit(EXIT_FAILURE);
+			continue;
+		}
 		if ((p = strptime(dt, fmt, )) == NULL || *p) {
 			warnx("Malformed time `%s' in `%s'", dt, ename);
 			if (!ignore)
 exit(EXIT_FAILURE);
+			continue;
 		}
 		tm.tm_isdst = 0;	// We are in GMT anyway
 		if ((t = mktime()) == (time_t)-1)
@@ -132,6 +140,8 @@ getlatest(const FTSENT *e, const char *r
 printlat(lat);
 		}
 	}
+	if (ferror(fp))
+		err(EXIT_FAILURE, "Can't read `%s'", ename);
 
 	fclose(fp);
 	return;



CVS commit: src/usr.bin/cvslatest

2019-03-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar  9 16:18:22 UTC 2019

Modified Files:
src/usr.bin/cvslatest: Makefile cvslatest.c

Log Message:
Fix another bug found by jemalloc: don't access dirent entry after closedir(3).


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/cvslatest/Makefile
cvs rdiff -u -r1.7 -r1.8 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/Makefile
diff -u src/usr.bin/cvslatest/Makefile:1.1 src/usr.bin/cvslatest/Makefile:1.2
--- src/usr.bin/cvslatest/Makefile:1.1	Sun Jan 24 12:08:16 2016
+++ src/usr.bin/cvslatest/Makefile	Sat Mar  9 11:18:22 2019
@@ -1,6 +1,7 @@
-#	$NetBSD: Makefile,v 1.1 2016/01/24 17:08:16 christos Exp $
+#	$NetBSD: Makefile,v 1.2 2019/03/09 16:18:22 christos Exp $
 
 WARNS=6
 PROG=	cvslatest
+DBG=-g
 
 .include 

Index: src/usr.bin/cvslatest/cvslatest.c
diff -u src/usr.bin/cvslatest/cvslatest.c:1.7 src/usr.bin/cvslatest/cvslatest.c:1.8
--- src/usr.bin/cvslatest/cvslatest.c:1.7	Sun Mar 11 10:59:41 2018
+++ src/usr.bin/cvslatest/cvslatest.c	Sat Mar  9 11:18:22 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: cvslatest.c,v 1.7 2018/03/11 14:59:41 christos Exp $	*/
+/*	$NetBSD: cvslatest.c,v 1.8 2019/03/09 16:18:22 christos Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: cvslatest.c,v 1.7 2018/03/11 14:59:41 christos Exp $");
+__RCSID("$NetBSD: cvslatest.c,v 1.8 2019/03/09 16:18:22 christos Exp $");
 
 /*
  * Find the latest timestamp in a set of CVS trees, by examining the
@@ -212,8 +212,8 @@ findCVSDir(char *path, size_t pathlen, c
 	}
 	n = "CVS";
 out:
-	closedir(dirp);
 	strlcpy(path, n, pathlen);
+	closedir(dirp);
 	return path;
 }
 



CVS commit: src/usr.bin/cvslatest

2019-03-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar  9 16:18:22 UTC 2019

Modified Files:
src/usr.bin/cvslatest: Makefile cvslatest.c

Log Message:
Fix another bug found by jemalloc: don't access dirent entry after closedir(3).


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/cvslatest/Makefile
cvs rdiff -u -r1.7 -r1.8 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.



CVS commit: src/usr.bin/cvslatest

2019-03-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar  9 16:18:37 UTC 2019

Modified Files:
src/usr.bin/cvslatest: Makefile

Log Message:
no -g


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/cvslatest/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/cvslatest

2019-03-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar  9 16:18:37 UTC 2019

Modified Files:
src/usr.bin/cvslatest: Makefile

Log Message:
no -g


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/cvslatest/Makefile

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/Makefile
diff -u src/usr.bin/cvslatest/Makefile:1.2 src/usr.bin/cvslatest/Makefile:1.3
--- src/usr.bin/cvslatest/Makefile:1.2	Sat Mar  9 11:18:22 2019
+++ src/usr.bin/cvslatest/Makefile	Sat Mar  9 11:18:37 2019
@@ -1,7 +1,6 @@
-#	$NetBSD: Makefile,v 1.2 2019/03/09 16:18:22 christos Exp $
+#	$NetBSD: Makefile,v 1.3 2019/03/09 16:18:37 christos Exp $
 
 WARNS=6
 PROG=	cvslatest
-DBG=-g
 
 .include 



CVS commit: src/usr.bin/cvslatest

2018-03-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar 11 14:59:41 UTC 2018

Modified Files:
src/usr.bin/cvslatest: cvslatest.c

Log Message:
deal with cvs meta-data directories not called CVS.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 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.6 src/usr.bin/cvslatest/cvslatest.c:1.7
--- src/usr.bin/cvslatest/cvslatest.c:1.6	Sun Sep 24 05:43:27 2017
+++ src/usr.bin/cvslatest/cvslatest.c	Sun Mar 11 10:59:41 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cvslatest.c,v 1.6 2017/09/24 09:43:27 joerg Exp $	*/
+/*	$NetBSD: cvslatest.c,v 1.7 2018/03/11 14:59:41 christos Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: cvslatest.c,v 1.6 2017/09/24 09:43:27 joerg Exp $");
+__RCSID("$NetBSD: cvslatest.c,v 1.7 2018/03/11 14:59:41 christos Exp $");
 
 /*
  * Find the latest timestamp in a set of CVS trees, by examining the
@@ -52,6 +52,7 @@ __RCSID("$NetBSD: cvslatest.c,v 1.6 2017
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -174,11 +175,55 @@ usage(void)
 	exit(EXIT_FAILURE);
 }
 
+static int
+checkDir(char *path, size_t pathlen, const char *name)
+{
+	static const char *files[] = {
+		"Entries", "Root", "Repository",
+	};
+	size_t i;
+
+	for (i = 0; i < __arraycount(files); i++) {
+		snprintf(path, pathlen, "%s/%s", name, files[i]);
+		if (access(path, F_OK) == -1)
+			return 0;
+	}
+
+	return 1;
+}
+
+static const char *
+findCVSDir(char *path, size_t pathlen, const char *name)
+{
+	DIR *dirp;
+	struct dirent *dp;
+	const char *n;
+
+	if ((dirp = opendir(name)) == NULL)
+		err(EXIT_FAILURE, "Can't open `%s'", name);
+
+	while ((dp = readdir(dirp)) != NULL) {
+		n = dp->d_name;
+		if (n[0] == '.' && (n[1] == '\0' ||
+		(n[1] == '.' && n[2] == '\0')))
+			continue;
+		if (checkDir(path, pathlen, n))
+			goto out;
+	}
+	n = "CVS";
+out:
+	closedir(dirp);
+	strlcpy(path, n, pathlen);
+	return path;
+}
+
+
 int
 main(int argc, char *argv[])
 {
 	struct latest lat;
-	const char *name = "CVS";
+	const char *name = NULL;
+	char path[MAXPATHLEN];
 	int c;
 
 	while ((c = getopt(argc, argv, "din:")) != -1)
@@ -202,6 +247,9 @@ main(int argc, char *argv[])
 	// So that mktime behaves consistently
 	setenv("TZ", "UTC", 1);
 
+	if (name == NULL)
+		name = findCVSDir(path, sizeof(path), argv[optind]);
+
 	cvsscan(argv + optind, name, );
 	if (debug)
 		printlat();



CVS commit: src/usr.bin/cvslatest

2018-03-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar 11 14:59:41 UTC 2018

Modified Files:
src/usr.bin/cvslatest: cvslatest.c

Log Message:
deal with cvs meta-data directories not called CVS.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 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.



CVS commit: src/usr.bin/cvslatest

2017-09-24 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sun Sep 24 09:43:27 UTC 2017

Modified Files:
src/usr.bin/cvslatest: cvslatest.c

Log Message:
Force _GNU_SOURCE on Linux, otherwise strptime is not defined and more
restrictive macros result in even nastier fallout.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 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.5 src/usr.bin/cvslatest/cvslatest.c:1.6
--- src/usr.bin/cvslatest/cvslatest.c:1.5	Thu Jan 12 14:27:14 2017
+++ src/usr.bin/cvslatest/cvslatest.c	Sun Sep 24 09:43:27 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cvslatest.c,v 1.5 2017/01/12 14:27:14 christos Exp $	*/
+/*	$NetBSD: cvslatest.c,v 1.6 2017/09/24 09:43:27 joerg Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -29,12 +29,16 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#ifdef __linux__
+#define _GNU_SOURCE
+#endif
+
 #ifdef HAVE_NBTOOL_CONFIG_H
 #include "nbtool_config.h"
 #endif
 
 #include 
-__RCSID("$NetBSD: cvslatest.c,v 1.5 2017/01/12 14:27:14 christos Exp $");
+__RCSID("$NetBSD: cvslatest.c,v 1.6 2017/09/24 09:43:27 joerg Exp $");
 
 /*
  * Find the latest timestamp in a set of CVS trees, by examining the



CVS commit: src/usr.bin/cvslatest

2017-09-24 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sun Sep 24 09:43:27 UTC 2017

Modified Files:
src/usr.bin/cvslatest: cvslatest.c

Log Message:
Force _GNU_SOURCE on Linux, otherwise strptime is not defined and more
restrictive macros result in even nastier fallout.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 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.



CVS commit: src/usr.bin/cvslatest

2017-01-12 Thread Christos Zoulas
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 
-__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, )) == 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()) == (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);



CVS commit: src/usr.bin/cvslatest

2017-01-12 Thread Christos Zoulas
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.



CVS commit: src/usr.bin/cvslatest

2016-12-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Dec 26 14:53:17 UTC 2016

Modified Files:
src/usr.bin/cvslatest: cvslatest.c

Log Message:
- use UTC
- initialize tm_isdst
- use accpath to handle relative paths


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 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.3 src/usr.bin/cvslatest/cvslatest.c:1.4
--- src/usr.bin/cvslatest/cvslatest.c:1.3	Sun Dec 18 20:48:00 2016
+++ src/usr.bin/cvslatest/cvslatest.c	Mon Dec 26 09:53:17 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: cvslatest.c,v 1.3 2016/12/19 01:48:00 christos Exp $	*/
+/*	$NetBSD: cvslatest.c,v 1.4 2016/12/26 14:53:17 christos Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: cvslatest.c,v 1.3 2016/12/19 01:48:00 christos Exp $");
+__RCSID("$NetBSD: cvslatest.c,v 1.4 2016/12/26 14:53:17 christos Exp $");
 
 /*
  * Find the latest timestamp in a set of CVS trees, by examining the
@@ -113,6 +113,7 @@ getlatest(const char *path, const char *
 			if (!ignore)
 exit(EXIT_FAILURE);
 		}
+		tm.tm_isdst = 0;	// We are in GMT anyway
 		if ((t = mktime()) == (time_t)-1)
 			errx(EXIT_FAILURE, "Time conversion `%s' in `%s'",
 			dt, name);
@@ -152,8 +153,8 @@ cvsscan(char **pathv, const char *name, 
 		if (strcmp(entry->fts_name, name) != 0)
 continue;
 
-		getrepo(entry->fts_path, repo, sizeof(repo));
-		getlatest(entry->fts_path, repo, lat);
+		getrepo(entry->fts_accpath, repo, sizeof(repo));
+		getlatest(entry->fts_accpath, repo, lat);
 }
 
 (void)fts_close(dh);
@@ -192,6 +193,9 @@ main(int argc, char *argv[])
 	if (argc == optind)
 		usage();
 
+	// So that mktime behaves consistently
+	setenv("TZ", "UTC", 1);
+
 	cvsscan(argv + optind, name, );
 	if (debug)
 		printlat();



CVS commit: src/usr.bin/cvslatest

2016-12-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Dec 26 14:53:17 UTC 2016

Modified Files:
src/usr.bin/cvslatest: cvslatest.c

Log Message:
- use UTC
- initialize tm_isdst
- use accpath to handle relative paths


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 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.



CVS commit: src/usr.bin/cvslatest

2016-12-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Dec 19 01:48:00 UTC 2016

Modified Files:
src/usr.bin/cvslatest: cvslatest.c

Log Message:
print only the latest entry for debugging.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 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.



CVS commit: src/usr.bin/cvslatest

2016-12-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Dec 19 01:48:00 UTC 2016

Modified Files:
src/usr.bin/cvslatest: cvslatest.c

Log Message:
print only the latest entry for debugging.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 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.2 src/usr.bin/cvslatest/cvslatest.c:1.3
--- src/usr.bin/cvslatest/cvslatest.c:1.2	Sun Jan 24 15:14:44 2016
+++ src/usr.bin/cvslatest/cvslatest.c	Sun Dec 18 20:48:00 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: cvslatest.c,v 1.2 2016/01/24 20:14:44 christos Exp $	*/
+/*	$NetBSD: cvslatest.c,v 1.3 2016/12/19 01:48:00 christos Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: cvslatest.c,v 1.2 2016/01/24 20:14:44 christos Exp $");
+__RCSID("$NetBSD: cvslatest.c,v 1.3 2016/12/19 01:48:00 christos Exp $");
 
 /*
  * Find the latest timestamp in a set of CVS trees, by examining the
@@ -120,7 +120,7 @@ getlatest(const char *path, const char *
 			lat->time = t;
 			snprintf(lat->path, sizeof(lat->path),
 			"%s/%s", repo, fn);
-			if (debug)
+			if (debug > 1)
 printlat(lat);
 		}
 	}



CVS commit: src/usr.bin/cvslatest

2016-01-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 24 20:14:44 UTC 2016

Modified Files:
src/usr.bin/cvslatest: cvslatest.c

Log Message:
Toolify


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 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.