-.\" $OpenBSD: whatis.1,v 1.6 2000/03/14 14:58:26 aaron Exp $
+.\" $OpenBSD: whatis.1,v 1.7 2000/04/01 05:05:35 millert Exp $
.\"
.\" Copyright (c) 1989, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
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 Fl
+.It Fl C Ar file
+Specify an alternate configuration 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
.Xr apropos 1 ,
.Xr man 1 ,
.Xr whereis 1 ,
-.Xr which 1
+.Xr which 1 ,
+.Xr man.conf 5
.Sh HISTORY
The
.Nm
-/* $OpenBSD: whatis.c,v 1.4 1997/11/30 05:30:37 deraadt Exp $ */
+/* $OpenBSD: whatis.c,v 1.5 2000/04/01 05:05:35 millert Exp $ */
/*
* Copyright (c) 1987, 1993
#define MAXLINELEN 8192 /* max line handled */
static int *found, foundman;
+extern char *__progname;
void dashtrunc __P((char *, char *));
int match __P((char *, char *));
memset(found, 0, argc * sizeof(int));
for (p = argv; *p; ++p) /* trim full paths */
- if (beg = strrchr(*p, '/'))
+ if ((beg = strrchr(*p, '/')))
*p = beg + 1;
if (p_augment)
char hold[MAXPATHLEN];
for (name = path; name; name = end) { /* through name list */
- if (end = strchr(name, ':'))
+ if ((end = strchr(name, ':')))
*end++ = '\0';
if (buildpath) {
/*
* match --
- * match a full word
+ * match a full word or a full string
*/
int
match(bp, str)
if (!*str || !*bp)
return(0);
for (len = strlen(str);;) {
- for (; *bp && !isdigit(*bp) && !isalpha(*bp); ++bp);
+ /* skip leading crud */
+ for (; *bp && !isalnum(*bp); ++bp)
+ ;
if (!*bp)
break;
- for (start = bp++;
- *bp && (*bp == '_' || isdigit(*bp) || isalpha(*bp)); ++bp);
- if (bp - start == len && !strncasecmp(start, str, len))
- return(1);
+
+ /* check for word match first */
+ for (start = bp++; *bp && (*bp == '_' || isalnum(*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(*bp); ++bp)
+ ;
+ if (bp - start == len && strncasecmp(start, str, len) == 0)
+ return(1);
+ }
}
return(0);
}
void
usage()
{
+
(void)fprintf(stderr,
- "usage: whatis [-C file] [-M path] [-m path] command ...\n");
+ "usage: %s [-C file] [-M path] [-m path] command ...\n",
+ __progname);
exit(1);
}