182 |
pager = "more"; |
pager = "more"; |
183 |
} |
} |
184 |
|
|
185 |
/* Parse man.conf */ |
/* Parse man.conf[ig] */ |
186 |
parser = config_open2("/etc/man.conf", fopen_for_read); |
/* man version 1.6f uses man.config */ |
187 |
|
parser = config_open2("/etc/man.config", fopen_for_read); |
188 |
|
if (!parser) |
189 |
|
parser = config_open2("/etc/man.conf", fopen_for_read); |
190 |
|
|
191 |
while (config_read(parser, token, 2, 0, "# \t", PARSE_NORMAL)) { |
while (config_read(parser, token, 2, 0, "# \t", PARSE_NORMAL)) { |
192 |
if (!token[1]) |
if (!token[1]) |
193 |
continue; |
continue; |
194 |
if (strcmp("MANPATH", token[0]) == 0) { |
if (strcmp("MANPATH", token[0]) == 0) { |
195 |
/* Do we already have it? */ |
char *path = token[1]; |
196 |
char **path_element = man_path_list; |
while (*path) { |
197 |
while (*path_element) { |
char *next_path; |
198 |
if (strcmp(*path_element, token[1]) == 0) |
char **path_element; |
199 |
goto skip; |
|
200 |
path_element++; |
next_path = strchr(path, ':'); |
201 |
|
if (next_path) { |
202 |
|
*next_path = '\0'; |
203 |
|
if (next_path++ == path) /* "::"? */ |
204 |
|
goto next; |
205 |
|
} |
206 |
|
/* Do we already have path? */ |
207 |
|
path_element = man_path_list; |
208 |
|
while (*path_element) { |
209 |
|
if (strcmp(*path_element, path) == 0) |
210 |
|
goto skip; |
211 |
|
path_element++; |
212 |
|
} |
213 |
|
man_path_list = xrealloc_vector(man_path_list, 4, count_mp); |
214 |
|
man_path_list[count_mp] = xstrdup(path); |
215 |
|
count_mp++; |
216 |
|
/* man_path_list is NULL terminated */ |
217 |
|
/*man_path_list[count_mp] = NULL; - xrealloc_vector did it */ |
218 |
|
skip: |
219 |
|
if (!next_path) |
220 |
|
break; |
221 |
|
next: |
222 |
|
path = next_path; |
223 |
} |
} |
|
man_path_list = xrealloc_vector(man_path_list, 4, count_mp); |
|
|
man_path_list[count_mp] = xstrdup(token[1]); |
|
|
count_mp++; |
|
|
/* man_path_list is NULL terminated */ |
|
|
/*man_path_list[count_mp] = NULL; - xrealloc_vector did it */ |
|
224 |
} |
} |
225 |
if (strcmp("MANSECT", token[0]) == 0) { |
if (strcmp("MANSECT", token[0]) == 0) { |
226 |
free(sec_list); |
free(sec_list); |
227 |
sec_list = xstrdup(token[1]); |
sec_list = xstrdup(token[1]); |
228 |
} |
} |
|
skip: ; |
|
229 |
} |
} |
230 |
config_close(parser); |
config_close(parser); |
231 |
|
|
240 |
} |
} |
241 |
while ((cur_path = man_path_list[cur_mp++]) != NULL) { |
while ((cur_path = man_path_list[cur_mp++]) != NULL) { |
242 |
/* for each MANPATH */ |
/* for each MANPATH */ |
243 |
do { /* for each MANPATH item */ |
cur_sect = sec_list; |
244 |
char *next_path = strchrnul(cur_path, ':'); |
do { /* for each section */ |
245 |
int path_len = next_path - cur_path; |
char *next_sect = strchrnul(cur_sect, ':'); |
246 |
cur_sect = sec_list; |
int sect_len = next_sect - cur_sect; |
247 |
do { /* for each section */ |
char *man_filename; |
248 |
char *next_sect = strchrnul(cur_sect, ':'); |
int cat0man1 = 0; |
249 |
int sect_len = next_sect - cur_sect; |
|
250 |
char *man_filename; |
/* Search for cat, then man page */ |
251 |
int cat0man1 = 0; |
while (cat0man1 < 2) { |
252 |
|
int found_here; |
253 |
/* Search for cat, then man page */ |
man_filename = xasprintf("%s/%s%.*s/%s.%.*s" Z_SUFFIX, |
254 |
while (cat0man1 < 2) { |
cur_path, |
255 |
int found_here; |
"cat\0man" + (cat0man1 * 4), |
256 |
man_filename = xasprintf("%.*s/%s%.*s/%s.%.*s" Z_SUFFIX, |
sect_len, cur_sect, |
257 |
path_len, cur_path, |
*argv, |
258 |
"cat\0man" + (cat0man1 * 4), |
sect_len, cur_sect); |
259 |
sect_len, cur_sect, |
found_here = show_manpage(pager, man_filename, cat0man1, 0); |
260 |
*argv, |
found |= found_here; |
261 |
sect_len, cur_sect); |
cat0man1 += found_here + 1; |
262 |
found_here = show_manpage(pager, man_filename, cat0man1, 0); |
free(man_filename); |
263 |
found |= found_here; |
} |
264 |
cat0man1 += found_here + 1; |
|
265 |
free(man_filename); |
if (found && !(opt & OPT_a)) |
266 |
} |
goto next_arg; |
267 |
|
cur_sect = next_sect; |
268 |
if (found && !(opt & OPT_a)) |
while (*cur_sect == ':') |
269 |
goto next_arg; |
cur_sect++; |
270 |
cur_sect = next_sect; |
} while (*cur_sect); |
|
while (*cur_sect == ':') |
|
|
cur_sect++; |
|
|
} while (*cur_sect); |
|
|
cur_path = next_path; |
|
|
while (*cur_path == ':') |
|
|
cur_path++; |
|
|
} while (*cur_path); |
|
271 |
} |
} |
272 |
check_found: |
check_found: |
273 |
if (!found) { |
if (!found) { |