summaryrefslogtreecommitdiffstats
path: root/mandocdb.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2018-02-23 18:25:57 +0000
committerIngo Schwarze <schwarze@openbsd.org>2018-02-23 18:25:57 +0000
commitd32de303089b01e25effdb54cc92a00b71a3a986 (patch)
tree0f4c97825a9a7b31225f8aae27c41300a1dcefe6 /mandocdb.c
parenta233afb35d3281662cd0deb51ea225388068e3b8 (diff)
downloadmandoc-d32de303089b01e25effdb54cc92a00b71a3a986.tar.gz
Logically, the following are are type names - just like .Vt,
some of them with an optional variable name following: - .Ft - .Fa in the SYNOPSIS - .Fn second and later arguments in the SYNOPSIS So add these to the .Vt macro table in the mandoc.db(5) database. During my LibreSSL work, i'm getting really tired of typing $ man -k Vt,Ft,Fa=some_type_name over and over again; now, this becomes just: $ man -k Vt=some_type_name
Diffstat (limited to 'mandocdb.c')
-rw-r--r--mandocdb.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/mandocdb.c b/mandocdb.c
index bbb7b0f9..80d9457f 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -139,6 +139,8 @@ static void parse_mdoc(struct mpage *, const struct roff_meta *,
const struct roff_node *);
static int parse_mdoc_head(struct mpage *, const struct roff_meta *,
const struct roff_node *);
+static int parse_mdoc_Fa(struct mpage *, const struct roff_meta *,
+ const struct roff_node *);
static int parse_mdoc_Fd(struct mpage *, const struct roff_meta *,
const struct roff_node *);
static void parse_mdoc_fname(struct mpage *, const struct roff_node *);
@@ -207,11 +209,11 @@ static const struct mdoc_handler __mdocs[MDOC_MAX - MDOC_Dd] = {
{ NULL, TYPE_Er, 0 }, /* Er */
{ NULL, TYPE_Ev, 0 }, /* Ev */
{ NULL, 0, 0 }, /* Ex */
- { NULL, TYPE_Fa, 0 }, /* Fa */
+ { parse_mdoc_Fa, 0, 0 }, /* Fa */
{ parse_mdoc_Fd, 0, 0 }, /* Fd */
{ NULL, TYPE_Fl, 0 }, /* Fl */
{ parse_mdoc_Fn, 0, 0 }, /* Fn */
- { NULL, TYPE_Ft, 0 }, /* Ft */
+ { NULL, TYPE_Ft | TYPE_Vt, 0 }, /* Ft */
{ NULL, TYPE_Ic, 0 }, /* Ic */
{ NULL, TYPE_In, 0 }, /* In */
{ NULL, TYPE_Li, 0 }, /* Li */
@@ -1573,6 +1575,20 @@ parse_mdoc(struct mpage *mpage, const struct roff_meta *meta,
}
static int
+parse_mdoc_Fa(struct mpage *mpage, const struct roff_meta *meta,
+ const struct roff_node *n)
+{
+ uint64_t mask;
+
+ mask = TYPE_Fa;
+ if (n->sec == SEC_SYNOPSIS)
+ mask |= TYPE_Vt;
+
+ putmdockey(mpage, n->child, mask, 0);
+ return 0;
+}
+
+static int
parse_mdoc_Fd(struct mpage *mpage, const struct roff_meta *meta,
const struct roff_node *n)
{
@@ -1641,15 +1657,20 @@ static int
parse_mdoc_Fn(struct mpage *mpage, const struct roff_meta *meta,
const struct roff_node *n)
{
+ uint64_t mask;
if (n->child == NULL)
return 0;
parse_mdoc_fname(mpage, n->child);
- for (n = n->child->next; n != NULL; n = n->next)
- if (n->type == ROFFT_TEXT)
- putkey(mpage, n->string, TYPE_Fa);
+ n = n->child->next;
+ if (n != NULL && n->type == ROFFT_TEXT) {
+ mask = TYPE_Fa;
+ if (n->sec == SEC_SYNOPSIS)
+ mask |= TYPE_Vt;
+ putmdockey(mpage, n, mask, 0);
+ }
return 0;
}