-/* $Id: mdoc_validate.c,v 1.219 2014/07/02 05:52:25 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.224 2014/07/03 23:24:56 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
break;
if (node)
- mdoc_nmsg(mdoc, n, MANDOCERR_NESTEDDISP);
+ mandoc_vmsg(MANDOCERR_BD_NEST,
+ mdoc->parse, n->line, n->pos,
+ "%s in Bd", mdoc_macronames[n->tok]);
return(1);
}
for (n = mdoc->last->child; n; n = n->next)
if (MDOC_TEXT != n->type)
- mdoc_nmsg(mdoc, n, MANDOCERR_CHILD);
+ mandoc_msg(MANDOCERR_VT_CHILD, mdoc->parse,
+ n->line, n->pos, mdoc_macronames[n->tok]);
return(1);
}
{
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:
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 */
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)
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:
continue;
}
- mdoc_nmsg(mdoc, nchild, MANDOCERR_CHILD);
+ mandoc_msg(MANDOCERR_BL_MOVE, mdoc->parse,
+ nchild->line, nchild->pos,
+ mdoc_macronames[nchild->tok]);
/*
* Move the node out of the Bl block.
{
if (NULL == mdoc->last->child) {
- mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_MACROEMPTY);
- mdoc_node_delete(mdoc, mdoc->last);
+ if (MDOC_Sm == mdoc->last->tok)
+ mdoc->flags ^= MDOC_SMOFF;
return(1);
}
- check_count(mdoc, MDOC_ELEM, CHECK_WARN, CHECK_EQ, 1);
+
+ check_count(mdoc, MDOC_ELEM, CHECK_WARN, CHECK_LT, 2);
assert(MDOC_TEXT == mdoc->last->child->type);
const char *p;
if (NULL == (ch = mdoc->last->child)) {
- mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_MACROEMPTY);
+ mandoc_msg(MANDOCERR_MACRO_EMPTY, mdoc->parse,
+ mdoc->last->line, mdoc->last->pos,
+ mdoc_macronames[mdoc->last->tok]);
mdoc_node_delete(mdoc, mdoc->last);
return(1);
}
}
next = nn->next;
- mdoc_nmsg(mdoc, nn, MANDOCERR_CHILD);
+ mandoc_msg(MANDOCERR_RS_SKIP, mdoc->parse,
+ nn->line, nn->pos, mdoc_macronames[nn->tok]);
mdoc_node_delete(mdoc, nn);
}
{
if (MDOC_LINE & mdoc->last->flags)
- mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_IGNNS);
+ mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NS_SKIP);
return(1);
}