From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: mdocml: In man(1) mode, prefer file name matches over .Dt name matches
Date: Mon, 17 Nov 2014 20:15:21 -0500 (EST) [thread overview]
Message-ID: <201411180115.sAI1FLcp017140@krisdoz.my.domain> (raw)
Log Message:
-----------
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.
Modified Files:
--------------
mdocml:
mansearch.c
mansearch.h
Revision Data
-------------
Index: mansearch.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mansearch.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -Lmansearch.h -Lmansearch.h -u -p -r1.19 -r1.20
--- mansearch.h
+++ mansearch.h
@@ -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 */
};
Index: mansearch.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mansearch.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -Lmansearch.c -Lmansearch.c -u -p -r1.49 -r1.50
--- mansearch.c
+++ mansearch.c
@@ -79,6 +79,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? */
};
@@ -301,6 +302,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));
@@ -336,6 +338,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,
@@ -396,8 +399,9 @@ manpage_compare(const void *vp1, const v
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
@@ -592,8 +596,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) {
@@ -613,8 +619,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
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
reply other threads:[~2014-11-18 1:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201411180115.sAI1FLcp017140@krisdoz.my.domain \
--to=schwarze@mdocml.bsd.lv \
--cc=source@mdocml.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).