diff options
author | mikeh <mikeh@FreeBSD.org> | 2001-12-12 20:38:07 +0000 |
---|---|---|
committer | mikeh <mikeh@FreeBSD.org> | 2001-12-12 20:38:07 +0000 |
commit | 53b37471d409cd98e02a24d3938a654aab377d1e (patch) | |
tree | 4ebe34485b23934eb336d950519f90285f441f5b /usr.bin/locate | |
parent | e231bcb1896b8f1b7ffab6183958ab0496f9c726 (diff) | |
download | FreeBSD-src-53b37471d409cd98e02a24d3938a654aab377d1e.zip FreeBSD-src-53b37471d409cd98e02a24d3938a654aab377d1e.tar.gz |
Print the path with the shortest absolute length, rather than
arbitrarily selecting one.
PR: bin/14361
Approved by: wosch
MFC after: 1 week
Diffstat (limited to 'usr.bin/locate')
-rw-r--r-- | usr.bin/locate/locate/util.c | 7 |
1 files changed, 5 insertions, 2 deletions
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); } |