diff options
author | ru <ru@FreeBSD.org> | 2001-02-19 14:19:57 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2001-02-19 14:19:57 +0000 |
commit | b62adaf1b8138256cf947a0b1e0f5a2600b8fe57 (patch) | |
tree | 2c09d1dfe21c4d5af672f2a118f50cd8abc6ee35 | |
parent | 58ea75454605ddbeb2fb9bb5d768471fa9c6b179 (diff) | |
download | FreeBSD-src-b62adaf1b8138256cf947a0b1e0f5a2600b8fe57.zip FreeBSD-src-b62adaf1b8138256cf947a0b1e0f5a2600b8fe57.tar.gz |
Implement one nice feature of original BSD man(1):
: As some manual pages are intended only for specific architectures,
: man 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 MACHINE to the name
: of a specific architecture.
-rw-r--r-- | gnu/usr.bin/man/man/man.c | 34 | ||||
-rw-r--r-- | gnu/usr.bin/man/man/man.man | 11 |
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 0fb6b87..0103953 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 5db190a..296db4d 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 |