diff options
author | 1998-03-09 23:20:12 +0000 | |
---|---|---|
committer | 1998-03-09 23:20:12 +0000 | |
commit | e8e16d01a49e3f476272a8293d1cb75a6ffbdccd (patch) | |
tree | fb347d44b41dfb7d6126c3c70940b4d7cafc116b /usr.bin/man/man.c | |
parent | Move man4 towards the end in the man section search order. (diff) | |
download | wireguard-openbsd-e8e16d01a49e3f476272a8293d1cb75a6ffbdccd.tar.xz wireguard-openbsd-e8e16d01a49e3f476272a8293d1cb75a6ffbdccd.zip |
Add -s section for svr4 compat and -S subsection ala:
man -s 4 -S alpha scc
Diffstat (limited to 'usr.bin/man/man.c')
-rw-r--r-- | usr.bin/man/man.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/usr.bin/man/man.c b/usr.bin/man/man.c index 0a5f2152393..10d71092095 100644 --- a/usr.bin/man/man.c +++ b/usr.bin/man/man.c @@ -1,4 +1,4 @@ -/* $OpenBSD: man.c,v 1.6 1997/09/10 04:16:30 deraadt Exp $ */ +/* $OpenBSD: man.c,v 1.7 1998/03/09 23:20:13 millert Exp $ */ /* $NetBSD: man.c,v 1.7 1995/09/28 06:05:34 tls Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95"; #else -static char rcsid[] = "$OpenBSD: man.c,v 1.6 1997/09/10 04:16:30 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: man.c,v 1.7 1998/03/09 23:20:13 millert Exp $"; #endif #endif /* not lint */ @@ -90,12 +90,13 @@ main(argc, argv) glob_t pg; size_t len; int ch, f_cat, f_how, found; - char **ap, *cmd, *machine, *p, *p_add, *p_path, *pager, *slashp; + char **ap, *cmd, *machine, *p, *p_add, *p_path, *pager, *sflag, *slashp; char *conffile, buf[MAXPATHLEN * 2]; + machine = sflag = NULL; f_cat = f_how = 0; conffile = p_add = p_path = NULL; - while ((ch = getopt(argc, argv, "-aC:cfhkM:m:P:w")) != -1) + while ((ch = getopt(argc, argv, "-aC:cfhkM:m:P:s:S:w")) != -1) switch (ch) { case 'a': f_all = 1; @@ -117,6 +118,12 @@ main(argc, argv) case 'P': /* Backward compatibility. */ p_path = optarg; break; + case 's': /* SVR4 compatibility. */ + sflag = optarg; + break; + case 'S': + machine = optarg; + break; /* * The -f and -k options are backward compatible, * undocumented ways of calling whatis(1) and apropos(1). @@ -151,8 +158,8 @@ main(argc, argv) /* Read the configuration file. */ config(conffile); - /* Get the machine type. */ - if ((machine = getenv("MACHINE")) == NULL) + /* Get the machine type unless specified by -S. */ + if (machine == NULL && (machine = getenv("MACHINE")) == NULL) machine = MACHINE; /* If there's no _default list, create an empty one. */ @@ -191,10 +198,14 @@ main(argc, argv) * 2: If the user did not specify MANPATH, -M or a section, rewrite * the _default list to include the _subdir list and the machine. */ - if (argv[1] == NULL) + if (sflag == NULL && argv[1] == NULL) section = NULL; - else if ((section = getlist(*argv)) != NULL) - ++argv; + else { + if (sflag != NULL && (section = getlist(sflag)) == NULL) + errx(1, "unknown manual section `%s'", sflag); + else if (sflag == NULL && (section = getlist(*argv)) != NULL) + ++argv; + } if (p_path == NULL && section == NULL) { defnewp = addlist("_default_new"); e_defp = |