diff options
Diffstat (limited to 'gnu/usr.bin/man/manpath')
| -rw-r--r-- | gnu/usr.bin/man/manpath/Makefile | 4 | ||||
| -rw-r--r-- | gnu/usr.bin/man/manpath/manpath.c | 54 | ||||
| -rw-r--r-- | gnu/usr.bin/man/manpath/manpath.config | 21 | ||||
| -rw-r--r-- | gnu/usr.bin/man/manpath/manpath.h | 8 | ||||
| -rw-r--r-- | gnu/usr.bin/man/manpath/manpath.man | 36 |
5 files changed, 67 insertions, 56 deletions
diff --git a/gnu/usr.bin/man/manpath/Makefile b/gnu/usr.bin/man/manpath/Makefile index e8d3bf61cb58..05ebcd296f39 100644 --- a/gnu/usr.bin/man/manpath/Makefile +++ b/gnu/usr.bin/man/manpath/Makefile @@ -18,7 +18,7 @@ ${MAN1}: ${.CURDIR}/manpath.man ${.CURDIR}/manpath.man > ${MAN1} afterinstall: - ${INSTALL} -c -o bin -g bin -m 644 ${.CURDIR}/manpath.config \ - ${DESTDIR}${manpath_config_file}.sample + ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 644 \ + ${.CURDIR}/manpath.config ${DESTDIR}${manpath_config_file}.sample .include <bsd.prog.mk> diff --git a/gnu/usr.bin/man/manpath/manpath.c b/gnu/usr.bin/man/manpath/manpath.c index a8c4cbc714dc..990805fae6a7 100644 --- a/gnu/usr.bin/man/manpath/manpath.c +++ b/gnu/usr.bin/man/manpath/manpath.c @@ -200,10 +200,8 @@ get_dirlist () if (*bp == '#' || *bp == '\n') continue; - 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 +209,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 +222,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 +236,7 @@ get_dirlist () bp = p; - dlp->mandatory = 0; + dlp->type = MANPATH_MAP; while (*bp && *bp != '\n' && (*bp == ' ' || *bp == '\t')) bp++; @@ -269,14 +268,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 +287,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 +301,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 +322,10 @@ def_path (perrs) memcpy (p, path, len); p += len; *p++ = ':'; - dlp++; } } + dlp++; + } p[-1] = '\0'; @@ -363,7 +362,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 +415,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 13baa453477e..900e5064a539 100644 --- a/gnu/usr.bin/man/manpath/manpath.config +++ b/gnu/usr.bin/man/manpath/manpath.config @@ -1,24 +1,21 @@ -# $Id: manpath.config,v 1.11 1999/07/25 19:33:06 markm Exp $ +# $Id: manpath.config,v 1.13 1999/08/20 10:44:51 ru 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 manpath, +# optional manpath and to map each path element to a manpath element. +# The format is: # -# MANBIN pathname # MANDATORY_MANPATH manpath_element +# OPTIONAL_MANPATH manpath_element # MANPATH_MAP path_element manpath_element # -# MANBIN is optional -# -#MANBIN /usr/local/bin/man -# # every automatically generated MANPATH includes these fields # 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 3039bd91ef91..ab6eb0ef6a98 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 3a80dbc7c71f..956e7d8aa6bc 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: manpath.man,v 1.4 1999/08/16 11:34:57 ru Exp $ +.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 |
