diff options
Diffstat (limited to 'gnu/usr.bin/man/manpath')
-rw-r--r-- | gnu/usr.bin/man/manpath/manpath.c | 51 | ||||
-rw-r--r-- | gnu/usr.bin/man/manpath/manpath.config | 16 | ||||
-rw-r--r-- | gnu/usr.bin/man/manpath/manpath.h | 8 | ||||
-rw-r--r-- | gnu/usr.bin/man/manpath/manpath.man | 36 |
4 files changed, 65 insertions, 46 deletions
diff --git a/gnu/usr.bin/man/manpath/manpath.c b/gnu/usr.bin/man/manpath/manpath.c index a8c4cbc..c4ddcf1 100644 --- a/gnu/usr.bin/man/manpath/manpath.c +++ b/gnu/usr.bin/man/manpath/manpath.c @@ -203,7 +203,8 @@ get_dirlist () if (!strncmp ("MANBIN", bp, 6)) continue; - if (!strncmp ("MANDATORY_MANPATH", bp, 17)) + if (!strncmp ("MANDATORY_MANPATH", bp, 17) || + !strncmp ("OPTIONAL_MANPATH", bp, 16)) { if ((p = strchr (bp, ' ')) == NULL && (p = strchr (bp, '\t')) == NULL) { @@ -211,9 +212,9 @@ get_dirlist () return -1; } - bp = p; + dlp->type = *bp == 'M'? MANPATH_MANDATORY: MANPATH_OPTIONAL; - dlp->mandatory = 1; + bp = p; while (*bp && *bp != '\n' && (*bp == ' ' || *bp == '\t')) bp++; @@ -224,7 +225,8 @@ get_dirlist () dlp->mandir[i] = '\0'; if (debug) - fprintf (stderr, "found mandatory man directory %s\n", + fprintf (stderr, "found %s man directory %s\n", + dlp->type == MANPATH_MANDATORY? "mandatory": "optional", dlp->mandir); } else if (!strncmp ("MANPATH_MAP", bp, 11)) @@ -237,7 +239,7 @@ get_dirlist () bp = p; - dlp->mandatory = 0; + dlp->type = MANPATH_MAP; while (*bp && *bp != '\n' && (*bp == ' ' || *bp == '\t')) bp++; @@ -269,14 +271,14 @@ get_dirlist () fclose(config); dlp->bin[0] = '\0'; dlp->mandir[0] = '\0'; - dlp->mandatory = 0; + dlp->type = MANPATH_NONE; return 0; } /* - * Construct the default manpath. This picks up mandatory manpaths - * only. + * Construct the default manpath. This picks up mandatory + * and optional (if they exist) manpaths only. */ char * def_path (perrs) @@ -288,11 +290,11 @@ def_path (perrs) len = 0; dlp = list; - while (dlp->mandatory != 0) - { + while (dlp->type != MANPATH_NONE) { + if (dlp->type == MANPATH_MANDATORY || dlp->type == MANPATH_OPTIONAL) len += strlen (dlp->mandir) + 1; - dlp++; - } + dlp++; + } manpathlist = (char *) malloc (len); if (manpathlist == NULL) @@ -302,21 +304,20 @@ def_path (perrs) dlp = list; p = manpathlist; - while (dlp->mandatory != 0) - { + while (dlp->type != MANPATH_NONE) { + if (dlp->type == MANPATH_MANDATORY || dlp->type == MANPATH_OPTIONAL) { int status; char *path = dlp->mandir; status = is_directory(path); - if (status < 0 && perrs) + if (status < 0 && perrs && dlp->type == MANPATH_MANDATORY) { fprintf (stderr, "Warning: couldn't stat file %s!\n", path); } else if (status == 0 && perrs) { - fprintf (stderr, "Warning: standard directory %s doesn't exist!\n", - path); + fprintf (stderr, "Warning: %s isn't a directory!\n", path); } else if (status == 1) { @@ -324,9 +325,10 @@ def_path (perrs) memcpy (p, path, len); p += len; *p++ = ':'; - dlp++; } } + dlp++; + } p[-1] = '\0'; @@ -363,7 +365,7 @@ get_manpath (perrs, path) for (p = tmppath; ; p = end+1) { - if (end = strchr(p, ':')) + if ((end = strchr(p, ':')) != NULL) *end = '\0'; if (debug) @@ -416,11 +418,12 @@ get_manpath (perrs, path) fprintf (stderr, "\nadding mandatory man directories\n\n"); dlp = list; - while (dlp->mandatory != 0) - { - add_dir_to_list (tmplist, dlp->mandir, perrs); - dlp++; - } + while (dlp->type != MANPATH_NONE) { + if (dlp->type == MANPATH_MANDATORY || dlp->type == MANPATH_OPTIONAL) + add_dir_to_list (tmplist, dlp->mandir, + dlp->type == MANPATH_MANDATORY? perrs: 0); + dlp++; + } len = 0; lp = tmplist; diff --git a/gnu/usr.bin/man/manpath/manpath.config b/gnu/usr.bin/man/manpath/manpath.config index 2beb011..a1fcdd3 100644 --- a/gnu/usr.bin/man/manpath/manpath.config +++ b/gnu/usr.bin/man/manpath/manpath.config @@ -1,11 +1,12 @@ -# $Id: manpath.config,v 1.10 1999/05/13 15:47:04 ache Exp $ +# $Id: manpath.config,v 1.11 1999/07/25 19:33:06 markm Exp $ # -# This file is read by manpath to configure the mandatory manpath, to -# map each path element to a manpath element and to determine where the -# "man" binary lives. The format is: +# This file is read by manpath(1) to configure the mandatory and +# optional manpath, to map each path element to a manpath element +# and to determine where the "man" binary lives. The format is: # # MANBIN pathname # MANDATORY_MANPATH manpath_element +# OPTIONAL_MANPATH manpath_element # MANPATH_MAP path_element manpath_element # # MANBIN is optional @@ -16,9 +17,10 @@ # MANDATORY_MANPATH /usr/share/man MANDATORY_MANPATH /usr/share/perl/man -#MANDATORY_MANPATH /usr/local/man -#MANDATORY_MANPATH /usr/local/lib/perl5/5.00503/man -MANDATORY_MANPATH /usr/X11R6/man +# +# check if the directory exists and if it does, add it to MANPATH +# +OPTIONAL_MANPATH /usr/local/lib/perl5/5.00503/man # # set up PATH to MANPATH mapping # diff --git a/gnu/usr.bin/man/manpath/manpath.h b/gnu/usr.bin/man/manpath/manpath.h index 3039bd9..ab6eb0e 100644 --- a/gnu/usr.bin/man/manpath/manpath.h +++ b/gnu/usr.bin/man/manpath/manpath.h @@ -18,9 +18,15 @@ typedef struct { char mandir[MAXPATHLEN]; char bin[MAXPATHLEN]; - int mandatory; + int type; } DIRLIST; +/* manpath types */ +#define MANPATH_NONE 0 +#define MANPATH_MANDATORY 1 /* manpath is mandatory */ +#define MANPATH_OPTIONAL 2 /* manpath is optional */ +#define MANPATH_MAP 3 /* maps path to manpath */ + DIRLIST list[MAXDIRS]; char *tmplist[MAXDIRS]; diff --git a/gnu/usr.bin/man/manpath/manpath.man b/gnu/usr.bin/man/manpath/manpath.man index 3a80dbc..c27c074 100644 --- a/gnu/usr.bin/man/manpath/manpath.man +++ b/gnu/usr.bin/man/manpath/manpath.man @@ -4,7 +4,7 @@ .\" .\" You may distribute under the terms of the GNU General Public .\" License as specified in the README file that comes with the man 1.0 -.\" distribution. +.\" distribution. .\" .\" John W. Eaton .\" jwe@che.utexas.edu @@ -12,7 +12,8 @@ .\" The University of Texas at Austin .\" Austin, Texas 78712 .\" -.Dd Jan 5, 1991 +.\" $Id$ +.Dd Aug 16, 1999 .Dt MANPATH 1 .Os .Sh NAME @@ -22,27 +23,34 @@ .Nm .Op Fl q .Sh DESCRIPTION -.Nm manpath +.Nm Manpath tries to determine the user's manpath from a set of system defaults and the user's .Ev PATH , -echoing the result to the standard output. Warnings and errors are -written to the standard error. -If a directory in the user's path is not listed in the manpath.config -file, manpath looks for the subdirectories man or MAN. If they exist, -they are added to the search path. -.Pp +echoing the result to the standard output. +Warnings and errors are written to the standard error. +If a directory in the user's path is not listed in the +.Pa %manpath_config_file% +file, .Nm +looks for the subdirectories +.Pa man +or +.Pa MAN . +If they exist, they are added to the search path. +.Pp +.Nm Manpath is used by -.Nm man -to determine the search path, so user's normally don't need to set the +.Xr man 1 +to determine the search path, so users normally don't need to set the .Ev MANPATH environment variable directly. .Pp The options are as follows: -.Bl -tag -width Ds +.Bl -tag -width Fl .It Fl q -Operate quietly. Only echo the final manpath. +Operate quietly. +Only echo the final manpath. .El .Sh ENVIRONMENT .Bl -tag -width MANPATH -compact @@ -50,7 +58,7 @@ Operate quietly. Only echo the final manpath. If .Ev MANPATH is set, -.Nm manpath +.Nm echoes its value on the standard output and issues a warning on the standard error. .El |