[BACK]Return to apropos.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/Attic/apropos.c between version 1.27 and 1.27.2.1

version 1.27, 2012/03/24 00:31:55 version 1.27.2.1, 2013/09/17 23:23:10
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>   * Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>   * Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
  *   *
  * Permission to use, copy, modify, and distribute this software for any   * Permission to use, copy, modify, and distribute this software for any
Line 32 
Line 32 
   
 static  int      cmp(const void *, const void *);  static  int      cmp(const void *, const void *);
 static  void     list(struct res *, size_t, void *);  static  void     list(struct res *, size_t, void *);
 static  void     usage(void);  
   
 static  char    *progname;  static  char    *progname;
   
Line 47  main(int argc, char *argv[])
Line 46  main(int argc, char *argv[])
         struct expr     *e;          struct expr     *e;
         char            *defpaths, *auxpaths;          char            *defpaths, *auxpaths;
         char            *conf_file;          char            *conf_file;
         extern int       optind;  
         extern char     *optarg;          extern char     *optarg;
           extern int       optind;
   
         progname = strrchr(argv[0], '/');          progname = strrchr(argv[0], '/');
         if (progname == NULL)          if (progname == NULL)
Line 56  main(int argc, char *argv[])
Line 55  main(int argc, char *argv[])
         else          else
                 ++progname;                  ++progname;
   
         whatis = 0 == strncmp(progname, "whatis", 6);          whatis = (0 == strncmp(progname, "whatis", 6));
   
         memset(&paths, 0, sizeof(struct manpaths));          memset(&paths, 0, sizeof(struct manpaths));
         memset(&opts, 0, sizeof(struct opts));          memset(&opts, 0, sizeof(struct opts));
Line 85  main(int argc, char *argv[])
Line 84  main(int argc, char *argv[])
                         opts.cat = optarg;                          opts.cat = optarg;
                         break;                          break;
                 default:                  default:
                         usage();                          goto usage;
                         return(EXIT_FAILURE);  
                 }                  }
   
         argc -= optind;          argc -= optind;
         argv += optind;          argv += optind;
   
         if (0 == argc)          if (0 == argc)
                 return(EXIT_SUCCESS);                  goto usage;
   
         rc = 0;          rc = 0;
   
Line 115  main(int argc, char *argv[])
Line 113  main(int argc, char *argv[])
                 fprintf(stderr, "%s: Bad database\n", progname);                  fprintf(stderr, "%s: Bad database\n", progname);
                 goto out;                  goto out;
         }          }
   
 out:  out:
         manpath_free(&paths);          manpath_free(&paths);
         resfree(res, ressz);          resfree(res, ressz);
         exprfree(e);          exprfree(e);
         return(rc ? EXIT_SUCCESS : EXIT_FAILURE);          return(rc ? EXIT_SUCCESS : EXIT_FAILURE);
   
   usage:
           fprintf(stderr, "usage: %s [-C file] [-M path] [-m path] "
                           "[-S arch] [-s section]%s ...\n", progname,
                           whatis ? " name" : "\n               expression");
           return(EXIT_FAILURE);
 }  }
   
 /* ARGSUSED */  /* ARGSUSED */
Line 133  list(struct res *res, size_t sz, void *arg)
Line 138  list(struct res *res, size_t sz, void *arg)
         for (i = 0; i < sz; i++) {          for (i = 0; i < sz; i++) {
                 if ( ! res[i].matched)                  if ( ! res[i].matched)
                         continue;                          continue;
                 printf("%s(%s%s%s) - %.70s\n",                  printf("%s(%s%s%s) - %.70s\n",
                                 res[i].title,                                  res[i].title,
                                 res[i].cat,                                  res[i].cat,
                                 *res[i].arch ? "/" : "",                                  *res[i].arch ? "/" : "",
Line 148  cmp(const void *p1, const void *p2)
Line 153  cmp(const void *p1, const void *p2)
   
         return(strcasecmp(((const struct res *)p1)->title,          return(strcasecmp(((const struct res *)p1)->title,
                                 ((const struct res *)p2)->title));                                  ((const struct res *)p2)->title));
 }  
   
 static void  
 usage(void)  
 {  
   
         fprintf(stderr, "usage: %s "  
                         "[-C file] "  
                         "[-M manpath] "  
                         "[-m manpath] "  
                         "[-S arch] "  
                         "[-s section] "  
                         "expression ...\n",  
                         progname);  
 }  }

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.27.2.1

CVSweb