summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mandoc.130
-rw-r--r--mandoc.h2
-rw-r--r--mdoc_validate.c38
-rw-r--r--read.c2
-rw-r--r--roff.h7
5 files changed, 77 insertions, 2 deletions
diff --git a/mandoc.1 b/mandoc.1
index 128667b1..69be40ac 100644
--- a/mandoc.1
+++ b/mandoc.1
@@ -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 767ebef1..58b31223 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -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 98e6a77d..18b83f42 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -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 51a191dc..6b478302 100644
--- a/read.c
+++ b/read.c
@@ -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 9800dfc9..6b383c9a 100644
--- a/roff.h
+++ b/roff.h
@@ -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 {