aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnu/usr.bin/man/man/man.c34
-rw-r--r--gnu/usr.bin/man/man/man.man11
2 files changed, 44 insertions, 1 deletions
diff --git a/gnu/usr.bin/man/man/man.c b/gnu/usr.bin/man/man/man.c
index 0fb6b87e5a48..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;
@@ -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)
@@ -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)
{
diff --git a/gnu/usr.bin/man/man/man.man b/gnu/usr.bin/man/man/man.man
index 5db190a1a806..296db4d504a8 100644
--- a/gnu/usr.bin/man/man/man.man
+++ b/gnu/usr.bin/man/man/man.man
@@ -184,6 +184,17 @@ 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