=================================================================== RCS file: /cvs/mandoc/mdoc_validate.c,v retrieving revision 1.218 retrieving revision 1.222 diff -u -p -r1.218 -r1.222 --- mandoc/mdoc_validate.c 2014/07/02 03:48:07 1.218 +++ mandoc/mdoc_validate.c 2014/07/02 19:55:10 1.222 @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.218 2014/07/02 03:48:07 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.222 2014/07/02 19:55:10 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -591,7 +591,9 @@ pre_display(PRE_ARGS) 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); } @@ -1115,7 +1117,8 @@ post_vt(POST_ARGS) 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); } @@ -1385,12 +1388,17 @@ post_bl_block(POST_ARGS) continue; } if (NULL == ni->next) { - mdoc_nmsg(mdoc, nc, MANDOCERR_MOVEPAR); + mandoc_msg(MANDOCERR_PAR_MOVE, + mdoc->parse, nc->line, nc->pos, + mdoc_macronames[nc->tok]); if ( ! mdoc_node_relink(mdoc, nc)) return(0); } else if (0 == n->norm->Bl.comp && LIST_column != n->norm->Bl.type) { - mdoc_nmsg(mdoc, nc, MANDOCERR_IGNPAR); + mandoc_vmsg(MANDOCERR_PAR_SKIP, + mdoc->parse, nc->line, nc->pos, + "%s before It", + mdoc_macronames[nc->tok]); mdoc_node_delete(mdoc, nc); } else break; @@ -1606,7 +1614,9 @@ post_bl(POST_ARGS) 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. @@ -1658,12 +1668,13 @@ ebool(struct mdoc *mdoc) { 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); if (0 == strcmp(mdoc->last->child->string, "on")) { @@ -1775,7 +1786,8 @@ post_rs(POST_ARGS) } 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); } @@ -1898,7 +1910,7 @@ post_ns(POST_ARGS) { if (MDOC_LINE & mdoc->last->flags) - mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_IGNNS); + mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_NS_SKIP); return(1); } @@ -2078,13 +2090,19 @@ post_ignpar(POST_ARGS) if (NULL != (np = mdoc->last->child)) if (MDOC_Pp == np->tok || MDOC_Lp == np->tok) { - mdoc_nmsg(mdoc, np, MANDOCERR_IGNPAR); + mandoc_vmsg(MANDOCERR_PAR_SKIP, + mdoc->parse, np->line, np->pos, + "%s after %s", mdoc_macronames[np->tok], + mdoc_macronames[mdoc->last->tok]); mdoc_node_delete(mdoc, np); } if (NULL != (np = mdoc->last->last)) if (MDOC_Pp == np->tok || MDOC_Lp == np->tok) { - mdoc_nmsg(mdoc, np, MANDOCERR_IGNPAR); + mandoc_vmsg(MANDOCERR_PAR_SKIP, mdoc->parse, + np->line, np->pos, "%s at the end of %s", + mdoc_macronames[np->tok], + mdoc_macronames[mdoc->last->tok]); mdoc_node_delete(mdoc, np); } @@ -2116,7 +2134,10 @@ pre_par(PRE_ARGS) if (MDOC_It == n->tok && n->parent->norm->Bl.comp) return(1); - mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_IGNPAR); + mandoc_vmsg(MANDOCERR_PAR_SKIP, mdoc->parse, + mdoc->last->line, mdoc->last->pos, + "%s before %s", mdoc_macronames[mdoc->last->tok], + mdoc_macronames[n->tok]); mdoc_node_delete(mdoc, mdoc->last); return(1); } @@ -2124,25 +2145,27 @@ pre_par(PRE_ARGS) static int post_par(POST_ARGS) { + struct mdoc_node *np; if (MDOC_ELEM != mdoc->last->type && MDOC_BLOCK != mdoc->last->type) return(1); - if (NULL == mdoc->last->prev) { - if (MDOC_Sh != mdoc->last->parent->tok && - MDOC_Ss != mdoc->last->parent->tok) + if (NULL == (np = mdoc->last->prev)) { + np = mdoc->last->parent; + if (MDOC_Sh != np->tok && MDOC_Ss != np->tok) return(1); } else { - if (MDOC_Pp != mdoc->last->prev->tok && - MDOC_Lp != mdoc->last->prev->tok && + if (MDOC_Pp != np->tok && MDOC_Lp != np->tok && (MDOC_br != mdoc->last->tok || - (MDOC_sp != mdoc->last->prev->tok && - MDOC_br != mdoc->last->prev->tok))) + (MDOC_sp != np->tok && MDOC_br != np->tok))) return(1); } - mdoc_nmsg(mdoc, mdoc->last, MANDOCERR_IGNPAR); + mandoc_vmsg(MANDOCERR_PAR_SKIP, mdoc->parse, + mdoc->last->line, mdoc->last->pos, + "%s after %s", mdoc_macronames[mdoc->last->tok], + mdoc_macronames[np->tok]); mdoc_node_delete(mdoc, mdoc->last); return(1); }