git: 9146546eaee3 - main - locate statistics: show number of longest path in database

From: Wolfram Schneider <wosch_at_FreeBSD.org>
Date: Sat, 29 Jan 2022 07:14:01 UTC
The branch main has been updated by wosch:

URL: https://cgit.FreeBSD.org/src/commit/?id=9146546eaee3e04e0d77f42b3a4fe4cd207021c6

commit 9146546eaee3e04e0d77f42b3a4fe4cd207021c6
Author:     Wolfram Schneider <wosch@FreeBSD.org>
AuthorDate: 2022-01-29 07:13:28 +0000
Commit:     Wolfram Schneider <wosch@FreeBSD.org>
CommitDate: 2022-01-29 07:13:28 +0000

    locate statistics: show number of longest path in database
---
 usr.bin/locate/locate/fastfind.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/usr.bin/locate/locate/fastfind.c b/usr.bin/locate/locate/fastfind.c
index fdbbb1c3db18..4cae9381024d 100644
--- a/usr.bin/locate/locate/fastfind.c
+++ b/usr.bin/locate/locate/fastfind.c
@@ -47,7 +47,7 @@ statistic (fp, path_fcodes)
 	long lines, chars, size, big, zwerg, umlaut;
 	register u_char *p, *s;
 	register int c;
-	int count;
+	int count, longest_path;
 	int error = 0;
 	u_char bigram1[NBG], bigram2[NBG], path[MAXPATHLEN];
 
@@ -56,7 +56,7 @@ statistic (fp, path_fcodes)
 		s[c] = check_bigram_char(getc(fp));
 	}
 
-	lines = chars = big = zwerg = umlaut = 0;
+	lines = chars = big = zwerg = umlaut = longest_path = 0;
 	size = NBG + NBG;
 
 	for (c = getc(fp), count = 0; c != EOF; size++) {
@@ -91,6 +91,8 @@ statistic (fp, path_fcodes)
 		p++;
 		lines++;
 		chars += (p - path);
+		if ((p - path) > longest_path)
+			longest_path = p - path;
 	}
 
 	(void)printf("\nDatabase: %s\n", path_fcodes);
@@ -105,6 +107,7 @@ statistic (fp, path_fcodes)
 	(void)printf("Bigram characters: %ld, ", big);
 	(void)printf("Integers: %ld, ", zwerg);
 	(void)printf("8-Bit characters: %ld\n", umlaut);
+	printf("Longest path: %d\n", longest_path - 1);
 
 	/* non zero exit on corrupt database */
 	if (error)