From 53b37471d409cd98e02a24d3938a654aab377d1e Mon Sep 17 00:00:00 2001 From: mikeh Date: Wed, 12 Dec 2001 20:38:07 +0000 Subject: Print the path with the shortest absolute length, rather than arbitrarily selecting one. PR: bin/14361 Approved by: wosch MFC after: 1 week --- usr.bin/locate/locate/util.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'usr.bin/locate') diff --git a/usr.bin/locate/locate/util.c b/usr.bin/locate/locate/util.c index 38fe284..feaa32a 100644 --- a/usr.bin/locate/locate/util.c +++ b/usr.bin/locate/locate/util.c @@ -241,7 +241,8 @@ getwm(p) if (i > MAXPATHLEN || i < -(MAXPATHLEN)) { i = ntohl(i); if (i > MAXPATHLEN || i < -(MAXPATHLEN)) - errx(1, "integer out of +-MAXPATHLEN (%d): %d", MAXPATHLEN, i); + errx(1, "integer out of +-MAXPATHLEN (%d): %d", + MAXPATHLEN, abs(i) < abs(htonl(i)) ? i : htonl(i)); } return(i); } @@ -265,7 +266,9 @@ getwf(fp) if (word > MAXPATHLEN || word < -(MAXPATHLEN)) { word = ntohl(word); if (word > MAXPATHLEN || word < -(MAXPATHLEN)) - errx(1, "integer out of +-MAXPATHLEN (%d): %d", MAXPATHLEN, word); + errx(1, "integer out of +-MAXPATHLEN (%d): %d", + MAXPATHLEN, abs(word) < abs(htonl(word)) ? word : + htonl(word)); } return(word); } -- cgit v1.1