aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_validate.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2016-08-20 14:43:50 +0000
committerIngo Schwarze <schwarze@openbsd.org>2016-08-20 14:43:50 +0000
commitd9fc4466dfe11ea393b124444b1eb4041db86b6d (patch)
treeddc11f8d8fb1ed25def30c7a4107584f9258d2b7 /mdoc_validate.c
parent9858b8f71c3c328d0b65b6edac5fe7ac7682f1e3 (diff)
downloadmandoc-d9fc4466dfe11ea393b124444b1eb4041db86b6d.tar.gz
mandoc-d9fc4466dfe11ea393b124444b1eb4041db86b6d.tar.zst
mandoc-d9fc4466dfe11ea393b124444b1eb4041db86b6d.zip
If a column list starts with implicit rows (that is, rows without .It)
and roff-level nodes (e.g. tbl or eqn) follow, don't run into an assertion. Instead, wrap the roff-level nodes in their own row. Issue found by tb@ with afl(1).
Diffstat (limited to 'mdoc_validate.c')
-rw-r--r--mdoc_validate.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c
index a997d4a9..0afd2f11 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.307 2016/08/11 11:39:46 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.308 2016/08/20 14:43:50 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2016 Ingo Schwarze <schwarze@openbsd.org>
@@ -1329,11 +1329,41 @@ 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;
}
@@ -1349,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;