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.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.c')
-rw-r--r-- | mdoc.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -1,7 +1,7 @@ /* $Id$ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> - * Copyright (c) 2010, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> + * Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -419,8 +419,10 @@ mdoc_endbody_alloc(struct mdoc *mdoc, int line, int pos, enum mdoct tok, { struct mdoc_node *p; + body->flags |= MDOC_ENDED; + body->parent->flags |= MDOC_ENDED; p = node_alloc(mdoc, line, pos, tok, MDOC_BODY); - p->pending = body; + p->body = body; p->norm = body->norm; p->end = end; node_append(mdoc, p); |