new man version, with much more complicated configuration file
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 28 May 1990 06:24:08 +0000 (22:24 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 28 May 1990 06:24:08 +0000 (22:24 -0800)
SCCS-vsn: usr.bin/man/man.c 5.20
SCCS-vsn: usr.bin/man/man.1 6.9
SCCS-vsn: usr.bin/man/config.c 5.2
SCCS-vsn: usr.bin/man/pathnames.h 5.3
SCCS-vsn: usr.bin/man/man.conf.5 5.2

usr/src/usr.bin/man/config.c
usr/src/usr.bin/man/man.1
usr/src/usr.bin/man/man.c
usr/src/usr.bin/man/man.conf.5
usr/src/usr.bin/man/pathnames.h

index 699f78d..69b527e 100644 (file)
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)config.c   5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)config.c   5.2 (Berkeley) %G%";
 #endif /* not lint */
 
 #endif /* not lint */
 
-#include <sys/types.h>
+#include <sys/param.h>
 #include <stdio.h>
 #include <errno.h>
 #include <string.h>
 #include <stdio.h>
 #include <errno.h>
 #include <string.h>
+#include <stdlib.h>
+#include <pwd.h>
 #include "pathnames.h"
 
 #include "pathnames.h"
 
+#define        MAXLINE         1024
+
 extern char *progname;
 
 extern char *progname;
 
+static FILE *cfp;
+static char *buf;
+
 /*
 /*
- * config --
- *     read in the configuration file, convert it to a colon separated
- *     path.
+ * getpath --
+ *     read in the configuration file, calling a function with the line
+ *     from each matching section.
  */
 char *
  */
 char *
-config()
+getpath(sects)
+       char **sects;
 {
 {
-       register char *p;
-       u_int buflen;
-       int len;
-       char *buf, *endp, line[256], *realloc();
+       register char **av, *p;
+       size_t len;
+       char **ar, line[MAXLINE], **getorder();
+
+       ar = getorder();
+       openconfig();
+       while (fgets(line, sizeof(line), cfp)) {
+               if (!index(line, '\n')) {
+                       (void)fprintf(stderr, "%s: config line too long.\n",
+                           progname);
+                       exit(1);
+               }
+               p = strtok(line, " \t\n");
+               if (!p || *p == '#')
+                       continue;
+               for (av = sects; *av; ++av)
+                       if (!strcmp(p, *av))
+                               break;
+               if (!*av)
+                       continue;
+               while (p = strtok((char *)NULL, " \t\n")) {
+                       len = strlen(p);
+                       if (p[len - 1] == '/')
+                               for (av = ar; *av; ++av)
+                                       cadd(p, len, *av);
+                       else
+                               cadd(p, len, (char *)NULL);
+               }
+       }
+       return(buf);
+}
 
 
-       if (!freopen(_PATH_MANCONF, "r", stdin)) {
+static
+cadd(add1, len1, add2)
+char *add1, *add2;
+register size_t len1;
+{
+       static size_t buflen;
+       static char *bp, *endp;
+       register size_t len2;
+
+       len2 = add2 ? strlen(add2) : 0;
+       if (!bp || bp + len1 + len2 + 2 >= endp) {
+               if (!(buf = realloc(buf, buflen += 1024)))
+                       enomem();
+               if (!bp)
+                       bp = buf;
+               endp = buf + buflen;
+       }
+       bcopy(add1, bp, len1);
+       bp += len1;
+       if (len2) {
+               bcopy(add2, bp, len2);
+               bp += len2;
+       }
+       *bp++ = ':';
+       *bp = '\0';
+}
+
+static
+openconfig()
+{
+       if (cfp) {
+               rewind(cfp);
+               return;
+       }
+       if (!(cfp = fopen(_PATH_MANCONF, "r"))) {
                (void)fprintf(stderr, "%s: no configuration file %s.\n",
                    progname, _PATH_MANCONF);
                exit(1);
        }
                (void)fprintf(stderr, "%s: no configuration file %s.\n",
                    progname, _PATH_MANCONF);
                exit(1);
        }
-       buflen = 0;
-       buf = endp = p = NULL;
-       while (fgets(line, sizeof(line), stdin)) {
+}
+
+char **
+getdb()
+{
+       register char *p;
+       int cnt, num;
+       char **ar, line[MAXLINE];
+
+       ar = NULL;
+       num = 0;
+       cnt = -1;
+       openconfig();
+       while (fgets(line, sizeof(line), cfp)) {
                if (!index(line, '\n')) {
                        (void)fprintf(stderr, "%s: config line too long.\n",
                            progname);
                        exit(1);
                }
                if (!index(line, '\n')) {
                        (void)fprintf(stderr, "%s: config line too long.\n",
                            progname);
                        exit(1);
                }
-               len = strcspn(line, " \t\n");
-               if (!len || *line == '#')
+               p = strtok(line, " \t\n");
+#define        WHATDB  "_whatdb"
+               if (!p || *p == '#' || strcmp(p, WHATDB))
                        continue;
                        continue;
-               if (!p || p + len + 2 >= endp) {
-                       if (!(buf = realloc(buf, buflen += 1024)))
+               while (p = strtok((char *)NULL, " \t\n")) {
+                       if (cnt == num - 1 &&
+                           !(ar = realloc(ar, (num += 30) * sizeof(char **))))
+                               enomem();
+                       if (!(ar[++cnt] = strdup(p)))
                                enomem();
                                enomem();
-                       if (!p)
-                               p = buf;
-                       endp = buf + buflen;
                }
                }
-               bcopy(line, p, len);
-               p += len;
-               *p++ = ':';
        }
        }
-       if (!buf)
-               return((char *)NULL);
-       *--p = '\0';
-       return(buf);
+       if (ar) {
+               if (cnt == num - 1 &&
+                   !(ar = realloc(ar, ++num * sizeof(char **))))
+                       enomem();
+               ar[++cnt] = NULL;
+       }
+       return(ar);
 }
 
 }
 
-enomem()
+static char **
+getorder()
+{
+       register char *p;
+       int cnt, num;
+       char **ar, line[MAXLINE];
+
+       ar = NULL;
+       num = 0;
+       cnt = -1;
+       openconfig();
+       while (fgets(line, sizeof(line), cfp)) {
+               if (!index(line, '\n')) {
+                       (void)fprintf(stderr, "%s: config line too long.\n",
+                           progname);
+                       exit(1);
+               }
+               p = strtok(line, " \t\n");
+#define        SUBDIR  "_subdir"
+               if (!p || *p == '#' || strcmp(p, SUBDIR))
+                       continue;
+               while (p = strtok((char *)NULL, " \t\n")) {
+                       if (cnt == num - 1 &&
+                           !(ar = realloc(ar, (num += 30) * sizeof(char **))))
+                               enomem();
+                       if (!(ar[++cnt] = strdup(p)))
+                               enomem();
+               }
+       }
+       if (ar) {
+               if (cnt == num - 1 &&
+                   !(ar = realloc(ar, ++num * sizeof(char **))))
+                       enomem();
+               ar[++cnt] = NULL;
+       }
+       return(ar);
+}
+
+getsection(sect)
+       char *sect;
 {
 {
-       extern int errno;
-       char *strerror();
+       register char *p;
+       char line[MAXLINE];
 
 
-       (void)fprintf(stderr, "%s: %s\n", strerror(ENOMEM), progname);
+       openconfig();
+       while (fgets(line, sizeof(line), cfp)) {
+               if (!index(line, '\n')) {
+                       (void)fprintf(stderr, "%s: config line too long.\n",
+                           progname);
+                       exit(1);
+               }
+               p = strtok(line, " \t\n");
+               if (!p || *p == '#')
+                       continue;
+               if (!strcmp(p, sect))
+                       return(1);
+       }
+       return(0);
+}
+
+enomem()
+{
+       (void)fprintf(stderr, "%s: %s\n", progname, strerror(ENOMEM));
        exit(1);
 }
        exit(1);
 }
index 19a9f7b..fc23cc3 100644 (file)
@@ -13,7 +13,7 @@
 .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
 .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.\"    @(#)man.1       6.8 (Berkeley) %G%
+.\"    @(#)man.1       6.9 (Berkeley) %G%
 .\"
 .TH MAN 1 ""
 .UC 4
 .\"
 .TH MAN 1 ""
 .UC 4
@@ -22,28 +22,32 @@ man \- display the on-line manual pages
 .SH SYNOPSIS
 .nf
 .ft B
 .SH SYNOPSIS
 .nf
 .ft B
-man [-acw] [-M path] [-m path] [section] title ...
+man [ -acw ] [ -M path ] [ -m path ] [ section ] name ...
 .ft R
 .fi
 .SH DESCRIPTION
 .I Man
 .ft R
 .fi
 .SH DESCRIPTION
 .I Man
-displays the UNIX manual pages.
+displays the UNIX manual pages entitled
+.IR name .
 .PP
 The options are as follows:
 .TP
 .PP
 The options are as follows:
 .TP
-.I a
+a
 Display all of the manual pages for a specified
 Display all of the manual pages for a specified
-.IR title .
+.I section
+and
+.I name
+combination.
 (Normally, only the first manual page found is displayed.)
 .TP
 (Normally, only the first manual page found is displayed.)
 .TP
-.I c
+c
 Copy the manual page to the standard output instead of using
 Copy the manual page to the standard output instead of using
-.I more (1)
+.IR more (1)
 to paginate it.
 This is done by default if the standard output is not a terminal device.
 .TP
 to paginate it.
 This is done by default if the standard output is not a terminal device.
 .TP
-.I M
-Override the list of standard directories where
+M
+Override the list of standard directories which
 .I man
 searches for manual pages.
 The supplied
 .I man
 searches for manual pages.
 The supplied
@@ -52,69 +56,73 @@ must be a colon (``:'') separated list of directories.
 This search path may also be set using the environmental variable
 .IR MANPATH .
 .TP
 This search path may also be set using the environmental variable
 .IR MANPATH .
 .TP
-.I m
-Augment the list of standard directories where
+m
+Augment the list of standard directories which
 .I man
 searches for manual pages.
 The supplied
 .I path
 must be a colon (``:'') separated list of directories.
 These directories will be searched before the standard directories or
 .I man
 searches for manual pages.
 The supplied
 .I path
 must be a colon (``:'') separated list of directories.
 These directories will be searched before the standard directories or
-the directories supplied with the
+the directories specified using the
 .I M
 option or the
 .I MANPATH
 .I M
 option or the
 .I MANPATH
-environmental variable are searched.
+environmental variable.
 .TP
 .I w
 .TP
 .I w
-List the locations of the manual pages that
+List the pathnames of the manual pages which
 .I man
 would display for the specified
 .I man
 would display for the specified
-.IR title .
+.I section
+and
+.I name
+combination.
 .PP
 .PP
-Section numbers restrict the portions of the manual that
+The optional
+.I section
+restricts the directories that
+.I man
+will search.
+The
 .I man
 .I man
-will search to a single section.
-The section number should be a number, ``1'' through ``8'', or ``3f''
-to specify the FORTRAN versions of section 3 of the manual.
-If no section number is given,
+configuration file (see
+.IR man.conf (5))
+specifies the possible
+.I section
+values that are currently available.
+If only a single argument is specified or if the first argument is
+not a valid section,
 .I man
 .I man
-will search the sections in the following order:
-``1'', ``8'', ``6'', ``2'', ``3'', ``4'', ``5'', ``7'' and ``3f''.
-This is to give precedence to commands over library subroutines.
+assumes that the argument is the name of a manual page to be displayed.
 .SH "ENVIRONMENTAL VARIABLES"
 .TP
 .SH "ENVIRONMENTAL VARIABLES"
 .TP
-.I
 MACHINE
 As some manual pages are intended only for use on certain architectures,
 .I man
 MACHINE
 As some manual pages are intended only for use on certain architectures,
 .I man
-only searches the directories applicable to the current machine.
+searches certain directories applicable to the current machine.
 .I Man's
 determination of the current machine type may be overridden by setting
 .I Man's
 determination of the current machine type may be overridden by setting
-the environmental variable
-.I MACHINE
-to the name of an architecture.
-Currently supported architectures are ``tahoe'' and ``vax''.
+the environmental variable MACHINE to the name of an architecture (see
+.IR machine (1)).
 Machine specific areas are checked before general areas.
 .TP
 Machine specific areas are checked before general areas.
 .TP
-.I MANPATH
+MANPATH
 The standard search path used by
 .I man
 The standard search path used by
 .I man
-may be overridden by specifying a path in the
-.I MANPATH
-environmental variable.
+may be overridden by specifying a path in the MANPATH environmental
+variable.
 The format of the path is a colon (``:'') separated list of directories.
 .TP
 The format of the path is a colon (``:'') separated list of directories.
 .TP
-.I
 PAGER
 Any value of the environmental variable
 .I PAGER
 will be used instead of the standard pagination program
 .IR more (1).
 .SH FILES
 PAGER
 Any value of the environmental variable
 .I PAGER
 will be used instead of the standard pagination program
 .IR more (1).
 .SH FILES
-/etc/man.config        standard directory search path
+/etc/man.config        man configuration file
 .SH "SEE ALSO"
 .SH "SEE ALSO"
-apropos(1), whatis(1), whereis(1), man.config(5)
+apropos(1), machine(1), whatis(1), whereis(1), man.conf(5)
 .SH BUGS
 The on-line manual pages are, by necessity, forgiving toward stupid
 display devices, causing some manual pages to not be as good as their
 .SH BUGS
 The on-line manual pages are, by necessity, forgiving toward stupid
 display devices, causing some manual pages to not be as good as their
index 97ddf9c..d292dbd 100644 (file)
@@ -22,7 +22,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)man.c      5.19 (Berkeley) %G%";
+static char sccsid[] = "@(#)man.c      5.20 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -30,12 +30,13 @@ static char sccsid[] = "@(#)man.c   5.19 (Berkeley) %G%";
 #include <errno.h>
 #include <ctype.h>
 #include <string.h>
 #include <errno.h>
 #include <ctype.h>
 #include <string.h>
+#include <stdlib.h>
 #include "pathnames.h"
 
 extern int errno;
 
 #include "pathnames.h"
 
 extern int errno;
 
-char *command, *machine, *p_augment, *p_path, *pager, *progname;
 int f_all, f_cat, f_where;
 int f_all, f_cat, f_where;
+char *command, *machine, *p_augment, *p_path, *pager, *progname;
 
 main(argc, argv)
        int argc;
 
 main(argc, argv)
        int argc;
@@ -43,8 +44,8 @@ main(argc, argv)
 {
        extern char *optarg;
        extern int optind;
 {
        extern char *optarg;
        extern int optind;
-       int ch;
-       char *check_pager(), *config(), *getenv();
+       int ch, res;
+       char *section[2], *check_pager(), *getpath();
 
        progname = "man";
        while ((ch = getopt(argc, argv, "-acfkM:m:P:w")) != EOF)
 
        progname = "man";
        while ((ch = getopt(argc, argv, "-acfkM:m:P:w")) != EOF)
@@ -63,11 +64,10 @@ main(argc, argv)
                case 'P':               /* backward compatibility */
                        p_path = optarg;
                        break;
                case 'P':               /* backward compatibility */
                        p_path = optarg;
                        break;
-                       /*
-                        * "man -f" and "man -k" are backward compatible,
-                        * undocumented ways of calling whatis(1) and
-                        * apropos(1).
-                        */
+               /*
+                * "man -f" and "man -k" are backward compatible, undocumented
+                * ways of calling whatis(1) and apropos(1).
+                */
                case 'f':
                        jump(argv, "-f", "whatis");
                        /* NOTREACHED */
                case 'f':
                        jump(argv, "-f", "whatis");
                        /* NOTREACHED */
@@ -97,10 +97,32 @@ main(argc, argv)
        if (!(machine = getenv("MACHINE")))
                machine = MACHINE;
 
        if (!(machine = getenv("MACHINE")))
                machine = MACHINE;
 
-       if (!p_path && !(p_path = getenv("MANPATH")))
-               p_path = config();
+       /* see if checking in a specific section */
+       if (argc > 1 && getsection(*argv)) {
+               section[0] = *argv++;
+               section[1] = (char *)NULL;
+       } else {
+               section[0] = "_default";
+               section[1] = (char *)NULL;
+       }
+
+       if (!p_path && !(p_path = getenv("MANPATH")) &&
+           !(p_path = getpath(section)) && !p_augment) {
+               (void)fprintf(stderr,
+                   "man: no place to search for those manual pages.\n");
+               exit(1);
+       }
 
 
-       man(argv);
+       for (; *argv; ++argv) {
+               if (p_augment)
+                       res = manual(p_augment, *argv);
+               res = manual(p_path, *argv);
+               if (res || f_where)
+                       continue;
+               (void)fprintf(stderr,
+                   "man: no entry for %s in the manual.\n", *argv);
+               exit(1);
+       }
 
        /* use system(3) in case someone's pager is "pager arg1 arg2" */
        if (command)
 
        /* use system(3) in case someone's pager is "pager arg1 arg2" */
        if (command)
@@ -108,109 +130,48 @@ main(argc, argv)
        exit(0);
 }
 
        exit(0);
 }
 
-typedef struct {
-       char    *name, *msg;
-} DIR;
-static DIR     list1[] = {             /* section one list */
-       "cat1", "1st",          "cat8", "8th",          "cat6", "6th",
-       "cat.old", "old",       NULL, NULL,
-},             list2[] = {             /* rest of the list */
-       "cat2", "2nd",          "cat3", "3rd",          "cat4", "4th",
-       "cat5", "5th",          "cat7", "7th",          "cat3f", "3rd (F)",
-       NULL, NULL,
-},             list3[2];               /* single section */
-
-/*
- * man --
- *     main loop to find the manual page and print it out.
- */
-man(argv)
-       char **argv;
-{
-       DIR *section, *getsect();
-       int res;
-
-       for (; *argv; ++argv) {
-               section = isdigit(**argv) ? getsect(*argv++) : NULL;
-               if (*argv) {
-                       if (p_augment)
-                               if (section)
-                                       res = manual(p_augment, section, *argv);
-                               else {
-                                       res = manual(p_augment, list1, *argv);
-                                       if (!res || f_all)
-                                               res += manual(p_augment, list2,
-                                                   *argv);
-                               }
-                       if (p_path)
-                               if (section)
-                                       res = manual(p_path, section, *argv);
-                               else {
-                                       res = manual(p_path, list1, *argv);
-                                       if (!res || f_all)
-                                               res += manual(p_path, list2,
-                                                   *argv);
-                               }
-                       if (res || f_where)
-                               continue;
-                       (void)fprintf(stderr,
-                           "man: no entry for %s in the ", *argv);
-               } else
-                       (void)fprintf(stderr,
-                           "man: what do you want from the ");
-               if (section)
-                       (void)fprintf(stderr,
-                           "%s section of the ", section->msg);
-               if (*argv)
-                       (void)fprintf(stderr, "manual.\n");
-               else
-                       (void)fprintf(stderr, "manual?\n");
-               exit(1);
-       }
-}
-
 /*
  * manual --
  *     given a path, a directory list and a file name, find a file
  *     that matches; check ${directory}/${dir}/{file name} and
  *     ${directory}/${dir}/${machine}/${file name}.
  */
 /*
  * manual --
  *     given a path, a directory list and a file name, find a file
  *     that matches; check ${directory}/${dir}/{file name} and
  *     ${directory}/${dir}/${machine}/${file name}.
  */
-manual(path, section, name)
+manual(path, name)
        char *path, *name;
        char *path, *name;
-       DIR *section;
 {
 {
-       register char *end;
-       register DIR *dp;
        register int res;
        register int res;
+       register char *end;
        char fname[MAXPATHLEN + 1];
 
        for (res = 0;; path = end + 1) {
        char fname[MAXPATHLEN + 1];
 
        for (res = 0;; path = end + 1) {
-               if (end = index(path, ':'))
+               if (!*path)                             /* foo: */
+                       break;
+               if (end = index(path, ':')) {
+                       if (end == path + 1)            /* foo::bar */
+                               continue;
                        *end = '\0';
                        *end = '\0';
-               for (dp = section; dp->name; ++dp) {
-                       (void)sprintf(fname, "%s/%s/%s.0",
-                           path, dp->name, name);
-                       if (access(fname, R_OK)) {
-                               (void)sprintf(fname, "%s/%s/%s/%s.0", path,
-                                   dp->name, machine, name);
-                               if (access(fname, R_OK))
-                                       continue;
-                       }
-                       if (f_where)
-                               (void)printf("man: found in %s.\n", fname);
-                       else if (f_cat)
-                               cat(fname);
-                       else
-                               add(fname);
-                       if (!f_all)
-                               return(1);
-                       res = 1;
                }
                }
+               (void)sprintf(fname, "%s/%s.0", path, name);
+               if (access(fname, R_OK)) {
+                       (void)sprintf(fname, "%s/%s/%s.0", path, machine, name);
+                       if (access(fname, R_OK))
+                               continue;
+               }
+
+               if (f_where)
+                       (void)printf("man: found in %s.\n", fname);
+               else if (f_cat)
+                       cat(fname);
+               else
+                       add(fname);
+               if (!f_all)
+                       return(1);
+               res = 1;
                if (!end)
                if (!end)
-                       return(res);
+                       break;
                *end = ':';
        }
                *end = ':';
        }
-       /* NOTREACHED */
+       return(res);
 }
 
 /*
 }
 
 /*
@@ -251,7 +212,6 @@ add(fname)
        static int len;
        static char *cp;
        int flen;
        static int len;
        static char *cp;
        int flen;
-       char *malloc(), *realloc(), *strcpy();
 
        if (!command) {
                if (!(command = malloc(buflen = 1024)))
 
        if (!command) {
                if (!(command = malloc(buflen = 1024)))
@@ -271,72 +231,6 @@ add(fname)
        cp += flen;
 }
 
        cp += flen;
 }
 
-/*
- * getsect --
- *     return a point to the section structure for a particular suffix
- */
-DIR *
-getsect(s)
-       char *s;
-{
-       switch(*s++) {
-       case '1':
-               if (!*s)
-                       return(list1);
-               break;
-       case '2':
-               if (!*s) {
-                       list3[0] = list2[0];
-                       return(list3);
-               }
-               break;
-       /* sect. 3 requests are for either section 3, or section 3[fF]. */
-       case '3':
-               if (!*s) {
-                       list3[0] = list2[1];
-                       return(list3);
-               }
-               else if ((*s == 'f'  || *s == 'F') && !*++s) {
-                       list3[0] = list2[5];
-                       return(list3);
-               }
-               break;
-       case '4':
-               if (!*s) {
-                       list3[0] = list2[2];
-                       return(list3);
-               }
-               break;
-       case '5':
-               if (!*s) {
-                       list3[0] = list2[3];
-                       return(list3);
-               }
-               break;
-       case '6':
-               if (!*s) {
-                       list3[0] = list1[2];
-                       return(list3);
-               }
-               break;
-       case '7':
-               if (!*s) {
-                       list3[0] = list2[4];
-                       return(list3);
-               }
-               break;
-       case '8':
-               if (!*s) {
-                       list3[0] = list1[1];
-                       return(list3);
-               }
-               break;
-       }
-       (void)fprintf(stderr, "man: unknown manual section.\n");
-       exit(1);
-       /* NOTREACHED */
-}
-
 /*
  * check_pager --
  *     check the user supplied page information
 /*
  * check_pager --
  *     check the user supplied page information
@@ -346,7 +240,7 @@ check_pager(name)
        char *name;
 {
        register char *p;
        char *name;
 {
        register char *p;
-       char *save, *malloc();
+       char *save;
 
        /*
         * if the user uses "more", we make it "more -s"; watch out for
 
        /*
         * if the user uses "more", we make it "more -s"; watch out for
@@ -386,7 +280,7 @@ jump(argv, flag, name)
        for (; *arg; ++arg)
                arg[0] = arg[1];
        execvp(name, argv);
        for (; *arg; ++arg)
                arg[0] = arg[1];
        execvp(name, argv);
-       fprintf(stderr, "%s: Command not found.\n", name);
+       (void)fprintf(stderr, "%s: Command not found.\n", name);
        exit(1);
 }
 
        exit(1);
 }
 
index 9051a72..78b697d 100644 (file)
 .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
 .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 .\"
-.\"    @(#)man.conf.5  5.1 (Berkeley) %G%
+.\"    @(#)man.conf.5  5.2 (Berkeley) %G%
 .\"
 .TH MAN.CONF 5 ""
 .SH NAME
 .\"
 .TH MAN.CONF 5 ""
 .SH NAME
-man.conf \- man command's directory list
+man.conf \- man command's configuration file
 .SH DESCRIPTION
 .SH DESCRIPTION
-.IR Man (1)
-searches the directories specified in the
+.IR Man (1),
+.IR apropos (1),
+and
+.IR whatis (1)
+search for manual pages or their database files as specified by the
 .I man.conf
 .I man.conf
-file for manual pages to display.
+file.
+Manual pages are expected to be preformatted (see
+.IR nroff (1))
+and named with a trailing ``.0''.
+.PP
 The
 .I man.conf
 The
 .I man.conf
-file should contain a list of pathnames, one per line.
-Lines starting with whitespace or a hash character (``#'') are ignored.
-.PP
-Each of these directories should contain sub-directories of the form
-``cat#'', where the ``#'' should be a manual section number, i.e. ``1''
-through ``8'' or ``3f''.
-Each of these sub-directories may in turn have sub-directories of their
-own, per machine type, for example ``tahoe''.
-Manual pages should be pre-formatted (see
-.IR nroff (1))
-and stored in a file named with a trailing ``.0''.
+file contains two types of lines.
+.PP
+The first type of line is a ``section'' line, which contains a
+section name followed by a directory path.
+Lines in this format specify that manual pages for the section
+may be found in the directory.
+Multiple specifications for a section are cumulative and the
+directories are searched in the order listed in the file.
+.PP
+Directories named with a trailing slash character (``/'') are expected
+to contain subdirectories (see the keyword ``_subdir'' below) instead
+of manual pages.
+These subdirectories are searched instead of the directory.
+.PP
+All directories (either explicitly specified or named with a trailing
+slash) may contain subdirectories.
+.IR Man (1)
+automatically searches any subdirectory with the same name as the
+current machine type before the directory is searched.
+No specification of these subdirectories is necessary in the
+.I man.conf
+file.
+.PP
+Section names are unrestricted except for the reserved words specified
+below; in general, however, it is best to avoid anything beginning with
+an underscore (``_'') in order to avoid future incompatibilities.
+.PP
+The section named ``_default'' is the list of directories to be
+searched if no section is specified.
 .PP
 .PP
-For example, the
+The second type of line is preceded with a ``keyword''.
+The possible keywords and their meanings are as follows:
+.sp
+.TP
+_subdir
+The list (in search order) of subdirectories which will be searched in
+any directory named with a trailing slash (``/'') character.
+.TP
+_version
+The version of the configuration file.
+.TP
+_whatdb
+The full pathname (not just a directory path) for a database to be used
+by the
+.IR apropos (1)
+and
+.IR whatis (1)
+commands.
+.PP
+Empty lines or lines whose first non-whitespace character is a hash
+mark (``#'') are ignored.
+.SH EXAMPLES
+Given the following
+.I man.conf file:
+.sp
+.nf
+.RS
+_version               BSD.1
+_subdir                cat1 cat2 cat3
+_default               /usr/share/man/
+sect3          /usr/share/man/cat3
+.fi
+.RE
+.sp
+The default
 .IR mktemp (3)
 .IR mktemp (3)
-manual page should be stored in ``cat3/mktemp.0''.
-A VAX specific version of it should be stored in ``cat3/vax/mktemp.0''.
-The FORTRAN version should be in ``cat3f/mktemp.0''.
-.FILE
+manual page should be stored in ``/usr/share/man/cat3/mktemp.0''.
+Any VAX architecture specific version of it should be stored in
+``cat3/vax/mktemp.0''.
+.PP
+The command ``man mktemp'' would search the subdirectories ``cat1''
+``cat2'', and ``cat3'', in ``/usr/share/man'', in that order, for
+``mktemp.0''.
+If a subdirectory with the same name as the current machine type
+existed in any of them, it would be searched as well.
+.PP
+The command ``man sect3 mktemp'' would only search ``/usr/share/man/cat3''
+and any possible per machine subdirectory.
 .SH FILES
 /etc/man.conf  standard manual directory search path
 .SH "SEE ALSO"
 .SH FILES
 /etc/man.conf  standard manual directory search path
 .SH "SEE ALSO"
-apropos(1), man(1), whatis(1), whereis(1)
+apropos(1), machine(1), man(1), whatis(1), whereis(1)
index b9076c6..3c28cc6 100644 (file)
@@ -14,7 +14,7 @@
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)pathnames.h 5.2 (Berkeley) %G%
+ *     @(#)pathnames.h 5.3 (Berkeley) %G%
  */
 
 #define        _PATH_MANCONF   "/etc/man.conf"
  */
 
 #define        _PATH_MANCONF   "/etc/man.conf"