From 3ddcc9e83d9e2fc34ee4eb5d332ad54f554cda1e Mon Sep 17 00:00:00 2001 From: schwarze Date: Fri, 23 Feb 2018 18:24:41 +0000 Subject: [PATCH] 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 --- regress/usr.bin/mandoc/db/out/fn.dout | 10 ++++++-- usr.bin/mandoc/mandocdb.c | 33 ++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/regress/usr.bin/mandoc/db/out/fn.dout b/regress/usr.bin/mandoc/db/out/fn.dout index d7048d7dc29..2d6732bd217 100644 --- a/regress/usr.bin/mandoc/db/out/fn.dout +++ b/regress/usr.bin/mandoc/db/out/fn.dout @@ -1,7 +1,7 @@ initial magic 0x3a7d0cdb version 0x00000001 macros offset 0x00000078 -end offset 0x0000022c +end offset 0x0000028c page count 1 === PAGES === page name # [f]fn # [1t]Fn # [s]fn_func # [s]fo_name @@ -57,7 +57,13 @@ macro 30 entry count 0 macro 31 entry count 0 macro 32 entry count 0 macro 33 entry count 0 -macro 34 entry count 0 +macro 34 entry count 4 +=== MACRO 34 === +macro 34 # fn_arg # fn +macro 34 # fn_type # fn +macro 34 # fo_arg # fn +macro 34 # fo_type # fn +=== END OF MACRO 34 === macro 35 entry count 0 === END OF MACROS === final magic 0x3a7d0cdb diff --git a/usr.bin/mandoc/mandocdb.c b/usr.bin/mandoc/mandocdb.c index 0e16fd39775..00a0cdf0b53 100644 --- a/usr.bin/mandoc/mandocdb.c +++ b/usr.bin/mandoc/mandocdb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mandocdb.c,v 1.206 2018/02/07 20:31:32 schwarze Exp $ */ +/* $OpenBSD: mandocdb.c,v 1.207 2018/02/23 18:24:41 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2011-2017 Ingo Schwarze @@ -124,6 +124,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 *); @@ -192,11 +194,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 */ @@ -1534,6 +1536,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) @@ -1603,15 +1619,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; } -- 2.20.1