218 |
|
|
219 |
/* The last argument must be NULL */ |
/* The last argument must be NULL */ |
220 |
argp[arg_no] = NULL; |
argp[arg_no] = NULL; |
221 |
|
|
222 |
catman (argp, arg_no); |
catman (argp, arg_no); |
223 |
|
|
224 |
/* don't free the last entry, it's NULL */ |
/* don't free the last entry, it's NULL */ |
250 |
|
|
251 |
/* find all pages that are in the supplied manpath and section and that are |
/* find all pages that are in the supplied manpath and section and that are |
252 |
ultimate source files. */ |
ultimate source files. */ |
253 |
static __inline__ int parse_for_sec (char *manpath, char *section) |
static int parse_for_sec (const char *manpath, const char *section) |
254 |
{ |
{ |
255 |
char *argp[MAX_ARGS]; |
char *argp[MAX_ARGS]; |
256 |
datum key; |
datum key; |
260 |
if (rdopen_db () || dbver_rd (dbf)) |
if (rdopen_db () || dbver_rd (dbf)) |
261 |
return 1; |
return 1; |
262 |
|
|
263 |
argp[arg_no++] = "man"; /* Name of program */ |
argp[arg_no++] = xstrdup ("man"); /* Name of program */ |
264 |
|
|
265 |
#ifdef HAVE_SETLOCALE |
#ifdef HAVE_SETLOCALE |
266 |
/* As we supply a NULL environment to save precious execve() space, |
/* As we supply a NULL environment to save precious execve() space, |
267 |
we must also supply a locale if necessary */ |
we must also supply a locale if necessary */ |
268 |
if (locale) { |
if (locale) { |
269 |
argp[arg_no++] = "-L"; /* locale option */ |
argp[arg_no++] = xstrdup ("-L"); /* locale option */ |
270 |
argp[arg_no++] = locale; /* The locale */ |
argp[arg_no++] = xstrdup (locale); /* The locale */ |
271 |
initial_bit += sizeof "-L" + strlen (locale) + 1; |
initial_bit += sizeof "-L" + strlen (locale) + 1; |
272 |
} else |
} else |
273 |
initial_bit = 0; |
initial_bit = 0; |
274 |
|
|
275 |
#endif /* HAVE_SETLOCALE */ |
#endif /* HAVE_SETLOCALE */ |
276 |
|
|
277 |
argp[arg_no++] = "-caM"; /* options */ |
argp[arg_no++] = xstrdup ("-caM"); /* options */ |
278 |
argp[arg_no++] = manpath; /* particular manpath */ |
argp[arg_no++] = xstrdup (manpath); /* particular manpath */ |
279 |
argp[arg_no++] = section; /* particular section */ |
argp[arg_no++] = xstrdup (section); /* particular section */ |
280 |
|
|
281 |
first_arg = arg_no; /* first pagename argument */ |
first_arg = arg_no; /* first pagename argument */ |
282 |
|
|
365 |
if (arg_no > first_arg) |
if (arg_no > first_arg) |
366 |
do_catman (argp, arg_no, first_arg); |
do_catman (argp, arg_no, first_arg); |
367 |
|
|
368 |
|
arg_no = first_arg - 1; |
369 |
|
while (arg_no >= 0) |
370 |
|
free (argp[arg_no--]); |
371 |
|
|
372 |
return 0; |
return 0; |
373 |
} |
} |
374 |
|
|
386 |
{ |
{ |
387 |
int c; |
int c; |
388 |
char *sys_manp; |
char *sys_manp; |
389 |
char **mp, **sections; |
char **mp; |
390 |
|
const char **sections; |
391 |
|
|
392 |
int option_index; /* not used, but required by getopt_long() */ |
int option_index; /* not used, but required by getopt_long() */ |
393 |
|
|
399 |
/* Obviously can't translate this. */ |
/* Obviously can't translate this. */ |
400 |
error (0, 0, "can't set the locale; make sure $LC_* and $LANG " |
error (0, 0, "can't set the locale; make sure $LC_* and $LANG " |
401 |
"are correct"); |
"are correct"); |
402 |
locale = "C"; |
locale = xstrdup ("C"); |
403 |
} |
} |
404 |
bindtextdomain (PACKAGE, LOCALEDIR); |
bindtextdomain (PACKAGE, LOCALEDIR); |
405 |
textdomain (PACKAGE); |
textdomain (PACKAGE); |
433 |
|
|
434 |
/* If we were supplied sections: sort them out */ |
/* If we were supplied sections: sort them out */ |
435 |
if (optind != argc) { |
if (optind != argc) { |
436 |
char **sp; |
const char **sp; |
437 |
|
|
438 |
sections = sp = (char **) xmalloc ((argc - optind + 1) * |
sections = sp = xmalloc ((argc - optind + 1) * |
439 |
sizeof (char *)); |
sizeof *sections); |
440 |
while (optind != argc) |
while (optind != argc) |
441 |
*sp++ = argv[optind++]; |
*sp++ = argv[optind++]; |
442 |
*sp = NULL; |
*sp = NULL; |
446 |
mansect = getenv ("MANSECT"); |
mansect = getenv ("MANSECT"); |
447 |
if (mansect && *mansect) { |
if (mansect && *mansect) { |
448 |
/* MANSECT contains sections */ |
/* MANSECT contains sections */ |
449 |
char *sec; |
const char *sec; |
450 |
int i = 0; |
int i = 0; |
451 |
|
|
452 |
mansect = xstrdup (mansect); |
mansect = xstrdup (mansect); |
453 |
sections = NULL; |
sections = NULL; |
454 |
for (sec = strtok (mansect, ":"); sec; |
for (sec = strtok (mansect, ":"); sec; |
455 |
sec = strtok (NULL, ":")) { |
sec = strtok (NULL, ":")) { |
456 |
sections = (char **) xrealloc (sections, |
sections = xrealloc (sections, |
457 |
(i + 2) * |
(i + 2) * |
458 |
sizeof (char *)); |
sizeof *sections); |
459 |
sections[i++] = sec; |
sections[i++] = sec; |
460 |
} |
} |
461 |
sections[i] = NULL; |
sections[i] = NULL; |
462 |
|
free (mansect); |
463 |
} else { |
} else { |
464 |
/* use default sections */ |
/* use default sections */ |
465 |
static char *std_sections[] = STD_SECTIONS; |
static const char *std_sections[] = STD_SECTIONS; |
466 |
sections = std_sections; |
sections = std_sections; |
467 |
} |
} |
468 |
} |
} |
469 |
|
|
470 |
if (debug) { |
if (debug) { |
471 |
char **sp; |
const char **sp; |
472 |
|
|
473 |
for (sp = sections; *sp; sp++) |
for (sp = sections; *sp; sp++) |
474 |
fprintf (stderr, "sections: %s\n", *sp); |
fprintf (stderr, "sections: %s\n", *sp); |
493 |
create_pathlist (manp, manpathlist); |
create_pathlist (manp, manpathlist); |
494 |
|
|
495 |
for (mp = manpathlist; *mp; mp++) { |
for (mp = manpathlist; *mp; mp++) { |
496 |
char *catpath, **sp; |
char *catpath; |
497 |
|
const char **sp; |
498 |
size_t len; |
size_t len; |
499 |
|
|
500 |
catpath = get_catpath (*mp, SYSTEM_CAT | USER_CAT); |
catpath = get_catpath (*mp, SYSTEM_CAT | USER_CAT); |