From 7018ba917db63c493918af0a5bf2977480d52bc7 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Thu, 28 Mar 2019 08:33:21 +0000 Subject: man: don't skip default path which appears in config file If the MANPATH environment variable isn't set a provisional default path of /usr/man is placed in man_path_list. This is only used if a configuration file doesn't contain an alternative path. If a configuration file lists the default path first: MANPATH /usr/man:/usr/share/man add_MANPATH() sees that the default entry is already present and skips it. As a result man_path_list only contains the second and subsequent components of the configured MANPATH. In such cases the path should not be skipped. --- miscutils/man.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/miscutils/man.c b/miscutils/man.c index fd5d90c1a..b2d42b043 100644 --- a/miscutils/man.c +++ b/miscutils/man.c @@ -208,8 +208,12 @@ static char **add_MANPATH(char **man_path_list, int *count_mp, char *path) /* Do we already have path? */ path_element = man_path_list; if (path_element) while (*path_element) { - if (strcmp(*path_element, path) == 0) + if (strcmp(*path_element, path) == 0) { + /* Have path but haven't counted it, must be default */ + if (*count_mp == 0) + break; goto skip; + } path_element++; } man_path_list = xrealloc_vector(man_path_list, 4, *count_mp); -- cgit v1.2.3-55-g6feb