man/man-db-2.5.2-catp.dif

169 lines
5.5 KiB
Plaintext
Raw Normal View History

--- include/manconfig.h.in
+++ include/manconfig.h.in 2008-04-21 13:32:56.000000000 +0200
@@ -375,8 +375,10 @@ extern char *program_name; /* the basena
#define NOT_FOUND 16 /* No action was taken */
/* System or user catpaths? Allow bitwise disjunctions of these. */
-#define SYSTEM_CAT 1
-#define USER_CAT 2
+#define SYSTEM_CATP 1
+#define USER_CATP 2
+#define FILE_CATP 4
+#define WHATIS_CATP 8
/* string macros */
#define STREQ(a,b) (strcmp(a,b) == 0)
--- src/catman.c
+++ src/catman.c 2008-01-30 12:02:21.000000000 +0100
@@ -450,7 +450,7 @@ int main (int argc, char *argv[])
char *catpath;
size_t len;
- catpath = get_catpath (*mp, SYSTEM_CAT | USER_CAT);
+ catpath = get_catpath (*mp, SYSTEM_CATP|USER_CATP);
if (catpath) {
if (is_directory (catpath) != 1) {
--- src/man.c
+++ src/man.c 2008-04-21 17:53:02.000000000 +0200
@@ -1249,8 +1304,7 @@ static pipeline *make_roff_command (cons
#ifdef ALT_EXT_FORMAT
/* Check both external formatter locations */
if (dir && !recode) {
- char *catpath = get_catpath
- (dir, global_manpath ? SYSTEM_CAT : USER_CAT);
+ char *catpath = get_catpath (dir, global_manpath ? SYSTEM_CATP : USER_CATP);
/* If we have an alternate catpath */
if (catpath) {
@@ -2366,8 +2450,7 @@ static char *find_cat_file (const char *
*/
if (!STREQ (man_file, original)) {
global_manpath = is_global_mandir (man_file);
- cat_path = get_catpath
- (man_file, global_manpath ? SYSTEM_CAT : USER_CAT);
+ cat_path = get_catpath (man_file, (global_manpath ? SYSTEM_CATP : USER_CATP)|FILE_CATP);
if (cat_path) {
cat_file = convert_name (cat_path, 0);
@@ -2394,8 +2477,7 @@ static char *find_cat_file (const char *
}
global_manpath = is_global_mandir (original);
- cat_path = get_catpath
- (original, global_manpath ? SYSTEM_CAT : USER_CAT);
+ cat_path = get_catpath (original, (global_manpath ? SYSTEM_CATP : USER_CATP)|FILE_CATP);
if (cat_path) {
cat_file = convert_name (cat_path, 0);
@@ -2884,9 +2966,7 @@ static int display_database (struct cand
if (access (file, R_OK) != 0) {
char *catpath;
- catpath = get_catpath (candp->path,
- global_manpath ? SYSTEM_CAT
- : USER_CAT);
+ catpath = get_catpath (candp->path, global_manpath ? SYSTEM_CATP : USER_CATP);
if (catpath && strcmp (catpath, candp->path) != 0) {
file = make_filename (catpath, name,
@@ -3001,7 +3081,7 @@ static int try_db (const char *manpath,
/* find out where our db for this manpath should be */
- catpath = get_catpath (manpath, global_manpath ? SYSTEM_CAT : USER_CAT);
+ catpath = get_catpath (manpath, (global_manpath ? SYSTEM_CATP : USER_CATP)|FILE_CATP);
if (catpath) {
database = mkdbname (catpath);
free (catpath);
--- src/mandb.c
+++ src/mandb.c 2008-01-30 12:01:40.000000000 +0100
@@ -484,10 +486,13 @@ static short process_manpath (const char
short amount = 0;
if (global_manpath) { /* system db */
- catpath = get_catpath (manpath, SYSTEM_CAT);
- assert (catpath);
+ catpath = get_catpath (manpath, SYSTEM_CATP);
+ if (!catpath) {
+ error (0, 0, _("warning: no system cat path for man path %s"), manpath);
+ return amount;
+ }
} else { /* user db */
- catpath = get_catpath (manpath, USER_CAT);
+ catpath = get_catpath (manpath, USER_CATP);
if (!catpath)
catpath = xstrdup (manpath);
}
--- src/manp.c
+++ src/manp.c 2008-01-30 12:01:03.000000000 +0100
@@ -1134,8 +1145,8 @@ char *get_catpath (const char *name, int
struct list *list;
for (list = namestore; list; list = list->next)
- if (((cattype & SYSTEM_CAT) && list->flag == MANDB_MAP) ||
- ((cattype & USER_CAT) && list->flag == MANDB_MAP_USER)) {
+ if (((cattype & SYSTEM_CATP) && list->flag == MANDB_MAP) ||
+ ((cattype & USER_CATP) && list->flag == MANDB_MAP_USER)) {
size_t manlen = strlen (list->key);
if (STRNEQ (name, list->key, manlen)) {
const char *suffix = name + manlen;
@@ -1143,16 +1154,30 @@ char *get_catpath (const char *name, int
if (*suffix == '/') {
++suffix;
- catpath = appendstr (catpath, "/",
- NULL);
+ catpath = appendstr (catpath, "/", NULL);
}
if (STRNEQ (suffix, "man", 3)) {
suffix += 3;
- catpath = appendstr (catpath, "cat",
- NULL);
+ catpath = appendstr (catpath, "cat", NULL);
}
catpath = appendstr (catpath, suffix, NULL);
- return catpath;
+ if (cattype & FILE_CATP)
+ return catpath;
+ if (is_directory (catpath) == 1)
+ return catpath;
+ if ((cattype & WHATIS_CATP) == 0) {
+ const char locale_delims[] = "_@,.";
+ const char *delim;
+ for (delim = locale_delims; *delim != '\0'; ++delim) {
+ char * tmp = strrchr (catpath, *delim);
+ if (!tmp)
+ continue;
+ *tmp = '\0';
+ if (is_directory (catpath) == 1)
+ return catpath;
+ }
+ }
+ free (catpath);
}
}
--- src/whatis.c
+++ src/whatis.c 2008-04-21 13:21:57.000000000 +0200
@@ -651,7 +651,7 @@ static int search (char *page)
debug ("lower(%s) = \"%s\"\n", page, lowpage);
for (mp = manpathlist; *mp; mp++) {
- catpath = get_catpath (*mp, SYSTEM_CAT | USER_CAT);
+ catpath = get_catpath (*mp, SYSTEM_CATP|USER_CATP|WHATIS_CATP);
if (catpath) {
database = mkdbname (catpath);
--- src/straycats.c
+++ src/straycats.c 2008-04-21 15:47:04.000000000 +0200
@@ -338,7 +343,7 @@ int straycats (const char *manpath)
return 0;
}
- catpath = get_catpath (manpath, SYSTEM_CAT | USER_CAT);
+ catpath = get_catpath (manpath, SYSTEM_CATP|USER_CATP);
/* look in the usual catpath location */
mandir = xstrdup (manpath);