summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2014-10-20 22:56:08 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2014-10-20 22:56:08 +0000
commit5c69c4be0b6b20e689fc8c59cbd976ffe09b6adb (patch)
treec980688c10d4892794186daddd5a493d703bb947
parentafe38cccf4807b37bea0564a529032720fa5f360 (diff)
superseded by usr.bin/mandoc/mansearch.c
removal suggested by daniel@; ok deraadt@
-rw-r--r--usr.bin/apropos/Makefile7
-rw-r--r--usr.bin/apropos/apropos.1166
-rw-r--r--usr.bin/apropos/apropos.c240
-rw-r--r--usr.bin/whatis/Makefile7
-rw-r--r--usr.bin/whatis/whatis.1151
-rw-r--r--usr.bin/whatis/whatis.c224
6 files changed, 0 insertions, 795 deletions
diff --git a/usr.bin/apropos/Makefile b/usr.bin/apropos/Makefile
deleted file mode 100644
index 19f24ce47b8..00000000000
--- a/usr.bin/apropos/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-# $OpenBSD: Makefile,v 1.3 1997/09/21 11:48:17 deraadt Exp $
-
-PROG= apropos
-SRCS= apropos.c config.c
-.PATH: ${.CURDIR}/../man
-
-.include <bsd.prog.mk>
diff --git a/usr.bin/apropos/apropos.1 b/usr.bin/apropos/apropos.1
deleted file mode 100644
index d75d3604123..00000000000
--- a/usr.bin/apropos/apropos.1
+++ /dev/null
@@ -1,166 +0,0 @@
-.\" $OpenBSD: apropos.1,v 1.16 2012/01/22 13:45:22 schwarze Exp $
-.\" $NetBSD: apropos.1,v 1.4 1995/09/04 20:46:17 tls 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.
-.\"
-.\" @(#)apropos.1 8.1 (Berkeley) 6/29/93
-.\"
-.Dd $Mdocdate: January 22 2012 $
-.Dt APROPOS 1
-.Os
-.Sh NAME
-.Nm apropos
-.Nd locate commands by keyword lookup
-.Sh SYNOPSIS
-.Nm apropos
-.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
-.Ar keyword ...
-.Sh DESCRIPTION
-.Nm
-shows which manual pages contain instances of any of the given
-.Ar keyword(s)
-in their title line.
-Each word is considered separately and case of letters is ignored.
-Words which are part of other words are considered; when looking for
-.Dq compile ,
-.Nm
-will also list all instances of
-.Dq compiler .
-.Pp
-If the line output by
-.Nm
-starts
-.Dq Li name (section) ... ,
-you can enter
-.Dq Li man section name
-to get
-its documentation.
-.Pp
-The options are as follows:
-.Bl -tag -width "-C file"
-.It Fl C Ar file
-Specify an alternative configuration
-.Ar file
-in
-.Xr man.conf 5
-format.
-.It Fl M Ar path
-Override the list of standard directories
-.Nm
-searches for a database named
-.Pa whatis.db .
-The supplied
-.Ar path
-must be a colon
-.Pq Sq \&:
-separated list of directories.
-This search path may also be set using the environment variable
-.Ev MANPATH .
-.It Fl m Ar path
-Augment the list of standard directories
-.Nm
-searches for its database.
-The supplied
-.Ar path
-must be a colon
-.Pq Sq \&:
-separated list of directories.
-These directories will be searched before the standard directories,
-or the directories supplied with the
-.Fl M
-option or the
-.Ev MANPATH
-environment variable.
-.It Fl S Ar subsection
-Restrict the search to pages for the specified machine architecture.
-By default, pages for all architectures are shown.
-.It Fl s Ar section
-Restrict the search to the specified section of the manual.
-By default, pages from all sections are shown.
-.El
-.Sh ENVIRONMENT
-.Bl -tag -width MANPATH
-.It Ev MANPATH
-The standard search path used by
-.Xr man 1
-may be overridden by specifying a path in the
-.Ev MANPATH
-environment variable.
-The format of the path is a colon
-.Pq Sq \&:
-separated list of directories.
-.El
-.Sh FILES
-.Bl -tag -width /etc/man.conf -compact
-.It Pa whatis.db
-name of the apropos database
-.It Pa /etc/man.conf
-default
-.Xr man 1
-configuration file
-.El
-.Sh SEE ALSO
-.Xr man 1 ,
-.Xr whatis 1 ,
-.Xr whereis 1 ,
-.Xr man.conf 5 ,
-.Xr makewhatis 8
-.Sh HISTORY
-The
-.Nm
-command first appeared in
-.Bx 2 .
-.Pp
-The
-.Fl M
-option and the
-.Ev MANPATH
-variable first appeared in
-.Bx 4.3 ;
-.Fl m
-in
-.Bx 4.3 Reno ;
-.Fl C
-in
-.Bx 4.4 Lite1 ;
-and
-.Fl s
-and
-.Fl S
-in
-.Ox 4.5 .
-.Sh AUTHORS
-.An Bill Joy
-wrote the original
-.Bx
-.Nm
-in February 1979.
diff --git a/usr.bin/apropos/apropos.c b/usr.bin/apropos/apropos.c
deleted file mode 100644
index 95f6f2115df..00000000000
--- a/usr.bin/apropos/apropos.c
+++ /dev/null
@@ -1,240 +0,0 @@
-/* $OpenBSD: apropos.c,v 1.16 2013/11/25 18:02:49 deraadt Exp $ */
-/* $NetBSD: apropos.c,v 1.5 1995/09/04 20:46:20 tls Exp $ */
-
-/*
- * Copyright (c) 1987, 1993, 1994
- * 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/param.h>
-#include <sys/queue.h>
-
-#include <ctype.h>
-#include <err.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "../man/config.h"
-#include "../man/pathnames.h"
-
-static int *found, foundman;
-
-#define MAXLINELEN 8192 /* max line handled */
-
-void apropos(char **, char *, int, char *, char *);
-void lowstr(char *, char *);
-int match(char *, char *);
-void usage(void);
-
-int
-main(int argc, char *argv[])
-{
- ENTRY *ep;
- TAG *tp;
- int ch, rv;
- char *conffile, *machine, **p, *p_augment, *p_path, *sflag;
-
- conffile = NULL;
- p_augment = p_path = NULL;
- machine = sflag = NULL;
- while ((ch = getopt(argc, argv, "C:M:m:P:S:s:")) != -1)
- switch (ch) {
- case 'C':
- conffile = optarg;
- break;
- case 'M':
- case 'P': /* backward compatible */
- p_path = optarg;
- break;
- case 'm':
- p_augment = optarg;
- break;
- case 'S':
- machine = optarg;
- lowstr(machine, machine);
- break;
- case 's':
- sflag = optarg;
- lowstr(sflag, sflag);
- break;
- case '?':
- default:
- usage();
- }
- argv += optind;
- argc -= optind;
-
- if (argc < 1)
- usage();
-
- if ((found = calloc(argc, sizeof(int))) == NULL)
- err(1, NULL);
-
- for (p = argv; *p; ++p) /* convert to lower-case */
- lowstr(*p, *p);
-
- if (p_augment)
- apropos(argv, p_augment, 1, sflag, machine);
- if (p_path || (p_path = getenv("MANPATH")))
- apropos(argv, p_path, 1, sflag, machine);
- else {
- config(conffile);
- ep = (tp = getlist("_whatdb")) == NULL ?
- NULL : TAILQ_FIRST(&tp->list);
- for (; ep != NULL; ep = TAILQ_NEXT(ep, q))
- apropos(argv, ep->s, 0, sflag, machine);
- }
-
- if (!foundman)
- errx(1, "no %s file found", _PATH_WHATIS);
-
- rv = 1;
- for (p = argv; *p; ++p)
- if (found[p - argv])
- rv = 0;
- else
- (void)printf("%s: nothing appropriate\n", *p);
- exit(rv);
-}
-
-void
-apropos(char **argv, char *path, int buildpath, char *sflag, char *machine)
-{
- char *end, *name, **p;
- char buf[MAXLINELEN + 1], wbuf[MAXLINELEN + 1];
- char hold[MAXPATHLEN];
- size_t slen = 0, mlen = 0;
-
- if (sflag)
- slen = strlen(sflag);
- if (machine)
- mlen = strlen(machine);
-
- for (name = path; name; name = end) { /* through name list */
- if ((end = strchr(name, ':')))
- *end++ = '\0';
-
- if (buildpath) {
- (void)snprintf(hold, sizeof(hold), "%s/%s", name,
- _PATH_WHATIS);
- name = hold;
- }
-
- if (!freopen(name, "r", stdin))
- continue;
-
- foundman = 1;
-
- /* for each file found */
- while (fgets(buf, sizeof(buf), stdin)) {
- if (!strchr(buf, '\n')) {
- warnx("%s: line too long", name);
- continue;
- }
- lowstr(buf, wbuf);
- if (sflag || machine) {
- char *s = strstr(wbuf, ") - ");
- if (!s)
- continue;
- while (s > wbuf && *s != '/' && *s != '(')
- s--;
- if (machine && *s == '/' &&
- strncmp(s+1, machine, mlen))
- continue;
- while (s > wbuf && *s != '(')
- s--;
- if (sflag && *s == '(' &&
- strncmp(s+1, sflag, slen))
- continue;
- }
- for (p = argv; *p; ++p)
- if (match(wbuf, *p)) {
- (void)printf("%s", buf);
- found[p - argv] = 1;
-
- /* only print line once */
- while (*++p)
- if (match(wbuf, *p))
- found[p - argv] = 1;
- break;
- }
- }
- }
-}
-
-/*
- * match --
- * match anywhere the string appears
- */
-int
-match(char *bp, char *str)
-{
- int len;
- char test;
-
- if (!*bp)
- return (0);
- /* backward compatible: everything matches empty string */
- if (!*str)
- return (1);
- for (test = *str++, len = strlen(str); *bp;)
- if (test == *bp++ && !strncmp(bp, str, len))
- return (1);
- return (0);
-}
-
-/*
- * lowstr --
- * convert a string to lower case
- */
-void
-lowstr(char *from, char *to)
-{
- unsigned char ch;
-
- while ((ch = *from++) && ch != '\n')
- *to++ = isupper(ch) ? tolower(ch) : ch;
- *to = '\0';
-}
-
-/*
- * usage --
- * print usage message and die
- */
-void
-usage(void)
-{
-
- (void)fprintf(stderr,
- "usage: apropos [-C file] [-M path] [-m path] "
- "[-S subsection] [-s section]\n"
- " keyword ...\n");
- exit(1);
-}
diff --git a/usr.bin/whatis/Makefile b/usr.bin/whatis/Makefile
deleted file mode 100644
index 9b844c2ef1a..00000000000
--- a/usr.bin/whatis/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-# $OpenBSD: Makefile,v 1.3 1997/09/21 11:51:59 deraadt Exp $
-
-PROG= whatis
-SRCS= whatis.c config.c
-.PATH: ${.CURDIR}/../man
-
-.include <bsd.prog.mk>
diff --git a/usr.bin/whatis/whatis.1 b/usr.bin/whatis/whatis.1
deleted file mode 100644
index de0a4286e9e..00000000000
--- a/usr.bin/whatis/whatis.1
+++ /dev/null
@@ -1,151 +0,0 @@
-.\" $OpenBSD: whatis.1,v 1.17 2012/01/22 13:45:22 schwarze 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.
-.\"
-.\" @(#)whatis.1 8.1 (Berkeley) 6/6/93
-.\"
-.Dd $Mdocdate: January 22 2012 $
-.Dt WHATIS 1
-.Os
-.Sh NAME
-.Nm whatis
-.Nd describe what a command is
-.Sh SYNOPSIS
-.Nm whatis
-.Op Fl C Ar file
-.Op Fl M Ar path
-.Op Fl m Ar path
-.Ar command ...
-.Sh DESCRIPTION
-The
-.Nm
-utility looks up the given commands and shows the header lines
-from the manual pages.
-You can then use the
-.Xr man 1
-command to get more information.
-.Nm
-will match on a case insensitive basis and for multiple word entries
-will match on each individual word.
-.Pp
-The options are as follows:
-.Bl -tag -width Ds
-.It Fl C Ar file
-Specify an alternate configuration
-.Ar file
-in
-.Xr man.conf 5
-format.
-The default is
-.Pa /etc/man.conf .
-.It Fl M Ar path
-Override the list of standard directories
-.Nm
-searches for its database named
-.Dq Pa whatis.db .
-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 .
-.It Fl m Ar path
-Augment the list of standard directories
-.Nm
-searches for its database named
-.Dq Pa whatis.db .
-The supplied
-.Ar path
-must be a colon-separated list of directories.
-These directories will be searched before the standard directories
-or the directories supplied with the
-.Fl M
-option or the
-.Ev MANPATH
-environment variable are searched.
-.El
-.Sh ENVIRONMENT
-.Bl -tag -width MANPATH
-.It Ev MANPATH
-The standard search path used by
-.Xr man 1
-may be overridden by specifying a path in the
-.Ev MANPATH
-environment variable.
-.El
-.Sh FILES
-.Bl -tag -width "/etc/man.conf" -compact
-.It Pa whatis.db
-name of the whatis database
-.It Pa /etc/man.conf
-default
-.Xr man 1
-configuration file
-.El
-.Sh SEE ALSO
-.Xr apropos 1 ,
-.Xr man 1 ,
-.Xr whereis 1 ,
-.Xr which 1 ,
-.Xr man.conf 5 ,
-.Xr makewhatis 8
-.Sh HISTORY
-Part of the functionality of
-.Nm
-was already provided by the former
-.Nm manwhere
-utility in
-.Bx 1 .
-The
-.Nm
-command first appeared in
-.Bx 2 .
-.Pp
-The
-.Fl M
-option and the
-.Ev MANPATH
-variable first appeared in
-.Bx 4.3 ;
-.Fl m
-in
-.Bx 4.3 Reno ;
-and
-.Fl C
-in
-.Bx 4.4 Lite1 .
-.Sh AUTHORS
-.An Bill Joy
-wrote
-.Nm manwhere
-in 1977
-and the original
-.Bx
-.Nm
-in February 1979.
diff --git a/usr.bin/whatis/whatis.c b/usr.bin/whatis/whatis.c
deleted file mode 100644
index 57426fe6df6..00000000000
--- a/usr.bin/whatis/whatis.c
+++ /dev/null
@@ -1,224 +0,0 @@
-/* $OpenBSD: whatis.c,v 1.15 2013/11/26 19:25:39 deraadt Exp $ */
-
-/*
- * Copyright (c) 1987, 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.
- */
-
-#include <sys/param.h>
-#include <sys/queue.h>
-
-#include <ctype.h>
-#include <err.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "../man/config.h"
-#include "../man/pathnames.h"
-
-#define MAXLINELEN 8192 /* max line handled */
-
-static int *found, foundman;
-extern char *__progname;
-
-void dashtrunc(char *, char *);
-int match(char *, char *);
-void usage(void);
-void whatis(char **, char *, int);
-
-int
-main(int argc, char *argv[])
-{
- ENTRY *ep;
- TAG *tp;
- int ch, rv;
- char *beg, *conffile, **p, *p_augment, *p_path;
-
- conffile = NULL;
- p_augment = p_path = NULL;
- while ((ch = getopt(argc, argv, "C:M:m:P:")) != -1)
- switch (ch) {
- case 'C':
- conffile = optarg;
- break;
- case 'M':
- case 'P': /* backward compatible */
- p_path = optarg;
- break;
- case 'm':
- p_augment = optarg;
- break;
- case '?':
- default:
- usage();
- }
- argv += optind;
- argc -= optind;
-
- if (argc < 1)
- usage();
-
- if ((found = calloc(argc, sizeof(int))) == NULL)
- err(1, NULL);
-
- for (p = argv; *p; ++p) /* trim full paths */
- if ((beg = strrchr(*p, '/')))
- *p = beg + 1;
-
- if (p_augment)
- whatis(argv, p_augment, 1);
- if (p_path || (p_path = getenv("MANPATH")))
- whatis(argv, p_path, 1);
- else {
- config(conffile);
- ep = (tp = getlist("_whatdb")) == NULL ?
- NULL : TAILQ_FIRST(&tp->list);
- for (; ep != NULL; ep = TAILQ_NEXT(ep, q))
- whatis(argv, ep->s, 0);
- }
-
- if (!foundman) {
- fprintf(stderr, "whatis: no %s file found.\n", _PATH_WHATIS);
- exit(1);
- }
- rv = 1;
- for (p = argv; *p; ++p)
- if (found[p - argv])
- rv = 0;
- else
- printf("%s: not found\n", *p);
- exit(rv);
-}
-
-void
-whatis(char **argv, char *path, int buildpath)
-{
- char *end, *name, **p;
- char buf[MAXLINELEN + 1], wbuf[MAXLINELEN + 1];
- char hold[MAXPATHLEN];
-
- for (name = path; name; name = end) { /* through name list */
- if ((end = strchr(name, ':')))
- *end++ = '\0';
-
- if (buildpath) {
- (void)snprintf(hold, sizeof hold, "%s/%s",
- name, _PATH_WHATIS);
- name = hold;
- }
-
- if (!freopen(name, "r", stdin))
- continue;
-
- foundman = 1;
-
- /* for each file found */
- while (fgets(buf, sizeof(buf), stdin)) {
- dashtrunc(buf, wbuf);
- for (p = argv; *p; ++p)
- if (match(wbuf, *p)) {
- printf("%s", buf);
- found[p - argv] = 1;
-
- /* only print line once */
- while (*++p)
- if (match(wbuf, *p))
- found[p - argv] = 1;
- break;
- }
- }
- }
-}
-
-/*
- * match --
- * match a full word or a full string
- */
-int
-match(char *bp, char *str)
-{
- int len;
- char *start;
-
- if (!*str || !*bp)
- return(0);
- for (len = strlen(str);;) {
- /* skip leading crud */
- for (; *bp && !isalnum((unsigned char)*bp); ++bp)
- ;
- if (!*bp)
- break;
-
- /* check for word match first */
- for (start = bp++; *bp == '_' || isalnum((unsigned char)*bp); ++bp)
- ;
- if (bp - start == len) {
- if (strncasecmp(start, str, len) == 0)
- return(1);
- } else if (*bp && *bp != ',') {
- /* check for full string match */
- for (bp = start;
- *bp && *bp != ',' && *bp != '(' &&
- !isspace((unsigned char)*bp); ++bp)
- ;
- if (bp - start == len && strncasecmp(start, str, len) == 0)
- return(1);
- }
- }
- return(0);
-}
-
-/*
- * dashtrunc --
- * truncate a string at " - "
- */
-void
-dashtrunc(char *from, char *to)
-{
- int ch;
-
- for (; (ch = *from) && ch != '\n' &&
- (ch != ' ' || from[1] != '-' || from[2] != ' '); ++from)
- *to++ = ch;
- *to = '\0';
-}
-
-/*
- * usage --
- * print usage message and die
- */
-void
-usage(void)
-{
-
- (void)fprintf(stderr,
- "usage: %s [-C file] [-M path] [-m path] command ...\n",
- __progname);
- exit(1);
-}