summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2016-12-28 17:21:18 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2016-12-28 17:21:18 +0000
commit78bcab5a5c200a429af92290e862e9f8a619eb00 (patch)
tree09a22a769989037a6efb0b7a2ee832d435f19abc /usr.bin/mandoc
parent378b5bd42555fe5d57a9dee3590c2be2f4a46187 (diff)
Make the second, section number argument of .Xr mandatory.
In fact, we have been requiring it for many years. The only reason to not warn when it was missing was excessive traditionalism - it was optional in 4.4BSD.
Diffstat (limited to 'usr.bin/mandoc')
-rw-r--r--usr.bin/mandoc/mandoc.111
-rw-r--r--usr.bin/mandoc/mandoc.h3
-rw-r--r--usr.bin/mandoc/mdoc_validate.c22
-rw-r--r--usr.bin/mandoc/read.c3
4 files changed, 32 insertions, 7 deletions
diff --git a/usr.bin/mandoc/mandoc.1 b/usr.bin/mandoc/mandoc.1
index 3b942c9ceb2..a3f2740f20d 100644
--- a/usr.bin/mandoc/mandoc.1
+++ b/usr.bin/mandoc/mandoc.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: mandoc.1,v 1.88 2015/11/05 17:47:53 schwarze Exp $
+.\" $OpenBSD: mandoc.1,v 1.89 2016/12/28 17:21:17 schwarze Exp $
.\"
.\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2012, 2014, 2015 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: November 5 2015 $
+.Dd $Mdocdate: December 28 2016 $
.Dt MANDOC 1
.Os
.Sh NAME
@@ -1147,6 +1147,13 @@ macro is immediately followed by an
.Ic \&Re
macro on the next input line.
Such an empty block does not produce any output.
+.It Sy "missing section argument"
+.Pq mdoc
+An
+.Ic \&Xr
+macro lacks its second, section number argument.
+The first argument, i.e. the name, is printed, but without subsequent
+parantheses.
.It Sy "missing -std argument, adding it"
.Pq mdoc
An
diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h
index c10730d026b..c0e1ff4ca2d 100644
--- a/usr.bin/mandoc/mandoc.h
+++ b/usr.bin/mandoc/mandoc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mandoc.h,v 1.152 2016/10/09 18:16:46 schwarze Exp $ */
+/* $OpenBSD: mandoc.h,v 1.153 2016/12/28 17:21:17 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2016 Ingo Schwarze <schwarze@openbsd.org>
@@ -107,6 +107,7 @@ enum mandocerr {
MANDOCERR_BF_BADFONT, /* unknown font type, using \fR: Bf font */
MANDOCERR_PF_SKIP, /* nothing follows prefix: Pf arg */
MANDOCERR_RS_EMPTY, /* empty reference block: Rs */
+ MANDOCERR_XR_NOSEC, /* missing section argument: Xr arg */
MANDOCERR_ARG_STD, /* missing -std argument, adding it: macro */
MANDOCERR_OP_EMPTY, /* missing option string, using "": OP */
MANDOCERR_UR_NOHEAD, /* missing resource identifier, using "": UR */
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c
index a087a21a470..bbfc3b9cdfe 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.225 2016/10/09 18:16:46 schwarze Exp $ */
+/* $OpenBSD: mdoc_validate.c,v 1.226 2016/12/28 17:21:17 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2016 Ingo Schwarze <schwarze@openbsd.org>
@@ -101,6 +101,7 @@ static void post_sh_authors(POST_ARGS);
static void post_sm(POST_ARGS);
static void post_st(POST_ARGS);
static void post_std(POST_ARGS);
+static void post_xr(POST_ARGS);
static v_post mdoc_valids[MDOC_MAX] = {
NULL, /* Ap */
@@ -143,7 +144,7 @@ static v_post mdoc_valids[MDOC_MAX] = {
post_st, /* St */
NULL, /* Va */
NULL, /* Vt */
- NULL, /* Xr */
+ post_xr, /* Xr */
NULL, /* %A */
post_hyph, /* %B */ /* FIXME: can be used outside Rs/Re. */
NULL, /* %D */
@@ -1798,6 +1799,21 @@ post_sh_head(POST_ARGS)
}
static void
+post_xr(POST_ARGS)
+{
+ struct roff_node *n, *nch;
+
+ n = mdoc->last;
+ nch = n->child;
+ if (nch->next == NULL) {
+ mandoc_vmsg(MANDOCERR_XR_NOSEC, mdoc->parse,
+ n->line, n->pos, "Xr %s", nch->string);
+ return;
+ }
+ assert(nch->next == n->last);
+}
+
+static void
post_ignpar(POST_ARGS)
{
struct roff_node *np;
@@ -1993,7 +2009,7 @@ post_dt(POST_ARGS)
}
}
- /* Mandatory second argument: section. */
+ /* Mandatory second argument: section. */
if (nn != NULL)
nn = nn->next;
diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c
index 3a44fedcf37..589983dd357 100644
--- a/usr.bin/mandoc/read.c
+++ b/usr.bin/mandoc/read.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: read.c,v 1.127 2016/12/07 22:57:35 schwarze Exp $ */
+/* $OpenBSD: read.c,v 1.128 2016/12/28 17:21:17 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2016 Ingo Schwarze <schwarze@openbsd.org>
@@ -145,6 +145,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"unknown font type, using \\fR",
"nothing follows prefix",
"empty reference block",
+ "missing section argument",
"missing -std argument, adding it",
"missing option string, using \"\"",
"missing resource identifier, using \"\"",