=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/mdoc_macro.c,v retrieving revision 1.28 retrieving revision 1.29 diff -c -r1.28 -r1.29 *** src/usr.bin/mandoc/mdoc_macro.c 2010/02/18 02:11:26 1.28 --- src/usr.bin/mandoc/mdoc_macro.c 2010/02/26 12:12:24 1.29 *************** *** 1,4 **** ! /* $Id: mdoc_macro.c,v 1.28 2010/02/18 02:11:26 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * --- 1,4 ---- ! /* $Id: mdoc_macro.c,v 1.29 2010/02/26 12:12:24 schwarze Exp $ */ /* * Copyright (c) 2008, 2009 Kristaps Dzonsons * *************** *** 591,597 **** } assert(n); ! return(rew_last(m, n)); } --- 591,611 ---- } assert(n); ! if ( ! rew_last(m, n)) ! return(0); ! ! /* ! * The current block extends an enclosing block beyond a line break. ! * Now that the current block ends, close the enclosing block, too. ! */ ! if ((n = n->pending) != NULL) { ! assert(MDOC_HEAD == n->type); ! if ( ! rew_last(m, n)) ! return(0); ! if ( ! mdoc_body_alloc(m, n->line, n->pos, n->tok)) ! return(0); ! } ! return(1); } *************** *** 855,860 **** --- 869,875 ---- { int c, lastarg, reopen, dohead; struct mdoc_arg *arg; + struct mdoc_node *head, *n; char *p; /* *************** *** 900,909 **** if ( ! mdoc_block_alloc(m, line, ppos, tok, arg)) return(0); if (0 == buf[*pos]) { - if ( ! mdoc_head_alloc(m, line, ppos, tok)) - return(0); if ( ! rew_sub(MDOC_HEAD, m, tok, line, ppos)) return(0); if ( ! mdoc_body_alloc(m, line, ppos, tok)) --- 915,925 ---- if ( ! mdoc_block_alloc(m, line, ppos, tok, arg)) return(0); + if ( ! mdoc_head_alloc(m, line, ppos, tok)) + return(0); + head = m->last; if (0 == buf[*pos]) { if ( ! rew_sub(MDOC_HEAD, m, tok, line, ppos)) return(0); if ( ! mdoc_body_alloc(m, line, ppos, tok)) *************** *** 911,919 **** return(1); } - if ( ! mdoc_head_alloc(m, line, ppos, tok)) - return(0); - /* Immediately close out head and enter body, if applicable. */ if (0 == dohead) { --- 927,932 ---- *************** *** 935,940 **** --- 948,954 ---- assert(dohead); if (reopen && ! mdoc_head_alloc(m, line, ppos, tok)) return(0); + head = m->last; /* * Phrases are self-contained macro phrases used * in the columnar output of a macro. They need *************** *** 966,971 **** --- 980,998 ---- /* If the body's already open, then just return. */ if (0 == dohead) return(1); + + /* + * If there is an open sub-block requiring explicit close-out, + * postpone switching the current block from head to body + * until the rew_sub() call closing out that sub-block. + */ + for (n = m->last; n && n != head; n = n->parent) { + if (MDOC_BLOCK == n->type && + MDOC_EXPLICIT & mdoc_macros[n->tok].flags) { + n->pending = head; + return(1); + } + } if ( ! rew_sub(MDOC_HEAD, m, tok, line, ppos)) return(0);