Module Name:    src
Committed By:   joerg
Date:           Wed Feb 15 23:53:13 UTC 2012

Modified Files:
        src/usr.sbin/makemandb: apropos.1 apropos.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/makemandb/apropos.1
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/makemandb/apropos.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.2 src/usr.sbin/makemandb/apropos.1:1.3
--- src/usr.sbin/makemandb/apropos.1:1.2	Fri Feb 10 16:57:44 2012
+++ src/usr.sbin/makemandb/apropos.1	Wed Feb 15 23:53:13 2012
@@ -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.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 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 @@ By default
 .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 @@ The default limit is 10.
 .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

Index: src/usr.sbin/makemandb/apropos.c
diff -u src/usr.sbin/makemandb/apropos.c:1.4 src/usr.sbin/makemandb/apropos.c:1.5
--- src/usr.sbin/makemandb/apropos.c:1.4	Tue Feb  7 23:03:34 2012
+++ src/usr.sbin/makemandb/apropos.c	Wed Feb 15 23:53:13 2012
@@ -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.upadh...@gmail.com>
  * 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 @@ main(int argc, char *argv[])
 	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 @@ main(int argc, char *argv[])
 	 * 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 @@ main(int argc, char *argv[])
 		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 @@ main(int argc, char *argv[])
 	
 	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;
 }

Reply via email to