=================================================================== RCS file: /cvs/mandoc/mdoc_validate.c,v retrieving revision 1.178 retrieving revision 1.183 diff -u -p -r1.178 -r1.183 --- mandoc/mdoc_validate.c 2011/11/18 14:58:24 1.178 +++ mandoc/mdoc_validate.c 2012/05/27 17:39:28 1.183 @@ -1,6 +1,6 @@ -/* $Id: mdoc_validate.c,v 1.178 2011/11/18 14:58:24 joerg Exp $ */ +/* $Id: mdoc_validate.c,v 1.183 2012/05/27 17:39:28 schwarze Exp $ */ /* - * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons + * Copyright (c) 2008-2012 Kristaps Dzonsons * Copyright (c) 2010, 2011 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any @@ -661,8 +661,13 @@ pre_bl(PRE_ARGS) comp = 1; break; case (MDOC_Width): - dup = (NULL != n->norm->Bl.width); - width = n->args->argv[i].value[0]; + /* NB: this can be empty! */ + if (n->args->argv[i].sz) { + width = n->args->argv[i].value[0]; + dup = (NULL != n->norm->Bl.width); + break; + } + mdoc_nmsg(mdoc, n, MANDOCERR_IGNARGV); break; case (MDOC_Offset): /* NB: this can be empty! */ @@ -1693,7 +1698,11 @@ post_rs(POST_ARGS) mdoc_node_delete(mdoc, nn); } - /* Bail out early if a plain text node is found inside .Rs. */ + /* + * Nothing to sort if only invalid nodes were found + * inside the `Rs' body. + */ + if (NULL == mdoc->last->child) return(1); @@ -1822,6 +1831,7 @@ static int post_sh_head(POST_ARGS) { char buf[BUFSIZ]; + struct mdoc_node *n; enum mdoc_sec sec; int c; @@ -1856,6 +1866,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) @@ -2080,7 +2104,7 @@ post_dt(POST_ARGS) * arch = NULL */ - cp = mdoc_a2msec(nn->string); + cp = mandoc_a2msec(nn->string); if (cp) { mdoc->meta.vol = mandoc_strdup(cp); mdoc->meta.msec = mandoc_strdup(nn->string);