aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_html.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-02-12 12:24:33 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-02-12 12:24:33 +0000
commite89dd22a4fc303f8cdf4180c4fb9655a45e8e724 (patch)
tree555addff5e528e9a957bfbbad3ddc582a60eec97 /mdoc_html.c
parent69f54c346ec87b3899a95b224628d8df313bbc85 (diff)
downloadmandoc-e89dd22a4fc303f8cdf4180c4fb9655a45e8e724.tar.gz
mandoc-e89dd22a4fc303f8cdf4180c4fb9655a45e8e724.tar.zst
mandoc-e89dd22a4fc303f8cdf4180c4fb9655a45e8e724.zip
Delete the mdoc_node.pending pointer and the function calculating
it, make_pending(), which was the most difficult function of the whole mdoc(7) parser. After almost five years of maintaining this hellhole, i just noticed the pointer isn't needed after all. Blocks are always rewound in the reverse order they were opened; that even holds for broken blocks. Consequently, it is sufficient to just mark broken blogs with the flag MDOC_BROKEN and breaking blocks with the flag MDOC_ENDED. When rewinding, instead of iterating the pending pointers, just iterate from each broken block to its parents, rewinding all that are MDOC_ENDED and stopping after processing the first ancestor that it not MDOC_BROKEN. For ENDBODY markers, use the mdoc_node.body pointer in place of the former mdoc_node.pending. This also fixes an assertion failure found by jsg@ with afl, test case #467 (Bo Bl It Bd Bc It), where (surprise surprise) the pending pointer got corrupted. Improved functionality, minus one function, minus one struct field, minus 50 lines of code.
Diffstat (limited to 'mdoc_html.c')
-rw-r--r--mdoc_html.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/mdoc_html.c b/mdoc_html.c
index 1ab344fc..09104f8f 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.224 2015/02/11 14:15:12 schwarze Exp $ */
+/* $Id: mdoc_html.c,v 1.225 2015/02/12 12:24:33 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -35,7 +35,7 @@
#define INDENT 5
#define MDOC_ARGS const struct mdoc_meta *meta, \
- const struct mdoc_node *n, \
+ struct mdoc_node *n, \
struct html *h
#ifndef MIN
@@ -267,7 +267,7 @@ void
html_mdoc(void *arg, const struct mdoc *mdoc)
{
- print_mdoc(mdoc_meta(mdoc), mdoc_node(mdoc),
+ print_mdoc(mdoc_meta(mdoc), mdoc_node(mdoc)->child,
(struct html *)arg);
putchar('\n');
}
@@ -387,6 +387,7 @@ print_mdoc_node(MDOC_ARGS)
child = 1;
t = h->tags.head;
+ n->flags &= ~MDOC_ENDED;
switch (n->type) {
case MDOC_ROOT:
@@ -457,7 +458,7 @@ print_mdoc_node(MDOC_ARGS)
break;
(*mdocs[n->tok].post)(meta, n, h);
if (n->end != ENDBODY_NOT)
- n->pending->flags |= MDOC_ENDED;
+ n->body->flags |= MDOC_ENDED;
if (n->end == ENDBODY_NOSPACE)
h->flags |= HTML_NOSPACE;
break;
@@ -1122,7 +1123,7 @@ mdoc_bd_pre(MDOC_ARGS)
{
struct htmlpair tag[2];
int comp, sv;
- const struct mdoc_node *nn;
+ struct mdoc_node *nn;
struct roffsu su;
if (MDOC_HEAD == n->type)