diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2011-12-03 16:58:54 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2011-12-03 16:58:54 +0000 |
commit | 289d7863c034d433321d52e2b4c0e4ea878df0ec (patch) | |
tree | 739f90806bab4c469677497ee8ee1ed5e6bddb15 /mdoc_validate.c | |
parent | bd84fbf4d9f29e27d3b34608e5bc635a50f2b889 (diff) | |
download | mandoc-289d7863c034d433321d52e2b4c0e4ea878df0ec.tar.gz |
When processing .Sh HEAD, as soon as we know which section this is,
fix up the section attributes of the HEAD, it's parent BLOCK, and
all its (text) children. This is required because the section
attributes get set when each node is allocated, i.e. before processing
the content of the node itself. Thus, the listed nodes got the section
attribute of the preceding section. No need to fix up the BODY, all
is fine there already.
Found while implementing TYPE_Sh for mandocdb(8).
OK and comment requested by kristaps@.
Diffstat (limited to 'mdoc_validate.c')
-rw-r--r-- | mdoc_validate.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c index 7dc24961..422e4c3a 100644 --- a/mdoc_validate.c +++ b/mdoc_validate.c @@ -1826,6 +1826,7 @@ static int post_sh_head(POST_ARGS) { char buf[BUFSIZ]; + struct mdoc_node *n; enum mdoc_sec sec; int c; @@ -1860,6 +1861,20 @@ post_sh_head(POST_ARGS) mdoc->lastsec = sec; + /* + * Set the section attribute for the current HEAD, for its + * parent BLOCK, and for the HEAD children; the latter can + * only be TEXT nodes, so no recursion is needed. + * For other blocks and elements, including .Sh BODY, this is + * done when allocating the node data structures, but for .Sh + * BLOCK and HEAD, the section is still unknown at that time. + */ + + mdoc->last->parent->sec = sec; + mdoc->last->sec = sec; + for (n = mdoc->last->child; n; n = n->next) + n->sec = sec; + /* We don't care about custom sections after this. */ if (SEC_CUSTOM == sec) |