summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--regress/usr.bin/mandoc/mdoc/blank/Makefile6
-rw-r--r--regress/usr.bin/mandoc/mdoc/blank/list.in66
-rw-r--r--regress/usr.bin/mandoc/mdoc/blank/list.out_ascii42
-rw-r--r--usr.bin/mandoc/libmdoc.h3
-rw-r--r--usr.bin/mandoc/mandoc.h3
-rw-r--r--usr.bin/mandoc/mdoc.c12
-rw-r--r--usr.bin/mandoc/mdoc_validate.c39
-rw-r--r--usr.bin/mandoc/read.c3
8 files changed, 162 insertions, 12 deletions
diff --git a/regress/usr.bin/mandoc/mdoc/blank/Makefile b/regress/usr.bin/mandoc/mdoc/blank/Makefile
index 3de9b48f2a7..d1a10ae120e 100644
--- a/regress/usr.bin/mandoc/mdoc/blank/Makefile
+++ b/regress/usr.bin/mandoc/mdoc/blank/Makefile
@@ -1,5 +1,7 @@
-# $OpenBSD: Makefile,v 1.2 2011/11/17 16:28:46 schwarze Exp $
+# $OpenBSD: Makefile,v 1.3 2012/07/18 11:09:30 schwarze Exp $
-REGRESS_TARGETS=line comment
+REGRESS_TARGETS = line comment list
+
+SKIP_TMAN = list
.include <bsd.regress.mk>
diff --git a/regress/usr.bin/mandoc/mdoc/blank/list.in b/regress/usr.bin/mandoc/mdoc/blank/list.in
new file mode 100644
index 00000000000..067e3dcfcc6
--- /dev/null
+++ b/regress/usr.bin/mandoc/mdoc/blank/list.in
@@ -0,0 +1,66 @@
+.Dd July 17, 2012
+.Dt BLANK-LIST 1
+.Os OpenBSD
+.Sh NAME
+.Nm blank-list
+.Nd handling of blank lines in lists
+.Sh DESCRIPTION
+normal list:
+.Bl -item -offset indent
+.It
+first item
+.It
+second item
+.El
+list with paragraphs:
+.Bl -item -offset indent
+.It
+first item
+.Pp
+.It
+second item
+.Pp
+.El
+list with final paragraph:
+.Bl -item -offset indent
+.It
+item
+.El
+.Pp
+list with double paragraph:
+.Bl -item -offset indent
+.It
+item
+.Pp
+.El
+.Pp
+normal compact list:
+.Bl -item -compact -offset indent
+.It
+first item
+.It
+second item
+.El
+compact list with paragraphs:
+.Bl -item -compact -offset indent
+.It
+first item
+.Pp
+.It
+second item
+.Pp
+.El
+compact list with final paragraph:
+.Bl -item -compact -offset indent
+.It
+item
+.El
+.Pp
+compact list with double paragraph:
+.Bl -item -compact -offset indent
+.It
+item
+.Pp
+.El
+.Pp
+End.
diff --git a/regress/usr.bin/mandoc/mdoc/blank/list.out_ascii b/regress/usr.bin/mandoc/mdoc/blank/list.out_ascii
new file mode 100644
index 00000000000..5dce1cb2c76
--- /dev/null
+++ b/regress/usr.bin/mandoc/mdoc/blank/list.out_ascii
@@ -0,0 +1,42 @@
+BLANK-LIST(1) OpenBSD Reference Manual BLANK-LIST(1)
+
+NNAAMMEE
+ bbllaannkk--lliisstt - handling of blank lines in lists
+
+DDEESSCCRRIIPPTTIIOONN
+ normal list:
+
+ first item
+
+ second item
+ list with paragraphs:
+
+ first item
+
+ second item
+
+ list with final paragraph:
+
+ item
+
+ list with double paragraph:
+
+ item
+
+ normal compact list:
+ first item
+ second item
+ compact list with paragraphs:
+ first item
+
+ second item
+
+ compact list with final paragraph:
+ item
+
+ compact list with double paragraph:
+ item
+
+ End.
+
+OpenBSD July 17, 2012 OpenBSD
diff --git a/usr.bin/mandoc/libmdoc.h b/usr.bin/mandoc/libmdoc.h
index b2903007b1e..f82dfb58140 100644
--- a/usr.bin/mandoc/libmdoc.h
+++ b/usr.bin/mandoc/libmdoc.h
@@ -1,4 +1,4 @@
-/* $Id: libmdoc.h,v 1.49 2012/05/24 23:33:23 schwarze Exp $ */
+/* $Id: libmdoc.h,v 1.50 2012/07/18 11:09:30 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h
index 2e615dd4fac..4eec27dabc4 100644
--- a/usr.bin/mandoc/mandoc.h
+++ b/usr.bin/mandoc/mandoc.h
@@ -1,4 +1,4 @@
-/* $Id: mandoc.h,v 1.47 2012/07/12 15:09:50 schwarze Exp $ */
+/* $Id: mandoc.h,v 1.48 2012/07/18 11:09:30 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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/usr.bin/mandoc/mdoc.c b/usr.bin/mandoc/mdoc.c
index ca5b09b2550..9ffc5dab783 100644
--- a/usr.bin/mandoc/mdoc.c
+++ b/usr.bin/mandoc/mdoc.c
@@ -1,7 +1,7 @@
-/* $Id: mdoc.c,v 1.90 2012/07/18 10:36:20 schwarze Exp $ */
+/* $Id: mdoc.c,v 1.91 2012/07/18 11:09:30 schwarze Exp $ */
/*
* 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
@@ -644,6 +644,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/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c
index 52632492afa..5523381b672 100644
--- a/usr.bin/mandoc/mdoc_validate.c
+++ b/usr.bin/mandoc/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.106 2012/07/16 09:51:03 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.107 2012/07/18 11:09:30 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011, 2012 Ingo Schwarze <schwarze@openbsd.org>
@@ -1349,7 +1349,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
@@ -1365,13 +1365,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/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c
index 38218aae620..2cc0f6a27ed 100644
--- a/usr.bin/mandoc/read.c
+++ b/usr.bin/mandoc/read.c
@@ -1,4 +1,4 @@
-/* $Id: read.c,v 1.9 2012/07/12 15:09:50 schwarze Exp $ */
+/* $Id: read.c,v 1.10 2012/07/18 11:09:30 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -102,6 +102,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",