summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2018-02-23 18:24:41 +0000
committerschwarze <schwarze@openbsd.org>2018-02-23 18:24:41 +0000
commit3ddcc9e83d9e2fc34ee4eb5d332ad54f554cda1e (patch)
tree6e8aa93a91a88d4de71e69b80bd2236000e77587
parentAdd experimental support for PQC XMSS keys (Extended Hash-Based Signatures) (diff)
downloadwireguard-openbsd-3ddcc9e83d9e2fc34ee4eb5d332ad54f554cda1e.tar.xz
wireguard-openbsd-3ddcc9e83d9e2fc34ee4eb5d332ad54f554cda1e.zip
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
-rw-r--r--regress/usr.bin/mandoc/db/out/fn.dout10
-rw-r--r--usr.bin/mandoc/mandocdb.c33
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 <kristaps@bsd.lv>
* Copyright (c) 2011-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -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 */
@@ -1535,6 +1537,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;
}