summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--TODO7
-rw-r--r--libmdoc.h1
-rw-r--r--mandoc.h1
-rw-r--r--mdoc.c10
-rw-r--r--mdoc_validate.c37
-rw-r--r--read.c1
6 files changed, 45 insertions, 12 deletions
diff --git a/TODO b/TODO
index 407823f5..771677cd 100644
--- a/TODO
+++ b/TODO
@@ -203,13 +203,6 @@
is just "o\bo".
see for example OpenBSD ksh(1)
-- A bogus .Pp between two .It must not produce a double blank line,
- see between -R and -r in OpenBSD rm(1), before "update" in mount(8),
- or in DIAGNOSTICS in init(8), or before "is always true" in ksh(1).
- The same happens with .Pp just before .El, see bgpd.conf(5).
- Also have `It' complain if `Pp' is invoked at certain times (not
- -compact?).
-
- .Pp between two .It in .Bl -column should produce one,
not two blank lines, see e.g. login.conf(5).
reported by jmc@ Sun, 17 Apr 2011 14:04:58 +0059
diff --git a/libmdoc.h b/libmdoc.h
index cf3a20bb..684f8ed1 100644
--- a/libmdoc.h
+++ b/libmdoc.h
@@ -118,6 +118,7 @@ int mdoc_endbody_alloc(struct mdoc *m, int line, int pos,
enum mdoct tok, struct mdoc_node *body,
enum mdoc_endbody end);
void mdoc_node_delete(struct mdoc *, struct mdoc_node *);
+int mdoc_node_relink(struct mdoc *, struct mdoc_node *);
void mdoc_hash_init(void);
enum mdoct mdoc_hash_find(const char *);
const char *mdoc_a2att(const char *);
diff --git a/mandoc.h b/mandoc.h
index 79807423..af8a5d93 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -68,6 +68,7 @@ enum mandocerr {
/* related to macros and nesting */
MANDOCERR_MACROOBS, /* skipping obsolete macro */
MANDOCERR_IGNPAR, /* skipping paragraph macro */
+ MANDOCERR_MOVEPAR, /* moving paragraph macro out of list */
MANDOCERR_IGNNS, /* skipping no-space macro */
MANDOCERR_SCOPENEST, /* blocks badly nested */
MANDOCERR_CHILD, /* child violates parent syntax */
diff --git a/mdoc.c b/mdoc.c
index e5486a52..01a0d2a6 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -1,7 +1,7 @@
/* $Id$ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010, 2012 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -648,6 +648,14 @@ mdoc_node_delete(struct mdoc *m, struct mdoc_node *p)
mdoc_node_free(p);
}
+int
+mdoc_node_relink(struct mdoc *m, struct mdoc_node *p)
+{
+
+ mdoc_node_unlink(m, p);
+ return(node_append(m, p));
+}
+
#if 0
/*
* Pre-treat a text line.
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 7f2a991e..8dcd19f8 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -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);
}
diff --git a/read.c b/read.c
index 84c35363..c124e1b2 100644
--- a/read.c
+++ b/read.c
@@ -113,6 +113,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
/* related to macros and nesting */
"skipping obsolete macro",
"skipping paragraph macro",
+ "moving paragraph macro out of list",
"skipping no-space macro",
"blocks badly nested",
"child violates parent syntax",