/[man-db]/man-db/src/catman.c
ViewVC logotype

Diff of /man-db/src/catman.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by cjwatson, Mon Apr 28 14:12:43 2003 UTC revision 1.12 by cjwatson, Thu May 1 15:54:03 2003 UTC
# Line 218  static void do_catman (char *argp[], int Line 218  static void do_catman (char *argp[], int
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 */
# Line 250  static __inline__ void reset_cursor (dat Line 250  static __inline__ void reset_cursor (dat
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;
# Line 260  static __inline__ int parse_for_sec (cha Line 260  static __inline__ int parse_for_sec (cha
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                    
# Line 365  static __inline__ int parse_for_sec (cha Line 365  static __inline__ int parse_for_sec (cha
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    
# Line 382  int main (int argc, char *argv[]) Line 386  int main (int argc, char *argv[])
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    
# Line 394  int main (int argc, char *argv[]) Line 399  int main (int argc, char *argv[])
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);
# Line 428  int main (int argc, char *argv[]) Line 433  int main (int argc, char *argv[])
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;
# Line 441  int main (int argc, char *argv[]) Line 446  int main (int argc, char *argv[])
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);
# Line 487  int main (int argc, char *argv[]) Line 493  int main (int argc, char *argv[])
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);

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26