summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2017-06-24 18:58:10 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2017-06-24 18:58:10 +0000
commitd7a2acd03c393f1a47677ae0b457aa176cd4b3ef (patch)
tree7232631a77d6f0bfcefe7bf8336df4cf9a869a63 /usr.bin
parentaaa409de0583faa507293ae1d4135f457dead40a (diff)
operating system dependent message about unknown architecture;
inspired by mdoclint
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mandoc/mandoc.h3
-rw-r--r--usr.bin/mandoc/mdoc_validate.c41
-rw-r--r--usr.bin/mandoc/read.c3
3 files changed, 44 insertions, 3 deletions
diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h
index cb6ffead8c3..3ffdb5f9c0c 100644
--- a/usr.bin/mandoc/mandoc.h
+++ b/usr.bin/mandoc/mandoc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mandoc.h,v 1.176 2017/06/24 15:59:28 schwarze Exp $ */
+/* $OpenBSD: mandoc.h,v 1.177 2017/06/24 18:58:09 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -48,6 +48,7 @@ enum mandocerr {
MANDOCERR_MDOCDATE, /* Mdocdate found: Dd ... */
MANDOCERR_MDOCDATE_MISSING, /* Mdocdate missing: Dd ... */
+ MANDOCERR_ARCH_BAD, /* unknown architecture: Dt ... arch */
MANDOCERR_OS_ARG, /* operating system explicitly specified: Os ... */
MANDOCERR_RCS_MISSING, /* RCS id missing */
diff --git a/usr.bin/mandoc/mdoc_validate.c b/usr.bin/mandoc/mdoc_validate.c
index 212af6c23f4..46f0bae730d 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.256 2017/06/24 15:59:28 schwarze Exp $ */
+/* $OpenBSD: mdoc_validate.c,v 1.257 2017/06/24 18:58:09 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -1771,7 +1771,29 @@ post_sm(POST_ARGS)
static void
post_root(POST_ARGS)
{
+ const char *openbsd_arch[] = {
+ "alpha", "amd64", "arm64", "armv7", "hppa", "i386",
+ "landisk", "loongson", "luna88k", "macppc", "mips64",
+ "octeon", "sgi", "socppc", "sparc64", NULL
+ };
+ const char *netbsd_arch[] = {
+ "acorn26", "acorn32", "algor", "alpha", "amiga",
+ "arc", "atari",
+ "bebox", "cats", "cesfic", "cobalt", "dreamcast",
+ "emips", "evbarm", "evbmips", "evbppc", "evbsh3", "evbsh5",
+ "hp300", "hpcarm", "hpcmips", "hpcsh", "hppa",
+ "i386", "ibmnws", "luna68k",
+ "mac68k", "macppc", "mipsco", "mmeye", "mvme68k", "mvmeppc",
+ "netwinder", "news68k", "newsmips", "next68k",
+ "pc532", "playstation2", "pmax", "pmppc", "prep",
+ "sandpoint", "sbmips", "sgimips", "shark",
+ "sparc", "sparc64", "sun2", "sun3",
+ "vax", "walnut", "x68k", "x86", "x86_64", "xen", NULL
+ };
+ const char **arches[] = { NULL, netbsd_arch, openbsd_arch };
+
struct roff_node *n;
+ const char **arch;
/* Add missing prologue data. */
@@ -1798,6 +1820,23 @@ post_root(POST_ARGS)
mdoc->meta.os_e == MANDOC_OS_OPENBSD ?
"(OpenBSD)" : "(NetBSD)");
+ if (mdoc->meta.arch != NULL &&
+ (arch = arches[mdoc->meta.os_e]) != NULL) {
+ while (*arch != NULL && strcmp(*arch, mdoc->meta.arch))
+ arch++;
+ if (*arch == NULL) {
+ n = mdoc->first->child;
+ while (n->tok != MDOC_Dt)
+ n = n->next;
+ n = n->child->next->next;
+ mandoc_vmsg(MANDOCERR_ARCH_BAD,
+ mdoc->parse, n->line, n->pos,
+ "Dt ... %s %s", mdoc->meta.arch,
+ mdoc->meta.os_e == MANDOC_OS_OPENBSD ?
+ "(OpenBSD)" : "(NetBSD)");
+ }
+ }
+
/* Check that we begin with a proper `Sh'. */
n = mdoc->first->child;
diff --git a/usr.bin/mandoc/read.c b/usr.bin/mandoc/read.c
index 40826ec152f..61466c5de74 100644
--- a/usr.bin/mandoc/read.c
+++ b/usr.bin/mandoc/read.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: read.c,v 1.152 2017/06/24 15:59:28 schwarze Exp $ */
+/* $OpenBSD: read.c,v 1.153 2017/06/24 18:58:09 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -86,6 +86,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"Mdocdate found",
"Mdocdate missing",
+ "unknown architecture",
"operating system explicitly specified",
"RCS id missing",