summaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_validate.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-06-17 14:08:47 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-06-17 14:08:47 +0000
commit92611c25bc500e0a4cac5a5e0e3be02f71d4672d (patch)
tree298b34a041c62c743102a96713ae97bbf6e5006c /mdoc_validate.c
parente4f6b8bbfc80228e5d06e0e611f6f7a939c1af51 (diff)
downloadmandoc-92611c25bc500e0a4cac5a5e0e3be02f71d4672d.tar.gz
mandoc-92611c25bc500e0a4cac5a5e0e3be02f71d4672d.tar.zst
mandoc-92611c25bc500e0a4cac5a5e0e3be02f71d4672d.zip
`Bl -column' now correctly handles tail entries (Bl -column -more... arg0...).
Diffstat (limited to 'mdoc_validate.c')
-rw-r--r--mdoc_validate.c50
1 files changed, 32 insertions, 18 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 81211db4..3111f864 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.13 2009/06/17 11:02:06 kristaps Exp $ */
+/* $Id: mdoc_validate.c,v 1.14 2009/06/17 14:08:47 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -46,6 +46,7 @@ enum merr {
EMULTILIST,
EARGREP,
EBOOL,
+ ECOLMIS,
ENESTDISP
};
@@ -138,6 +139,7 @@ static int post_args(POST_ARGS);
static int post_at(POST_ARGS);
static int post_bf(POST_ARGS);
static int post_bl(POST_ARGS);
+static int post_bl_head(POST_ARGS);
static int post_it(POST_ARGS);
static int post_nm(POST_ARGS);
static int post_root(POST_ARGS);
@@ -174,7 +176,7 @@ static v_post posts_wtext[] = { ewarn_ge1, NULL };
static v_post posts_notext[] = { eerr_eq0, NULL };
static v_post posts_wline[] = { bwarn_ge1, herr_eq0, NULL };
static v_post posts_sh[] = { herr_ge1, bwarn_ge1, post_sh, NULL };
-static v_post posts_bl[] = { herr_eq0, bwarn_ge1, post_bl, NULL };
+static v_post posts_bl[] = { bwarn_ge1, post_bl, NULL };
static v_post posts_it[] = { post_it, NULL };
static v_post posts_in[] = { ewarn_eq1, NULL };
static v_post posts_ss[] = { herr_ge1, NULL };
@@ -425,6 +427,9 @@ perr(struct mdoc *m, int line, int pos, enum merr type)
case (ENODATA):
p = "document has no data";
break;
+ case (ECOLMIS):
+ p = "column syntax style mismatch";
+ break;
case (EATT):
p = "expected valid AT&T symbol";
break;
@@ -879,22 +884,6 @@ pre_bl(PRE_ARGS)
break;
}
- /*
- * General validation of fields.
- */
-
- switch (type) {
- case (MDOC_Column):
- assert(col >= 0);
- if (0 == n->args->argv[col].sz)
- break;
- if ( ! nwarn(mdoc, n, WDEPCOL))
- return(0);
- break;
- default:
- break;
- }
-
return(1);
}
@@ -1257,10 +1246,35 @@ post_it(POST_ARGS)
static int
+post_bl_head(POST_ARGS)
+{
+ int i;
+ const struct mdoc_node *n;
+
+ n = mdoc->last->parent;
+ assert(n->args);
+
+ for (i = 0; i < (int)n->args->argc; i++)
+ if (n->args->argv[i].arg == MDOC_Column)
+ break;
+
+ if (i == (int)n->args->argc)
+ return(1);
+
+ if (n->args->argv[i].sz && mdoc->last->child)
+ return(nerr(mdoc, n, ECOLMIS));
+
+ return(1);
+}
+
+
+static int
post_bl(POST_ARGS)
{
struct mdoc_node *n;
+ if (MDOC_HEAD == mdoc->last->type)
+ return(post_bl_head(mdoc));
if (MDOC_BODY != mdoc->last->type)
return(1);
if (NULL == mdoc->last->child)