From b981028b7b1f17de7dd7e6ce533d8c0b06c2a96f Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Wed, 2 Jul 2014 05:52:24 +0000 Subject: [PATCH] Improve "skipping paragraph macro" messages, showing which macro was skipped and before or after what. --- man_validate.c | 14 ++++++++++---- mandoc.h | 6 +++--- mdoc_validate.c | 44 ++++++++++++++++++++++++++++++-------------- 3 files changed, 43 insertions(+), 21 deletions(-) diff --git a/man_validate.c b/man_validate.c index 579e91ff..545341d9 100644 --- a/man_validate.c +++ b/man_validate.c @@ -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.95 2014/07/02 05:52:24 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze @@ -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: /* diff --git a/mandoc.h b/mandoc.h index f61d28f0..18cddca9 100644 --- a/mandoc.h +++ b/mandoc.h @@ -1,4 +1,4 @@ -/* $Id: mandoc.h,v 1.126 2014/07/02 03:48:07 schwarze Exp $ */ +/* $Id: mandoc.h,v 1.127 2014/07/02 05:52:25 schwarze Exp $ */ /* * Copyright (c) 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -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 01475f95..ec72c2ab 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -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.219 2014/07/02 05:52:25 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2014 Ingo Schwarze @@ -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); } -- 2.47.1