summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko2008-09-14 21:26:55 +0000
committerDenis Vlasenko2008-09-14 21:26:55 +0000
commite357d2ae6833e3ca306f3aa6e12c6ddf2ff1eae2 (patch)
tree6d7eeb35abf5a1f915a89e7fa5ac35fd84c78960
parent7c9c1bb61655d5d15a14dd7080e5bda0df43ef75 (diff)
downloadbusybox-e357d2ae6833e3ca306f3aa6e12c6ddf2ff1eae2.zip
busybox-e357d2ae6833e3ca306f3aa6e12c6ddf2ff1eae2.tar.gz
man: use default MANPATH of "/usr/man"; do not search paths twice
-rw-r--r--miscutils/man.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/miscutils/man.c b/miscutils/man.c
index e6824eb..26fd44d 100644
--- a/miscutils/man.c
+++ b/miscutils/man.c
@@ -169,10 +169,10 @@ int man_main(int argc UNUSED_PARAM, char **argv)
sec_list = xstrdup("1:2:3:4:5:6:7:8:9");
/* Last valid man_path_list[] is [0x10] */
man_path_list = xzalloc(0x11 * sizeof(man_path_list[0]));
- count_mp = 0;
- man_path_list[0] = xstrdup(getenv("MANPATH"));
- if (man_path_list[0])
- count_mp++;
+ man_path_list[0] = getenv("MANPATH");
+ if (!man_path_list[0])
+ man_path_list[0] = (char*)"/usr/man";
+ count_mp = 1;
pager = getenv("MANPAGER");
if (!pager) {
pager = getenv("PAGER");
@@ -186,6 +186,13 @@ int man_main(int argc UNUSED_PARAM, char **argv)
if (!token[1])
continue;
if (strcmp("MANPATH", token[0]) == 0) {
+ /* Do we already have it? */
+ char **path_element = man_path_list;
+ while (*path_element) {
+ if (strcmp(*path_element, token[1]) == 0)
+ goto skip;
+ path_element++;
+ }
man_path_list = xrealloc_vector(man_path_list, 4, count_mp);
man_path_list[count_mp] = xstrdup(token[1]);
count_mp++;
@@ -196,6 +203,7 @@ int man_main(int argc UNUSED_PARAM, char **argv)
free(sec_list);
sec_list = xstrdup(token[1]);
}
+ skip: ;
}
config_close(parser);