summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2015-03-27 01:59:27 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2015-03-27 01:59:27 +0000
commit62305f849c5af4fad036b035140329655ee2cf8f (patch)
tree5f45af0a535e964d5c61e5d3a926fbebd7c1363b
parent00c93307190da7451eea2c0a5d85e7e73042ff1d (diff)
Move help(1) to share/man and send the remains of man(1) to the Attic.
It is implemented by the code in usr.bin/mandoc since OpenBSD 5.7.
-rw-r--r--share/man/man1/Makefile4
-rw-r--r--share/man/man1/help.1 (renamed from usr.bin/man/help.1)4
-rw-r--r--usr.bin/Makefile4
-rw-r--r--usr.bin/man/Makefile5
-rw-r--r--usr.bin/man/config.c154
-rw-r--r--usr.bin/man/config.h53
-rw-r--r--usr.bin/man/man.1393
-rw-r--r--usr.bin/man/man.c939
-rw-r--r--usr.bin/man/man.conf.5225
-rw-r--r--usr.bin/man/pathnames.h38
10 files changed, 6 insertions, 1813 deletions
diff --git a/share/man/man1/Makefile b/share/man/man1/Makefile
index f60bbe98857..2e0778b026f 100644
--- a/share/man/man1/Makefile
+++ b/share/man/man1/Makefile
@@ -1,6 +1,6 @@
-# $OpenBSD: Makefile,v 1.5 2014/07/16 20:05:28 okan Exp $
+# $OpenBSD: Makefile,v 1.6 2015/03/27 01:59:26 schwarze Exp $
# $NetBSD: Makefile,v 1.4 1994/12/22 10:48:04 cgd Exp $
-MAN= intro.1 gcc-local.1
+MAN= help.1 intro.1 gcc-local.1
.include <bsd.prog.mk>
diff --git a/usr.bin/man/help.1 b/share/man/man1/help.1
index fbc9c1345c2..f726a3ab1d5 100644
--- a/usr.bin/man/help.1
+++ b/share/man/man1/help.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: help.1,v 1.12 2013/07/16 00:07:52 schwarze Exp $
+.\" $OpenBSD: help.1,v 1.1 2015/03/27 01:59:26 schwarze Exp $
.\"
.\" Copyright (c) 1999 Aaron Campbell
.\" All rights reserved.
@@ -24,7 +24,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd $Mdocdate: July 16 2013 $
+.Dd $Mdocdate: March 27 2015 $
.Dt HELP 1
.Os
.Sh NAME
diff --git a/usr.bin/Makefile b/usr.bin/Makefile
index 49ee4a20592..c905c2a1a71 100644
--- a/usr.bin/Makefile
+++ b/usr.bin/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.149 2015/03/11 22:32:48 deraadt Exp $
+# $OpenBSD: Makefile,v 1.150 2015/03/27 01:59:26 schwarze Exp $
.include <bsd.own.mk>
@@ -13,7 +13,7 @@ SUBDIR= apply arch at aucat audioctl awk banner \
join jot kdump keynote ktrace lam last lastcomm leave less lex \
libtool lndir \
locale locate lock logger login logname look lorder \
- m4 mail make man mandoc mesg mg \
+ m4 mail make mandoc mesg mg \
midiplay mixerctl mkdep mklocale mktemp nc netstat \
newsyslog \
nfsstat nice nm nl nohup openssl pagesize passwd paste patch pctr \
diff --git a/usr.bin/man/Makefile b/usr.bin/man/Makefile
deleted file mode 100644
index 35a8c0e4390..00000000000
--- a/usr.bin/man/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-# $OpenBSD: Makefile,v 1.7 2015/03/26 23:45:37 schwarze Exp $
-
-MAN= help.1
-
-.include <bsd.prog.mk>
diff --git a/usr.bin/man/config.c b/usr.bin/man/config.c
deleted file mode 100644
index a4053a5c4df..00000000000
--- a/usr.bin/man/config.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/* $OpenBSD: config.c,v 1.10 2014/07/21 19:51:32 schwarze Exp $ */
-/* $NetBSD: config.c,v 1.7 1995/09/28 06:05:21 tls Exp $ */
-
-/*
- * Copyright (c) 1989, 1993, 1995
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/types.h>
-#include <sys/queue.h>
-
-#include <ctype.h>
-#include <err.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "config.h"
-#include "pathnames.h"
-
-struct _head head;
-
-/*
- * config --
- *
- * Read the configuration file and build a doubly linked
- * list that looks like:
- *
- * tag1 <-> record <-> record <-> record
- * |
- * tag2 <-> record <-> record <-> record
- */
-void
-config(char *fname)
-{
- TAG *tp;
- ENTRY *ep;
- FILE *cfp;
- size_t len;
- int lcnt;
- char *p, *t;
-
- if (fname == NULL)
- fname = _PATH_MANCONF;
- if ((cfp = fopen(fname, "r")) == NULL)
- err(1, "%s", fname);
- TAILQ_INIT(&head);
- for (lcnt = 1; (p = fgetln(cfp, &len)) != NULL; ++lcnt) {
- if (len == 1) /* Skip empty lines. */
- continue;
- if (p[len - 1] != '\n') { /* Skip corrupted lines. */
- warnx("%s: line %d corrupted", fname, lcnt);
- continue;
- }
- p[len - 1] = '\0'; /* Terminate the line. */
-
- /* Skip leading space. */
- while (isspace(*p))
- p++;
- /* Skip empty/comment lines. */
- if (*p == '\0' || *p == '#')
- continue;
- /* Find first token. */
- for (t = p; *t && !isspace(*t); ++t)
- continue;
- if (*t == '\0') /* Need more than one token.*/
- continue;
- *t = '\0';
-
- tp = getlist(p); /* Find any matching tag. */
-
- if (tp == NULL) /* Create a new tag. */
- tp = addlist(p);
-
- /*
- * Attach new records. The keyword _build takes the rest of
- * the line as a single entity, everything else is white
- * space separated. The reason we're not just using strtok(3)
- * for all of the parsing is so we don't get caught if a line
- * has only a single token on it.
- */
- if (!strcmp(p, "_build")) {
- while (isspace(*++t));
- if ((ep = malloc(sizeof(ENTRY))) == NULL ||
- (ep->s = strdup(t)) == NULL)
- err(1, NULL);
- TAILQ_INSERT_TAIL(&tp->list, ep, q);
- } else for (++t; (p = strtok(t, " \t\n")) != NULL; t = NULL) {
- if ((ep = malloc(sizeof(ENTRY))) == NULL ||
- (ep->s = strdup(p)) == NULL)
- err(1, NULL);
- TAILQ_INSERT_TAIL(&tp->list, ep, q);
- }
- }
-
- fclose(cfp);
-}
-
-/*
- * addlist --
- * Add a tag to the list.
- */
-TAG *
-addlist(char *name)
-{
- TAG *tp;
-
- if ((tp = calloc(1, sizeof(TAG))) == NULL ||
- (tp->s = strdup(name)) == NULL)
- err(1, NULL);
- TAILQ_INIT(&tp->list);
- TAILQ_INSERT_TAIL(&head, tp, q);
- return (tp);
-}
-
-/*
- * getlist --
- * Return the linked list of entries for a tag if it exists.
- */
-TAG *
-getlist(char *name)
-{
- TAG *tp;
-
- TAILQ_FOREACH(tp, &head, q)
- if (!strcmp(name, tp->s))
- return (tp);
- return (NULL);
-}
diff --git a/usr.bin/man/config.h b/usr.bin/man/config.h
deleted file mode 100644
index 96262c8939a..00000000000
--- a/usr.bin/man/config.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* $OpenBSD: config.h,v 1.6 2012/02/05 18:51:18 schwarze Exp $ */
-/* $NetBSD: config.h,v 1.2 1995/09/28 06:05:28 tls Exp $ */
-
-/*-
- * Copyright (c) 1993
- * The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)config.h 8.4 (Berkeley) 12/18/93
- */
-
-typedef struct _tag {
- TAILQ_ENTRY(_tag) q; /* Queue of tags. */
-
- TAILQ_HEAD(tqh, _entry) list; /* Queue of entries. */
- char *s; /* Associated string. */
-} TAG;
-typedef struct _entry {
- TAILQ_ENTRY(_entry) q; /* Queue of entries. */
-
- char *s; /* Associated string. */
-} ENTRY;
-
-TAILQ_HEAD(_head, _tag);
-extern struct _head head;
-
-TAG *addlist(char *);
-void config(char *);
-TAG *getlist(char *);
diff --git a/usr.bin/man/man.1 b/usr.bin/man/man.1
deleted file mode 100644
index f691bede8f7..00000000000
--- a/usr.bin/man/man.1
+++ /dev/null
@@ -1,393 +0,0 @@
-.\" $OpenBSD: man.1,v 1.56 2014/09/08 04:40:30 doug Exp $
-.\"
-.\" Copyright (c) 1989, 1990, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)man.1 8.2 (Berkeley) 1/2/94
-.\"
-.Dd $Mdocdate: September 8 2014 $
-.Dt MAN 1
-.Os
-.Sh NAME
-.Nm man
-.Nd display manual pages
-.Sh SYNOPSIS
-.Nm man
-.Op Fl achw
-.Op Fl C Ar file
-.Op Fl M Ar path
-.Op Fl m Ar path
-.Op Fl S Ar subsection
-.Op Fl s Ar section
-.Op Ar section
-.Ar name ...
-.Nm man
-.Fl f Ar command ...
-.Nm man
-.Fl k Ar keyword ...
-.Sh DESCRIPTION
-The
-.Nm
-utility
-displays the
-.Bx
-manual pages entitled
-.Ar name .
-Pages may be selected according to
-a specific category
-.Pq Ar section
-or
-machine architecture
-.Pq Ar subsection .
-.Pp
-The options are as follows:
-.Bl -tag -width Ds
-.It Fl a
-Display all of the manual pages for a specified
-.Ar section
-and
-.Ar name
-combination.
-Normally, only the first manual page found is displayed.
-.It Fl C Ar file
-Use the specified
-.Ar file
-instead of the default configuration file.
-This permits users to configure their own manual environment.
-See
-.Xr man.conf 5
-for a description of the contents of this file.
-.It Fl c
-Copy the manual page to the standard output instead of using
-.Xr more 1
-to paginate it.
-This is done by default if the standard output is not a terminal device.
-.It Fl f Ar command
-A synonym for
-.Xr whatis 1 .
-It looks up a given command and
-gives the header line from the manual page.
-.Ar command
-is case insensitive.
-.It Fl h
-Display only the
-.Dq SYNOPSIS
-lines of the requested manual pages.
-.It Fl k Ar keyword
-A synonym for
-.Xr apropos 1 .
-It shows which manual pages contain instances of any of the given
-keywords in their title line.
-.Ar keyword
-is case insensitive.
-.Pp
-For instance,
-to list all man pages which contain
-.Dq mount
-in the
-.Dq NAME
-line of the man page:
-.Pp
-.Dl $ man -k mount
-.Pp
-Which would produce a list much like this:
-.Bd -literal
-amd (8) \(en automatically mount file systems
-amq (8) \(en automounter query tool
-domountroothooks (9) \(en run all mountroot hooks
-exports (5) \(en define remote mount points for NFS mount requests
-getfsstat (2) \(en get list of all mounted file systems
-getmntinfo (3) \(en get information about mounted file systems
-mount (8) \(en mount file systems
-mount, unmount (2) \(en mount or dismount a filesystem
-mount_cd9660 (8) \(en mount an ISO-9660 filesystem
-mount_ext2fs (8) \(en mount an ext2fs file system
-mount_ffs (8) \(en mount a Berkeley Fast File System
-mount_msdos (8) \(en mount an MS-DOS file system
-mount_nfs (8) \(en mount NFS file systems
-mount_ntfs (8) \(en mount an NTFS file system
-mount_udf (8) \(en mount a UDF filesystem
-mount_vnd, vnconfig (8) \(en configure vnode disks
-mountd (8) \(en service remote NFS mount requests
-\&...
-.Ed
-.It Fl M Ar path
-Override the list of standard directories which
-.Nm
-searches for manual pages.
-The supplied
-.Ar path
-must be a colon
-.Pq Ql \&:
-separated list of directories.
-This search path may also be set using the environment variable
-.Ev MANPATH .
-The subdirectories to be searched, and their search order,
-are specified by the
-.Dq _subdir
-line in the
-.Nm
-configuration file.
-.It Fl m Ar path
-Augment the list of standard directories which
-.Nm
-searches for manual pages.
-The supplied
-.Ar path
-must be a colon
-.Pq Ql \&:
-separated list of directories.
-These directories will be searched before the standard directories or
-the directories specified using the
-.Fl M
-option or the
-.Ev MANPATH
-environment variable.
-The subdirectories to be searched, and their search order,
-are specified by the
-.Dq _subdir
-line in the
-.Nm
-configuration file.
-.It Fl S Ar subsection
-Restricts the directories that
-.Nm
-will search to those of a specific
-.Xr machine 1
-architecture.
-.Ar subsection
-is case insensitive.
-.Pp
-By default manual pages for all architectures are installed.
-Therefore this option can be used to view pages for one
-architecture whilst using another.
-.Pp
-This option overrides the
-.Ev MACHINE
-environment variable.
-.It Xo
-.Op Fl s
-.Ar section
-.Xc
-Restricts the directories that
-.Nm
-will search to a specific section.
-The currently available sections are:
-.Pp
-.Bl -tag -width "localXXX" -offset indent -compact
-.It 1
-General commands
-.Pq tools and utilities .
-.It 2
-System calls and error numbers.
-.It 3
-Libraries.
-.It 3f
-Fortran programmer's reference guide.
-.It 3p
-.Xr perl 1
-programmer's reference guide.
-.It 4
-Device drivers.
-.It 5
-File formats.
-.It 6
-Games.
-.It 7
-Miscellaneous.
-.It 8
-System maintenance and operation commands.
-.It 9
-Kernel internals.
-.It X11
-An alias for X11R6.
-.It X11R6
-X Window System.
-.It local
-Pages located in
-.Pa /usr/local .
-.It n
-Tcl/Tk commands.
-.El
-.Pp
-The
-.Nm
-configuration file,
-.Xr man.conf 5 ,
-specifies the possible
-.Ar section
-values, and their search order.
-Additional sections may be specified.
-.It Fl w
-List the pathnames of the manual pages which
-.Nm
-would display for the specified
-.Ar section
-and
-.Ar name
-combination.
-.El
-.Pp
-Guidelines for
-.Ox
-man pages can be found in
-.Xr mdoc 7 .
-.Pp
-If both a formatted and an unformatted version of the same manual page,
-for example
-.Pa cat1/foo.0
-and
-.Pa man1/foo.1 ,
-exist in the same directory, and at least one of them is selected,
-only the newer one is used.
-However, if both the
-.Fl a
-and the
-.Fl w
-options are specified, both file names are printed.
-.Sh ENVIRONMENT
-.Bl -tag -width MANPATHX
-.It Ev MACHINE
-As some manual pages are intended only for specific architectures,
-.Nm
-searches any subdirectories,
-with the same name as the current architecture,
-in every directory which it searches.
-Machine specific areas are checked before general areas.
-The current machine type may be overridden by setting the environment
-variable
-.Ev MACHINE
-to the name of a specific architecture,
-or with the
-.Fl S
-option.
-.Ev MACHINE
-is case insensitive.
-.It Ev MANPAGER
-Any non-empty value of the environment variable
-.Ev MANPAGER
-will be used instead of the standard pagination program,
-.Xr more 1 .
-.It Ev MANPATH
-The standard search path used by
-.Nm
-may be overridden by specifying a path in the
-.Ev MANPATH
-environment
-variable.
-The format of the path is a colon
-.Pq Ql \&:
-separated list of directories.
-The subdirectories to be searched, as well as their search order,
-are specified by the
-.Dq _subdir
-line in the
-.Nm
-configuration file.
-.It Ev PAGER
-Specifies the pagination program to use when
-.Ev MANPAGER
-is not defined.
-If neither PAGER nor MANPAGER is defined,
-.Pa /usr/bin/more Fl s
-will be used.
-.El
-.Sh FILES
-.Bl -tag -width /etc/man.conf -compact
-.It Pa /etc/man.conf
-default man configuration file
-.El
-.Sh EXIT STATUS
-.Ex -std man
-.Sh SEE ALSO
-.Xr apropos 1 ,
-.Xr intro 1 ,
-.Xr whatis 1 ,
-.Xr whereis 1 ,
-.Xr intro 2 ,
-.Xr intro 3 ,
-.Xr intro 4 ,
-.Xr intro 5 ,
-.Xr man.conf 5 ,
-.Xr intro 6 ,
-.Xr intro 7 ,
-.Xr mdoc 7 ,
-.Xr intro 8 ,
-.Xr intro 9
-.Sh STANDARDS
-The
-.Nm
-utility is compliant with the
-.St -p1003.1-2008
-specification.
-.Pp
-The flags
-.Op Fl aCcfhMmSsw ,
-as well as the environment variables
-.Ev MACHINE ,
-.Ev MANPAGER ,
-and
-.Ev MANPATH ,
-are extensions to that specification.
-.Sh HISTORY
-A
-.Nm
-command first appeared in
-.At v3 .
-.Pp
-The
-.Fl w
-option first appeared in
-.At v7 ;
-.Fl f
-and
-.Fl k
-in
-.Bx 4 ;
-.Fl M
-in
-.Bx 4.3 ;
-.Fl a
-in
-.Bx 4.3 Tahoe ;
-.Fl c
-and
-.Fl m
-in
-.Bx 4.3 Reno ;
-.Fl h
-in
-.Bx 4.3 Net/2 ;
-.Fl C
-in
-.Nx 1.0 ;
-and
-.Fl s
-and
-.Fl S
-in
-.Ox 2.3 .
diff --git a/usr.bin/man/man.c b/usr.bin/man/man.c
deleted file mode 100644
index ed380019bbb..00000000000
--- a/usr.bin/man/man.c
+++ /dev/null
@@ -1,939 +0,0 @@
-/* $OpenBSD: man.c,v 1.49 2015/01/16 06:40:09 deraadt Exp $ */
-/* $NetBSD: man.c,v 1.7 1995/09/28 06:05:34 tls Exp $ */
-
-/*
- * Copyright (c) 2010, 2011, 2012 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.
- */
-
-/*
- * Copyright (c) 1987, 1993, 1994, 1995
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/types.h>
-#include <sys/queue.h>
-#include <sys/stat.h>
-
-#include <ctype.h>
-#include <err.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <fnmatch.h>
-#include <glob.h>
-#include <signal.h>
-#include <stdio.h>
-#include <libgen.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "config.h"
-#include "pathnames.h"
-
-int f_all, f_where;
-static char gbuf[MAXPATHLEN * 2];
-static TAG *section;
-
-extern char *__progname;
-
-static void clearlist(TAG *);
-static void parse_path(TAG *, const char *);
-static void append_subdirs(TAG *, const char *);
-static void build_page(char *, char **);
-static void cat(char *);
-static int cleanup(int);
-static void how(char *);
-static void jump(char **, char *, char *);
-static int manual(const char *, TAG *, glob_t *);
-static void check_companion(char **, TAG *);
-static void onsig(int);
-static void usage(void);
-
-sigset_t blocksigs;
-
-int
-main(int argc, char *argv[])
-{
- extern char *optarg;
- extern int optind;
- TAG *searchlist;
- glob_t pg;
- size_t len;
- int ch, f_cat, f_how, found;
- const char *pager, *p_path;
- char **ap, *cmd, *machine, *p, *p_add, *sflag;
- char *conffile;
-
- if (argv[1] == NULL && strcmp(basename(__progname), "help") == 0) {
- static char *nargv[3];
- nargv[0] = "man";
- nargv[1] = "help";
- nargv[2] = NULL;
- argv = nargv;
- argc = 2;
- }
-
- machine = sflag = NULL;
- f_cat = f_how = 0;
- conffile = p_add = NULL;
- p_path = (const char *)NULL;
- while ((ch = getopt(argc, argv, "aC:cfhkM:m:P:s:S:w-")) != -1)
- switch (ch) {
- case 'a':
- f_all = 1;
- break;
- case 'C':
- conffile = optarg;
- break;
- case 'c':
- case '-': /* Deprecated. */
- f_cat = 1;
- break;
- case 'h':
- f_how = 1;
- break;
- case 'm':
- p_add = optarg;
- break;
- case 'M':
- case 'P': /* Backward compatibility. */
- p_path = optarg;
- break;
- case 's': /* SVR4 compatibility. */
- sflag = optarg;
- break;
- case 'S':
- machine = optarg;
- break;
- /*
- * The -f and -k options are backward compatible
- * ways of calling whatis(1) and apropos(1).
- */
- case 'f':
- jump(argv, "-f", "whatis");
- /* NOTREACHED */
- case 'k':
- jump(argv, "-k", "apropos");
- /* NOTREACHED */
- case 'w':
- f_where = 1;
- break;
- case '?':
- default:
- usage();
- }
- argc -= optind;
- argv += optind;
-
- if (!*argv)
- usage();
-
- if (!f_cat && !f_how && !f_where) {
- if (!isatty(1))
- f_cat = 1;
- else {
- pager = getenv("MANPAGER");
- if (pager == NULL || *pager == '\0')
- pager = getenv("PAGER");
- if (pager == NULL || *pager == '\0')
- pager = _PATH_PAGER;
- }
- }
-
- /* Read the configuration file. */
- config(conffile);
-
- /*
- * 1: If the user specified a section,
- * use the section list from the configuration file.
- * Otherwise, fall back to the default list or to an empty list.
- */
- if (sflag && (section = getlist(sflag)) == NULL)
- errx(1, "unknown manual section `%s'", sflag);
- else if (argv[1] && (section = getlist(*argv)) != NULL)
- ++argv;
-
- searchlist = section;
- if (searchlist == NULL)
- searchlist = getlist("_default");
- if (searchlist == NULL)
- searchlist = addlist("_default");
-
- /*
- * 2: If the user set the -M option or defined the MANPATH variable,
- * clear what we have and take the user's list instead.
- */
- if (p_path == NULL)
- p_path = getenv("MANPATH");
-
- if (p_path) {
- clearlist(searchlist);
- parse_path(searchlist, p_path);
- }
-
- /*
- * 3: If the user set the -m option, insert the user's list before
- * whatever list we have.
- */
- if (p_add)
- parse_path(searchlist, p_add);
-
- /*
- * 4: Append the _subdir list where appropriate,
- * and always append the machine type.
- */
- if (machine || (machine = getenv("MACHINE"))) {
- /* Avoid mangling argv/environment. */
- if ((machine = strdup(machine)) == NULL)
- err(1, NULL);
- for (p = machine; *p; ++p)
- *p = tolower(*p);
- } else
- machine = MACHINE;
-
- append_subdirs(searchlist, machine);
-
- /*
- * 5: Search for the files. Set up an interrupt handler, so the
- * temporary files go away.
- */
- (void)signal(SIGINT, onsig);
- (void)signal(SIGHUP, onsig);
-
- sigemptyset(&blocksigs);
- sigaddset(&blocksigs, SIGINT);
- sigaddset(&blocksigs, SIGHUP);
-
- memset(&pg, 0, sizeof(pg));
- for (found = 0; *argv; ++argv)
- if (manual(*argv, searchlist, &pg))
- found = 1;
-
- /* 6: If nothing found, we're done. */
- if (!found) {
- (void)cleanup(0);
- exit (1);
- }
-
- /* 7: If it's simple, display it fast. */
- if (f_cat) {
- for (ap = pg.gl_pathv; *ap != NULL; ++ap) {
- if (**ap == '\0')
- continue;
- cat(*ap);
- }
- exit (cleanup(0));
- }
- if (f_how) {
- for (ap = pg.gl_pathv; *ap != NULL; ++ap) {
- if (**ap == '\0')
- continue;
- how(*ap);
- }
- exit(cleanup(0));
- }
- if (f_where) {
- for (ap = pg.gl_pathv; *ap != NULL; ++ap) {
- if (**ap == '\0')
- continue;
- (void)puts(*ap);
- }
- exit(cleanup(0));
- }
-
- /*
- * 8: We display things in a single command; build a list of things
- * to display.
- */
- for (ap = pg.gl_pathv, len = strlen(pager) + 1; *ap != NULL; ++ap) {
- if (**ap == '\0')
- continue;
- len += strlen(*ap) + 1;
- }
- if ((cmd = malloc(len)) == NULL) {
- warn(NULL);
- (void)cleanup(0);
- exit(1);
- }
- p = cmd;
- len = strlen(pager);
- memcpy(p, pager, len);
- p += len;
- *p++ = ' ';
- for (ap = pg.gl_pathv; *ap != NULL; ++ap) {
- if (**ap == '\0')
- continue;
- len = strlen(*ap);
- memcpy(p, *ap, len);
- p += len;
- *p++ = ' ';
- }
- *--p = '\0';
-
- /* Use system(3) in case someone's pager is "pager arg1 arg2". */
- (void)system(cmd);
-
- exit(cleanup(0));
-}
-
-/*
- * clearlist --
- * Remove all entries from a list,
- * but leave the list header intact.
- */
-static void
-clearlist(TAG *t)
-{
- ENTRY *e;
-
- while ((e = TAILQ_FIRST(&t->list)) != NULL) {
- free(e->s);
- TAILQ_REMOVE(&t->list, e, q);
- free(e);
- }
-}
-
-/*
- * parse_path --
- * Split the -M or -m argument or the MANPATH variable at colons,
- * and insert the parts into the searchlist.
- */
-static void
-parse_path(TAG *t, const char *path)
-{
- ENTRY *eplast = NULL, *ep;
- char *p, *slashp, *path_copy;
-
- if ((path_copy = strdup(path)) == NULL)
- err(1, NULL);
-
- while ((p = strsep(&path_copy, ":")) != NULL) {
- /* Skip empty fields */
- if (*p == '\0')
- continue;
-
- if ((ep = malloc(sizeof(ENTRY))) == NULL)
- err(1, NULL);
-
- /*
- * Bring section specific paths to the same format as
- * used in the configuration file, ending in /{cat,man}N.
- */
- if (section) {
- slashp = p[strlen(p) - 1] == '/' ? "" : "/";
- (void)snprintf(gbuf, sizeof(gbuf),
- "%s%s{cat,man}%s", p, slashp, t->s);
- if ((ep->s = strdup(gbuf)) == NULL)
- err(1, NULL);
- }
-
- /* Without a section, subdirs will be appended later. */
- else
- if ((ep->s = strdup(p)) == NULL)
- err(1, NULL);
-
- /*
- * Even in case of -M, inserting in front is fine:
- * We have just cleared the list.
- */
- if (eplast)
- TAILQ_INSERT_AFTER(&t->list, eplast, ep, q);
- else
- TAILQ_INSERT_HEAD(&t->list, ep, q);
- eplast = ep;
- }
-
- free(path_copy);
-}
-
-/*
- * append_subdirs --
- * Iterate the searchlist and append section and machine
- * subdirectories as needed.
- */
-static void
-append_subdirs(TAG *t, const char *machine)
-{
- TAG *tsub;
- ENTRY *eold, *elast, *enew, *esub;
- char *slashp;
-
- eold = elast = TAILQ_FIRST(&t->list);
- while (eold) {
-
- /*
- * Section subdirectories *not* ending in a slash
- * only get the machine suffix: They already had
- * the {cat,man}N part in the configuration file
- * or got it in parse_path().
- */
- if (section && eold->s[strlen(eold->s)-1] != '/') {
- (void)snprintf(gbuf, sizeof(gbuf), "%s{/%s,}",
- eold->s, machine);
- free(eold->s);
- if ((eold->s = strdup(gbuf)) == NULL)
- err(1, NULL);
- eold = elast = TAILQ_NEXT(eold, q);
- continue;
- }
-
- /*
- * Without a section, expand each entry using the
- * subdir list, then drop the original entry.
- */
- esub = (tsub = getlist("_subdir")) == NULL ?
- NULL : TAILQ_FIRST(&tsub->list);
- while (esub) {
- slashp = eold->s[strlen(eold->s)-1] == '/' ? "" : "/";
- (void)snprintf(gbuf, sizeof(gbuf), "%s%s%s{/%s,}",
- eold->s, slashp, esub->s, machine);
- if ((enew = malloc(sizeof(ENTRY))) == NULL ||
- (enew->s = strdup(gbuf)) == NULL)
- err(1, NULL);
- TAILQ_INSERT_AFTER(&t->list, elast, enew, q);
- elast = enew;
- esub = TAILQ_NEXT(esub, q);
- }
- elast = TAILQ_NEXT(elast, q);
- TAILQ_REMOVE(&t->list, eold, q);
- eold = elast;
- }
-}
-
-/*
- * manual --
- * Search the manuals for the pages.
- */
-static int
-manual(const char *page, TAG *tag, glob_t *pg)
-{
- ENTRY *ep, *e_sufp, *e_tag;
- TAG *missp, *sufp;
- int anyfound, cnt, found;
- char *p, buf[MAXPATHLEN];
-
- anyfound = 0;
- buf[0] = '*';
-
- /* Expand the search path. */
- if (f_all != f_where) {
- e_tag = tag == NULL ? NULL : TAILQ_FIRST(&tag->list);
- while (e_tag != NULL) {
- if (glob(e_tag->s, GLOB_BRACE | GLOB_NOSORT,
- NULL, pg)) {
- /* No GLOB_NOMATCH here due to {arch,}. */
- warn("globbing directories");
- (void)cleanup(0);
- exit(1);
- }
- for (cnt = 0; cnt < pg->gl_pathc; cnt++) {
- if ((ep = malloc(sizeof(ENTRY))) == NULL ||
- (ep->s = strdup(pg->gl_pathv[cnt])) ==
- NULL) {
- warn(NULL);
- (void)cleanup(0);
- exit(1);
- }
- TAILQ_INSERT_BEFORE(e_tag, ep, q);
- }
- ep = e_tag;
- e_tag = TAILQ_NEXT(e_tag, q);
- free(ep->s);
- TAILQ_REMOVE(&tag->list, ep, q);
- free(ep);
- globfree(pg);
- pg->gl_pathc = 0;
- }
- }
-
- /* For each element in the list... */
- e_tag = tag == NULL ? NULL : TAILQ_FIRST(&tag->list);
- for (; e_tag != NULL; e_tag = TAILQ_NEXT(e_tag, q)) {
- (void)snprintf(buf, sizeof(buf), "%s/%s.*", e_tag->s, page);
- switch (glob(buf, GLOB_APPEND | GLOB_BRACE | GLOB_NOSORT,
- NULL, pg)) {
- case (0):
- break;
- case (GLOB_NOMATCH):
- continue;
- default:
- warn("globbing files");
- (void)cleanup(0);
- exit(1);
- }
- if (pg->gl_matchc == 0)
- continue;
-
- /* Find out if it's really a man page. */
- for (cnt = pg->gl_pathc - pg->gl_matchc;
- cnt < pg->gl_pathc; ++cnt) {
-
- if (!f_all || !f_where) {
- check_companion(pg->gl_pathv + cnt, tag);
- if (*pg->gl_pathv[cnt] == '\0')
- continue;
- }
-
- /*
- * Try the _suffix key words first.
- *
- * XXX
- * Older versions of man.conf didn't have the suffix
- * key words, it was assumed that everything was a .0.
- * We just test for .0 first, it's fast and probably
- * going to hit.
- */
- (void)snprintf(buf, sizeof(buf), "*/%s.0", page);
- if (!fnmatch(buf, pg->gl_pathv[cnt], 0))
- goto next;
-
- e_sufp = (sufp = getlist("_suffix")) == NULL ?
- NULL : TAILQ_FIRST(&sufp->list);
- for (found = 0;
- e_sufp != NULL; e_sufp = TAILQ_NEXT(e_sufp, q)) {
- (void)snprintf(buf,
- sizeof(buf), "*/%s%s", page, e_sufp->s);
- if (!fnmatch(buf, pg->gl_pathv[cnt], 0)) {
- found = 1;
- break;
- }
- }
- if (found)
- goto next;
-
- /* Try the _build key words next. */
- e_sufp = (sufp = getlist("_build")) == NULL ?
- NULL : TAILQ_FIRST(&sufp->list);
- for (found = 0;
- e_sufp != NULL; e_sufp = TAILQ_NEXT(e_sufp, q)) {
- for (p = e_sufp->s;
- *p != '\0' && !isspace(*p); ++p);
- if (*p == '\0')
- continue;
- *p = '\0';
- (void)snprintf(buf,
- sizeof(buf), "*/%s%s", page, e_sufp->s);
- if (!fnmatch(buf, pg->gl_pathv[cnt], 0)) {
- if (!f_where)
- build_page(p + 1,
- &pg->gl_pathv[cnt]);
- *p = ' ';
- found = 1;
- break;
- }
- *p = ' ';
- }
- if (found) {
-next: anyfound = 1;
- if (!f_all && !f_where) {
- /* Delete any other matches. */
- while (++cnt< pg->gl_pathc)
- pg->gl_pathv[cnt] = "";
- break;
- }
- continue;
- }
-
- /* It's not a man page, forget about it. */
- pg->gl_pathv[cnt] = "";
- }
-
- if (anyfound && !f_all && !f_where)
- break;
- }
-
- /* If not found, enter onto the missing list. */
- if (!anyfound) {
- sigset_t osigs;
-
- sigprocmask(SIG_BLOCK, &blocksigs, &osigs);
-
- if ((missp = getlist("_missing")) == NULL)
- missp = addlist("_missing");
- if ((ep = malloc(sizeof(ENTRY))) == NULL ||
- (ep->s = strdup(page)) == NULL) {
- warn(NULL);
- (void)cleanup(0);
- exit(1);
- }
- TAILQ_INSERT_TAIL(&missp->list, ep, q);
- sigprocmask(SIG_SETMASK, &osigs, NULL);
- }
- return (anyfound);
-}
-
-/*
- * check_companion --
- * Check for a companion [un]formatted page.
- * If one is found, skip this page.
- * Use the companion instead, unless it will be found anyway.
- */
-static void
-check_companion(char **orig, TAG *tag) {
- struct stat sb_orig, sb_comp;
- char *p, *pext, comp[MAXPATHLEN];
- ENTRY *entry;
- size_t len;
- int found;
-
- len = strlcpy(comp, *orig, sizeof(comp));
- /* The minus 2 avoids a buffer overrun in case of a trailing dot. */
- p = comp + len - 2;
-
- /* Locate the file name extension. */
- while (p > comp && *p != '.' && *p != '/')
- p--;
- if (*p != '.')
- return;
- pext = p + 1;
-
- /* Search for slashes. */
- for (found = 0; 1; p--) {
- if (*p != '/')
- continue;
-
- /* Did not find /{cat,man}. */
- if (p == comp)
- return;
-
- /* Pass over one slash, the one before "page". */
- if (!found++) {
- len = p - comp;
- continue;
- }
-
- /* Rewrite manN/page.N <-> catN/page.0. */
- if (!strncmp(p+1, "man", 3)) {
- memcpy(++p, "cat", 3);
- *pext++ = '0';
- break;
- } else if (!strncmp(p+1, "cat", 3)) {
- memcpy(++p, "man", 3);
- p += 3;
- while (*p != '/' && pext < comp + sizeof(comp) - 1)
- *pext++ = *p++;
- break;
-
- /* Accept one architecture subdir, but not more. */
- } else if (found > 2)
- return;
- }
- *pext = '\0';
-
- /* Check whether both files exist. */
- if (stat(*orig, &sb_orig) || stat(comp, &sb_comp))
- return;
-
- /* No action if the companion file is older. */
- if (sb_orig.st_mtim.tv_sec > sb_comp.st_mtim.tv_sec || (
- sb_orig.st_mtim.tv_sec == sb_comp.st_mtim.tv_sec &&
- sb_orig.st_mtim.tv_nsec > sb_comp.st_mtim.tv_nsec))
- return;
-
- /* Drop the companion if it is in the path, too. */
- if (f_all || f_where)
- for(entry = TAILQ_FIRST(&tag->list); entry != NULL;
- entry = TAILQ_NEXT(entry, q))
- if (!strncmp(entry->s, comp, len)) {
- **orig = '\0';
- return;
- }
-
- /* The companion file is newer, use it. */
- free(*orig);
- if ((p = strdup(comp)) == NULL) {
- warn(NULL);
- (void)cleanup(0);
- exit(1);
- }
- *orig = p;
-}
-
-/*
- * build_page --
- * Build a man page for display.
- */
-static void
-build_page(char *fmt, char **pathp)
-{
- ENTRY *ep;
- TAG *intmpp;
- int fd, n;
- char *p, *b;
- char buf[MAXPATHLEN], cmd[MAXPATHLEN], tpath[MAXPATHLEN];
- sigset_t osigs;
-
- /*
- * Historically man chdir'd to the root of the man tree.
- * This was used in man pages that contained relative ".so"
- * directives (including other man pages for command aliases etc.)
- * It even went one step farther, by examining the first line
- * of the man page and parsing the .so filename so it would
- * make hard(?) links to the cat'ted man pages for space savings.
- * (We don't do that here, but we could).
- */
-
- /* copy and find the end */
- for (b = buf, p = *pathp; (*b++ = *p++) != '\0';)
- continue;
-
- /* skip the last two path components, page name and man[n] */
- for (--b, n = 2; b != buf; b--)
- if (*b == '/')
- if (--n == 0) {
- *b = '\0';
- (void) chdir(buf);
- }
-
-
- /* Add a remove-when-done list. */
- sigprocmask(SIG_BLOCK, &blocksigs, &osigs);
- if ((intmpp = getlist("_intmp")) == NULL)
- intmpp = addlist("_intmp");
- sigprocmask(SIG_SETMASK, &osigs, NULL);
-
- /* Move to the printf(3) format string. */
- for (; *fmt && isspace(*fmt); ++fmt)
- ;
-
- /*
- * Get a temporary file and build a version of the file
- * to display. Replace the old file name with the new one.
- */
- (void)strlcpy(tpath, _PATH_TMPFILE, sizeof(tpath));
- if ((fd = mkstemp(tpath)) == -1) {
- warn("%s", tpath);
- (void)cleanup(0);
- exit(1);
- }
- (void)snprintf(buf, sizeof(buf), "%s > %s", fmt, tpath);
- (void)snprintf(cmd, sizeof(cmd), buf, *pathp);
- (void)system(cmd);
- (void)close(fd);
- if ((*pathp = strdup(tpath)) == NULL) {
- warn(NULL);
- (void)cleanup(0);
- exit(1);
- }
-
- /* Link the built file into the remove-when-done list. */
- if ((ep = malloc(sizeof(ENTRY))) == NULL) {
- warn(NULL);
- (void)cleanup(0);
- exit(1);
- }
- ep->s = *pathp;
-
- sigprocmask(SIG_BLOCK, &blocksigs, &osigs);
- TAILQ_INSERT_TAIL(&intmpp->list, ep, q);
- sigprocmask(SIG_SETMASK, &osigs, NULL);
-}
-
-/*
- * how --
- * display how information
- */
-static void
-how(char *fname)
-{
- FILE *fp;
-
- int lcnt, print;
- char *p, buf[256];
-
- if (!(fp = fopen(fname, "r"))) {
- warn("%s", fname);
- (void)cleanup(0);
- exit (1);
- }
-#define S1 "SYNOPSIS"
-#define S2 "S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS"
- for (lcnt = print = 0; fgets(buf, sizeof(buf), fp);) {
- if (!strncmp(buf, S1, sizeof(S1) - 1) ||
- !strncmp(buf, S2, sizeof(S2) - 1)) {
- print = 1;
- continue;
- } else if (print) {
- char *p = buf;
- int allcaps = 0;
-
- while (*p) {
- if (!allcaps && isalpha(*p))
- allcaps = 1;
- if (isalpha(*p) && !isupper(*p)) {
- allcaps = 0;
- break;
- }
- p++;
- }
- if (allcaps) {
- (void)fclose(fp);
- return;
- }
- }
- if (!print)
- continue;
- if (*buf == '\n')
- ++lcnt;
- else {
- while (lcnt) {
- --lcnt;
- (void)putchar('\n');
- }
- for (p = buf; isspace(*p); ++p)
- ;
- (void)fputs(p, stdout);
- }
- }
- (void)fclose(fp);
-}
-
-/*
- * cat --
- * cat out the file
- */
-static void
-cat(char *fname)
-{
- int fd, n;
- char buf[2048];
-
- if ((fd = open(fname, O_RDONLY, 0)) < 0) {
- warn("%s", fname);
- (void)cleanup(0);
- exit(1);
- }
- while ((n = read(fd, buf, sizeof(buf))) > 0)
- if (write(STDOUT_FILENO, buf, n) != n) {
- warn("write");
- (void)cleanup(0);
- exit (1);
- }
- if (n == -1) {
- warn("read");
- (void)cleanup(0);
- exit(1);
- }
- (void)close(fd);
-}
-
-/*
- * jump --
- * strip out flag argument and jump
- */
-static void
-jump(char **argv, char *flag, char *name)
-{
- char **arg;
-
- argv[0] = name;
- for (arg = argv + 1; *arg; ++arg)
- if (!strcmp(*arg, flag))
- break;
- for (; *arg; ++arg)
- arg[0] = arg[1];
- execvp(name, argv);
- (void)fprintf(stderr, "%s: Command not found.\n", name);
- exit(1);
-}
-
-/*
- * onsig --
- * If signaled, delete the temporary files.
- */
-static void
-onsig(int signo)
-{
- (void)cleanup(1);
-
- (void)signal(signo, SIG_DFL);
- (void)kill(getpid(), signo);
-
- /* NOTREACHED */
- _exit(1);
-}
-
-/*
- * cleanup --
- * Clean up temporary files, show any error messages.
- */
-static int
-cleanup(int insig)
-{
- TAG *intmpp, *missp;
- ENTRY *ep;
- int rval = 0;
-
- if (insig == 0) {
- ep = (missp = getlist("_missing")) == NULL ?
- NULL : TAILQ_FIRST(&missp->list);
- if (ep != NULL)
- for (; ep != NULL; ep = TAILQ_NEXT(ep, q)) {
- if (section)
- warnx("no entry for %s in "
- "section %s of the manual.",
- ep->s, section->s);
- else
- warnx("no entry for %s in the manual.",
- ep->s);
- rval = 1;
- }
- }
-
- ep = (intmpp = getlist("_intmp")) == NULL ?
- NULL : TAILQ_FIRST(&intmpp->list);
- for (; ep != NULL; ep = TAILQ_NEXT(ep, q))
- (void)unlink(ep->s);
- return (rval);
-}
-
-/*
- * usage --
- * print usage message and die
- */
-static void
-usage(void)
-{
- (void)fprintf(stderr, "usage: %s [-achw] [-C file] [-M path] [-m path] "
- "[-S subsection] [-s section]\n\t [section] name ...\n",
- __progname);
- (void)fprintf(stderr, " %s -f command ...\n", __progname);
- (void)fprintf(stderr, " %s -k keyword ...\n", __progname);
- exit(1);
-}
diff --git a/usr.bin/man/man.conf.5 b/usr.bin/man/man.conf.5
deleted file mode 100644
index 53ef081a01b..00000000000
--- a/usr.bin/man/man.conf.5
+++ /dev/null
@@ -1,225 +0,0 @@
-.\" $OpenBSD: man.conf.5,v 1.13 2010/10/28 21:18:03 jmc Exp $
-.\"
-.\" Copyright (c) 1989, 1991, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)man.conf.5 8.5 (Berkeley) 1/2/94
-.\"
-.Dd $Mdocdate: October 28 2010 $
-.Dt MAN.CONF 5
-.Os
-.Sh NAME
-.Nm man.conf
-.Nd configuration file for
-.Xr man 1
-.Sh DESCRIPTION
-The
-.Xr man 1 ,
-.Xr apropos 1 ,
-and
-.Xr whatis 1
-commands
-search for manual pages or their database files as specified by the
-.Nm man.conf
-file.
-Manual pages are normally expected to be preformatted (see
-.Xr mandoc 1 )
-and named with a trailing
-.Sq .0 .
-.Pp
-The
-.Nm man.conf
-file contains two types of lines.
-.Pp
-The first type of line is a
-.Dq section
-line, which contains a section name followed by one or more directory paths.
-The directory paths may contain the normal shell globbing characters,
-including curly braces
-.Pq Sq {} ;
-to escape a shell globbing character, precede it with a backslash
-.Pq Sq \e .
-Lines in this format specify that manual pages for the section
-may be found in the following directories.
-.Pp
-Directories named with a trailing slash character
-.Pq Sq /
-are expected to contain subdirectories of manual pages, (see the keyword
-.Dq _subdir
-below) instead of manual pages.
-These subdirectories are searched instead of the directory.
-.Pp
-Before searching any directory for a manual page, the
-.Xr man 1
-command always searches the subdirectory with the same name
-as the current machine type, if it exists.
-No specification of these subdirectories is necessary in the
-.Nm man.conf
-file.
-.Pp
-Section names are unrestricted except for the reserved words specified
-below; in general, you should avoid anything with a leading underscore
-.Pq Sq _
-to avoid future incompatibilities.
-.Pp
-The section named
-.Dq _default
-is the list of directories that will
-be searched if no section is specified by the user.
-.Pp
-The second type of line is preceded with a
-.Dq keyword .
-The possible keywords and their meanings are as follows:
-.Bl -tag -width "_version"
-.It _build
-Man file names, regardless of their format, are expected to end in a
-.Sq .*
-pattern, i.e. a
-.Sq .\&
-followed by some suffix.
-The first field of a _build line lists a suffix which indicates
-files which need to be reformatted or manipulated in some way before
-being displayed to the user.
-The suffix may contain the normal shell globbing characters (NOT
-including curly braces
-.Pq Sq {} ) .
-The rest of the line must be a shell command line, the standard
-output of which is the manual page in a format which may be directly
-displayed to the user.
-Any occurrences of the string
-.Sq %s
-in the shell command line will
-be replaced by the name of the file which is being reformatted.
-.It _subdir
-The list
-.Pq in search order
-of subdirectories which will be searched in
-any directory named with a trailing slash
-.Pq Sq /
-character.
-This list is also used when a path is specified to the
-.Xr man 1
-utility by the user, using the
-.Ev MANPATH
-environment variable or the
-.Fl M
-and
-.Fl m
-options.
-.It _suffix
-Man file names, regardless of their format, are expected to end in a
-.Sq .*
-pattern, i.e. a
-.Sq .\&
-followed by some suffix.
-Each field of a _suffix line is a suffix which indicates
-files which do not need to be reformatted or manipulated
-in any way, but which may be directly displayed to the user.
-Each suffix may contain the normal shell globbing characters (NOT
-including curly braces
-.Pq Sq {} ) .
-.It _version
-The version of the configuration file.
-.It _whatdb
-The full pathname
-.Pq not just a directory path
-for a database to be used by the
-.Xr apropos 1
-and
-.Xr whatis 1
-commands.
-.El
-.Pp
-Multiple specifications for all types of lines are cumulative and the
-entries are used in the order listed in the file; multiple entries may
-be listed per line, as well.
-.Pp
-Empty lines or lines whose first non-whitespace character is a hash mark
-.Pq Sq #
-are ignored.
-.Sh FILES
-.Bl -tag -width /etc/man.conf -compact
-.It Pa /etc/man.conf
-standard manual directory search path
-.El
-.Sh EXAMPLES
-Given the following
-.Nm man.conf
-file:
-.Bd -literal -offset indent
-_version BSD.2
-_subdir cat1 cat3 cat2
-_suffix .0
-_build .[1-9] /usr/bin/mandoc %s
-_build .tbl /usr/bin/mandoc %s
-_default /usr/share/man/
-sect3 /usr/share/man/{old/,}cat3
-.Ed
-.Pp
-By default, the command
-.Dq Li man mktemp
-will search for
-.Dq mktemp.\*(Ltany_digit\*(Gt
-and
-.Dq mktemp.tbl
-in the directories
-.Pa /usr/share/man/cat1 ,
-.Pa /usr/share/man/cat3 ,
-and
-.Pa /usr/share/man/cat2 ,
-in that order.
-If on a machine of type
-.Dq vax ,
-the subdirectory
-.Dq vax
-in each directory would be searched as well,
-before the rest of the directory was searched.
-.Pp
-If
-.Dq mktemp.tbl
-was found first, the command
-.Dq /usr/bin/mandoc mktemp.tbl
-would be run to build a man page for display to the user.
-.Pp
-The command
-.Dq Li man sect3 mktemp
-would search the directories
-.Pa /usr/share/man/old/cat3
-and
-.Pa /usr/share/man/cat3 ,
-in that order, for the mktemp manual page.
-If a subdirectory with the same name as the current machine type
-existed in any of them, it would be searched as well, before each
-of them were searched.
-.Sh SEE ALSO
-.Xr apropos 1 ,
-.Xr machine 1 ,
-.Xr man 1 ,
-.Xr whatis 1 ,
-.Xr whereis 1 ,
-.Xr fnmatch 3 ,
-.Xr glob 3
diff --git a/usr.bin/man/pathnames.h b/usr.bin/man/pathnames.h
deleted file mode 100644
index 4a00ef5ebdb..00000000000
--- a/usr.bin/man/pathnames.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* $OpenBSD: pathnames.h,v 1.5 2003/06/03 02:56:12 millert Exp $ */
-/* $NetBSD: pathnames.h,v 1.3 1995/09/28 06:05:40 tls Exp $ */
-
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)pathnames.h 8.3 (Berkeley) 1/2/94
- */
-
-#define _PATH_MANCONF "/etc/man.conf"
-#define _PATH_PAGER "/usr/bin/more -s"
-#define _PATH_TMPFILE "/tmp/man.XXXXXXXXXX"
-#define _PATH_WHATIS "whatis.db"