=================================================================== RCS file: /cvs/mandoc/mdoc_validate.c,v retrieving revision 1.306 retrieving revision 1.308 diff -u -p -r1.306 -r1.308 --- mandoc/mdoc_validate.c 2016/08/11 10:47:16 1.306 +++ mandoc/mdoc_validate.c 2016/08/20 14:43:50 1.308 @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.306 2016/08/11 10:47:16 schwarze Exp $ */ +/* $Id: mdoc_validate.c,v 1.308 2016/08/20 14:43:50 schwarze Exp $ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010-2016 Ingo Schwarze @@ -887,7 +887,8 @@ post_display(POST_ARGS) switch (n->type) { case ROFFT_BODY: if (n->end != ENDBODY_NOT) { - if (n->tok == MDOC_Bd && n->parent->args == NULL) + if (n->tok == MDOC_Bd && + n->body->parent->args == NULL) roff_node_delete(mdoc, n); } else if (n->child == NULL) mandoc_msg(MANDOCERR_BLK_EMPTY, mdoc->parse, @@ -1328,14 +1329,44 @@ post_bl(POST_ARGS) return; } while (nchild != NULL) { + nnext = nchild->next; if (nchild->tok == MDOC_It || (nchild->tok == MDOC_Sm && - nchild->next != NULL && - nchild->next->tok == MDOC_It)) { - nchild = nchild->next; + nnext != NULL && nnext->tok == MDOC_It)) { + nchild = nnext; continue; } + /* + * In .Bl -column, the first rows may be implicit, + * that is, they may not start with .It macros. + * Such rows may be followed by nodes generated on the + * roff level, for example .TS, which cannot be moved + * out of the list. In that case, wrap such roff nodes + * into an implicit row. + */ + + if (nchild->prev != NULL) { + mdoc->last = nchild; + mdoc->next = ROFF_NEXT_SIBLING; + roff_block_alloc(mdoc, nchild->line, + nchild->pos, MDOC_It); + roff_head_alloc(mdoc, nchild->line, + nchild->pos, MDOC_It); + mdoc->next = ROFF_NEXT_SIBLING; + roff_body_alloc(mdoc, nchild->line, + nchild->pos, MDOC_It); + while (nchild->tok != MDOC_It) { + mdoc_node_relink(mdoc, nchild); + if ((nchild = nnext) == NULL) + break; + nnext = nchild->next; + mdoc->next = ROFF_NEXT_SIBLING; + } + mdoc->last = nbody; + continue; + } + mandoc_msg(MANDOCERR_BL_MOVE, mdoc->parse, nchild->line, nchild->pos, mdoc_macronames[nchild->tok]); @@ -1348,13 +1379,11 @@ post_bl(POST_ARGS) nblock = nbody->parent; nprev = nblock->prev; nparent = nblock->parent; - nnext = nchild->next; /* * Unlink this child. */ - assert(nchild->prev == NULL); nbody->child = nnext; if (nnext == NULL) nbody->last = NULL;