=================================================================== RCS file: /cvs/mandoc/mdoc_macro.c,v retrieving revision 1.193 retrieving revision 1.197 diff -u -p -r1.193 -r1.197 --- mandoc/mdoc_macro.c 2015/04/19 14:57:38 1.193 +++ mandoc/mdoc_macro.c 2015/04/29 21:58:32 1.197 @@ -1,4 +1,4 @@ -/* $Id: mdoc_macro.c,v 1.193 2015/04/19 14:57:38 schwarze Exp $ */ +/* $Id: mdoc_macro.c,v 1.197 2015/04/29 21:58:32 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010, 2012-2015 Ingo Schwarze @@ -210,7 +210,7 @@ const struct mdoc_macro * const mdoc_macros = __mdoc_m * are errors. */ void -mdoc_macroend(struct roff_man *mdoc) +mdoc_endparse(struct roff_man *mdoc) { struct roff_node *n; @@ -291,19 +291,22 @@ rew_pending(struct roff_man *mdoc, const struct roff_n for (;;) { rew_last(mdoc, n); - switch (n->type) { - case ROFFT_HEAD: - roff_body_alloc(mdoc, n->line, n->pos, n->tok); - return; - case ROFFT_BLOCK: - break; - default: - return; - } + if (mdoc->last == n) { + switch (n->type) { + case ROFFT_HEAD: + roff_body_alloc(mdoc, n->line, n->pos, + n->tok); + return; + case ROFFT_BLOCK: + break; + default: + return; + } + if ( ! (n->flags & MDOC_BROKEN)) + return; + } else + n = mdoc->last; - if ( ! (n->flags & MDOC_BROKEN)) - return; - for (;;) { if ((n = n->parent) == NULL) return; @@ -641,6 +644,8 @@ blk_exp_close(MACRO_PROT_ARGS) if (body == NULL) { mandoc_msg(MANDOCERR_BLK_NOTOPEN, mdoc->parse, line, ppos, mdoc_macronames[tok]); + if (later != NULL) + later->flags &= ~MDOC_BROKEN; if (maxargs && endbody == NULL) { /* * Stray .Ec without previous .Eo: @@ -668,6 +673,8 @@ blk_exp_close(MACRO_PROT_ARGS) if (endbody != NULL) n = endbody; + + ntok = TOKEN_NONE; for (j = 0; ; j++) { lastarg = *pos; @@ -695,7 +702,7 @@ blk_exp_close(MACRO_PROT_ARGS) } if (n != NULL) { - if (n != mdoc->last && n->flags & MDOC_BROKEN) { + if (ntok != TOKEN_NONE && n->flags & MDOC_BROKEN) { target = n; do target = target->parent;