From: Kristaps Dzonsons Date: Wed, 12 Jan 2011 16:55:22 +0000 (+0000) Subject: Downgrade -man message of ignored empty paragraph to MANDOC_IGNPAR. The X-Git-Tag: VERSION_1_10_10~79 X-Git-Url: https://git.cameronkatri.com/mandoc.git/commitdiff_plain/3993f4018345b61b4de0132b521228ff054fc092 Downgrade -man message of ignored empty paragraph to MANDOC_IGNPAR. The change in man_macro.c was from an assertion caused by a subtle problem: (1) macro is removed, causing m->last to be m->last->parent; (2) by jumping to the m->last->parent after post-validation, the original m->last->parent is skipped; (3) the rewinder climbs to the root of the tree and aborts. The original issue recorded in the TODO by schwarze@, reminded by Brad Smith. --- diff --git a/TODO b/TODO index c4ecf365..e6516ced 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,6 @@ ************************************************************************ * Official mandoc TODO. -* $Id: TODO,v 1.77 2011/01/12 15:50:42 kristaps Exp $ +* $Id: TODO,v 1.78 2011/01/12 16:55:22 kristaps Exp $ ************************************************************************ ************************************************************************ @@ -172,10 +172,6 @@ * error reporting issues ************************************************************************ -- downgrade "ERROR: macro requires body argument(s)" to WARNING - for the typical man(7) cases, it keeps confusing people - reminded by brad@ Sun, Jan 09, 2011 at 09:45:58PM -0500 - ************************************************************************ * performance issues ************************************************************************ diff --git a/man_macro.c b/man_macro.c index bd0ca992..dbc4b4b0 100644 --- a/man_macro.c +++ b/man_macro.c @@ -1,4 +1,4 @@ -/* $Id: man_macro.c,v 1.54 2010/12/08 10:58:22 kristaps Exp $ */ +/* $Id: man_macro.c,v 1.55 2011/01/12 16:55:22 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * @@ -107,19 +107,27 @@ rew_warn(struct man *m, struct man_node *n, enum mandocerr er) * will be used if an explicit block scope is being closed out. */ int -man_unscope(struct man *m, const struct man_node *n, +man_unscope(struct man *m, const struct man_node *to, enum mandocerr er) { + struct man_node *n; - assert(n); + assert(to); /* LINTED */ - while (m->last != n) { + while (m->last != to) { + /* + * Save the parent here, because we may delete the + * m->last node in the post-validation phase and reset + * it to m->last->parent, causing a step in the closing + * out to be lost. + */ + n = m->last->parent; if ( ! rew_warn(m, m->last, er)) return(0); if ( ! man_valid_post(m)) return(0); - m->last = m->last->parent; + m->last = n; assert(m->last); } diff --git a/man_validate.c b/man_validate.c index 136b63aa..0762c15a 100644 --- a/man_validate.c +++ b/man_validate.c @@ -1,4 +1,4 @@ -/* $Id: man_validate.c,v 1.58 2011/01/12 15:50:42 kristaps Exp $ */ +/* $Id: man_validate.c,v 1.59 2011/01/12 16:55:22 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * @@ -80,12 +80,12 @@ static const struct man_valid man_valids[MAN_MAX] = { { pres_bline, posts_th }, /* TH */ { pres_bline, posts_sec }, /* SH */ { pres_bline, posts_sec }, /* SS */ - { pres_bline, posts_par }, /* TP */ + { pres_bline, NULL }, /* TP */ { pres_bline, posts_par }, /* LP */ { pres_bline, posts_par }, /* PP */ { pres_bline, posts_par }, /* P */ - { pres_bline, posts_par }, /* IP */ - { pres_bline, posts_par }, /* HP */ + { pres_bline, NULL }, /* IP */ + { pres_bline, NULL }, /* HP */ { NULL, NULL }, /* SM */ { NULL, NULL }, /* SB */ { NULL, NULL }, /* BI */ @@ -359,33 +359,22 @@ static int check_par(CHKARGS) { - if (MAN_BODY == n->type) - switch (n->tok) { - case (MAN_IP): - /* FALLTHROUGH */ - case (MAN_HP): - /* FALLTHROUGH */ - case (MAN_TP): - /* Body-less lists are ok. */ - break; - default: - if (0 == n->nchild) - man_nmsg(m, n, MANDOCERR_NOBODY); - break; - } - if (MAN_HEAD == n->type) - switch (n->tok) { - case (MAN_PP): - /* FALLTHROUGH */ - case (MAN_P): - /* FALLTHROUGH */ - case (MAN_LP): - if (n->nchild) - man_nmsg(m, n, MANDOCERR_ARGSLOST); - break; - default: - break; - } + switch (n->type) { + case (MAN_BLOCK): + if (0 == n->body->nchild) + man_node_delete(m, n); + break; + case (MAN_BODY): + if (0 == n->nchild) + man_nmsg(m, n, MANDOCERR_IGNPAR); + break; + case (MAN_HEAD): + if (n->nchild) + man_nmsg(m, n, MANDOCERR_ARGSLOST); + break; + default: + break; + } return(1); }