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 support for apropos -s like in the ol...



details:   https://anonhg.NetBSD.org/src/rev/79d9a78ba7d3
branches:  trunk
changeset: 777346:79d9a78ba7d3
user:      joerg <joerg%NetBSD.org@localhost>
date:      Wed Feb 15 23:53:13 2012 +0000

description:
Add support for apropos -s like in the old apropos. Fix capitalisation.
Add note about optional quotation. From Abhinav Upadhyay.

diffstat:

 usr.sbin/makemandb/apropos.1 |  16 +++++++++++++---
 usr.sbin/makemandb/apropos.c |  17 ++++++++++++-----
 2 files changed, 25 insertions(+), 8 deletions(-)

diffs (112 lines):

diff -r 30983b757e7e -r 79d9a78ba7d3 usr.sbin/makemandb/apropos.1
--- a/usr.sbin/makemandb/apropos.1      Wed Feb 15 23:36:10 2012 +0000
+++ b/usr.sbin/makemandb/apropos.1      Wed Feb 15 23:53:13 2012 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: apropos.1,v 1.2 2012/02/10 16:57:44 njoly Exp $
+.\" $NetBSD: apropos.1,v 1.3 2012/02/15 23:53:13 joerg 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 February 6, 2012
+.Dd February 15, 2012
 .Dt APROPOS 1
 .Os
 .Sh NAME
@@ -40,6 +40,7 @@
 .Op Fl 123456789Ccp
 .Op Fl n Ar Number of results
 .Op Fl S Ar machine
+.Op Fl s Ar section
 .Ar query
 .Sh DESCRIPTION
 The
@@ -61,6 +62,8 @@
 .Nm
 will only display the top 10 matches in the output.
 .Pp
+Quotes are optional for specifying multiword queries.
+.Pp
 It supports the following options:
 .Bl -tag -width indent
 .It Fl 1
@@ -91,9 +94,16 @@
 .It Fl p
 Display all matching results and pipe them through a pager (defaulting to
 .Xr more 1 ) .
-.It Fl S
+.It Fl S Ar machine
 Limit the search to the pages for the specified machine architecture.
 By default pages for all architectures are shown in the search results.
+.It Fl s Ar section
+Restrict the search to the specified section of the manual.
+By default, pages from all section are shown.
+This option is for backwards compatibility with the classic version of apropos,
+using it is equivalent to using the
+.Op 123456789
+options directly.
 .El
 .Sh FILES
 .Bl -hang -width -compact
diff -r 30983b757e7e -r 79d9a78ba7d3 usr.sbin/makemandb/apropos.c
--- a/usr.sbin/makemandb/apropos.c      Wed Feb 15 23:36:10 2012 +0000
+++ b/usr.sbin/makemandb/apropos.c      Wed Feb 15 23:53:13 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: apropos.c,v 1.4 2012/02/07 23:03:34 joerg Exp $        */
+/*     $NetBSD: apropos.c,v 1.5 2012/02/15 23:53:13 joerg 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.4 2012/02/07 23:03:34 joerg Exp $");
+__RCSID("$NetBSD: apropos.c,v 1.5 2012/02/15 23:53:13 joerg Exp $");
 
 #include <err.h>
 #include <search.h>
@@ -76,6 +76,7 @@
        char *errmsg = NULL;
        char *str;
        int ch, rc = 0;
+       int s;
        callback_data cbdata;
        cbdata.out = stdout;            // the default output stream
        cbdata.count = 0;
@@ -92,7 +93,7 @@
         * index element in sec_nums is set to the string representing that 
         * section number.
         */
-       while ((ch = getopt(argc, argv, "123456789Ccn:pS:")) != -1) {
+       while ((ch = getopt(argc, argv, "123456789Ccn:pS:s:")) != -1) {
                switch (ch) {
                case '1':
                case '2':
@@ -121,6 +122,12 @@
                case 'S':
                        aflags.machine = optarg;
                        break;
+               case 's':
+                       s = atoi(optarg);
+                       if (s < 1 || s > 9)
+                               errx(EXIT_FAILURE, "Invalid section");
+                       aflags.sec_nums[s - 1] = 1;
+                       break;
                case '?':
                default:
                        usage();
@@ -189,8 +196,8 @@
        
        if (cbdata.count == 0) {
                warnx("No relevant results obtained.\n"
-                         "Please make sure that you spelled all the terms correctly\n"
-                         "Or try using better keywords.");
+                         "Please make sure that you spelled all the terms correctly "
+                         "or try using better keywords.");
        }
        return 0;
 }



Home | Main Index | Thread Index | Old Index