summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2016-12-28 17:21:17 +0000
committerschwarze <schwarze@openbsd.org>2016-12-28 17:21:17 +0000
commit5ae080407ec66ae75ef79a0b293b7b3aeddc028e (patch)
tree139a2fcd0c75dad23bfd313917554d92b1d5fcc2
parentIn pf_find_state() pkt_sk was set to NULL if pkt_sk->reverse was (diff)
downloadwireguard-openbsd-5ae080407ec66ae75ef79a0b293b7b3aeddc028e.tar.xz
wireguard-openbsd-5ae080407ec66ae75ef79a0b293b7b3aeddc028e.zip
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.
-rw-r--r--regress/usr.bin/mandoc/mdoc/Xr/args.out_lint1
-rw-r--r--share/man/man7/mdoc.711
-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
6 files changed, 38 insertions, 13 deletions
diff --git a/regress/usr.bin/mandoc/mdoc/Xr/args.out_lint b/regress/usr.bin/mandoc/mdoc/Xr/args.out_lint
index 703a0abf3e6..8ade74883cc 100644
--- a/regress/usr.bin/mandoc/mdoc/Xr/args.out_lint
+++ b/regress/usr.bin/mandoc/mdoc/Xr/args.out_lint
@@ -1,2 +1,3 @@
mandoc: args.in:24:2: WARNING: skipping empty macro: Xr
mandoc: args.in:26:2: WARNING: skipping empty macro: Xr
+mandoc: args.in:22:2: WARNING: missing section argument: Xr echo
diff --git a/share/man/man7/mdoc.7 b/share/man/man7/mdoc.7
index 1a54280fbf5..f46b578a174 100644
--- a/share/man/man7/mdoc.7
+++ b/share/man/man7/mdoc.7
@@ -1,4 +1,4 @@
-.\" $OpenBSD: mdoc.7,v 1.145 2016/10/11 17:30:28 schwarze Exp $
+.\" $OpenBSD: mdoc.7,v 1.146 2016/12/28 17:21:17 schwarze Exp $
.\"
.\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2010, 2011, 2013 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: October 11 2016 $
+.Dd $Mdocdate: December 28 2016 $
.Dt MDOC 7
.Os
.Sh NAME
@@ -2726,14 +2726,13 @@ Link to another manual
.Pq Qq cross-reference .
Its syntax is as follows:
.Pp
-.D1 Pf \. Sx \&Xr Ar name Op section
+.D1 Pf \. Sx \&Xr Ar name section
.Pp
Cross reference the
.Ar name
and
.Ar section
-number of another man page;
-omitting the section number is rarely useful.
+number of another man page.
.Pp
Examples:
.Dl \&.Xr mandoc 1
@@ -3045,7 +3044,7 @@ then the macro accepts an arbitrary number of arguments.
.It Sx \&Ux Ta Yes Ta Yes Ta n
.It Sx \&Va Ta Yes Ta Yes Ta n
.It Sx \&Vt Ta Yes Ta Yes Ta >0
-.It Sx \&Xr Ta Yes Ta Yes Ta >0
+.It Sx \&Xr Ta Yes Ta Yes Ta 2
.It Sx \&br Ta \&No Ta \&No Ta 0
.It Sx \&sp Ta \&No Ta \&No Ta 1
.El
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 \"\"",