aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mandocdb.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2016-01-04 14:44:57 +0000
committerIngo Schwarze <schwarze@openbsd.org>2016-01-04 14:44:57 +0000
commitee975016524dfb3382109fda2f0b49dd3f2b45f1 (patch)
tree283151c92d4836cb6f31e90ec9300beafae57e70 /mandocdb.c
parentfc78f53cd921d410f5a0cc2831a9a8791a0a7a8f (diff)
downloadmandoc-ee975016524dfb3382109fda2f0b49dd3f2b45f1.tar.gz
mandoc-ee975016524dfb3382109fda2f0b49dd3f2b45f1.tar.zst
mandoc-ee975016524dfb3382109fda2f0b49dd3f2b45f1.zip
Improve handling of .Va and .Vt macros.
tedu@ noticed that no Vt= database entries were generated. Serguey Parkhomovsky suggested the deletion of parse_mdoc_body(). tb@ noticed that the fix requires more than just adding TYPE_Vt to the MDOC_Vt mask in the mdoc_handler array.
Diffstat (limited to 'mandocdb.c')
-rw-r--r--mandocdb.c43
1 files changed, 29 insertions, 14 deletions
diff --git a/mandocdb.c b/mandocdb.c
index 04ba1acf..a86a7856 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1,7 +1,7 @@
-/* $Id: mandocdb.c,v 1.210 2015/12/15 17:38:45 schwarze Exp $ */
+/* $Id: mandocdb.c,v 1.211 2016/01/04 14:44:57 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2011-2016 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -156,8 +156,6 @@ static void parse_man(struct mpage *, const struct roff_meta *,
const struct roff_node *);
static void parse_mdoc(struct mpage *, const struct roff_meta *,
const struct roff_node *);
-static int parse_mdoc_body(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_Fd(struct mpage *, const struct roff_meta *,
@@ -173,6 +171,8 @@ static int parse_mdoc_Nm(struct mpage *, const struct roff_meta *,
const struct roff_node *);
static int parse_mdoc_Sh(struct mpage *, const struct roff_meta *,
const struct roff_node *);
+static int parse_mdoc_Va(struct mpage *, const struct roff_meta *,
+ const struct roff_node *);
static int parse_mdoc_Xr(struct mpage *, const struct roff_meta *,
const struct roff_node *);
static void putkey(const struct mpage *, char *, uint64_t);
@@ -242,8 +242,8 @@ static const struct mdoc_handler mdocs[MDOC_MAX] = {
{ NULL, TYPE_Pa }, /* Pa */
{ NULL, 0 }, /* Rv */
{ NULL, TYPE_St }, /* St */
- { NULL, TYPE_Va }, /* Va */
- { parse_mdoc_body, TYPE_Va }, /* Vt */
+ { parse_mdoc_Va, TYPE_Va }, /* Va */
+ { parse_mdoc_Va, TYPE_Vt }, /* Vt */
{ parse_mdoc_Xr, 0 }, /* Xr */
{ NULL, 0 }, /* %A */
{ NULL, 0 }, /* %B */
@@ -1689,6 +1689,29 @@ parse_mdoc_Fo(struct mpage *mpage, const struct roff_meta *meta,
}
static int
+parse_mdoc_Va(struct mpage *mpage, const struct roff_meta *meta,
+ const struct roff_node *n)
+{
+ char *cp;
+
+ if (n->type != ROFFT_ELEM && n->type != ROFFT_BODY)
+ return 0;
+
+ if (n->nchild == 1 && n->child->type == ROFFT_TEXT)
+ return 1;
+
+ cp = NULL;
+ deroff(&cp, n);
+ if (cp != NULL) {
+ putkey(mpage, cp, TYPE_Vt | (n->tok == MDOC_Va ||
+ n->type == ROFFT_BODY ? TYPE_Va : 0));
+ free(cp);
+ }
+
+ return 0;
+}
+
+static int
parse_mdoc_Xr(struct mpage *mpage, const struct roff_meta *meta,
const struct roff_node *n)
{
@@ -1756,14 +1779,6 @@ parse_mdoc_head(struct mpage *mpage, const struct roff_meta *meta,
return n->type == ROFFT_HEAD;
}
-static int
-parse_mdoc_body(struct mpage *mpage, const struct roff_meta *meta,
- const struct roff_node *n)
-{
-
- return n->type == ROFFT_BODY;
-}
-
/*
* Add a string to the hash table for the current manual.
* Each string has a bitmask telling which macros it belongs to.