diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-07-03 23:24:56 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-07-03 23:24:56 +0000 |
commit | d34c8b8f2efbf5e05c8603d4ea4f46f0b338661a (patch) | |
tree | 62e804b33db8a43ba1843508cbd098ccb404999a /mdoc_validate.c | |
parent | b3a2c4a288eaff61368f73f9008d243d10ff5f7c (diff) | |
download | mandoc-d34c8b8f2efbf5e05c8603d4ea4f46f0b338661a.tar.gz |
Fix formatting of empty .Bl -inset item heads.
Downgrade empty item heads from ERROR to WARNING.
Show the list type in the error message.
Choose better variable names for nodes in post_it().
Diffstat (limited to 'mdoc_validate.c')
-rw-r--r-- | mdoc_validate.c | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c index 945d684b..71b87562 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -1270,27 +1270,24 @@ post_it(POST_ARGS) { int i, cols; enum mdoc_list lt; - struct mdoc_node *n, *c; + struct mdoc_node *nbl, *nit, *nch; enum mandocerr er; - if (MDOC_BLOCK != mdoc->last->type) + nit = mdoc->last; + if (MDOC_BLOCK != nit->type) return(1); - n = mdoc->last->parent->parent; - lt = n->norm->Bl.type; + nbl = nit->parent->parent; + lt = nbl->norm->Bl.type; if (LIST__NONE == lt) { - mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_LISTTYPE); + mdoc_nmsg(mdoc, nit, MANDOCERR_LISTTYPE); return(1); } switch (lt) { case LIST_tag: - if (mdoc->last->head->child) - break; - /* FIXME: give this a dummy value. */ - mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOARGS); - break; + /* FALLTHROUGH */ case LIST_hang: /* FALLTHROUGH */ case LIST_ohang: @@ -1298,8 +1295,10 @@ post_it(POST_ARGS) case LIST_inset: /* FALLTHROUGH */ case LIST_diag: - if (NULL == mdoc->last->head->child) - mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOARGS); + if (NULL == nit->head->child) + mandoc_msg(MANDOCERR_IT_NOHEAD, + mdoc->parse, nit->line, nit->pos, + mdoc_argnames[nbl->args->argv[0].arg]); break; case LIST_bullet: /* FALLTHROUGH */ @@ -1308,23 +1307,23 @@ post_it(POST_ARGS) case LIST_enum: /* FALLTHROUGH */ case LIST_hyphen: - if (NULL == mdoc->last->body->child) - mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOBODY); + if (NULL == nit->body->child) + mdoc_nmsg(mdoc, nit, MANDOCERR_NOBODY); /* FALLTHROUGH */ case LIST_item: - if (mdoc->last->head->child) - mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_ARGSLOST); + if (NULL != nit->head->child) + mdoc_nmsg(mdoc, nit, MANDOCERR_ARGSLOST); break; case LIST_column: - cols = (int)n->norm->Bl.ncols; + cols = (int)nbl->norm->Bl.ncols; - assert(NULL == mdoc->last->head->child); + assert(NULL == nit->head->child); - if (NULL == mdoc->last->body->child) - mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NOBODY); + if (NULL == nit->body->child) + mdoc_nmsg(mdoc, nit, MANDOCERR_NOBODY); - for (i = 0, c = mdoc->last->child; c; c = c->next) - if (MDOC_BODY == c->type) + for (i = 0, nch = nit->child; nch; nch = nch->next) + if (MDOC_BODY == nch->type) i++; if (i < cols) @@ -1334,8 +1333,7 @@ post_it(POST_ARGS) else er = MANDOCERR_SYNTARGCOUNT; - mandoc_vmsg(er, mdoc->parse, - mdoc->last->line, mdoc->last->pos, + mandoc_vmsg(er, mdoc->parse, nit->line, nit->pos, "columns == %d (have %d)", cols, i); return(MANDOCERR_ARGCOUNT == er); default: |