diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2015-02-12 12:24:33 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2015-02-12 12:24:33 +0000 |
commit | 33da493a191d7c9f4dd1e96d178eeb11d1218abc (patch) | |
tree | 686aa38a2482948a55f21b52b23fc267ac7c729f /mdoc_html.c | |
parent | a5ec4b155fd2b5756e3494144f8347f3ad03d4c1 (diff) | |
download | mandoc-33da493a191d7c9f4dd1e96d178eeb11d1218abc.tar.gz |
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.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/mdoc_html.c b/mdoc_html.c index 067cfabd..bff01cf2 100644 --- a/mdoc_html.c +++ b/mdoc_html.c @@ -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) |