diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2019-04-30 18:48:27 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2019-04-30 18:48:27 +0000 |
commit | 799b52443c6f6334c88bf35a88b8f600052b3568 (patch) | |
tree | 3a22927b22edd7aee5552bcdcd1d6d4f86db4977 | |
parent | 4b8312b0d1979ecf033be8a3607fe52e95221790 (diff) |
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.213 and mansearch.h rev. 1.23
and includes a partial revert of mansearch.c rev. 1.62.
Regression reported by Lorenzo Beretta <loreb at github>
as part of https://github.com/void-linux/void-packages/issues/9868 .
-rw-r--r-- | usr.bin/mandoc/main.c | 4 | ||||
-rw-r--r-- | usr.bin/mandoc/mansearch.c | 10 | ||||
-rw-r--r-- | usr.bin/mandoc/mansearch.h | 3 |
3 files changed, 12 insertions, 5 deletions
diff --git a/usr.bin/mandoc/main.c b/usr.bin/mandoc/main.c index cb2487a916f..eb582df2b38 100644 --- a/usr.bin/mandoc/main.c +++ b/usr.bin/mandoc/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.224 2019/03/04 18:14:27 schwarze Exp $ */ +/* $OpenBSD: main.c,v 1.225 2019/04/30 18:48:26 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2012, 2014-2019 Ingo Schwarze <schwarze@openbsd.org> @@ -383,6 +383,7 @@ main(int argc, char *argv[]) res[sz].file = mandoc_strdup(argv[c]); res[sz].names = NULL; res[sz].output = NULL; + res[sz].bits = 0; res[sz].ipath = SIZE_MAX; res[sz].sec = 10; res[sz].form = FORM_SRC; @@ -731,6 +732,7 @@ found: page->file = file; page->names = NULL; page->output = NULL; + page->bits = NAME_FILE & NAME_MASK; page->ipath = ipath; page->sec = (*sec >= '1' && *sec <= '9') ? *sec - '1' + 1 : 10; page->form = form; diff --git a/usr.bin/mandoc/mansearch.c b/usr.bin/mandoc/mansearch.c index 1ac4558a0f1..010adfd06a3 100644 --- a/usr.bin/mandoc/mansearch.c +++ b/usr.bin/mandoc/mansearch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mansearch.c,v 1.63 2018/12/13 11:55:14 schwarze Exp $ */ +/* $OpenBSD: mansearch.c,v 1.64 2019/04/30 18:48:26 schwarze Exp $ */ /* * Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013-2018 Ingo Schwarze <schwarze@openbsd.org> @@ -196,6 +196,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) @@ -291,8 +292,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); @@ -405,7 +408,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. */ diff --git a/usr.bin/mandoc/mansearch.h b/usr.bin/mandoc/mansearch.h index d05ece1e050..c2efe7c55df 100644 --- a/usr.bin/mandoc/mansearch.h +++ b/usr.bin/mandoc/mansearch.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mansearch.h,v 1.23 2018/11/22 12:01:42 schwarze Exp $ */ +/* $OpenBSD: mansearch.h,v 1.24 2019/04/30 18:48:26 schwarze Exp $ */ /* * Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013, 2014, 2016, 2017 Ingo Schwarze <schwarze@openbsd.org> @@ -92,6 +92,7 @@ struct manpage { char *file; /* to be prefixed by manpath */ char *names; /* a list of names with sections */ char *output; /* user-defined additional output */ + uint64_t bits; /* name type mask */ size_t ipath; /* number of the manpath */ int sec; /* section number, 10 means invalid */ enum form form; |