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

Diff for /mandoc/Attic/apropos_db.c between version 1.9 and 1.10

version 1.9, 2011/11/20 15:45:37 version 1.10, 2011/11/20 16:29:50
Line 374  index_read(const DBT *key, const DBT *val, 
Line 374  index_read(const DBT *key, const DBT *val, 
 }  }
   
 /*  /*
  * Search mandocdb databases in argv (size argc) for the expression   * Search mandocdb databases in paths for expression "expr".
  * "expr".  
  * Filter out by "opts".   * Filter out by "opts".
  * Call "res" with the results, which may be zero.   * Call "res" with the results, which may be zero.
  * Return 0 if there was a database error, else return 1.   * Return 0 if there was a database error, else return 1.
  */   */
 int  int
 apropos_search(int argc, char *argv[], const struct opts *opts,  apropos_search(int pathsz, char **paths, const struct opts *opts,
                 const struct expr *expr, size_t terms, void *arg,                  const struct expr *expr, size_t terms, void *arg,
                 void (*res)(struct res *, size_t, void *))                  void (*res)(struct res *, size_t, void *))
 {  {
Line 392  apropos_search(int argc, char *argv[], const struct op
Line 391  apropos_search(int argc, char *argv[], const struct op
   
         memset(&tree, 0, sizeof(struct rectree));          memset(&tree, 0, sizeof(struct rectree));
   
           rc = 0;
         mc = mchars_alloc();          mc = mchars_alloc();
   
         for (rc = 1, i = 0; rc && i < argc; i++) {          /*
                 /* FIXME: ugly warning: we shouldn't get here! */           * Main loop.  Change into the directory containing manpage
                 if (chdir(argv[i]))           * databases.  Run our expession over each database in the set.
            */
   
           for (i = 0; i < pathsz; i++) {
                   if (chdir(paths[i]))
                         continue;                          continue;
                 rc = single_search(&tree, opts, expr, terms, mc);                  if ( ! single_search(&tree, opts, expr, terms, mc))
                 /* FIXME: warn and continue... ? */                          goto out;
         }          }
   
         /*          /*
          * Count the matching files           * Count matching files, transfer to a "clean" array, then feed
          * and feed them to the output handler.           * them to the output handler.
          */           */
   
         for (mlen = i = 0; i < tree.len; i++)          for (mlen = i = 0; i < tree.len; i++)
Line 421  apropos_search(int argc, char *argv[], const struct op
Line 425  apropos_search(int argc, char *argv[], const struct op
         (*res)(ress, mlen, arg);          (*res)(ress, mlen, arg);
         free(ress);          free(ress);
   
           rc = 1;
   out:
         for (i = 0; i < tree.len; i++)          for (i = 0; i < tree.len; i++)
                 recfree(&tree.node[i]);                  recfree(&tree.node[i]);
   
Line 454  single_search(struct rectree *tree, const struct opts 
Line 460  single_search(struct rectree *tree, const struct opts 
         memset(&r, 0, sizeof(struct rec));          memset(&r, 0, sizeof(struct rec));
   
         if (NULL == (btree = btree_open()))          if (NULL == (btree = btree_open()))
                 return(0);                  return(1);
   
         if (NULL == (idx = index_open())) {          if (NULL == (idx = index_open())) {
                 (*btree->close)(btree);                  (*btree->close)(btree);
                 return(0);                  return(1);
         }          }
   
         while (0 == (ch = (*btree->seq)(btree, &key, &val, R_NEXT))) {          while (0 == (ch = (*btree->seq)(btree, &key, &val, R_NEXT))) {

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

CVSweb