summaryrefslogtreecommitdiffstats
path: root/mansearch.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2019-04-30 18:51:57 +0000
committerIngo Schwarze <schwarze@openbsd.org>2019-04-30 18:51:57 +0000
commitd756850b9bce47856068b05130c6277125b6f0a1 (patch)
tree7df759c59f9fe2bb9c502bad08c2b331ddb0d685 /mansearch.c
parentee0b68f80757c3f0a4e09e9fdbde02dcd76fa6e8 (diff)
downloadmandoc-d756850b9bce47856068b05130c6277125b6f0a1.tar.gz
In man(1) mode, i.e. when asking for a single manual page by name,
prefer file name matches over .Dt/.TH matches over first NAME matches over later NAME matches, but do not change the ordering for apropos(1) nor for man -a. This reverts main.c rev. 1.310 and mansearch.h rev. 1.29 and includes a partial revert of mansearch.c rev. 1.79. Regression reported by Lorenzo Beretta <loreb at github> as part of https://github.com/void-linux/void-packages/issues/9868 .
Diffstat (limited to 'mansearch.c')
-rw-r--r--mansearch.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/mansearch.c b/mansearch.c
index dfd1d39f..89601fde 100644
--- a/mansearch.c
+++ b/mansearch.c
@@ -199,6 +199,7 @@ mansearch(const struct mansearch *search,
}
mpage->names = buildnames(page);
mpage->output = buildoutput(outkey, page);
+ mpage->bits = search->firstmatch ? rp->bits : 0;
mpage->ipath = i;
mpage->sec = *page->sect - '0';
if (mpage->sec < 0 || mpage->sec > 9)
@@ -294,8 +295,10 @@ manmerge_term(struct expr *e, struct ohash *htab)
break;
slot = ohash_lookup_memory(htab,
(char *)&res, sizeof(res.page), res.page);
- if ((rp = ohash_find(htab, slot)) != NULL)
+ if ((rp = ohash_find(htab, slot)) != NULL) {
+ rp->bits |= res.bits;
continue;
+ }
rp = mandoc_malloc(sizeof(*rp));
*rp = res;
ohash_insert(htab, slot, rp);
@@ -408,7 +411,8 @@ manpage_compare(const void *vp1, const void *vp2)
mp1 = vp1;
mp2 = vp2;
- if ((diff = mp1->sec - mp2->sec))
+ if ((diff = mp2->bits - mp1->bits) ||
+ (diff = mp1->sec - mp2->sec))
return diff;
/* Fall back to alphabetic ordering of names. */