=================================================================== RCS file: /cvs/mandoc/man_validate.c,v retrieving revision 1.94 retrieving revision 1.103 diff -u -p -r1.94 -r1.103 --- mandoc/man_validate.c 2014/07/01 22:37:15 1.94 +++ mandoc/man_validate.c 2014/08/01 17:40:34 1.103 @@ -1,4 +1,4 @@ -/* $Id: man_validate.c,v 1.94 2014/07/01 22:37:15 schwarze Exp $ */ +/* $Id: man_validate.c,v 1.103 2014/08/01 17:40:34 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze @@ -62,7 +62,6 @@ static int post_vs(CHKARGS); static int post_fi(CHKARGS); static int post_ft(CHKARGS); static int post_nf(CHKARGS); -static int post_sec(CHKARGS); static int post_TH(CHKARGS); static int post_UC(CHKARGS); static int pre_sec(CHKARGS); @@ -78,7 +77,6 @@ static v_check posts_le1[] = { check_le1, NULL }; static v_check posts_nf[] = { check_eq0, post_nf, NULL }; static v_check posts_par[] = { check_par, NULL }; static v_check posts_part[] = { check_part, NULL }; -static v_check posts_sec[] = { post_sec, NULL }; static v_check posts_sp[] = { post_vs, check_le1, NULL }; static v_check posts_th[] = { check_ge2, check_le5, post_TH, NULL }; static v_check posts_uc[] = { post_UC, NULL }; @@ -88,8 +86,8 @@ static v_check pres_sec[] = { pre_sec, NULL }; static const struct man_valid man_valids[MAN_MAX] = { { NULL, posts_br }, /* br */ { NULL, posts_th }, /* TH */ - { pres_sec, posts_sec }, /* SH */ - { pres_sec, posts_sec }, /* SS */ + { pres_sec, NULL }, /* SH */ + { pres_sec, NULL }, /* SS */ { NULL, NULL }, /* TP */ { NULL, posts_par }, /* LP */ { NULL, posts_par }, /* PP */ @@ -190,21 +188,17 @@ static int check_root(CHKARGS) { - if (MAN_BLINE & man->flags) - man_nmsg(man, n, MANDOCERR_SCOPEEXIT); - else if (MAN_ELINE & man->flags) - man_nmsg(man, n, MANDOCERR_SCOPEEXIT); + assert((man->flags & (MAN_BLINE | MAN_ELINE)) == 0); - man->flags &= ~MAN_BLINE; - man->flags &= ~MAN_ELINE; - if (NULL == man->first->child) - man_nmsg(man, n, MANDOCERR_DOC_EMPTY); + mandoc_msg(MANDOCERR_DOC_EMPTY, man->parse, + n->line, n->pos, NULL); else man->meta.hasbody = 1; if (NULL == man->meta.title) { - man_nmsg(man, n, MANDOCERR_TH_MISSING); + mandoc_msg(MANDOCERR_TH_MISSING, man->parse, + n->line, n->pos, NULL); /* * If a title hasn't been set, do so now (by @@ -230,7 +224,8 @@ check_text(CHKARGS) cp = n->string; for (p = cp; NULL != (p = strchr(p, '\t')); p++) - man_pmsg(man, n->line, (int)(p - cp), MANDOCERR_BADTAB); + mandoc_msg(MANDOCERR_FI_TAB, man->parse, + n->line, n->pos + (p - cp), NULL); } #define INEQ_DEFINE(x, ineq, name) \ @@ -303,8 +298,8 @@ post_ft(CHKARGS) } if (0 == ok) { - mandoc_vmsg(MANDOCERR_BADFONT, man->parse, n->line, - n->pos, "%s", cp); + mandoc_vmsg(MANDOCERR_FT_BAD, man->parse, + n->line, n->pos, "ft %s", cp); *cp = '\0'; } @@ -325,17 +320,6 @@ pre_sec(CHKARGS) } static int -post_sec(CHKARGS) -{ - - if ( ! (MAN_HEAD == n->type && 0 == n->nchild)) - return(1); - - man_nmsg(man, n, MANDOCERR_SYNTARGCOUNT); - return(0); -} - -static int check_part(CHKARGS) { @@ -357,11 +341,17 @@ check_par(CHKARGS) break; case MAN_BODY: if (0 == n->nchild) - man_nmsg(man, n, MANDOCERR_IGNPAR); + mandoc_vmsg(MANDOCERR_PAR_SKIP, + man->parse, n->line, n->pos, + "%s empty", man_macronames[n->tok]); break; case MAN_HEAD: if (n->nchild) - man_nmsg(man, n, MANDOCERR_ARGSLOST); + mandoc_vmsg(MANDOCERR_ARG_SKIP, + man->parse, n->line, n->pos, + "%s %s%s", man_macronames[n->tok], + n->child->string, + n->nchild > 1 ? " ..." : ""); break; default: break; @@ -381,7 +371,9 @@ post_IP(CHKARGS) break; case MAN_BODY: if (0 == n->parent->head->nchild && 0 == n->nchild) - man_nmsg(man, n, MANDOCERR_IGNPAR); + mandoc_vmsg(MANDOCERR_PAR_SKIP, + man->parse, n->line, n->pos, + "%s empty", man_macronames[n->tok]); break; default: break; @@ -414,10 +406,10 @@ post_TH(CHKARGS) /* Only warn about this once... */ if (isalpha((unsigned char)*p) && ! isupper((unsigned char)*p)) { - mandoc_msg(MANDOCERR_TITLE_CASE, + mandoc_vmsg(MANDOCERR_TITLE_CASE, man->parse, n->line, n->pos + (p - n->string), - n->string); + "TH %s", n->string); break; } } @@ -445,7 +437,9 @@ post_TH(CHKARGS) n->line, n->pos); } else { man->meta.date = mandoc_strdup(""); - man_nmsg(man, n ? n : nb, MANDOCERR_DATE_MISSING); + mandoc_msg(MANDOCERR_DATE_MISSING, man->parse, + n ? n->line : nb->line, + n ? n->pos : nb->pos, "TH"); } /* TITLE MSEC DATE ->SOURCE<- VOL */ @@ -475,7 +469,8 @@ post_nf(CHKARGS) { if (MAN_LITERAL & man->flags) - man_nmsg(man, n, MANDOCERR_SCOPEREP); + mandoc_msg(MANDOCERR_NF_SKIP, man->parse, + n->line, n->pos, "nf"); man->flags |= MAN_LITERAL; return(1); @@ -486,7 +481,8 @@ post_fi(CHKARGS) { if ( ! (MAN_LITERAL & man->flags)) - man_nmsg(man, n, MANDOCERR_WNOSCOPE); + mandoc_msg(MANDOCERR_FI_SKIP, man->parse, + n->line, n->pos, "fi"); man->flags &= ~MAN_LITERAL; return(1); @@ -579,7 +575,9 @@ post_vs(CHKARGS) case MAN_SH: /* FALLTHROUGH */ case MAN_SS: - man_nmsg(man, n, MANDOCERR_IGNPAR); + mandoc_vmsg(MANDOCERR_PAR_SKIP, man->parse, n->line, n->pos, + "%s after %s", man_macronames[n->tok], + man_macronames[n->parent->tok]); /* FALLTHROUGH */ case MAN_MAX: /*