Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/makemandb Add options to whatis and apropos to acce...



details:   https://anonhg.NetBSD.org/src/rev/6dafae49140c
branches:  trunk
changeset: 345370:6dafae49140c
user:      abhinav <abhinav%NetBSD.org@localhost>
date:      Sun May 22 19:26:04 2016 +0000

description:
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.

diffstat:

 usr.sbin/makemandb/apropos.1 |  20 +++++++++++++-------
 usr.sbin/makemandb/apropos.c |  23 ++++++++++++++---------
 usr.sbin/makemandb/whatis.1  |  14 ++++++++++++--
 usr.sbin/makemandb/whatis.c  |  14 +++++++++-----
 4 files changed, 48 insertions(+), 23 deletions(-)

diffs (228 lines):

diff -r bc88e798d81d -r 6dafae49140c usr.sbin/makemandb/apropos.1
--- a/usr.sbin/makemandb/apropos.1      Sun May 22 14:26:09 2016 +0000
+++ b/usr.sbin/makemandb/apropos.1      Sun May 22 19:26:04 2016 +0000
@@ -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.upadhyay%gmail.com@localhost>
 .\" 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 @@
 .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 @@
 .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.
diff -r bc88e798d81d -r 6dafae49140c usr.sbin/makemandb/apropos.c
--- a/usr.sbin/makemandb/apropos.c      Sun May 22 14:26:09 2016 +0000
+++ b/usr.sbin/makemandb/apropos.c      Sun May 22 19:26:04 2016 +0000
@@ -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.upadhyay%gmail.com@localhost>
  * 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 @@
        query_format format;
        int legacy;
        const char *machine;
+       const char *manconf;
 } apropos_flags;
 
 typedef struct callback_data {
@@ -72,8 +73,9 @@
 {
        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 @@
                                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 @@
                        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 @@
        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 @@
 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);
diff -r bc88e798d81d -r 6dafae49140c usr.sbin/makemandb/whatis.1
--- a/usr.sbin/makemandb/whatis.1       Sun May 22 14:26:09 2016 +0000
+++ b/usr.sbin/makemandb/whatis.1       Sun May 22 19:26:04 2016 +0000
@@ -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 <joerg%NetBSD.org@localhost>
 .\" 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 @@
 .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
diff -r bc88e798d81d -r 6dafae49140c usr.sbin/makemandb/whatis.c
--- a/usr.sbin/makemandb/whatis.c       Sun May 22 14:26:09 2016 +0000
+++ b/usr.sbin/makemandb/whatis.c       Sun May 22 19:26:04 2016 +0000
@@ -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 <joerg%NetBSD.org@localhost>
  * 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 @@
 __dead static void
 usage(void)
 {
-       fprintf(stderr, "%s ...\n", "whatis");
+       fprintf(stderr, "%s [-C path] ...\n", "whatis");
        exit(EXIT_FAILURE);
 }
 
@@ -78,9 +78,13 @@
 {
        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 @@
        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;



Home | Main Index | Thread Index | Old Index