* mdocml: If there is random stuff inside a .Bl block body before the
@ 2013-10-06 13:32 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2013-10-06 13:32 UTC (permalink / raw)
To: source
Log Message:
-----------
If there is random stuff inside a .Bl block body before the first .It,
do not throw a FATAL error and do not die, but just throw a WARNING
and move the stuff out of the .Bl block.
This bug felt completely 2008-ish; meanwhile, such bugs from the
Kristaps-doesnt-like-syntax-errors-so-lets-just-give-up--Era
are becoming rare, but this was one of the last survivors.
Thanks to bentley@ for reminding me to finally fix this.
Modified Files:
--------------
mdocml:
TODO
mdoc_validate.c
Revision Data
-------------
Index: mdoc_validate.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_validate.c,v
retrieving revision 1.194
retrieving revision 1.195
diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.194 -r1.195
--- mdoc_validate.c
+++ mdoc_validate.c
@@ -1590,32 +1590,71 @@ post_bl_head(POST_ARGS)
static int
post_bl(POST_ARGS)
{
- struct mdoc_node *n;
+ struct mdoc_node *nparent, *nprev; /* of the Bl block */
+ struct mdoc_node *nblock, *nbody; /* of the Bl */
+ struct mdoc_node *nchild, *nnext; /* of the Bl body */
- if (MDOC_HEAD == mdoc->last->type)
- return(post_bl_head(mdoc));
- if (MDOC_BLOCK == mdoc->last->type)
+ nbody = mdoc->last;
+ switch (nbody->type) {
+ case (MDOC_BLOCK):
return(post_bl_block(mdoc));
- if (MDOC_BODY != mdoc->last->type)
+ case (MDOC_HEAD):
+ return(post_bl_head(mdoc));
+ case (MDOC_BODY):
+ break;
+ default:
return(1);
+ }
- for (n = mdoc->last->child; n; n = n->next) {
- switch (n->tok) {
- case (MDOC_Lp):
- /* FALLTHROUGH */
- case (MDOC_Pp):
- mdoc_nmsg(mdoc, n, MANDOCERR_CHILD);
- /* FALLTHROUGH */
- case (MDOC_It):
- /* FALLTHROUGH */
- case (MDOC_Sm):
+ nchild = nbody->child;
+ while (NULL != nchild) {
+ if (MDOC_It == nchild->tok || MDOC_Sm == nchild->tok) {
+ nchild = nchild->next;
continue;
- default:
- break;
}
- mdoc_nmsg(mdoc, n, MANDOCERR_SYNTCHILD);
- return(0);
+ mdoc_nmsg(mdoc, nchild, MANDOCERR_CHILD);
+
+ /*
+ * Move the node out of the Bl block.
+ * First, collect all required node pointers.
+ */
+
+ nblock = nbody->parent;
+ nprev = nblock->prev;
+ nparent = nblock->parent;
+ nnext = nchild->next;
+
+ /*
+ * Unlink this child.
+ */
+
+ assert(NULL == nchild->prev);
+ if (0 == --nbody->nchild) {
+ nbody->child = NULL;
+ nbody->last = NULL;
+ assert(NULL == nnext);
+ } else {
+ nbody->child = nnext;
+ nnext->prev = NULL;
+ }
+
+ /*
+ * Relink this child.
+ */
+
+ nchild->parent = nparent;
+ nchild->prev = nprev;
+ nchild->next = nblock;
+
+ nblock->prev = nchild;
+ nparent->nchild++;
+ if (NULL == nprev)
+ nparent->child = nchild;
+ else
+ nprev->next = nchild;
+
+ nchild = nnext;
}
return(1);
Index: TODO
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/TODO,v
retrieving revision 1.157
retrieving revision 1.158
diff -LTODO -LTODO -u -p -r1.157 -r1.158
--- TODO
+++ TODO
@@ -7,13 +7,7 @@
* crashes
************************************************************************
-- .Bl -tag followed by a text node preceding the first .It should not
- throw a FATAL error, but only a normal ERROR. Putting this into the
- HEAD of an implicit .It might be cleanest, inserting an implicit .Pp
- or just dumping the orphan stuff directly into the BODY of the .Bl
- might be easier to implement, and all options can no doubt be made
- to yield correct (i.e. groff bug-compatible) rendering.
- Anthony J. Bentley on discuss@ Sun, 22 Sep 2013 16:33:21 -0600
+None known.
************************************************************************
* missing features
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2013-10-06 13:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-06 13:32 mdocml: If there is random stuff inside a .Bl block body before the schwarze
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).