diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-07-02 05:52:24 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-07-02 05:52:24 +0000 |
commit | 82b921ceb9411072fc74ac549038d20ec4b2dc2a (patch) | |
tree | e2b75775d1bc0f63e7c29fa50870bc570f854d0d | |
parent | 6953ebc600f2fbc755c081f62f54e09e92399d68 (diff) | |
download | mandoc-82b921ceb9411072fc74ac549038d20ec4b2dc2a.tar.gz |
Improve "skipping paragraph macro" messages,
showing which macro was skipped and before or after what.
-rw-r--r-- | man_validate.c | 12 | ||||
-rw-r--r-- | mandoc.h | 4 | ||||
-rw-r--r-- | mdoc_validate.c | 42 |
3 files changed, 40 insertions, 18 deletions
diff --git a/man_validate.c b/man_validate.c index ad01423f..def1e47d 100644 --- a/man_validate.c +++ b/man_validate.c @@ -357,7 +357,9 @@ 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) @@ -381,7 +383,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; @@ -579,7 +583,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: /* @@ -72,8 +72,8 @@ enum mandocerr { /* related to macros and nesting */ MANDOCERR_MACRO_OBS, /* obsolete macro: macro */ - MANDOCERR_IGNPAR, /* skipping paragraph macro */ - MANDOCERR_MOVEPAR, /* moving paragraph macro out of list */ + MANDOCERR_PAR_SKIP, /* skipping paragraph macro: macro ... */ + MANDOCERR_PAR_MOVE, /* moving paragraph macro out of list: macro */ MANDOCERR_IGNNS, /* skipping no-space macro */ MANDOCERR_SCOPENEST, /* blocks badly nested */ MANDOCERR_CHILD, /* child violates parent syntax */ diff --git a/mdoc_validate.c b/mdoc_validate.c index 54257b29..a0dad19c 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -1385,12 +1385,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; @@ -2078,13 +2083,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 +2127,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 +2138,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); } |