summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2017-03-06 17:25:25 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2017-03-06 17:25:25 +0000
commite97a931ae10e92cc819161356e644924f116be0e (patch)
tree27f5744ecdb4b5f55ab3add94f886dc5cf7afa84 /usr.bin
parente29e95111c52b9166101865542edd7dcc27c60ef (diff)
Using .Nd only makes sense in the NAME section.
Warn if that macro occurs elsewhere. Triggered by a question from Dag-Erling Smoergrav <des @ FreeBSD>.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mandoc/mandoc.112
-rw-r--r--usr.bin/mandoc/mandoc.h3
-rw-r--r--usr.bin/mandoc/mdoc_validate.c6
-rw-r--r--usr.bin/mandoc/read.c3
4 files changed, 19 insertions, 5 deletions
diff --git a/usr.bin/mandoc/mandoc.1 b/usr.bin/mandoc/mandoc.1
index ced1237d02d..e60f1fec44f 100644
--- a/usr.bin/mandoc/mandoc.1
+++ b/usr.bin/mandoc/mandoc.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: mandoc.1,v 1.100 2017/03/04 17:17:17 schwarze Exp $
+.\" $OpenBSD: mandoc.1,v 1.101 2017/03/06 17:25:24 schwarze Exp $
.\"
.\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2012, 2014-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: March 4 2017 $
+.Dd $Mdocdate: March 6 2017 $
.Dt MANDOC 1
.Os
.Sh NAME
@@ -908,6 +908,14 @@ The
.Ic \&Nd
macro lacks the required argument.
The title line of the manual will end after the dash.
+.It Sy "description line outside NAME section"
+.Pq mdoc
+An
+.Ic \&Nd
+macro appears outside the NAME section.
+The arguments are printed anyway and the following text is used for
+.Xr apropos 1 ,
+but none of that behaviour is portable.
.It Sy "sections out of conventional order"
.Pq mdoc
A standard section occurs after another section it usually precedes.
diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h
index 3662aa8fbd7..074354f69ef 100644
--- a/usr.bin/mandoc/mandoc.h
+++ b/usr.bin/mandoc/mandoc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mandoc.h,v 1.156 2017/01/28 23:26:56 schwarze Exp $ */
+/* $OpenBSD: mandoc.h,v 1.157 2017/03/06 17:25:24 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -71,6 +71,7 @@ enum mandocerr {
MANDOCERR_NAMESEC_BAD, /* bad NAME section content: macro */
MANDOCERR_NAMESEC_PUNCT, /* missing comma before name: Nm name */
MANDOCERR_ND_EMPTY, /* missing description line, using "" */
+ MANDOCERR_ND_LATE, /* description line outside NAME section */
MANDOCERR_SEC_ORDER, /* sections out of conventional order: Sh title */
MANDOCERR_SEC_REP, /* duplicate section title: Sh title */
MANDOCERR_SEC_MSEC, /* unexpected section: Sh title for ... only */
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c
index 5c9ea668d60..713660fca46 100644
--- a/usr.bin/mandoc/mdoc_validate.c
+++ b/usr.bin/mandoc/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdoc_validate.c,v 1.234 2017/02/06 03:41:44 schwarze Exp $ */
+/* $OpenBSD: mdoc_validate.c,v 1.235 2017/03/06 17:25:24 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -1023,6 +1023,10 @@ post_nd(POST_ARGS)
if (n->type != ROFFT_BODY)
return;
+ if (n->sec != SEC_NAME)
+ mandoc_msg(MANDOCERR_ND_LATE, mdoc->parse,
+ n->line, n->pos, "Nd");
+
if (n->child == NULL)
mandoc_msg(MANDOCERR_ND_EMPTY, mdoc->parse,
n->line, n->pos, "Nd");
diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c
index 4acf098a0db..45638414076 100644
--- a/usr.bin/mandoc/read.c
+++ b/usr.bin/mandoc/read.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: read.c,v 1.133 2017/02/03 18:18:08 schwarze Exp $ */
+/* $OpenBSD: read.c,v 1.134 2017/03/06 17:25:24 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -109,6 +109,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"bad NAME section content",
"missing comma before name",
"missing description line, using \"\"",
+ "description line outside NAME section",
"sections out of conventional order",
"duplicate section title",
"unexpected section",