summaryrefslogtreecommitdiffstats
path: root/usr.bin/mandoc/mdoc_validate.c
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2010-02-18 02:11:25 +0000
committerschwarze <schwarze@openbsd.org>2010-02-18 02:11:25 +0000
commit8521b0bc6a75dbf2d60be65720832c7020cebee4 (patch)
tree8ab758f039cdac98a59ee9d190ce4bb9b9617f2d /usr.bin/mandoc/mdoc_validate.c
parentThe .TP man(7) macro requires text on the following line, to be used as (diff)
downloadwireguard-openbsd-8521b0bc6a75dbf2d60be65720832c7020cebee4.tar.xz
wireguard-openbsd-8521b0bc6a75dbf2d60be65720832c7020cebee4.zip
sync to release 1.9.15:
* corrected .Vt handling (spotted by Joerg Sonnenberger) * corrected .Xr argument handling (based on my patch) * removed \\ escape sequence (because it is for low-level roff only) * warn about trailing whitespace (suggested by jmc@) * -Txhtml support * and some general cleanup and doc improvements
Diffstat (limited to 'usr.bin/mandoc/mdoc_validate.c')
-rw-r--r--usr.bin/mandoc/mdoc_validate.c36
1 files changed, 31 insertions, 5 deletions
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c
index 2f87c6424a6..1c3b1b71a56 100644
--- a/usr.bin/mandoc/mdoc_validate.c
+++ b/usr.bin/mandoc/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.41 2010/01/01 22:20:24 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.42 2010/02/18 02:11:26 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -68,7 +68,6 @@ static int ebool(POST_ARGS);
static int eerr_eq0(POST_ARGS);
static int eerr_eq1(POST_ARGS);
static int eerr_ge1(POST_ARGS);
-static int eerr_le2(POST_ARGS);
static int eerr_le1(POST_ARGS);
static int ewarn_ge1(POST_ARGS);
static int herr_eq0(POST_ARGS);
@@ -90,6 +89,7 @@ static int post_sh(POST_ARGS);
static int post_sh_body(POST_ARGS);
static int post_sh_head(POST_ARGS);
static int post_st(POST_ARGS);
+static int post_vt(POST_ARGS);
static int pre_an(PRE_ARGS);
static int pre_bd(PRE_ARGS);
static int pre_bl(PRE_ARGS);
@@ -126,9 +126,10 @@ static v_post posts_ss[] = { herr_ge1, NULL };
static v_post posts_st[] = { eerr_eq1, post_st, NULL };
static v_post posts_text[] = { eerr_ge1, NULL };
static v_post posts_text1[] = { eerr_eq1, NULL };
+static v_post posts_vt[] = { post_vt, NULL };
static v_post posts_wline[] = { bwarn_ge1, herr_eq0, NULL };
static v_post posts_wtext[] = { ewarn_ge1, NULL };
-static v_post posts_xr[] = { eerr_ge1, eerr_le2, NULL };
+static v_post posts_xr[] = { eerr_ge1, NULL };
static v_pre pres_an[] = { pre_an, NULL };
static v_pre pres_bd[] = { pre_display, pre_bd, NULL };
static v_pre pres_bl[] = { pre_bl, NULL };
@@ -186,7 +187,7 @@ const struct valids mdoc_valids[MDOC_MAX] = {
{ pres_rv, NULL }, /* Rv */
{ NULL, posts_st }, /* St */
{ NULL, NULL }, /* Va */
- { NULL, posts_text }, /* Vt */
+ { NULL, posts_vt }, /* Vt */
{ NULL, posts_xr }, /* Xr */
{ NULL, posts_text }, /* %A */
{ NULL, posts_text }, /* %B */ /* FIXME: can be used outside Rs/Re. */
@@ -402,7 +403,6 @@ CHECK_BODY_DEFN(ge1, warn, warn_child_gt, 0) /* bwarn_ge1() */
CHECK_BODY_DEFN(ge1, err, err_child_gt, 0) /* berr_ge1() */
CHECK_ELEM_DEFN(ge1, warn, warn_child_gt, 0) /* ewarn_gt1() */
CHECK_ELEM_DEFN(eq1, err, err_child_eq, 1) /* eerr_eq1() */
-CHECK_ELEM_DEFN(le2, err, err_child_lt, 3) /* eerr_le2() */
CHECK_ELEM_DEFN(le1, err, err_child_lt, 2) /* eerr_le1() */
CHECK_ELEM_DEFN(eq0, err, err_child_eq, 0) /* eerr_eq0() */
CHECK_ELEM_DEFN(ge1, err, err_child_gt, 0) /* eerr_ge1() */
@@ -887,6 +887,32 @@ post_lb(POST_ARGS)
static int
+post_vt(POST_ARGS)
+{
+ const struct mdoc_node *n;
+
+ /*
+ * The Vt macro comes in both ELEM and BLOCK form, both of which
+ * have different syntaxes (yet more context-sensitive
+ * behaviour). ELEM types must have a child; BLOCK types,
+ * specifically the BODY, should only have TEXT children.
+ */
+
+ if (MDOC_ELEM == mdoc->last->type)
+ return(eerr_ge1(mdoc));
+ if (MDOC_BODY != mdoc->last->type)
+ return(1);
+
+ for (n = mdoc->last->child; n; n = n->next)
+ if (MDOC_TEXT != n->type)
+ if ( ! mdoc_nwarn(mdoc, n, EBADCHILD))
+ return(0);
+
+ return(1);
+}
+
+
+static int
post_nm(POST_ARGS)
{