diff options
author | ru <ru@FreeBSD.org> | 2005-12-05 14:22:12 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2005-12-05 14:22:12 +0000 |
commit | 6e96e6259d287eca55fb509febe1122cd1742e16 (patch) | |
tree | 40d79d56305386356866f6c99a9547c2d0b01395 /usr.bin/catman | |
parent | 92cbca9c0a7ad409d87bff6fa6943c6b016bfc94 (diff) | |
download | FreeBSD-src-6e96e6259d287eca55fb509febe1122cd1742e16.zip FreeBSD-src-6e96e6259d287eca55fb509febe1122cd1742e16.tar.gz |
Prepare for MACHINE and hw.machine switching to "pc98" on FreeBSD/pc98.
Reviewed by: nyan
Diffstat (limited to 'usr.bin/catman')
-rw-r--r-- | usr.bin/catman/catman.1 | 5 | ||||
-rw-r--r-- | usr.bin/catman/catman.c | 24 |
2 files changed, 24 insertions, 5 deletions
diff --git a/usr.bin/catman/catman.1 b/usr.bin/catman/catman.1 index 8fc7780..fe85587 100644 --- a/usr.bin/catman/catman.1 +++ b/usr.bin/catman/catman.1 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 22, 2004 +.Dd December 3, 2005 .Dt CATMAN 1 .Os .Sh NAME @@ -80,6 +80,9 @@ option is used. .It Ev MACHINE If set, overrides the current machine type when searching for machine specific man page subdirectories. +.It Ev MACHINE_ARCH +If set, overrides the current architecture when searching for +architecture specific man page subdirectories. .It Ev MANPATH Determines the set of directories to be processed if none are given on the command line. diff --git a/usr.bin/catman/catman.c b/usr.bin/catman/catman.c index 6fcd975..ced6ae6 100644 --- a/usr.bin/catman/catman.c +++ b/usr.bin/catman/catman.c @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <sys/stat.h> #include <sys/param.h> +#include <sys/utsname.h> #include <ctype.h> #include <dirent.h> @@ -65,7 +66,7 @@ static int force; /* -f flag: force overwriting all cat pages */ static int rm_junk; /* -r flag: remove garbage pages */ static char *locale; /* user's locale if -L is used */ static char *lang_locale; /* short form of locale */ -static const char *machine; +static const char *machine, *machine_arch; static int exit_code; /* exit code to use when finished */ /* @@ -634,7 +635,7 @@ process_mandir(char *dir_name, char *section) process_section(dir_name, section); } else { struct dirent **entries; - char *machine_dir; + char *machine_dir, *arch_dir; int nsections; int i; @@ -651,6 +652,13 @@ process_mandir(char *dir_name, char *section) if (test_path(machine_dir, NULL) & TEST_DIR) process_section(dir_name, machine_dir); free(machine_dir); + if (strcmp(machine_arch, machine) != 0) { + asprintf(&arch_dir, "%s/%s", entries[i]->d_name, + machine_arch); + if (test_path(arch_dir, NULL) & TEST_DIR) + process_section(dir_name, arch_dir); + free(arch_dir); + } free(entries[i]); } free(entries); @@ -791,8 +799,16 @@ main(int argc, char **argv) signal(SIGQUIT, trap_signal); signal(SIGTERM, trap_signal); - if ((machine = getenv("MACHINE")) == NULL) - machine = MACHINE; + if ((machine = getenv("MACHINE")) == NULL) { + static struct utsname utsname; + + if (uname(&utsname) == -1) + err(1, "uname"); + machine = utsname.machine; + } + + if ((machine_arch = getenv("MACHINE_ARCH")) == NULL) + machine_arch = MACHINE_ARCH; if (optind == argc) { const char *manpath = getenv("MANPATH"); |