man: use default MANPATH of "/usr/man"; do not search paths twice
This commit is contained in:
parent
7c9c1bb616
commit
e357d2ae68
@ -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");
|
sec_list = xstrdup("1:2:3:4:5:6:7:8:9");
|
||||||
/* Last valid man_path_list[] is [0x10] */
|
/* Last valid man_path_list[] is [0x10] */
|
||||||
man_path_list = xzalloc(0x11 * sizeof(man_path_list[0]));
|
man_path_list = xzalloc(0x11 * sizeof(man_path_list[0]));
|
||||||
count_mp = 0;
|
man_path_list[0] = getenv("MANPATH");
|
||||||
man_path_list[0] = xstrdup(getenv("MANPATH"));
|
if (!man_path_list[0])
|
||||||
if (man_path_list[0])
|
man_path_list[0] = (char*)"/usr/man";
|
||||||
count_mp++;
|
count_mp = 1;
|
||||||
pager = getenv("MANPAGER");
|
pager = getenv("MANPAGER");
|
||||||
if (!pager) {
|
if (!pager) {
|
||||||
pager = getenv("PAGER");
|
pager = getenv("PAGER");
|
||||||
@ -186,6 +186,13 @@ int man_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
if (!token[1])
|
if (!token[1])
|
||||||
continue;
|
continue;
|
||||||
if (strcmp("MANPATH", token[0]) == 0) {
|
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 = xrealloc_vector(man_path_list, 4, count_mp);
|
||||||
man_path_list[count_mp] = xstrdup(token[1]);
|
man_path_list[count_mp] = xstrdup(token[1]);
|
||||||
count_mp++;
|
count_mp++;
|
||||||
@ -196,6 +203,7 @@ int man_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
free(sec_list);
|
free(sec_list);
|
||||||
sec_list = xstrdup(token[1]);
|
sec_list = xstrdup(token[1]);
|
||||||
}
|
}
|
||||||
|
skip: ;
|
||||||
}
|
}
|
||||||
config_close(parser);
|
config_close(parser);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user