=================================================================== RCS file: /cvs/mandoc/mdoc_macro.c,v retrieving revision 1.192 retrieving revision 1.201 diff -u -p -r1.192 -r1.201 --- mandoc/mdoc_macro.c 2015/04/19 14:25:41 1.192 +++ mandoc/mdoc_macro.c 2015/09/26 00:54:04 1.201 @@ -1,4 +1,4 @@ -/* $Id: mdoc_macro.c,v 1.192 2015/04/19 14:25:41 schwarze Exp $ */ +/* $Id: mdoc_macro.c,v 1.201 2015/09/26 00:54:04 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; @@ -258,12 +258,11 @@ lookup(struct roff_man *mdoc, int from, int line, int static void rew_last(struct roff_man *mdoc, const struct roff_node *to) { - struct roff_node *n, *np; + struct roff_node *np; if (to->flags & MDOC_VALID) return; - mdoc->next = ROFF_NEXT_SIBLING; while (mdoc->last != to) { /* * Save the parent here, because we may delete the @@ -273,11 +272,10 @@ rew_last(struct roff_man *mdoc, const struct roff_node */ np = mdoc->last->parent; mdoc_valid_post(mdoc); - n = mdoc->last; mdoc->last = np; assert(mdoc->last); - mdoc->last->last = n; } + mdoc->next = ROFF_NEXT_SIBLING; mdoc_valid_post(mdoc); } @@ -291,19 +289,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; @@ -362,7 +363,6 @@ rew_alt(int tok) default: return(tok); } - /* NOTREACHED */ } static void @@ -641,12 +641,14 @@ 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: * Break the output line, keep the arguments. */ - mdoc_elem_alloc(mdoc, line, ppos, MDOC_br, NULL); + roff_elem_alloc(mdoc, line, ppos, MDOC_br); rew_elem(mdoc, MDOC_br); } } else if (endbody == NULL) { @@ -668,6 +670,8 @@ blk_exp_close(MACRO_PROT_ARGS) if (endbody != NULL) n = endbody; + + ntok = TOKEN_NONE; for (j = 0; ; j++) { lastarg = *pos; @@ -695,7 +699,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; @@ -990,7 +994,7 @@ blk_full(MACRO_PROT_ARGS) if (tok == MDOC_It && (n == NULL || n->tok != MDOC_Bl)) { mandoc_vmsg(MANDOCERR_IT_STRAY, mdoc->parse, line, ppos, "It %s", buf + *pos); - mdoc_elem_alloc(mdoc, line, ppos, MDOC_br, NULL); + roff_elem_alloc(mdoc, line, ppos, MDOC_br); rew_elem(mdoc, MDOC_br); return; } @@ -1223,7 +1227,7 @@ blk_part_exp(MACRO_PROT_ARGS) * case of `Eo'); and a body that may be empty. */ - mdoc_block_alloc(mdoc, line, ppos, tok, NULL); + roff_block_alloc(mdoc, line, ppos, tok); head = NULL; for (;;) { la = *pos; @@ -1392,7 +1396,7 @@ in_line_eoln(MACRO_PROT_ARGS) if (mdoc->next == ROFF_NEXT_SIBLING) n = n->parent; if (n->tok == MDOC_Nm) - rew_last(mdoc, mdoc->last->parent); + rew_last(mdoc, n->parent); } if (buf[*pos] == '\0' &&