From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from krisdoz.my.domain (schwarze@localhost [127.0.0.1]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id pB3Gwsew002714 for ; Sat, 3 Dec 2011 11:58:54 -0500 (EST) Received: (from schwarze@localhost) by krisdoz.my.domain (8.14.3/8.14.3/Submit) id pB3Gwsk2022866; Sat, 3 Dec 2011 11:58:54 -0500 (EST) Date: Sat, 3 Dec 2011 11:58:54 -0500 (EST) Message-Id: <201112031658.pB3Gwsk2022866@krisdoz.my.domain> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: schwarze@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: When processing .Sh HEAD, as soon as we know which section this X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- 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@. Modified Files: -------------- mdocml: 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.180 retrieving revision 1.181 diff -Lmdoc_validate.c -Lmdoc_validate.c -u -p -r1.180 -r1.181 --- mdoc_validate.c +++ 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; @@ -1859,6 +1860,20 @@ post_sh_head(POST_ARGS) /* Mark our last section. */ 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. */ -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv