SHA256
1
0
forked from pool/man
man/man-db-2.5.2-fhs.dif

109 lines
3.2 KiB
Plaintext

--- manual/files.me
+++ manual/files.me 2009-01-15 01:02:11.000000000 +0100
@@ -135,9 +135,11 @@ manpath.
However, if the element is not mentioned in the config file, a man directory
relative to it will be sought.
The subdirectories
-.i ../man
+.i ../man ,
+.i man ,
+.i ../share/man ,
or
-.i man
+.i share/man
relative to the path component are appended to the internal manpath if they
exist.
Finally, the internal manpath is stripped of duplicate paths before
--- src/manp.c
+++ src/manp.c 2009-01-15 01:02:11.000000000 +0100
@@ -58,6 +58,7 @@
#include <unistd.h>
#include "xgetcwd.h"
+#include "xvasprintf.h"
#include "gettext.h"
#define _(String) gettext (String)
@@ -886,7 +887,8 @@ static char *def_path (int flag)
* directories listed in the man_db.config file. If so, and it is
* not already in the manpath, add it. If the directory is not listed
* in the man_db.config file, see if there is a subdirectory `../man' or
- * `man'. If so, and it is not already in the manpath, add it.
+ * `man', or, for FHS-compliance, `../share/man' or `share/man'. If so,
+ * and it is not already in the manpath, add it.
* Example: user has $HOME/bin in his path and the directory
* $HOME/man exists -- the directory $HOME/man will be added
* to the manpath.
@@ -941,13 +943,15 @@ static inline char *get_manpath_from_pat
t = has_mandir (p);
if (t) {
- debug ("but does have a ../man or man "
+ debug ("but does have a ../man, man, "
+ "../share/man, or share/man "
"subdirectory\n");
add_dir_to_list (tmplist, t);
free (t);
} else
- debug ("and doesn't have ../man or man "
+ debug ("and doesn't have ../man, man, "
+ "../share/man, or share/man "
"subdirectories\n");
}
}
@@ -1022,34 +1026,41 @@ static void add_dir_to_list (char **lp,
}
}
-/* path does not exist in config file: check to see if path/../man or
- path/man exist. If so return it, if not return NULL. */
+/* path does not exist in config file: check to see if path/../man,
+ path/man, path/../share/man, or path/share/man exist. If so return
+ it, if not return NULL. */
static inline char *has_mandir (const char *path)
{
- char *newpath = NULL;
+ char *newpath;
/* don't assume anything about path, especially that it ends in
"bin" or even has a '/' in it! */
char *subdir = strrchr (path, '/');
if (subdir) {
- const int prefix_len = subdir + 1 - path;
- newpath = xmalloc (prefix_len + sizeof ("man") + 1);
- strncpy (newpath, path, prefix_len);
- strcpy (newpath + prefix_len, "man");
-
+ newpath = xasprintf ("%.*s/man", subdir - path, path);
if (is_directory (newpath) == 1)
return newpath;
- else
- *newpath = '\0';
+ free (newpath);
}
- newpath = appendstr (newpath, path, "/man", NULL);
-
+ newpath = appendstr (NULL, path, "/man", NULL);
if (is_directory (newpath) == 1)
return newpath;
+ free (newpath);
+
+ if (subdir) {
+ newpath = xasprintf ("%.*s/share/man", subdir - path, path);
+ if (is_directory (newpath) == 1)
+ return newpath;
+ free (newpath);
+ }
+ newpath = appendstr (NULL, path, "/share/man", NULL);
+ if (is_directory (newpath) == 1)
+ return newpath;
free (newpath);
+
return NULL;
}