diff -up man-db-2.5.9/src/ult_src.cpom man-db-2.5.9/src/ult_src.c --- man-db-2.5.9/src/ult_src.cpom 2011-06-16 15:48:00.000000000 +0200 +++ man-db-2.5.9/src/ult_src.c 2011-06-17 09:24:57.000000000 +0200 @@ -196,6 +196,8 @@ const char *ult_src (const char *name, c struct stat *buf, int flags) { static char *base; /* must be static */ + char *full_path; + char *end; static short recurse; /* must be static */ /* initialise the function */ @@ -311,14 +313,37 @@ const char *ult_src (const char *name, c free (base); base = appendstr (NULL, path, "/", include, NULL); - free (include); debug ("ult_src: points to %s\n", base); + recurse++; + ult = ult_src (base, path, NULL, flags); + recurse--; + if (ult != NULL) + goto found; + + /* link to the man page can be relevant to the directory in + * which the man page containing the link is + */ + free(base); + + full_path = xstrdup (name); + end = strrchr(full_path, '/'); + if (end == NULL) + goto clean; + end[0] = '\0'; + base = appendstr (NULL, full_path, "/", include, + NULL); + + debug ("ult_src: points to %s\n", base); recurse++; ult = ult_src (base, path, NULL, flags); recurse--; +clean: + free(include); + free(full_path); +found: pipeline_wait (decomp); pipeline_free (decomp); free (decomp_base);