aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mdoc_validate.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2012-07-18 11:11:12 +0000
committerIngo Schwarze <schwarze@openbsd.org>2012-07-18 11:11:12 +0000
commit50e01545158506c75fea9e1828a29ae1b8c911f0 (patch)
tree5aa45bc2432543e3f9c1c56589afa3665d7c21bd /mdoc_validate.c
parent7a9cc4a7da8d626f4484e36248129567b2bef7f8 (diff)
downloadmandoc-50e01545158506c75fea9e1828a29ae1b8c911f0.tar.gz
mandoc-50e01545158506c75fea9e1828a29ae1b8c911f0.tar.zst
mandoc-50e01545158506c75fea9e1828a29ae1b8c911f0.zip
Fix handling of paragraph macros inside lists:
* When they are trailing the last item, move them outside the list. * When they are trailing any other none-compact item, drop them. OpenBSD rev. mdoc_validate.c 1.107, mdoc.c 1.91
Diffstat (limited to 'mdoc_validate.c')
-rw-r--r--mdoc_validate.c39
1 files changed, 34 insertions, 5 deletions
diff --git a/mdoc_validate.c b/mdoc_validate.c
index d85f0cc2..b690efbc 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.188 2012/07/16 09:51:54 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.189 2012/07/18 11:11:12 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011, 2012 Ingo Schwarze <schwarze@openbsd.org>
@@ -1353,7 +1353,7 @@ post_it(POST_ARGS)
static int
post_bl_block(POST_ARGS)
{
- struct mdoc_node *n;
+ struct mdoc_node *n, *ni, *nc;
/*
* These are fairly complicated, so we've broken them into two
@@ -1369,13 +1369,42 @@ post_bl_block(POST_ARGS)
NULL == n->norm->Bl.width) {
if ( ! post_bl_block_tag(mdoc))
return(0);
+ assert(n->norm->Bl.width);
} else if (NULL != n->norm->Bl.width) {
if ( ! post_bl_block_width(mdoc))
return(0);
- } else
- return(1);
+ assert(n->norm->Bl.width);
+ }
- assert(n->norm->Bl.width);
+ for (ni = n->body->child; ni; ni = ni->next) {
+ if (NULL == ni->body)
+ continue;
+ nc = ni->body->last;
+ while (NULL != nc) {
+ switch (nc->tok) {
+ case (MDOC_Pp):
+ /* FALLTHROUGH */
+ case (MDOC_Lp):
+ /* FALLTHROUGH */
+ case (MDOC_br):
+ break;
+ default:
+ nc = NULL;
+ continue;
+ }
+ if (NULL == ni->next) {
+ mdoc_nmsg(mdoc, nc, MANDOCERR_MOVEPAR);
+ if ( ! mdoc_node_relink(mdoc, nc))
+ return(0);
+ } else if (0 == n->norm->Bl.comp &&
+ LIST_column != n->norm->Bl.type) {
+ mdoc_nmsg(mdoc, nc, MANDOCERR_IGNPAR);
+ mdoc_node_delete(mdoc, nc);
+ } else
+ break;
+ nc = ni->body->last;
+ }
+ }
return(1);
}