=================================================================== RCS file: /cvs/mandoc/mdoc_validate.c,v retrieving revision 1.174 retrieving revision 1.181 diff -u -p -r1.174 -r1.181 --- mandoc/mdoc_validate.c 2011/08/16 12:23:51 1.174 +++ mandoc/mdoc_validate.c 2011/12/03 16:58:54 1.181 @@ -1,4 +1,4 @@ -/* $Id: mdoc_validate.c,v 1.174 2011/08/16 12:23:51 kristaps Exp $ */ +/* $Id: mdoc_validate.c,v 1.181 2011/12/03 16:58:54 schwarze Exp $ */ /* * Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2010, 2011 Ingo Schwarze @@ -545,12 +545,11 @@ check_text(struct mdoc *m, int ln, int pos, char *p) { char *cp; - cp = p; - for (cp = p; NULL != (p = strchr(p, '\t')); p++) { - if (MDOC_LITERAL & m->flags) - continue; - mdoc_pmsg(m, ln, (int)(p - cp), MANDOCERR_BADTAB); - } + if (MDOC_LITERAL & m->flags) + return; + + for (cp = p; NULL != (p = strchr(p, '\t')); p++) + mdoc_pmsg(m, ln, pos + (int)(p - cp), MANDOCERR_BADTAB); } static int @@ -703,7 +702,7 @@ pre_bl(PRE_ARGS) if (LIST_column == lt) { n->norm->Bl.ncols = n->args->argv[i].sz; - n->norm->Bl.cols = (const char **) + n->norm->Bl.cols = (void *) n->args->argv[i].value; } } @@ -1521,7 +1520,7 @@ post_bl_head(POST_ARGS) ((size_t)mdoc->last->nchild * sizeof(char *)); mdoc->last->norm->Bl.ncols = np->args->argv[j].sz; - mdoc->last->norm->Bl.cols = (const char **)np->args->argv[j].value; + mdoc->last->norm->Bl.cols = (void *)np->args->argv[j].value; for (i = 0, nn = mdoc->last->child; nn; i++) { np->args->argv[j].value[i] = nn->string; @@ -1695,6 +1694,14 @@ post_rs(POST_ARGS) } /* + * Nothing to sort if only invalid nodes were found + * inside the `Rs' body. + */ + + if (NULL == mdoc->last->child) + return(1); + + /* * The full `Rs' block needs special handling to order the * sub-elements according to `rsord'. Pick through each element * and correctly order it. This is a insertion sort. @@ -1819,6 +1826,7 @@ static int post_sh_head(POST_ARGS) { char buf[BUFSIZ]; + struct mdoc_node *n; enum mdoc_sec sec; int c; @@ -1853,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) @@ -2077,7 +2099,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);