=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/mdoc_macro.c,v retrieving revision 1.169 retrieving revision 1.170 diff -u -r1.169 -r1.170 --- src/usr.bin/mandoc/mdoc_macro.c 2017/02/10 22:19:11 1.169 +++ src/usr.bin/mandoc/mdoc_macro.c 2017/02/11 13:23:11 1.170 @@ -1,4 +1,4 @@ -/* $OpenBSD: mdoc_macro.c,v 1.169 2017/02/10 22:19:11 schwarze Exp $ */ +/* $OpenBSD: mdoc_macro.c,v 1.170 2017/02/11 13:23:11 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010, 2012-2016 Ingo Schwarze @@ -48,6 +48,8 @@ struct roff_node *); static int lookup(struct roff_man *, int, int, int, const char *); static int macro_or_word(MACRO_PROT_ARGS, int); +static void break_intermediate(struct roff_node *, + struct roff_node *); static int parse_rest(struct roff_man *, int, int, int *, char *); static int rew_alt(int); static void rew_elem(struct roff_man *, int); @@ -374,6 +376,16 @@ rew_last(mdoc, n); } +static void +break_intermediate(struct roff_node *n, struct roff_node *breaker) +{ + while (n != breaker) { + if ( ! (n->flags & NODE_VALID)) + n->flags |= NODE_BROKEN; + n = n->parent; + } +} + /* * If there is an open sub-block of the target requiring * explicit close-out, postpone closing out the target until @@ -388,14 +400,12 @@ irc = 0; for (n = mdoc->last; n != NULL && n != target; n = n->parent) { - if (n->flags & NODE_ENDED) { - if ( ! (n->flags & NODE_VALID)) - n->flags |= NODE_BROKEN; + if (n->flags & NODE_ENDED) continue; - } if (n->type == ROFFT_BLOCK && mdoc_macros[n->tok].flags & MDOC_EXPLICIT) { irc = 1; + break_intermediate(mdoc->last, n); n->flags |= NODE_BROKEN; if (target->type == ROFFT_HEAD) target->flags |= NODE_ENDED; @@ -566,11 +576,8 @@ endbody = itblk = later = NULL; for (n = mdoc->last; n; n = n->parent) { - if (n->flags & NODE_ENDED) { - if ( ! (n->flags & NODE_VALID)) - n->flags |= NODE_BROKEN; + if (n->flags & NODE_ENDED) continue; - } /* * Mismatching end macros can never break anything @@ -597,7 +604,6 @@ } if (atok == n->tok) { - assert(body); /* * Found the start of our own block. @@ -648,6 +654,7 @@ /* Breaking an open sub block. */ + break_intermediate(mdoc->last, body); n->flags |= NODE_BROKEN; if (later == NULL) later = n;