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/makewhatis | |
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/makewhatis')
-rw-r--r-- | usr.bin/makewhatis/makewhatis.1 | 5 | ||||
-rw-r--r-- | usr.bin/makewhatis/makewhatis.c | 21 |
2 files changed, 22 insertions, 4 deletions
diff --git a/usr.bin/makewhatis/makewhatis.1 b/usr.bin/makewhatis/makewhatis.1 index 4e20ceb..1928c84 100644 --- a/usr.bin/makewhatis/makewhatis.1 +++ b/usr.bin/makewhatis/makewhatis.1 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 12, 2002 +.Dd December 3, 2005 .Dt MAKEWHATIS 1 .Os .Sh NAME @@ -98,6 +98,9 @@ option is used. .It Ev MACHINE If set, its value is used to override the current machine type when searching machine specific subdirectories. +.It Ev MACHINE_ARCH +If set, its value is used to override the current +architecture when searching architecture specific 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/makewhatis/makewhatis.c b/usr.bin/makewhatis/makewhatis.c index 30f2da8..ea089fe 100644 --- a/usr.bin/makewhatis/makewhatis.c +++ b/usr.bin/makewhatis/makewhatis.c @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include <sys/stat.h> #include <sys/param.h> #include <sys/queue.h> +#include <sys/utsname.h> #include <ctype.h> #include <dirent.h> @@ -98,7 +99,7 @@ static const char *whatis_name="whatis";/* -n option: the name */ static char *common_output; /* -o option: the single output file */ 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 */ static SLIST_HEAD(, visited_dir) visited_dirs = @@ -921,6 +922,12 @@ process_mandir(char *dir_name) entries[i]->d_name, machine); if (stat(section_dir, &st) == 0 && S_ISDIR(st.st_mode)) process_section(section_dir); + if (strcmp(machine_arch, machine) != 0) { + snprintf(section_dir, sizeof section_dir, "%s/%s/%s", + dir_name, entries[i]->d_name, machine_arch); + if (stat(section_dir, &st) == 0 && S_ISDIR(st.st_mode)) + process_section(section_dir); + } free(entries[i]); } free(entries); @@ -1011,8 +1018,16 @@ main(int argc, char **argv) whatis_proto = new_sbuf(); whatis_final = new_sbuf(); - 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 (common_output != NULL && (fp = open_output(common_output)) == NULL) err(1, "%s", common_output); |