[BACK]Return to apropos.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mandoc

Diff for /src/usr.bin/mandoc/Attic/apropos.c between version 1.15 and 1.16

version 1.15, 2012/01/05 22:07:42 version 1.16, 2012/04/15 11:54:47
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 15 
Line 15 
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF   * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */   */
   #include <sys/param.h>
   
 #include <assert.h>  #include <assert.h>
 #include <getopt.h>  #include <getopt.h>
 #include <stdio.h>  #include <stdio.h>
Line 34 
Line 36 
 apropos(int argc, char *argv[])  apropos(int argc, char *argv[])
 {  {
         int              ch, rc, whatis;          int              ch, rc, whatis;
           struct res      *res;
         struct manpaths  paths;          struct manpaths  paths;
         size_t           terms;          size_t           terms, ressz;
         struct opts      opts;          struct opts      opts;
         struct expr     *e;          struct expr     *e;
         char            *defpaths, *auxpaths;          char            *defpaths, *auxpaths;
Line 54 
Line 57 
         memset(&paths, 0, sizeof(struct manpaths));          memset(&paths, 0, sizeof(struct manpaths));
         memset(&opts, 0, sizeof(struct opts));          memset(&opts, 0, sizeof(struct opts));
   
           ressz = 0;
           res = NULL;
         auxpaths = defpaths = NULL;          auxpaths = defpaths = NULL;
         conf_file = NULL;          conf_file = NULL;
         e = NULL;          e = NULL;
Line 104 
Line 109 
         }          }
   
         rc = apropos_search          rc = apropos_search
                 (paths.sz, paths.paths,                  (paths.sz, paths.paths, &opts,
                  &opts, e, terms, NULL, list);                   e, terms, NULL, &ressz, &res, list);
   
         if (0 == rc)          if (0 == rc) {
                 fprintf(stderr, "%s: Error reading "                  fprintf(stderr, "%s: Bad database\n", progname);
                                 "manual database\n", progname);                  goto out;
           }
 out:  out:
         manpath_free(&paths);          manpath_free(&paths);
           resfree(res, ressz);
         exprfree(e);          exprfree(e);
   
         return(rc ? EXIT_SUCCESS : EXIT_FAILURE);          return(rc ? EXIT_SUCCESS : EXIT_FAILURE);
 }  }
   
Line 122 
Line 127 
 static void  static void
 list(struct res *res, size_t sz, void *arg)  list(struct res *res, size_t sz, void *arg)
 {  {
         int              i;          size_t           i;
   
         qsort(res, sz, sizeof(struct res), cmp);          qsort(res, sz, sizeof(struct res), cmp);
   
         for (i = 0; i < (int)sz; i++)          for (i = 0; i < sz; i++) {
                 printf("%s(%s%s%s) - %.*s\n", res[i].title,                  if ( ! res[i].matched)
                           continue;
                   printf("%s(%s%s%s) - %.70s\n",
                                   res[i].title,
                                 res[i].cat,                                  res[i].cat,
                                 *res[i].arch ? "/" : "",                                  *res[i].arch ? "/" : "",
                                 *res[i].arch ? res[i].arch : "",                                  *res[i].arch ? res[i].arch : "",
                                 70, res[i].desc);                                  res[i].desc);
           }
 }  }
   
 static int  static int

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16