summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2011-12-12 02:00:49 +0000
committerIngo Schwarze <schwarze@openbsd.org>2011-12-12 02:00:49 +0000
commitc42838fef393e5adf1aa518e01ad6d6a81fdacac (patch)
tree4159f03b7d7c3896b82b9ac86577327883c89771
parent21233e404785a217f2bc0d3060f79f76911b9e1e (diff)
downloadmandoc-c42838fef393e5adf1aa518e01ad6d6a81fdacac.tar.gz
implement -C (alternative config file) for apropos(1) and mandocdb(8),
including various tweaks to the whatis(8) manual; ok kristaps@
-rw-r--r--apropos.124
-rw-r--r--apropos.c12
-rw-r--r--catman.c2
-rw-r--r--cgi.c4
-rw-r--r--mandocdb.824
-rw-r--r--mandocdb.c16
-rw-r--r--manpath.c11
-rw-r--r--manpath.h6
-rw-r--r--whatis.171
9 files changed, 132 insertions, 38 deletions
diff --git a/apropos.1 b/apropos.1
index 887897c0..a390d8a3 100644
--- a/apropos.1
+++ b/apropos.1
@@ -22,11 +22,12 @@
.Nd search manual page databases
.Sh SYNOPSIS
.Nm
+.Op Fl C Ar file
.Op Fl M Ar manpath
.Op Fl m Ar manpath
.Op Fl S Ar arch
.Op Fl s Ar section
-.Ar expression...
+.Ar expression ...
.Sh DESCRIPTION
The
.Nm
@@ -37,6 +38,12 @@ evaluating on
for each file in each database.
Its arguments are as follows:
.Bl -tag -width Ds
+.It Fl C Ar file
+Specify an alternative configuration
+.Ar file
+in
+.Xr man.conf 5
+format.
.It Fl M Ar manpath
Use the colon-separated path instead of the default list of paths
searched for
@@ -238,6 +245,21 @@ Invalid paths, or paths without manual databases, are ignored.
Overridden by
.Fl M .
.El
+.Sh FILES
+.Bl -tag -width "/etc/man.conf" -compact
+.It Pa mandoc.db
+name of the
+.Xr mandocdb 8
+keyword database
+.It Pa mandoc.index
+name of the
+.Xr mandocdb 8
+filename database
+.It Pa /etc/man.conf
+default
+.Xr man 1
+configuration file
+.El
.Sh EXIT STATUS
.Ex -std
.Sh EXAMPLES
diff --git a/apropos.c b/apropos.c
index 4a5bbd0d..7ab4873e 100644
--- a/apropos.c
+++ b/apropos.c
@@ -44,6 +44,7 @@ main(int argc, char *argv[])
struct opts opts;
struct expr *e;
char *defpaths, *auxpaths;
+ char *conf_file;
extern int optind;
extern char *optarg;
@@ -59,10 +60,14 @@ main(int argc, char *argv[])
memset(&opts, 0, sizeof(struct opts));
auxpaths = defpaths = NULL;
+ conf_file = NULL;
e = NULL;
- while (-1 != (ch = getopt(argc, argv, "M:m:S:s:")))
+ while (-1 != (ch = getopt(argc, argv, "C:M:m:S:s:")))
switch (ch) {
+ case ('C'):
+ conf_file = optarg;
+ break;
case ('M'):
defpaths = optarg;
break;
@@ -88,7 +93,7 @@ main(int argc, char *argv[])
rc = 0;
- manpath_parse(&paths, defpaths, auxpaths);
+ manpath_parse(&paths, conf_file, defpaths, auxpaths);
e = whatis ? termcomp(argc, argv, &terms) :
exprcomp(argc, argv, &terms);
@@ -142,10 +147,11 @@ usage(void)
{
fprintf(stderr, "usage: %s "
+ "[-C file] "
"[-M manpath] "
"[-m manpath] "
"[-S arch] "
"[-s section] "
- "expression...\n",
+ "expression ...\n",
progname);
}
diff --git a/catman.c b/catman.c
index ca7a3860..be5b9834 100644
--- a/catman.c
+++ b/catman.c
@@ -112,7 +112,7 @@ main(int argc, char *argv[])
}
memset(&dirs, 0, sizeof(struct manpaths));
- manpath_parse(&dirs, base, aux);
+ manpath_parse(&dirs, NULL, base, aux);
ch = manup(&dirs, buf);
manpath_free(&dirs);
return(ch ? EXIT_SUCCESS : EXIT_FAILURE);
diff --git a/cgi.c b/cgi.c
index e81ee815..8e84c7df 100644
--- a/cgi.c
+++ b/cgi.c
@@ -792,7 +792,7 @@ pg_show(const struct req *req, char *path)
}
memset(&ps, 0, sizeof(struct manpaths));
- manpath_manconf("etc/catman.conf", &ps);
+ manpath_manconf(&ps, "etc/catman.conf");
if (vol >= (unsigned int)ps.sz) {
resp_error400();
@@ -878,7 +878,7 @@ pg_search(const struct req *req, char *path)
}
memset(&ps, 0, sizeof(struct manpaths));
- manpath_manconf("etc/catman.conf", &ps);
+ manpath_manconf(&ps, "etc/catman.conf");
/*
* Poor man's tokenisation: just break apart by spaces.
diff --git a/mandocdb.8 b/mandocdb.8
index bdc81893..4d555176 100644
--- a/mandocdb.8
+++ b/mandocdb.8
@@ -23,7 +23,10 @@
.Sh SYNOPSIS
.Nm
.Op Fl av
-.Op Ar dir ...
+.Op Fl C Ar file
+.Nm
+.Op Fl av
+.Ar dir ...
.Nm
.Op Fl v
.Fl d Ar dir
@@ -69,10 +72,16 @@ uses the default paths stipulated by
.Xr man 1 .
.Pp
The arguments are as follows:
-.Bl -tag -width Ds
+.Bl -tag -width "-C file"
.It Fl a
Use all directories and files found below
.Ar dir ... .
+.It Fl C Ar file
+Specify an alternative configuration
+.Ar file
+in
+.Xr man.conf 5
+format.
.It Fl d Ar dir
Merge (remove and re-add)
.Ar
@@ -141,7 +150,7 @@ length plus one) mapping to a 12-byte binary field consisting of the
64-bit keyword type and 32-bit source
.Sx Index Database
record number, both in network-byte order.
-The typet bit-mask consists of the following
+The type bit-mask consists of the following
values mapping into
.Xr mdoc 7
macro identifiers:
@@ -208,6 +217,10 @@ keyword database mapping keywords to a type and file reference in
A
.Xr recno 3
database of indexed file-names.
+.It Pa /etc/man.conf
+The default
+.Xr man 1
+configuration file.
.El
.Sh EXIT STATUS
The
@@ -249,9 +262,12 @@ This usually indicates database corruption or invalid command-line
arguments.
.El
.Sh SEE ALSO
+.Xr apropos 1 ,
.Xr man 1 ,
+.Xr whatis 1 ,
.Xr btree 3 ,
-.Xr recno 3
+.Xr recno 3 ,
+.Xr man.conf 5
.Sh AUTHORS
The
.Nm
diff --git a/mandocdb.c b/mandocdb.c
index 1ad98626..4990b65c 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -273,6 +273,7 @@ main(int argc, char *argv[])
struct manpaths dirs;
enum op op; /* current operation */
const char *dir;
+ char *conf_file;
char *cp;
char pbuf[PATH_MAX],
ibuf[MAXPATHLEN], /* index fname */
@@ -312,12 +313,16 @@ main(int argc, char *argv[])
maxrec = 0;
op = OP_NEW;
dir = NULL;
+ conf_file = NULL;
- while (-1 != (ch = getopt(argc, argv, "ad:u:v")))
+ while (-1 != (ch = getopt(argc, argv, "aC:d:u:v")))
switch (ch) {
case ('a'):
use_all = 1;
break;
+ case ('C'):
+ conf_file = optarg;
+ break;
case ('d'):
dir = optarg;
op = OP_UPDATE;
@@ -426,7 +431,7 @@ main(int argc, char *argv[])
dirs.paths[i] = mandoc_strdup(cp);
}
} else
- manpath_parse(&dirs, NULL, NULL);
+ manpath_parse(&dirs, conf_file, NULL, NULL);
for (i = 0; i < dirs.sz; i++) {
ibuf[0] = fbuf[0] = '\0';
@@ -1660,7 +1665,8 @@ usage(void)
{
fprintf(stderr, "usage: %s [-v] "
- "[-d dir [files...] |"
- " -u dir [files...] |"
- " dir...]\n", progname);
+ "[-C file] |"
+ " dir ... |"
+ " -d dir [file ...] |"
+ " -u dir [file ...]\n", progname);
}
diff --git a/manpath.c b/manpath.c
index 36b65612..888c862e 100644
--- a/manpath.c
+++ b/manpath.c
@@ -36,7 +36,8 @@
static void manpath_add(struct manpaths *, const char *);
void
-manpath_parse(struct manpaths *dirs, char *defp, char *auxp)
+manpath_parse(struct manpaths *dirs, const char *file,
+ char *defp, char *auxp)
{
manpath_parseline(dirs, auxp);
@@ -45,7 +46,7 @@ manpath_parse(struct manpaths *dirs, char *defp, char *auxp)
defp = getenv("MANPATH");
if (NULL == defp)
- manpath_parseconf(dirs);
+ manpath_parseconf(dirs, file);
else
manpath_parseline(dirs, defp);
}
@@ -91,7 +92,7 @@ manpath_add(struct manpaths *dirs, const char *dir)
}
void
-manpath_parseconf(struct manpaths *dirs)
+manpath_parseconf(struct manpaths *dirs, const char *file)
{
#ifdef USE_MANPATH
FILE *stream;
@@ -124,7 +125,7 @@ manpath_parseconf(struct manpaths *dirs)
free(buf);
pclose(stream);
#else
- manpath_manconf(MAN_CONF_FILE, dirs);
+ manpath_manconf(dirs, file ? file : MAN_CONF_FILE);
#endif
}
@@ -140,7 +141,7 @@ manpath_free(struct manpaths *p)
}
void
-manpath_manconf(const char *file, struct manpaths *dirs)
+manpath_manconf(struct manpaths *dirs, const char *file)
{
FILE *stream;
char *p, *q;
diff --git a/manpath.h b/manpath.h
index 7e6950d0..074967ba 100644
--- a/manpath.h
+++ b/manpath.h
@@ -29,9 +29,9 @@ struct manpaths {
__BEGIN_DECLS
-void manpath_manconf(const char *, struct manpaths *);
-void manpath_parse(struct manpaths *, char *, char *);
-void manpath_parseconf(struct manpaths *);
+void manpath_manconf(struct manpaths *, const char *);
+void manpath_parse(struct manpaths *, const char *, char *, char *);
+void manpath_parseconf(struct manpaths *, const char *);
void manpath_parseline(struct manpaths *, char *);
void manpath_free(struct manpaths *);
diff --git a/whatis.1 b/whatis.1
index ee794bb4..0537bbaf 100644
--- a/whatis.1
+++ b/whatis.1
@@ -19,32 +19,47 @@
.Os
.Sh NAME
.Nm whatis
-.Nd search manual page databases
+.Nd search for manual pages by page names
.Sh SYNOPSIS
.Nm
+.Op Fl C Ar file
.Op Fl M Ar manpath
.Op Fl m Ar manpath
.Op Fl S Ar arch
.Op Fl s Ar section
-.Ar term...
+.Ar name ...
.Sh DESCRIPTION
The
.Nm
-utility searches for manuals named or described with
-.Ar term
-in manual page databases generated by
-.Xr mandocdb 8 .
-Its arguments are as follows:
+utility searches databases generated by
+.Xr mandocdb 8
+for manuals containing the word
+.Ar name
+in their page name, ignoring case.
+It returns the header lines from all matching pages.
+You can then use the
+.Xr man 1
+command to get more information.
+.Pp
+The options are as follows:
.Bl -tag -width Ds
+.It Fl C Ar file
+Specify an alternative configuration
+.Ar file
+in
+.Xr man.conf 5
+format.
.It Fl M Ar manpath
-Use the colon-separated path instead of the default list of paths
-searched for
+Use the colon-separated
+.Ar manpath
+instead of the default list of paths searched for
.Xr mandocdb 8
databases.
Invalid paths, or paths without manual databases, are ignored.
.It Fl m Ar manpath
-Prepend the colon-separated paths to the list of paths searched
-for
+Prepend the colon-separated
+.Ar manpath
+to the list of paths searched for
.Xr mandocdb 8
databases.
Invalid paths, or paths without manual databases, are ignored.
@@ -102,16 +117,44 @@ Invalid paths, or paths without manual databases, are ignored.
Overridden by
.Fl M .
.El
-.\" .Sh FILES
+.Sh FILES
+.Bl -tag -width "/etc/man.conf" -compact
+.It Pa mandoc.db
+name of the
+.Xr mandocdb 8
+keyword database
+.It Pa mandoc.index
+name of the
+.Xr mandocdb 8
+filename database
+.It Pa /etc/man.conf
+default
+.Xr man 1
+configuration file
+.El
.Sh EXIT STATUS
.Ex -std
.Sh SEE ALSO
.Xr apropos 1 ,
.Xr man 1 ,
+.Xr man.conf 5 ,
.Xr mandocdb 8
-.Sh AUTHORS
+.Sh HISTORY
The
.Nm
-utility was written by
+utility first appeared in
+.Bx 2 .
+It was rewritten from scratch as part of the
+.Xr mandocdb 8
+project for
+.Ox 5.1 .
+.Sh AUTHORS
+.An -nosplit
+.An Bill Joy
+wrote the original
+.Bx
+.Nm
+in 1979.
+The current version was written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .