aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--mandoc.134
-rw-r--r--mandoc.h4
-rw-r--r--mdoc_validate.c40
-rw-r--r--read.c4
-rw-r--r--roff.h9
5 files changed, 83 insertions, 8 deletions
diff --git a/mandoc.1 b/mandoc.1
index 783ac2b9..e2b2a1c8 100644
--- a/mandoc.1
+++ b/mandoc.1
@@ -1,4 +1,4 @@
-.\" $Id: mandoc.1,v 1.194 2017/06/06 15:01:04 schwarze Exp $
+.\" $Id: mandoc.1,v 1.195 2017/06/07 23:29:48 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: June 6 2017 $
+.Dd $Mdocdate: June 7 2017 $
.Dt MANDOC 1
.Os
.Sh NAME
@@ -75,6 +75,11 @@ and for the
.Xr man 7
.Ic \&TH
macro.
+This can also be used to perform style checks according to the
+conventions of one operating system while running on a different
+operating system; see
+.Sx Style messages
+for details.
.It Fl K Ar encoding
Specify the input encoding.
The supported
@@ -743,6 +748,15 @@ option or
.Fl T Cm lint
output mode.
.Ss Style messages
+As indicated below, some style checks are only performed if a
+specific operating system name occurs in the arguments of the
+.Ic \&Os
+macro, of the
+.Fl Ios
+command line option, or, if neither are present, in the return value
+of the
+.Xr uname 3
+function.
.Bl -ohang
.It Sy "useless macro"
.Pq mdoc
@@ -763,6 +777,22 @@ macro that could be represented using
.Ic \&Fx ,
or
.Ic \&Dx .
+.It Sy "errnos out of order"
+.Pq mdoc, Nx
+The
+.Ic \&Er
+items in a
+.Ic \&Bl
+list are not in alphabetical order.
+.It Sy "duplicate errno"
+.Pq mdoc, Nx
+A
+.Ic \&Bl
+list contains two consecutive
+.Ic \&It
+entries describing the same
+.Ic \&Er
+number.
.It Sy "description line ends with a full stop"
.Pq mdoc
Do not use punctuation at the end of an
diff --git a/mandoc.h b/mandoc.h
index fc8418ae..e3813d07 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -1,4 +1,4 @@
-/* $Id: mandoc.h,v 1.223 2017/06/06 15:01:04 schwarze Exp $ */
+/* $Id: mandoc.h,v 1.224 2017/06/07 23:29:48 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -48,6 +48,8 @@ enum mandocerr {
MANDOCERR_MACRO_USELESS, /* useless macro: macro */
MANDOCERR_BX, /* consider using OS macro: macro */
+ MANDOCERR_ER_ORDER, /* errnos out of order: Er ... */
+ MANDOCERR_ER_REP, /* duplicate errno: Er ... */
MANDOCERR_ND_DOT, /* description line ends with a full stop */
MANDOCERR_WARNING, /* ===== start of warnings ===== */
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 69e6f603..589fd794 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.330 2017/06/01 15:25:39 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.331 2017/06/07 23:29:48 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -1479,6 +1479,8 @@ post_bl(POST_ARGS)
struct roff_node *nparent, *nprev; /* of the Bl block */
struct roff_node *nblock, *nbody; /* of the Bl */
struct roff_node *nchild, *nnext; /* of the Bl body */
+ const char *prev_Er;
+ int order;
nbody = mdoc->last;
switch (nbody->type) {
@@ -1579,6 +1581,34 @@ post_bl(POST_ARGS)
nchild = nnext;
}
+
+ if (mdoc->meta.os_e != MDOC_OS_NETBSD)
+ return;
+
+ prev_Er = NULL;
+ for (nchild = nbody->child; nchild != NULL; nchild = nchild->next) {
+ if (nchild->tok != MDOC_It)
+ continue;
+ if ((nnext = nchild->head->child) == NULL)
+ continue;
+ if (nnext->type == ROFFT_BLOCK)
+ nnext = nnext->body->child;
+ if (nnext == NULL || nnext->tok != MDOC_Er)
+ continue;
+ nnext = nnext->child;
+ if (prev_Er != NULL) {
+ order = strcmp(prev_Er, nnext->string);
+ if (order > 0)
+ mandoc_vmsg(MANDOCERR_ER_ORDER,
+ mdoc->parse, nnext->line, nnext->pos,
+ "Er %s %s", prev_Er, nnext->string);
+ else if (order == 0)
+ mandoc_vmsg(MANDOCERR_ER_REP,
+ mdoc->parse, nnext->line, nnext->pos,
+ "Er %s", prev_Er);
+ }
+ prev_Er = nnext->string;
+ }
}
static void
@@ -2385,11 +2415,11 @@ post_os(POST_ARGS)
mdoc->meta.os = NULL;
deroff(&mdoc->meta.os, n);
if (mdoc->meta.os)
- return;
+ goto out;
if (mdoc->defos) {
mdoc->meta.os = mandoc_strdup(mdoc->defos);
- return;
+ goto out;
}
#ifdef OSNAME
@@ -2406,6 +2436,10 @@ post_os(POST_ARGS)
}
mdoc->meta.os = mandoc_strdup(defbuf);
#endif /*!OSNAME*/
+
+out: mdoc->meta.os_e = strstr(mdoc->meta.os, "OpenBSD") != NULL ?
+ MDOC_OS_OPENBSD : strstr(mdoc->meta.os, "NetBSD") != NULL ?
+ MDOC_OS_NETBSD : MDOC_OS_OTHER;
}
enum roff_sec
diff --git a/read.c b/read.c
index e302658f..f0cf5b0c 100644
--- a/read.c
+++ b/read.c
@@ -1,4 +1,4 @@
-/* $Id: read.c,v 1.171 2017/06/06 15:01:04 schwarze Exp $ */
+/* $Id: read.c,v 1.172 2017/06/07 23:29:48 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -90,6 +90,8 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"useless macro",
"consider using OS macro",
+ "errnos out of order",
+ "duplicate errno",
"description line ends with a full stop",
"generic warning",
diff --git a/roff.h b/roff.h
index 0a7c2455..bf5c4c17 100644
--- a/roff.h
+++ b/roff.h
@@ -1,4 +1,4 @@
-/* $Id: roff.h,v 1.51 2017/06/07 00:50:34 schwarze Exp $ */
+/* $Id: roff.h,v 1.52 2017/06/07 23:29:49 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2013, 2014, 2015, 2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -26,6 +26,12 @@ enum roff_macroset {
MACROSET_MAN
};
+enum mdoc_os {
+ MDOC_OS_OTHER = 0,
+ MDOC_OS_NETBSD,
+ MDOC_OS_OPENBSD
+};
+
enum roff_sec {
SEC_NONE = 0,
SEC_NAME,
@@ -528,6 +534,7 @@ struct roff_meta {
char *name; /* Leading manual name. */
char *date; /* Normalized date. */
int hasbody; /* Document is not empty. */
+ enum mdoc_os os_e; /* Operating system. */
};
struct roff_man {