From 6ca7be8f333b28c465a7b7d961bddcb31d59d72f Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Mon, 12 Dec 2011 02:00:49 +0000 Subject: implement -C (alternative config file) for apropos(1) and mandocdb(8), including various tweaks to the whatis(8) manual; ok kristaps@ --- mandocdb.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'mandocdb.c') diff --git a/mandocdb.c b/mandocdb.c index b7c7e0b3..fe9c01a7 100644 --- a/mandocdb.c +++ b/mandocdb.c @@ -1,4 +1,4 @@ -/* $Id: mandocdb.c,v 1.33 2011/12/10 22:01:06 schwarze Exp $ */ +/* $Id: mandocdb.c,v 1.34 2011/12/12 02:00:49 schwarze Exp $ */ /* * Copyright (c) 2011 Kristaps Dzonsons * Copyright (c) 2011 Ingo Schwarze @@ -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); } -- cgit v1.2.3-56-ge451