summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mandoc.117
-rw-r--r--mandoc.h5
-rw-r--r--mdoc_validate.c28
-rw-r--r--read.c5
4 files changed, 36 insertions, 19 deletions
diff --git a/mandoc.1 b/mandoc.1
index 65e61074..10623355 100644
--- a/mandoc.1
+++ b/mandoc.1
@@ -1,7 +1,7 @@
.\" $Id$
.\"
.\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
-.\" Copyright (c) 2012, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
+.\" Copyright (c) 2012, 2014-2017 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
@@ -809,11 +809,13 @@ This may confuse
.Xr makewhatis 8
and
.Xr apropos 1 .
-.It Sy "NAME section without name"
+.It Sy "NAME section without Nm before Nd"
.Pq mdoc
The NAME section does not contain any
.Ic \&Nm
-child macro.
+child macro before the first
+.Ic \&Nd
+macro.
.It Sy "NAME section without description"
.Pq mdoc
The NAME section lacks the mandatory
@@ -830,6 +832,11 @@ The NAME section contains plain text or macros other than
.Ic \&Nm
and
.Ic \&Nd .
+.It Sy "missing comma before name"
+.Pq mdoc
+The NAME section contains an
+.Ic \&Nm
+macro that is neither the first one nor preceded by a comma.
.It Sy "missing description line, using \(dq\(dq"
.Pq mdoc
The
@@ -1622,8 +1629,8 @@ macro fails to specify the list type.
.It Sy "missing manual name, using \(dq\(dq"
.Pq mdoc
The first call to
-.Ic \&Nm
-lacks the required argument.
+.Ic \&Nm ,
+or any call in the NAME section, lacks the required argument.
.It Sy "uname(3) system call failed, using UNKNOWN"
.Pq mdoc
The
diff --git a/mandoc.h b/mandoc.h
index 79756aec..623d3b61 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -1,7 +1,7 @@
/* $Id$ */
/*
* Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010-2016 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010-2017 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
@@ -65,10 +65,11 @@ enum mandocerr {
MANDOCERR_DOC_EMPTY, /* no document body */
MANDOCERR_SEC_BEFORE, /* content before first section header: macro */
MANDOCERR_NAMESEC_FIRST, /* first section is not NAME: Sh title */
- MANDOCERR_NAMESEC_NONM, /* NAME section without name */
+ MANDOCERR_NAMESEC_NONM, /* NAME section without Nm before Nd */
MANDOCERR_NAMESEC_NOND, /* NAME section without description */
MANDOCERR_NAMESEC_ND, /* description not at the end of NAME */
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_SEC_ORDER, /* sections out of conventional order: Sh title */
MANDOCERR_SEC_REP, /* duplicate section title: Sh title */
diff --git a/mdoc_validate.c b/mdoc_validate.c
index f5f73df0..49168e51 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,7 +1,7 @@
/* $Id$ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010-2016 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2010 Joerg Sonnenberger <joerg@netbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -851,12 +851,11 @@ post_nm(POST_ARGS)
n->last->tok == MDOC_Lp))
mdoc_node_relink(mdoc, n->last);
- if (mdoc->meta.name != NULL)
- return;
-
- deroff(&mdoc->meta.name, n);
-
if (mdoc->meta.name == NULL)
+ deroff(&mdoc->meta.name, n);
+
+ if (mdoc->meta.name == NULL ||
+ (mdoc->lastsec == SEC_NAME && n->child == NULL))
mandoc_msg(MANDOCERR_NM_NONAME, mdoc->parse,
n->line, n->pos, "Nm");
}
@@ -1598,8 +1597,12 @@ post_sh_name(POST_ARGS)
for (n = mdoc->last->child; n != NULL; n = n->next) {
switch (n->tok) {
case MDOC_Nm:
+ if (hasnm && n->child != NULL)
+ mandoc_vmsg(MANDOCERR_NAMESEC_PUNCT,
+ mdoc->parse, n->line, n->pos,
+ "Nm %s", n->child->string);
hasnm = 1;
- break;
+ continue;
case MDOC_Nd:
hasnd = 1;
if (n->next != NULL)
@@ -1607,14 +1610,19 @@ post_sh_name(POST_ARGS)
mdoc->parse, n->line, n->pos, NULL);
break;
case TOKEN_NONE:
- if (hasnm)
- break;
+ if (n->type == ROFFT_TEXT &&
+ n->string[0] == ',' && n->string[1] == '\0' &&
+ n->next != NULL && n->next->tok == MDOC_Nm) {
+ n = n->next;
+ continue;
+ }
/* FALLTHROUGH */
default:
mandoc_msg(MANDOCERR_NAMESEC_BAD, mdoc->parse,
n->line, n->pos, mdoc_macronames[n->tok]);
- break;
+ continue;
}
+ break;
}
if ( ! hasnm)
diff --git a/read.c b/read.c
index 9bfe2bda..566fac78 100644
--- a/read.c
+++ b/read.c
@@ -1,7 +1,7 @@
/* $Id$ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010-2016 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2010, 2012 Joerg Sonnenberger <joerg@netbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -108,10 +108,11 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"no document body",
"content before first section header",
"first section is not \"NAME\"",
- "NAME section without name",
+ "NAME section without Nm before Nd",
"NAME section without description",
"description not at the end of NAME",
"bad NAME section content",
+ "missing comma before name",
"missing description line, using \"\"",
"sections out of conventional order",
"duplicate section title",