summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@FreeBSD.org>2001-03-05 11:02:22 +0000
committerRuslan Ermilov <ru@FreeBSD.org>2001-03-05 11:02:22 +0000
commit74d89837e7842004ac17c6960f25cdae4a797e77 (patch)
treebec7bcd1ed5d4cd3786297201b8dbc050bff5676
parent25ec23bc1efb9e9da33088f907180898899d3b34 (diff)
Notes
-rw-r--r--gnu/usr.bin/man/man/man.c66
-rw-r--r--gnu/usr.bin/man/man/man.man130
2 files changed, 151 insertions, 45 deletions
diff --git a/gnu/usr.bin/man/man/man.c b/gnu/usr.bin/man/man/man.c
index 7f16eb299547..010395323383 100644
--- a/gnu/usr.bin/man/man/man.c
+++ b/gnu/usr.bin/man/man/man.c
@@ -20,7 +20,7 @@
#include <sys/file.h>
#include <sys/stat.h>
-#include <sys/types.h>
+#include <sys/param.h>
#include <ctype.h>
#include <errno.h>
#ifdef __FreeBSD__
@@ -74,6 +74,7 @@ extern int do_system_command ();
char *prognam;
static char *pager;
+static char *machine;
static char *manp;
static char *manpathlist[MAXDIRS];
static char *section;
@@ -99,9 +100,9 @@ struct ltable {
char *nroff;
};
static struct ltable ltable[] = {
- {"KOI8-R", " -Tkoi8-r"},
- {"ISO_8859-1", " -Tlatin1"},
- {NULL, NULL}
+ {"KOI8-R", "koi8-r"},
+ {"ISO_8859-1", "latin1"},
+ {NULL}
};
#endif
@@ -495,6 +496,12 @@ man_getopt (argc, argv)
if (debug)
fprintf (stderr, "\nusing %s as pager\n", pager);
+ if ((machine = getenv ("MACHINE")) == NULL)
+ machine = MACHINE;
+
+ if (debug)
+ fprintf (stderr, "\nusing %s architecture\n", machine);
+
if (manp == NULL)
{
if ((manp = manpath (0)) == NULL)
@@ -662,6 +669,15 @@ convert_name (name, to_cat)
*t1 = '\0';
t2 = strrchr (to_name, '/');
*t1 = '/';
+
+ /* Skip architecture part (if present). */
+ if (t2 != NULL && (t1 - t2 < 5 || *(t2 + 1) != 'm' || *(t2 + 3) != 'n'))
+ {
+ t1 = t2;
+ *t1 = '\0';
+ t2 = strrchr (to_name, '/');
+ *t1 = '/';
+ }
}
if (t2 == NULL)
@@ -946,8 +962,8 @@ parse_roff_directive (cp, file, buf, bufsize)
#ifdef __FreeBSD__
char lbuf[FILENAME_MAX];
- snprintf(lbuf, sizeof(lbuf), "%s%s", NEQN,
- locale_opts == NULL ? " -Tascii" : locale_opts);
+ snprintf(lbuf, sizeof(lbuf), "%s -T%s", NEQN,
+ locale_opts == NULL ? "ascii" : locale_opts);
add_directive (&first, lbuf, file, buf, bufsize);
#else
add_directive (&first, NEQN, file, buf, bufsize);
@@ -1025,8 +1041,8 @@ parse_roff_directive (cp, file, buf, bufsize)
#ifdef __FreeBSD__
char lbuf[FILENAME_MAX];
- snprintf(lbuf, sizeof(lbuf), "%s%s", NROFF,
- locale_opts == NULL ? " -Tascii" : locale_opts);
+ snprintf(lbuf, sizeof(lbuf), "%s -T%s", NROFF,
+ locale_opts == NULL ? "ascii" : locale_opts);
add_directive (&first, lbuf, file, buf, bufsize);
#else
add_directive (&first, NROFF " -Tascii", file, buf, bufsize);
@@ -1469,6 +1485,22 @@ try_section (path, section, name, glob)
register int cat;
register char **names;
register char **np;
+ static int arch_search;
+ char buf[FILENAME_MAX];
+
+ if (!arch_search)
+ {
+ snprintf(buf, sizeof(buf), "%s/man%s/%s", path, section, machine);
+ if (is_directory (buf) == 1)
+ {
+ snprintf(buf, sizeof(buf), "%s/%s", machine, name);
+ arch_search++;
+ found = try_section (path, section, buf, glob);
+ arch_search--;
+ if (found && !findall) /* only do this architecture... */
+ return found;
+ }
+ }
if (debug)
{
@@ -1591,12 +1623,17 @@ man (name)
if (locale != NULL) {
locale_opts = locale_nroff;
snprintf(buf, sizeof(buf), "%s/%s", *mp, locale);
- if (is_directory (buf))
+ if (is_directory (buf) == 1)
l_found = try_section (buf, section, name, glob);
if (!l_found) {
snprintf(buf, sizeof(buf), "%s/%s", *mp, short_locale);
- if (is_directory (buf))
+ if (is_directory (buf) == 1)
l_found = try_section (buf, section, name, glob);
+ if (!l_found && (*short_locale != 'e' || *(short_locale + 1) != 'n')) {
+ snprintf(buf, sizeof(buf), "%s/en.%s", *mp, short_locale + 3);
+ if (is_directory (buf) == 1)
+ l_found = try_section (buf, section, name, glob);
+ }
}
locale_opts = NULL;
}
@@ -1628,12 +1665,17 @@ man (name)
if (locale != NULL) {
locale_opts = locale_nroff;
snprintf(buf, sizeof(buf), "%s/%s", *mp, locale);
- if (is_directory (buf))
+ if (is_directory (buf) == 1)
l_found = try_section (buf, *sp, name, glob);
if (!l_found) {
snprintf(buf, sizeof(buf), "%s/%s", *mp, short_locale);
- if (is_directory (buf))
+ if (is_directory (buf) == 1)
l_found = try_section (buf, *sp, name, glob);
+ if (!l_found && (*short_locale != 'e' || *(short_locale + 1) != 'n')) {
+ snprintf(buf, sizeof(buf), "%s/en.%s", *mp, short_locale + 3);
+ if (is_directory (buf) == 1)
+ l_found = try_section (buf, *sp, name, glob);
+ }
}
locale_opts = NULL;
}
diff --git a/gnu/usr.bin/man/man/man.man b/gnu/usr.bin/man/man/man.man
index 63d21eeada57..bd2e4ce9d1ba 100644
--- a/gnu/usr.bin/man/man/man.man
+++ b/gnu/usr.bin/man/man/man.man
@@ -21,7 +21,7 @@
.Nm man
.Nd format and display the on-line manual pages
.Sh SYNOPSIS
-.Nm man
+.Nm
.Op Fl adfhkotw
.Op Fl m Ar system
.Op Fl p Ar string
@@ -39,7 +39,8 @@ and
.Ev PAGER
environment variables, so you can have
your own set(s) of personal man pages and choose whatever program you
-like to display the formatted pages. If section is specified, man
+like to display the formatted pages. If section is specified,
+.Nm
only looks in that section of the manual. You may also specify the
order to search the sections for entries and which preprocessors to
run on the source files via command line options or environment
@@ -50,13 +51,22 @@ space.
The options are as follows:
.Bl -tag -width Fl
.It Fl M Ar path
-Specify an alternate manpath. By default, man uses
-.Nm manpath
+Specify an alternate manpath.
+By default,
+.Nm
+uses
+.Xr manpath 1
+(which is built into the
+.Nm
+binary)
to determine the path to search. This option overrides the
.Ev MANPATH
environment variable.
.It Fl P Ar pager
-Specify which pager to use. By default, man uses
+Specify which pager to use.
+By default,
+.Nm
+uses
.Nm %pager% ,
This option overrides the
.Ev PAGER
@@ -67,8 +77,12 @@ This option overrides the
.Ev MANSECT
environment variable.
.It Fl a
-By default, man will exit after displaying the first manual page it
-finds. Using this option forces man to display all the manual pages
+By default,
+.Nm
+will exit after displaying the first manual page it
+finds. Using this option forces
+.Nm
+to display all the manual pages
that match
.Ar name ,
not just the first.
@@ -87,32 +101,62 @@ Equivalent to
Specify an alternate set of man pages to search based on the system
name given.
.It Fl o
-Use original, non-localized manpages. By default, man searches
-for localized subdirectories of each manpath component, subdirectory
-name is determined by the
-.Ev LANG
-or
-.Ev LC_CTYPE
-environment variables.
-Localized directory name builded
-using following rule: directory name
-merged with
-.Ev LC_CTYPE
+Look for original, non-localized manpages only.
+.Pp
+By default,
+.Nm
+searches for a localized manpage
+in a set of locale subdirectories of each
+.Xr manpath 1
+component.
+.Pp
+Locale name is taken from the first of three environment variables
+with a nonempty value:
+.Ev LC_ALL , LC_CTYPE ,
or
-.Ev LANG
-environment variable value.
-If
-.Ev LC_CTYPE
-has no value, then
-.Ev LANG
-variable value will be used. If both
-these variables have no value, then no actions will be performed.
+.Ev LANG ,
+in the specified order.
+.Pp
+If the value could not be determined, or is not a valid locale name,
+then only non-localized manpage will be looked up.
+.Pp
+Otherwise,
+.Nm
+will search in the following subdirectories, in the order of precedence:
+.Pp
+.Bl -item -offset indent -compact
+.Sm off
+.It
+.Pa <lang> _ <country> . <charset>
+.It
+.Pa <lang> . <charset>
+.It
+.Pa en . <charset>
+.Sm on
+.El
+.Pp
+For example, for
+.Dq de_DE.ISO_8859-1
+locale,
.Nm
-can handle long and short notations of localized directory names. Long notation
-means that directory has name "path/<lang>_<country>.<charset>", for
-example ".../man/ru_RU.KOI8-R". Short notation "path/<lang>.<charset>", for
-example ".../man/ru.KOI8-R". Short notation have priority over
-long one.
+will search in the following subdirectories of the
+.Pa /usr/share/man
+manpath component:
+.Pp
+.Bl -item -offset indent -compact
+.It
+.Pa /usr/share/man/de_DE.ISO_8859-1
+.It
+.Pa /usr/share/man/de.ISO_8859-1
+.It
+.Pa /usr/share/man/en.ISO_8859-1
+.El
+.Pp
+Finally,
+if the search of localized manpage fails,
+it will be looked up in the default
+.Pa /usr/share/man
+directory.
.It Fl p Ar string
Specify the sequence of preprocessors to run before nroff or troff.
Not all installations will have a full set of preprocessors.
@@ -134,7 +178,23 @@ Don't actually display the man pages, but do print the location(s) of
the files that would be formatted or displayed.
.El
.Sh ENVIRONMENT
-.Bl -tag -width MANROFFSEQ -compact
+.Bl -tag -width MANROFFSEQ
+.It Ev LC_ALL , LC_CTYPE , LANG
+These variables specify the preferred language for manual pages.
+(See the
+.Fl o
+option above.)
+.It Ev MACHINE
+As some manual pages are intended only for specific architectures,
+.Nm
+searches any subdirectories,
+with the same name as the current architecture,
+in every directory which it searches.
+Machine specific areas are checked before general areas.
+The current machine type may be overridden by setting the environment
+variable
+.Ev MACHINE
+to the name of a specific architecture.
.It Ev MANPATH
If
.Ev MANPATH
@@ -161,12 +221,14 @@ is used.
.Pp
Normally, to look at the relevant manpage information for getopt,
one would use:
+.Pp
.Dl man getopt
.Pp
However, when referring to a specific section of the manual,
such as
.Xr getopt 3 ,
one would use:
+.Pp
.Dl man 3 getopt
.Sh SEE ALSO
.Xr apropos 1 ,
@@ -180,4 +242,6 @@ one would use:
.Sh BUGS
The
.Fl t
-option only works if a troff-like program is installed.
+option only works if the
+.Xr troff 1 Ns -like
+program is installed.