=================================================================== RCS file: /cvs/mandoc/mandocdb.c,v retrieving revision 1.209 retrieving revision 1.211 diff -u -p -r1.209 -r1.211 --- mandoc/mandocdb.c 2015/11/07 17:58:55 1.209 +++ mandoc/mandocdb.c 2016/01/04 14:44:57 1.211 @@ -1,7 +1,7 @@ -/* $Id: mandocdb.c,v 1.209 2015/11/07 17:58:55 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 ro 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 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 */ @@ -420,9 +420,11 @@ mandocdb(int argc, char *argv[]) argv += optind; #if HAVE_PLEDGE - if (nodb && pledge("stdio rpath", NULL) == -1) { - perror("pledge"); - return (int)MANDOCLEVEL_SYSERR; + if (nodb) { + if (pledge("stdio rpath", NULL) == -1) { + perror("pledge"); + return (int)MANDOCLEVEL_SYSERR; + } } #endif @@ -452,11 +454,12 @@ mandocdb(int argc, char *argv[]) * all files specified on the command-line. */ #if HAVE_PLEDGE - if (!nodb && pledge("stdio rpath wpath cpath fattr flock", - NULL) == -1) { - perror("pledge"); - exitcode = (int)MANDOCLEVEL_SYSERR; - goto out; + if (!nodb) { + if (pledge("stdio rpath wpath cpath fattr flock", NULL) == -1) { + perror("pledge"); + exitcode = (int)MANDOCLEVEL_SYSERR; + goto out; + } } #endif use_all = 1; @@ -1686,6 +1689,29 @@ parse_mdoc_Fo(struct mpage *mpage, const struct roff_m } 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) { @@ -1751,14 +1777,6 @@ parse_mdoc_head(struct mpage *mpage, const struct roff { 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; } /*