diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2011-12-12 01:59:14 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2011-12-12 01:59:14 +0000 |
commit | 95ff32580540b6b60c92de49abf3bdcceb9e4632 (patch) | |
tree | 7f1c9863ac2e8d5096d4ea9594284c4af33ea533 | |
parent | 862f63944db00d55fc36806c09f2822e6ac59833 (diff) |
implement -C (alternative config file) for apropos(1) and mandocdb(8);
ok kristaps@
-rw-r--r-- | usr.bin/mandoc/apropos.1 | 28 | ||||
-rw-r--r-- | usr.bin/mandoc/apropos.c | 14 | ||||
-rw-r--r-- | usr.bin/mandoc/mandocdb.8 | 26 | ||||
-rw-r--r-- | usr.bin/mandoc/mandocdb.c | 18 | ||||
-rw-r--r-- | usr.bin/mandoc/manpath.c | 13 | ||||
-rw-r--r-- | usr.bin/mandoc/manpath.h | 8 |
6 files changed, 79 insertions, 28 deletions
diff --git a/usr.bin/mandoc/apropos.1 b/usr.bin/mandoc/apropos.1 index 3c9401d0d82..80d2f00e47a 100644 --- a/usr.bin/mandoc/apropos.1 +++ b/usr.bin/mandoc/apropos.1 @@ -1,4 +1,4 @@ -.\" $Id: apropos.1,v 1.8 2011/11/29 22:30:56 schwarze Exp $ +.\" $Id: apropos.1,v 1.9 2011/12/12 01:59:13 schwarze Exp $ .\" .\" Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: November 29 2011 $ +.Dd $Mdocdate: December 12 2011 $ .Dt APROPOS 1 .Os .Sh NAME @@ -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/usr.bin/mandoc/apropos.c b/usr.bin/mandoc/apropos.c index 23ac54bc31a..aab04ac25f3 100644 --- a/usr.bin/mandoc/apropos.c +++ b/usr.bin/mandoc/apropos.c @@ -1,4 +1,4 @@ -/* $Id: apropos.c,v 1.11 2011/12/09 00:44:15 schwarze Exp $ */ +/* $Id: apropos.c,v 1.12 2011/12/12 01:59:13 schwarze Exp $ */ /* * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org> @@ -40,6 +40,7 @@ apropos(int argc, char *argv[]) struct opts opts; struct expr *e; char *defpaths, *auxpaths; + char *conf_file; extern int optind; extern char *optarg; @@ -55,10 +56,14 @@ apropos(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; @@ -84,7 +89,7 @@ apropos(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); @@ -138,10 +143,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/usr.bin/mandoc/mandocdb.8 b/usr.bin/mandoc/mandocdb.8 index 7d9b30a014d..c0c72a1224c 100644 --- a/usr.bin/mandoc/mandocdb.8 +++ b/usr.bin/mandoc/mandocdb.8 @@ -1,4 +1,4 @@ -.\" $Id: mandocdb.8,v 1.11 2011/12/03 14:53:12 schwarze Exp $ +.\" $Id: mandocdb.8,v 1.12 2011/12/12 01:59:13 schwarze Exp $ .\" .\" Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: December 3 2011 $ +.Dd $Mdocdate: December 12 2011 $ .Dt MANDOCDB 8 .Os .Sh NAME @@ -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 @@ -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/usr.bin/mandoc/mandocdb.c b/usr.bin/mandoc/mandocdb.c index e2c7db6bedc..3e2152e5c54 100644 --- a/usr.bin/mandoc/mandocdb.c +++ b/usr.bin/mandoc/mandocdb.c @@ -1,4 +1,4 @@ -/* $Id: mandocdb.c,v 1.24 2011/12/10 22:01:03 schwarze Exp $ */ +/* $Id: mandocdb.c,v 1.25 2011/12/12 01:59:13 schwarze Exp $ */ /* * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org> @@ -260,6 +260,7 @@ mandocdb(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 */ @@ -299,12 +300,16 @@ mandocdb(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; @@ -414,7 +419,7 @@ mandocdb(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'; @@ -1648,7 +1653,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/usr.bin/mandoc/manpath.c b/usr.bin/mandoc/manpath.c index cbe70e5339a..86084a7aca5 100644 --- a/usr.bin/mandoc/manpath.c +++ b/usr.bin/mandoc/manpath.c @@ -1,4 +1,4 @@ -/* $Id: manpath.c,v 1.1 2011/11/26 16:41:35 schwarze Exp $ */ +/* $Id: manpath.c,v 1.2 2011/12/12 01:59:13 schwarze Exp $ */ /* * Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org> * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv> @@ -33,7 +33,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); @@ -42,7 +43,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); } @@ -88,10 +89,10 @@ manpath_add(struct manpaths *dirs, const char *dir) } void -manpath_parseconf(struct manpaths *dirs) +manpath_parseconf(struct manpaths *dirs, const char *file) { - manpath_manconf(MAN_CONF_FILE, dirs); + manpath_manconf(dirs, file ? file : MAN_CONF_FILE); } void @@ -106,7 +107,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/usr.bin/mandoc/manpath.h b/usr.bin/mandoc/manpath.h index a30b1c26082..632834d6fc4 100644 --- a/usr.bin/mandoc/manpath.h +++ b/usr.bin/mandoc/manpath.h @@ -1,4 +1,4 @@ -/* $Id: manpath.h,v 1.1 2011/11/26 16:41:35 schwarze Exp $ */ +/* $Id: manpath.h,v 1.2 2011/12/12 01:59:13 schwarze Exp $ */ /* * Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org> * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv> @@ -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 *); |