127 |
static __inline__ char *fsstnd (const char *path); |
static __inline__ char *fsstnd (const char *path); |
128 |
static char *def_path (int flag); |
static char *def_path (int flag); |
129 |
static void add_dir_to_list (char **lp, const char *dir); |
static void add_dir_to_list (char **lp, const char *dir); |
130 |
static char **add_dir_to_path_list (char **mp, const char *p); |
static char **add_dir_to_path_list (char **mphead, char **mp, const char *p); |
131 |
|
|
132 |
|
|
133 |
static void add_to_list (const char *key, const char *cont, int flag) |
static void add_to_list (const char *key, const char *cont, int flag) |
347 |
error (0, 0, _("warning: %s isn't a directory"), dir); |
error (0, 0, _("warning: %s isn't a directory"), dir); |
348 |
} |
} |
349 |
|
|
350 |
|
static void gripe_overlong_list (void) |
351 |
|
{ |
352 |
|
error (FAIL, 0, _("manpath list too long")); |
353 |
|
} |
354 |
|
|
355 |
/* accept a manpath list, separated with ':', return the associated |
/* accept a manpath list, separated with ':', return the associated |
356 |
catpath list */ |
catpath list */ |
947 |
static void add_dir_to_list (char **lp, const char *dir) |
static void add_dir_to_list (char **lp, const char *dir) |
948 |
{ |
{ |
949 |
int status; |
int status; |
950 |
|
int pos = 0; |
951 |
|
|
952 |
while (*lp != NULL) { |
while (*lp != NULL) { |
953 |
|
if (pos > MAXDIRS - 1) |
954 |
|
gripe_overlong_list (); |
955 |
if (!strcmp (*lp, dir)) { |
if (!strcmp (*lp, dir)) { |
956 |
if (debug) |
if (debug) |
957 |
fprintf (stderr, |
fprintf (stderr, |
960 |
return; |
return; |
961 |
} |
} |
962 |
lp++; |
lp++; |
963 |
|
pos++; |
964 |
} |
} |
965 |
|
|
966 |
/* Not found -- add it. */ |
/* Not found -- add it. */ |
1010 |
return NULL; |
return NULL; |
1011 |
} |
} |
1012 |
|
|
1013 |
static __inline__ char **add_dir_to_path_list (char **mp, const char *p) |
static char **add_dir_to_path_list (char **mphead, char **mp, const char *p) |
1014 |
{ |
{ |
1015 |
int status; |
int status; |
1016 |
char wd[PATH_MAX]; |
char wd[PATH_MAX]; |
1017 |
char *cwd = wd; |
char *cwd = wd; |
1018 |
|
|
1019 |
|
if (mp - mphead > MAXDIRS - 1) |
1020 |
|
gripe_overlong_list (); |
1021 |
|
|
1022 |
status = is_directory (p); |
status = is_directory (p); |
1023 |
|
|
1024 |
if (status < 0) |
if (status < 0) |
1048 |
void create_pathlist (const char *manp, char **mp) |
void create_pathlist (const char *manp, char **mp) |
1049 |
{ |
{ |
1050 |
const char *p, *end; |
const char *p, *end; |
1051 |
|
char **mphead = mp; |
1052 |
|
|
1053 |
/* Expand the manpath into a list for easier handling. */ |
/* Expand the manpath into a list for easier handling. */ |
1054 |
|
|
1055 |
for (p = manp;; p = end + 1) { |
for (p = manp;; p = end + 1) { |
1056 |
end = strchr (p, ':'); |
end = strchr (p, ':'); |
1057 |
if (end) |
if (end) |
1058 |
mp = add_dir_to_path_list (mp, xstrndup (p, end - p)); |
mp = add_dir_to_path_list (mphead, mp, |
1059 |
|
xstrndup (p, end - p)); |
1060 |
else { |
else { |
1061 |
mp = add_dir_to_path_list (mp, p); |
mp = add_dir_to_path_list (mphead, mp, p); |
1062 |
break; |
break; |
1063 |
} |
} |
1064 |
} |
} |