aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--Makefile8
-rw-r--r--TODO11
-rw-r--r--arch.c54
-rwxr-xr-xconfigure26
-rw-r--r--configure.local.example17
-rw-r--r--main.c8
-rw-r--r--mdoc_validate.c54
-rw-r--r--roff.h5
8 files changed, 121 insertions, 62 deletions
diff --git a/Makefile b/Makefile
index 7f48296b..74daff14 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
-# $Id: Makefile,v 1.527 2018/12/14 01:18:25 schwarze Exp $
+# $Id: Makefile,v 1.528 2019/03/04 13:01:57 schwarze Exp $
#
# Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
-# Copyright (c) 2011, 2013-2018 Ingo Schwarze <schwarze@openbsd.org>
+# Copyright (c) 2011, 2013-2019 Ingo Schwarze <schwarze@openbsd.org>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@@ -54,7 +54,8 @@ TESTSRCS = test-be32toh.c \
test-vasprintf.c \
test-wchar.c
-SRCS = att.c \
+SRCS = arch.c \
+ att.c \
catman.c \
cgi.c \
chars.c \
@@ -235,6 +236,7 @@ LIBROFF_OBJS = eqn.o \
LIBMANDOC_OBJS = $(LIBMAN_OBJS) \
$(LIBMDOC_OBJS) \
$(LIBROFF_OBJS) \
+ arch.o \
chars.o \
mandoc.o \
mandoc_aux.o \
diff --git a/TODO b/TODO
index 5df81ae1..063e2789 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,6 @@
************************************************************************
* Official mandoc TODO.
-* $Id: TODO,v 1.288 2019/03/04 11:40:09 schwarze Exp $
+* $Id: TODO,v 1.289 2019/03/04 13:01:57 schwarze Exp $
************************************************************************
Many issues are annotated for difficulty as follows:
@@ -446,15 +446,6 @@ are mere guesses, and some may be wrong.
* warning issues
************************************************************************
-- When a man(1) command returns no result and there was an -S
- argument, check the -S argument against the list of valid
- architectures and say "Unknown architecture AAA" rather than
- "No entry for NNN in the manual" if there is no match.
- Requires moving the lists of valid architectures out of
- mdoc_validate.c such that they can be used by main.c.
- Discussed with jmc@ 10 Aug 2018 19:20:12 +0100.
- loc ** exist * algo * size * imp **
-
- warn about duplicate .Sh/.Ss heads
gre(4): Rename duplicate sections 20 Apr 2018 15:27:33 +0200
loc * exist * algo * size * imp **
diff --git a/arch.c b/arch.c
new file mode 100644
index 00000000..56b937ec
--- /dev/null
+++ b/arch.c
@@ -0,0 +1,54 @@
+/* $Id: arch.c,v 1.14 2019/03/04 13:01:57 schwarze Exp $ */
+/*
+ * Copyright (c) 2017, 2019 Ingo Schwarze <schwarze@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#include "config.h"
+
+#include <string.h>
+
+#include "roff.h"
+
+int
+arch_valid(const char *arch, enum mandoc_os os)
+{
+ 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 };
+ const char **arch_p;
+
+ if ((arch_p = arches[os]) == NULL)
+ return 1;
+ for (; *arch_p != NULL; arch_p++)
+ if (strcmp(*arch_p, arch) == 0)
+ return 1;
+ return 0;
+}
diff --git a/configure b/configure
index 90eacc83..5dca7ad8 100755
--- a/configure
+++ b/configure
@@ -1,8 +1,8 @@
#!/bin/sh
#
-# $Id: configure,v 1.67 2018/08/15 02:15:52 schwarze Exp $
+# $Id: configure,v 1.68 2019/03/04 13:01:57 schwarze Exp $
#
-# Copyright (c) 2014,2015,2016,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
+# Copyright (c) 2014-2019 Ingo Schwarze <schwarze@openbsd.org>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@@ -37,6 +37,7 @@ SOURCEDIR=`dirname "$0"`
MANPATH_BASE="/usr/share/man:/usr/X11R6/man"
MANPATH_DEFAULT="/usr/share/man:/usr/X11R6/man:/usr/local/man"
+OSENUM=
OSNAME=
UTF8_LOCALE=
@@ -219,6 +220,26 @@ get_locale() {
return 0;
}
+# --- operating system -------------------------------------------------
+
+if [ -n "${OSENUM}" ]; then
+ echo "OSENUM specified manually: ${OSENUM}" 1>&2
+ echo "OSENUM specified manually: ${OSENUM}" 1>&3
+else
+ OSDETECT=$(uname)
+ if [ "X${OSDETECT}" = "XNetBSD" ]; then
+ OSENUM=MANDOC_OS_NETBSD
+ elif [ "X${OSDETECT}" = "XOpenBSD" ]; then
+ OSENUM=MANDOC_OS_OPENBSD
+ else
+ OSENUM=MANDOC_OS_OTHER
+ fi
+ echo "tested operating system: ${OSDETECT} -> OSENUM=${OSENUM}" 1>&2
+ echo "tested operating system: ${OSDETECT} -> OSENUM=${OSENUM}" 1>&3
+ unset OSDETECT
+fi
+echo 1>&3
+
# --- compiler options -------------------------------------------------
DEFCFLAGS="-g -W -Wall -Wmissing-prototypes -Wstrict-prototypes -Wwrite-strings -Wno-unused-parameter"
@@ -419,6 +440,7 @@ echo
echo "#define MAN_CONF_FILE \"/etc/${MANM_MANCONF}\""
echo "#define MANPATH_BASE \"${MANPATH_BASE}\""
echo "#define MANPATH_DEFAULT \"${MANPATH_DEFAULT}\""
+echo "#define OSENUM ${OSENUM}"
[ -n "${OSNAME}" ] && echo "#define OSNAME \"${OSNAME}\""
[ -n "${UTF8_LOCALE}" ] && echo "#define UTF8_LOCALE \"${UTF8_LOCALE}\""
[ -n "${HOMEBREWDIR}" ] && echo "#define HOMEBREWDIR \"${HOMEBREWDIR}\""
diff --git a/configure.local.example b/configure.local.example
index 82fc2a2c..c56cdaa5 100644
--- a/configure.local.example
+++ b/configure.local.example
@@ -1,6 +1,6 @@
-# $Id: configure.local.example,v 1.34 2018/07/31 15:34:00 schwarze Exp $
+# $Id: configure.local.example,v 1.35 2019/03/04 13:01:57 schwarze Exp $
#
-# Copyright (c) 2014,2015,2016,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
+# Copyright (c) 2014-2019 Ingo Schwarze <schwarze@openbsd.org>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@@ -67,6 +67,17 @@ MANPATH_DEFAULT="/usr/share/man:/usr/X11R6/man:/usr/local/man"
MANPATH_BASE="/usr/share/man:/usr/X11R6/man"
+# When man(1) is called with the -S option and no manual page is
+# found matching the requested name and the requested architecture,
+# it tries to figure out whether the requested architecture is valid
+# for the present operating system. Normally, ./configure detects
+# the operating system using uname(1). If that fails or is not
+# desired, either of the following lines can be used:
+
+OSENUM=MANDOC_OS_NETBSD
+OSENUM=MANDOC_OS_OPENBSD
+OSENUM=MANDOC_OS_OTHER
+
# In manual pages written in the mdoc(7) language, the operating system
# version is displayed in the page footer line. If an operating system
# is specified as an argument to the .Os macro, that is always used.
@@ -77,7 +88,7 @@ MANPATH_BASE="/usr/share/man:/usr/X11R6/man"
# If you do not want uname(3) to be called but instead want a fixed
# string to be used, use the following line:
-OSNAME="OpenBSD 6.3"
+OSNAME="OpenBSD 6.5"
# The following installation directories are used.
# It is possible to set only one or a few of these variables,
diff --git a/main.c b/main.c
index 74912cf5..257d82cc 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.319 2019/03/03 13:02:11 schwarze Exp $ */
+/* $Id: main.c,v 1.320 2019/03/04 13:01:57 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2012, 2014-2019 Ingo Schwarze <schwarze@openbsd.org>
@@ -797,7 +797,11 @@ fs_search(const struct mansearch *cfg, const struct manpaths *paths,
}
if (res != NULL && *ressz == lastsz &&
strchr(*argv, '/') == NULL) {
- if (cfg->sec == NULL)
+ if (cfg->arch != NULL &&
+ arch_valid(cfg->arch, OSENUM) == 0)
+ warnx("Unknown architecture \"%s\".",
+ cfg->arch);
+ else if (cfg->sec == NULL)
warnx("No entry for %s in the manual.",
*argv);
else
diff --git a/mdoc_validate.c b/mdoc_validate.c
index 448cc7ca..7d1575f2 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,7 +1,7 @@
-/* $Id: mdoc_validate.c,v 1.370 2019/03/04 11:40:09 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.371 2019/03/04 13:01:57 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010-2018 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010-2019 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2010 Joerg Sonnenberger <joerg@netbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -1898,29 +1898,7 @@ 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. */
@@ -1946,22 +1924,18 @@ post_root(POST_ARGS)
"(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->meta.first->child;
- while (n->tok != MDOC_Dt ||
- n->child == NULL ||
- n->child->next == NULL ||
- n->child->next->next == NULL)
- n = n->next;
- n = n->child->next->next;
- mandoc_msg(MANDOCERR_ARCH_BAD, n->line, n->pos,
- "Dt ... %s %s", mdoc->meta.arch,
- mdoc->meta.os_e == MANDOC_OS_OPENBSD ?
- "(OpenBSD)" : "(NetBSD)");
- }
+ arch_valid(mdoc->meta.arch, mdoc->meta.os_e) == 0) {
+ n = mdoc->meta.first->child;
+ while (n->tok != MDOC_Dt ||
+ n->child == NULL ||
+ n->child->next == NULL ||
+ n->child->next->next == NULL)
+ n = n->next;
+ n = n->child->next->next;
+ mandoc_msg(MANDOCERR_ARCH_BAD, 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'. */
diff --git a/roff.h b/roff.h
index a65e5508..49b09275 100644
--- a/roff.h
+++ b/roff.h
@@ -1,7 +1,7 @@
-/* $Id: roff.h,v 1.68 2018/12/31 08:18:12 schwarze Exp $ */
+/* $Id: roff.h,v 1.69 2019/03/04 13:01:57 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2013,2014,2015,2017,2018 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2013-2015, 2017-2019 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -548,4 +548,5 @@ struct roff_meta {
extern const char *const *roff_name;
+int arch_valid(const char *, enum mandoc_os);
void deroff(char **, const struct roff_node *);