Module Name: src Committed By: abhinav Date: Sun May 22 19:26:04 UTC 2016
Modified Files: src/usr.sbin/makemandb: apropos.1 apropos.c whatis.1 whatis.c Log Message: Add options to whatis and apropos to accept custom man.conf. makemandb(8), man(1) already use -C as an option to take man.conf path, so use the same option for whatis(1) and apropos(1) for consitency. apropos was using -C/-c to disable/enable context of the search matches, change that to -M/-m respectively. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/usr.sbin/makemandb/apropos.1 cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/makemandb/apropos.c cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/makemandb/whatis.1 cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/makemandb/whatis.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.sbin/makemandb/apropos.1 diff -u src/usr.sbin/makemandb/apropos.1:1.15 src/usr.sbin/makemandb/apropos.1:1.16 --- src/usr.sbin/makemandb/apropos.1:1.15 Tue Nov 4 08:05:21 2014 +++ src/usr.sbin/makemandb/apropos.1 Sun May 22 19:26:04 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: apropos.1,v 1.15 2014/11/04 08:05:21 snj Exp $ +.\" $NetBSD: apropos.1,v 1.16 2016/05/22 19:26:04 abhinav Exp $ .\" .\" Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadh...@gmail.com> .\" All rights reserved. @@ -29,7 +29,7 @@ .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd November 22, 2013 +.Dd May 22, 2016 .Dt APROPOS 1 .Os .Sh NAME @@ -37,7 +37,8 @@ .Nd search the complete content of all man pages .Sh SYNOPSIS .Nm -.Op Fl 123456789CchilPpr +.Op Fl 123456789hilMmPpr +.Op Fl C Ar path .Op Fl n Ar results .Op Fl S Ar machine .Op Fl s Ar section @@ -64,10 +65,11 @@ It supports the following options: .Bl -tag -width indent .It Fl [1-9] Search only within the specified section manual pages. -.It Fl C -Do not show the context of the match. -.It Fl c -Do show the context of the match (default). +.It Fl C Ar path +Use different +.Xr man 1 +configuration file than the default, +.Pa /etc/man.conf . .It Fl h Turn on html formatting. .It Fl i @@ -75,6 +77,10 @@ Turn on terminal escape code formatting. .It Fl l Legacy mode: Only searches name and name description. Does not print context and turns off formatting. +.It Fl M +Do not show the context of the match. +.It Fl m +Show the context of the match (default). .It Fl n Ar results Output up to the specified number of search results. The default limit is infinity. Index: src/usr.sbin/makemandb/apropos.c diff -u src/usr.sbin/makemandb/apropos.c:1.20 src/usr.sbin/makemandb/apropos.c:1.21 --- src/usr.sbin/makemandb/apropos.c:1.20 Sat Apr 23 14:15:36 2016 +++ src/usr.sbin/makemandb/apropos.c Sun May 22 19:26:04 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: apropos.c,v 1.20 2016/04/23 14:15:36 christos Exp $ */ +/* $NetBSD: apropos.c,v 1.21 2016/05/22 19:26:04 abhinav Exp $ */ /*- * Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadh...@gmail.com> * All rights reserved. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: apropos.c,v 1.20 2016/04/23 14:15:36 christos Exp $"); +__RCSID("$NetBSD: apropos.c,v 1.21 2016/05/22 19:26:04 abhinav Exp $"); #include <err.h> #include <stdio.h> @@ -50,6 +50,7 @@ typedef struct apropos_flags { query_format format; int legacy; const char *machine; + const char *manconf; } apropos_flags; typedef struct callback_data { @@ -72,8 +73,9 @@ parseargs(int argc, char **argv, struct { int ch; char sec[2] = {0, 0}; + aflags->manconf = MANCONF; - while ((ch = getopt(argc, argv, "123456789Cchiln:PprS:s:")) != -1) { + while ((ch = getopt(argc, argv, "123456789C:hilMmn:PprS:s:")) != -1) { switch (ch) { case '1': case '2': @@ -97,10 +99,7 @@ parseargs(int argc, char **argv, struct concat2(&aflags->sec_nums, sec, 1); break; case 'C': - aflags->no_context = 1; - break; - case 'c': - aflags->no_context = 0; + aflags->manconf = optarg; break; case 'h': aflags->format = APROPOS_HTML; @@ -113,6 +112,12 @@ parseargs(int argc, char **argv, struct aflags->no_context = 1; aflags->format = APROPOS_NONE; break; + case 'M': + aflags->no_context = 1; + break; + case 'm': + aflags->no_context = 0; + break; case 'n': aflags->nresults = atoi(optarg); break; @@ -210,7 +215,7 @@ main(int argc, char *argv[]) else free(str); - if ((db = init_db(MANDB_READONLY, MANCONF)) == NULL) + if ((db = init_db(MANDB_READONLY, aflags.manconf)) == NULL) exit(EXIT_FAILURE); /* If user wants to page the output, then set some settings */ @@ -348,7 +353,7 @@ remove_stopwords(const char *query) static void usage(void) { - fprintf(stderr, "Usage: %s [-123456789Ccilpr] [-n results] " + fprintf(stderr, "Usage: %s [-123456789ilMmpr] [-C path] [-n results] " "[-S machine] [-s section] query\n", getprogname()); exit(1); Index: src/usr.sbin/makemandb/whatis.1 diff -u src/usr.sbin/makemandb/whatis.1:1.2 src/usr.sbin/makemandb/whatis.1:1.3 --- src/usr.sbin/makemandb/whatis.1:1.2 Sat Oct 6 15:33:59 2012 +++ src/usr.sbin/makemandb/whatis.1 Sun May 22 19:26:04 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: whatis.1,v 1.2 2012/10/06 15:33:59 wiz Exp $ +.\" $NetBSD: whatis.1,v 1.3 2016/05/22 19:26:04 abhinav Exp $ .\" .\" Copyright (c) 2012 Joerg Sonnenberger <jo...@netbsd.org> .\" All rights reserved. @@ -27,7 +27,7 @@ .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd October 5, 2012 +.Dd May 22, 2016 .Dt WHATIS 1 .Os .Sh NAME @@ -35,6 +35,7 @@ .Nd describe what a command is .Sh SYNOPSIS .Nm +.Op Fl C Ar path .Ar command Ar ... .Sh DESCRIPTION The @@ -45,6 +46,15 @@ It searches for manual pages with name .Ar command and outputs name of the matching manual pages along with the section and the brief description from the NAME section. +.Pp +It supports the following options: +.Bl -tag -width indent +.It Fl C Ar path +Use different +.Xr man 1 +configuration file than the default, +.Pa /etc/man.conf . +.El .Sh FILES .Bl -hang -width /etc/man.conf -compact .It Pa /etc/man.conf Index: src/usr.sbin/makemandb/whatis.c diff -u src/usr.sbin/makemandb/whatis.c:1.4 src/usr.sbin/makemandb/whatis.c:1.5 --- src/usr.sbin/makemandb/whatis.c:1.4 Sat Oct 6 15:33:59 2012 +++ src/usr.sbin/makemandb/whatis.c Sun May 22 19:26:04 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: whatis.c,v 1.4 2012/10/06 15:33:59 wiz Exp $ */ +/* $NetBSD: whatis.c,v 1.5 2016/05/22 19:26:04 abhinav Exp $ */ /*- * Copyright (c) 2012 Joerg Sonnenberger <jo...@netbsd.org> * All rights reserved. @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: whatis.c,v 1.4 2012/10/06 15:33:59 wiz Exp $"); +__RCSID("$NetBSD: whatis.c,v 1.5 2016/05/22 19:26:04 abhinav Exp $"); #include <err.h> #include <stdio.h> @@ -41,7 +41,7 @@ __RCSID("$NetBSD: whatis.c,v 1.4 2012/10 __dead static void usage(void) { - fprintf(stderr, "%s ...\n", "whatis"); + fprintf(stderr, "%s [-C path] ...\n", "whatis"); exit(EXIT_FAILURE); } @@ -78,9 +78,13 @@ main(int argc, char *argv[]) { sqlite3 *db; int ch, retval; + const char *manconf = MANCONF; - while ((ch = getopt(argc, argv, "")) != -1) { + while ((ch = getopt(argc, argv, "C:")) != -1) { switch (ch) { + case 'C': + manconf = optarg; + break; default: usage(); } @@ -91,7 +95,7 @@ main(int argc, char *argv[]) if (argc == 0) usage(); - if ((db = init_db(MANDB_READONLY, MANCONF)) == NULL) + if ((db = init_db(MANDB_READONLY, manconf)) == NULL) exit(EXIT_FAILURE); retval = 0;