Add -L: print MANLOCALES variable for man locales list

This commit is contained in:
Andrey A. Chernov 1999-11-23 03:06:18 +00:00
parent af4f75caf0
commit f052fd3563
3 changed files with 75 additions and 5 deletions

View file

@ -12,6 +12,8 @@
* Department of Chemical Engineering
* The University of Texas at Austin
* Austin, Texas 78712
*
* $FreeBSD$
*/
#define MANPATH_MAIN
@ -53,6 +55,8 @@ extern int fflush ();
char *prognam;
int debug;
int locale;
char *man_locales;
/*
* Examine user's PATH and print a reasonable MANPATH.
@ -74,13 +78,16 @@ main(argc, argv)
prognam = mkprogname (argv[0]);
while ((c = getopt (argc, argv, "dhq?")) != EOF)
while ((c = getopt (argc, argv, "dhLq?")) != EOF)
{
switch (c)
{
case 'd':
debug++;
break;
case 'L':
locale++;
break;
case 'q':
quiet = 0;
break;
@ -103,7 +110,7 @@ main(argc, argv)
void
usage ()
{
fprintf (stderr, "usage: %s [-q]\n", prognam);
fprintf (stderr, "usage: %s [-dLq]\n", prognam);
exit (1);
}
#endif /* MAIN */
@ -140,6 +147,20 @@ manpath (perrs)
if (get_dirlist ())
gripe_reading_mp_config (config_file);
if (locale)
{
if ((manpathlist = getenv ("MANLOCALES")) != NULL)
/*
* This must be it.
*/
{
if (perrs)
fprintf (stderr, "(Warning: MANLOCALES environment variable set)\n");
return strdup (manpathlist);
}
return (man_locales ? man_locales : "");
}
if ((manpathlist = getenv ("MANPATH")) != NULL)
/*
* This must be it.
@ -258,6 +279,37 @@ get_dirlist ()
fprintf (stderr, "found manpath map %s --> %s\n",
dlp->bin, dlp->mandir);
}
else if (!strncmp ("MANLOCALES", bp, 10))
{
if ((p = strchr (bp, ' ')) == NULL &&
(p = strchr (bp, '\t')) == NULL) {
fclose(config);
return -1;
}
bp = p;
while (*bp && *bp != '\n' && (*bp == ' ' || *bp == '\t'))
bp++;
for (p = bp; *p && *p != '\n'; p++)
;
do {
*p-- = '\0';
} while (p >= bp && (*p == ' ' || *p == '\t'));
if (man_locales != NULL)
free (man_locales);
if ((man_locales = strdup (bp)) == NULL) {
fclose(config);
return -1;
}
if (debug)
fprintf (stderr, "found man locales: %s\n",
man_locales);
}
else
{
gripe_reading_mp_config (config_file);

View file

@ -7,6 +7,7 @@
# MANDATORY_MANPATH manpath_element
# OPTIONAL_MANPATH manpath_element
# MANPATH_MAP path_element manpath_element
# MANLOCALES locale1 locale2 ...
#
# every automatically generated MANPATH includes these fields
#
@ -23,3 +24,7 @@ MANPATH_MAP /bin /usr/share/man
MANPATH_MAP /usr/bin /usr/share/man
MANPATH_MAP /usr/local/bin /usr/local/man
MANPATH_MAP /usr/X11R6/bin /usr/X11R6/man
#
# set man locales, if needed
#
#MANLOCALES ru_RU.KOI8-R

View file

@ -21,7 +21,7 @@
.Nd determine user's search path for man pages
.Sh SYNOPSIS
.Nm
.Op Fl q
.Op Fl dLq
.Sh DESCRIPTION
.Nm Manpath
tries to determine the user's manpath from a set of system
@ -48,12 +48,16 @@ environment variable directly.
.Pp
The options are as follows:
.Bl -tag -width Fl
.It Fl d
Output additional debug information.
.It Fl L
Output man locales list (if exist).
.It Fl q
Operate quietly.
Only echo the final manpath.
Only echo the final result.
.El
.Sh ENVIRONMENT
.Bl -tag -width MANPATH -compact
.Bl -tag -width MANLOCALES -compact
.It Ev MANPATH
If
.Ev MANPATH
@ -61,6 +65,15 @@ is set,
.Nm
echoes its value on the standard output and issues a warning on the
standard error.
.It Ev MANLOCALES
If
.Ev MANLOCALES
is set and
.Fl L
option is set,
.Nm
echoes its value on the standard output and issues a warning on the
standard error.
.El
.Sh FILES
.Bl -tag -width %manpath_config_file% -compact