Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/man Allow "-s" to specify a section name, ala the Sy...
details: https://anonhg.NetBSD.org/src/rev/dd46c307b6e6
branches: trunk
changeset: 487755:dd46c307b6e6
user: simonb <simonb%NetBSD.org@localhost>
date: Mon Jun 12 14:53:48 2000 +0000
description:
Allow "-s" to specify a section name, ala the SysV man command.
Unlike the SysV man command, this doesn't allow for the -s argument
to be a list.
diffstat:
usr.bin/man/man.1 | 44 ++++++++++++++++++++++++--------------------
usr.bin/man/man.c | 32 +++++++++++++++++++-------------
2 files changed, 43 insertions(+), 33 deletions(-)
diffs (154 lines):
diff -r 62a5012000c1 -r dd46c307b6e6 usr.bin/man/man.1
--- a/usr.bin/man/man.1 Mon Jun 12 14:42:02 2000 +0000
+++ b/usr.bin/man/man.1 Mon Jun 12 14:53:48 2000 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: man.1,v 1.10 2000/05/27 21:33:26 jdolecek Exp $
+.\" $NetBSD: man.1,v 1.11 2000/06/12 14:53:48 simonb Exp $
.\"
.\" Copyright (c) 1989, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -47,7 +47,10 @@
.Op Fl M Ar path
.Op Fl m Ar path
.Op Fl S Ar srch
-.Op Ar section
+.Oo
+.Op Fl s
+.Ar section
+.Oc
.Ar name Ar ...
.Nm ""
.Op Fl k
@@ -127,6 +130,16 @@
is specified by the ``_subdir'' line in the
.Nm
configuration file.
+.It Fl s
+Restrict the directories that
+.Nm
+will search. The
+.Nm
+configuration file (see
+.Xr man.conf 5 )
+specifies the possible
+.Ar section
+values that are currently available.
.It Fl S
Display only man pages that have the specified string in their
filenames. This allows the man page search process criteria to be
@@ -142,25 +155,16 @@
combination.
.El
.Pp
-The optional
-.Ar section
-argument restricts the directories that
-.Nm
-will search.
-The
-.Nm
-configuration file (see
-.Xr man.conf 5 )
-specifies the possible
-.Ar section
-values that are currently available.
-Except when used with the
+If the
+.Ql Fl s
+option is not specified,
+there is more than one argument,
+the
.Ql Fl k
-option,
-if only a single argument is specified or if the first argument is
-not a valid section,
-.Nm
-assumes that the argument is the name of a man page to be displayed.
+option is not used and the first argument is a valid section, that
+argument will be used as if specified by the
+.Ql Fl s
+option.
.Sh ENVIRONMENT
.Bl -tag -width MANPATHX
.It Ev MACHINE
diff -r 62a5012000c1 -r dd46c307b6e6 usr.bin/man/man.c
--- a/usr.bin/man/man.c Mon Jun 12 14:42:02 2000 +0000
+++ b/usr.bin/man/man.c Mon Jun 12 14:53:48 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: man.c,v 1.24 2000/06/07 18:52:31 thorpej Exp $ */
+/* $NetBSD: man.c,v 1.25 2000/06/12 14:53:48 simonb Exp $ */
/*
* Copyright (c) 1987, 1993, 1994, 1995
@@ -44,7 +44,7 @@
#if 0
static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95";
#else
-__RCSID("$NetBSD: man.c,v 1.24 2000/06/07 18:52:31 thorpej Exp $");
+__RCSID("$NetBSD: man.c,v 1.25 2000/06/12 14:53:48 simonb Exp $");
#endif
#endif /* not lint */
@@ -91,7 +91,7 @@
size_t len;
int ch, f_cat, f_how, found, abs_section;
char **ap, *cmd, *p, *p_add, *p_path;
- const char *machine, *pager, *conffile, *pathsearch;
+ const char *machine, *pager, *conffile, *pathsearch, *sectionname;
char buf[MAXPATHLEN * 2];
#ifdef __GNUC__
@@ -99,9 +99,8 @@
#endif
f_cat = f_how = 0;
- conffile = p_add = p_path = NULL;
- pathsearch = NULL;
- while ((ch = getopt(argc, argv, "-aC:cfhkM:m:P:S:w")) != -1)
+ sectionname = pathsearch = conffile = p_add = p_path = NULL;
+ while ((ch = getopt(argc, argv, "-aC:cfhkM:m:P:s:S:w")) != -1)
switch (ch) {
case 'a':
f_all = 1;
@@ -133,6 +132,11 @@
case 'k':
jump(argv, "-k", "apropos");
/* NOTREACHED */
+ case 's':
+ if (sectionname != NULL)
+ usage();
+ sectionname = optarg;
+ break;
case 'S':
pathsearch = optarg;
break;
@@ -188,11 +192,14 @@
* specified a section and it had absolute (rather than
* relative) paths in the man.conf file.
*/
- if (argc > 1 && (section = getlist(*argv)) != NULL) {
- argv++;
- argc--;
+ if ((argc > 1 || sectionname != NULL) &&
+ (section = getlist(sectionname ? sectionname : *argv)) != NULL) {
+ if (sectionname == NULL) {
+ argv++;
+ argc--;
+ }
abs_section = (TAILQ_FIRST(§ion->list) != NULL &&
- *(TAILQ_FIRST(§ion->list)->s) == '/');
+ *(TAILQ_FIRST(§ion->list)->s) == '/');
} else {
section = NULL;
abs_section = 0;
@@ -780,8 +787,7 @@
usage()
{
extern char *__progname;
- (void)fprintf(stderr,
- "Usage: %s [-achw] [-C file] [-M path] [-m path] [-S srch] [section] title ...\n",
- __progname);
+ (void)fprintf(stderr, "Usage: %s [-achw] [-C file] [-M path] [-m path]"
+ "[-S srch] [[-s] section] title ...\n", __progname);
exit(1);
}
Home |
Main Index |
Thread Index |
Old Index