From ee975016524dfb3382109fda2f0b49dd3f2b45f1 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Mon, 4 Jan 2016 14:44:57 +0000 Subject: 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. --- mandocdb.c | 43 +++++++++++++++++++++++++++++-------------- 1 file 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 - * Copyright (c) 2011-2015 Ingo Schwarze + * Copyright (c) 2011-2016 Ingo Schwarze * * 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 */ @@ -1688,6 +1688,29 @@ parse_mdoc_Fo(struct mpage *mpage, const struct roff_meta *meta, return 0; } +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. -- cgit v1.2.3-56-ge451