diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2014-11-18 01:14:41 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2014-11-18 01:14:41 +0000 |
commit | 15c2dd2768cab5e369a3264da0ee5847bbc29f1b (patch) | |
tree | a6e90e55fb8aae05745e2ac584259de8db135797 /usr.bin/mandoc | |
parent | 5f22109207efa29eeccc8198d7efceab0a10e067 (diff) |
In man(1) mode, prefer file name matches over .Dt name matches over
first .Nm entries over other NAME .Nm entries over SYNOPSIS .Nm entries.
For example, this makes sure "man ypbind" does not return yp(8).
Re-run "makewhatis" to profit from this change.
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r-- | usr.bin/mandoc/mansearch.c | 19 | ||||
-rw-r--r-- | usr.bin/mandoc/mansearch.h | 11 |
2 files changed, 18 insertions, 12 deletions
diff --git a/usr.bin/mandoc/mansearch.c b/usr.bin/mandoc/mansearch.c index d5c8360c0d2..95a624955a3 100644 --- a/usr.bin/mandoc/mansearch.c +++ b/usr.bin/mandoc/mansearch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mansearch.c,v 1.36 2014/11/11 19:03:10 schwarze Exp $ */ +/* $OpenBSD: mansearch.c,v 1.37 2014/11/18 01:14:40 schwarze Exp $ */ /* * Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -71,6 +71,7 @@ struct expr { struct match { uint64_t pageid; /* identifier in database */ + uint64_t bits; /* name type mask */ char *desc; /* manual page description */ int form; /* bit field: formatted, zipped? */ }; @@ -293,6 +294,7 @@ mansearch(const struct mansearch *search, mp = mandoc_calloc(1, sizeof(struct match)); mp->pageid = pageid; mp->form = sqlite3_column_int(s, 1); + mp->bits = sqlite3_column_int64(s, 3); if (TYPE_Nd == outbit) mp->desc = mandoc_strdup((const char *) sqlite3_column_text(s, 0)); @@ -328,6 +330,7 @@ mansearch(const struct mansearch *search, } mpage = *res + cur; mpage->ipath = i; + mpage->bits = mp->bits; mpage->sec = 10; mpage->form = mp->form; buildnames(mpage, db, s, mp->pageid, @@ -388,8 +391,9 @@ manpage_compare(const void *vp1, const void *vp2) mp1 = vp1; mp2 = vp2; - diff = mp1->sec - mp2->sec; - return(diff ? diff : strcasecmp(mp1->names, mp2->names)); + return( (diff = mp2->bits - mp1->bits) ? diff : + (diff = mp1->sec - mp2->sec) ? diff : + strcasecmp(mp1->names, mp2->names)); } static void @@ -584,8 +588,10 @@ sql_statement(const struct expr *e) size_t sz; int needop; - sql = mandoc_strdup( - "SELECT desc, form, pageid FROM mpages WHERE "); + sql = mandoc_strdup(e->equal ? + "SELECT desc, form, pageid, bits " + "FROM mpages NATURAL JOIN names WHERE " : + "SELECT desc, form, pageid, 0 FROM mpages WHERE "); sz = strlen(sql); for (needop = 0; NULL != e; e = e->next) { @@ -605,8 +611,7 @@ sql_statement(const struct expr *e) ? "pageid IN (SELECT pageid FROM names " "WHERE name REGEXP ?)" : e->equal - ? "pageid IN (SELECT pageid FROM names " - "WHERE name = ?)" + ? "name = ? " : "pageid IN (SELECT pageid FROM names " "WHERE name MATCH ?)") : (NULL == e->substr diff --git a/usr.bin/mandoc/mansearch.h b/usr.bin/mandoc/mansearch.h index 325193b0309..e8dbd59786b 100644 --- a/usr.bin/mandoc/mansearch.h +++ b/usr.bin/mandoc/mansearch.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mansearch.h,v 1.15 2014/11/11 19:03:10 schwarze Exp $ */ +/* $OpenBSD: mansearch.h,v 1.16 2014/11/18 01:14:40 schwarze Exp $ */ /* * Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -62,10 +62,10 @@ #define TYPE_Nd 0x0000008000000000ULL #define NAME_SYN 0x0000004000000001ULL -#define NAME_FILE 0x0000004000000002ULL -#define NAME_TITLE 0x000000400000000cULL -#define NAME_FIRST 0x0000004000000008ULL -#define NAME_HEAD 0x0000004000000010ULL +#define NAME_FIRST 0x0000004000000004ULL +#define NAME_TITLE 0x0000004000000006ULL +#define NAME_HEAD 0x0000004000000008ULL +#define NAME_FILE 0x0000004000000010ULL #define NAME_MASK 0x000000000000001fULL #define FORM_CAT 0 /* manual page is preformatted */ @@ -85,6 +85,7 @@ struct manpage { char *names; /* a list of names with sections */ char *output; /* user-defined additional output */ size_t ipath; /* number of the manpath */ + uint64_t bits; /* name type mask */ int sec; /* section number, 10 means invalid */ int form; /* 0 == catpage */ }; |