+#endif
+#if ENABLE_FEATURE_SEAMLESS_GZ
+ strcpy(ext, "gz");
+ if (run_pipe(filename_with_zext, man, level))
+ return 1;
+#endif
+
+ return run_pipe(man_filename, man, level);
+}
+
+static char **add_MANPATH(char **man_path_list, int *count_mp, char *path)
+{
+ if (path) while (*path) {
+ char *next_path;
+ char **path_element;
+
+ next_path = strchr(path, ':');
+ if (next_path) {
+ if (next_path == path) /* "::"? */
+ goto next;
+ *next_path = '\0';
+ }
+ /* Do we already have path? */
+ path_element = man_path_list;
+ if (path_element) while (*path_element) {
+ if (strcmp(*path_element, path) == 0)
+ goto skip;
+ path_element++;
+ }
+ man_path_list = xrealloc_vector(man_path_list, 4, *count_mp);
+ man_path_list[*count_mp] = xstrdup(path);
+ (*count_mp)++;
+ /* man_path_list is NULL terminated */
+ /* man_path_list[*count_mp] = NULL; - xrealloc_vector did it */
+ skip:
+ if (!next_path)
+ break;
+ /* "path" may be a result of getenv(), be nice and don't mangle it */
+ *next_path = ':';
+ next:
+ path = next_path + 1;
+ }
+ return man_path_list;
+}