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

Diff for /mandoc/mandocdb.c between version 1.201 and 1.202

version 1.201, 2015/10/12 21:17:15 version 1.202, 2015/10/13 15:53:05
Line 40 
Line 40 
 #include <string.h>  #include <string.h>
 #include <unistd.h>  #include <unistd.h>
   
 #if HAVE_OHASH  
 #include <ohash.h>  
 #else  
 #include "compat_ohash.h"  
 #endif  
 #include <sqlite3.h>  #include <sqlite3.h>
   
 #include "mandoc_aux.h"  #include "mandoc_aux.h"
   #include "mandoc_ohash.h"
 #include "mandoc.h"  #include "mandoc.h"
 #include "roff.h"  #include "roff.h"
 #include "mdoc.h"  #include "mdoc.h"
Line 146  static void  dbadd_mlink_name(const struct mlink *mlin
Line 142  static void  dbadd_mlink_name(const struct mlink *mlin
 static  int      dbopen(int);  static  int      dbopen(int);
 static  void     dbprune(void);  static  void     dbprune(void);
 static  void     filescan(const char *);  static  void     filescan(const char *);
 static  void    *hash_alloc(size_t, void *);  
 static  void     hash_free(void *, void *);  
 static  void    *hash_calloc(size_t, size_t, void *);  
 static  void     mlink_add(struct mlink *, const struct stat *);  static  void     mlink_add(struct mlink *, const struct stat *);
 static  void     mlink_check(struct mpage *, struct mlink *);  static  void     mlink_check(struct mpage *, struct mlink *);
 static  void     mlink_free(struct mlink *);  static  void     mlink_free(struct mlink *);
Line 342  int
Line 335  int
 mandocdb(int argc, char *argv[])  mandocdb(int argc, char *argv[])
 {  {
         struct manconf    conf;          struct manconf    conf;
         struct ohash_info mpages_info, mlinks_info;  
         struct mparse    *mp;          struct mparse    *mp;
         const char       *path_arg;          const char       *path_arg;
         size_t            j, sz;          size_t            j, sz;
Line 351  mandocdb(int argc, char *argv[])
Line 343  mandocdb(int argc, char *argv[])
         memset(&conf, 0, sizeof(conf));          memset(&conf, 0, sizeof(conf));
         memset(stmts, 0, STMT__MAX * sizeof(sqlite3_stmt *));          memset(stmts, 0, STMT__MAX * sizeof(sqlite3_stmt *));
   
         mpages_info.alloc  = mlinks_info.alloc  = hash_alloc;  
         mpages_info.calloc = mlinks_info.calloc = hash_calloc;  
         mpages_info.free   = mlinks_info.free   = hash_free;  
         mpages_info.data   = mlinks_info.data   = NULL;  
   
         mpages_info.key_offset = offsetof(struct mpage, inodev);  
         mlinks_info.key_offset = offsetof(struct mlink, file);  
   
         /*          /*
          * We accept a few different invocations.           * We accept a few different invocations.
          * The CHECKOP macro makes sure that invocation styles don't           * The CHECKOP macro makes sure that invocation styles don't
Line 438  mandocdb(int argc, char *argv[])
Line 422  mandocdb(int argc, char *argv[])
         mchars = mchars_alloc();          mchars = mchars_alloc();
         mp = mparse_alloc(mparse_options, MANDOCLEVEL_BADARG, NULL,          mp = mparse_alloc(mparse_options, MANDOCLEVEL_BADARG, NULL,
             mchars, NULL);              mchars, NULL);
         ohash_init(&mpages, 6, &mpages_info);          mandoc_ohash_init(&mpages, 6, offsetof(struct mpage, inodev));
         ohash_init(&mlinks, 6, &mlinks_info);          mandoc_ohash_init(&mlinks, 6, offsetof(struct mlink, file));
   
         if (OP_UPDATE == op || OP_DELETE == op || OP_TEST == op) {          if (OP_UPDATE == op || OP_DELETE == op || OP_TEST == op) {
   
Line 509  mandocdb(int argc, char *argv[])
Line 493  mandocdb(int argc, char *argv[])
                                 continue;                                  continue;
   
                         if (j) {                          if (j) {
                                 ohash_init(&mpages, 6, &mpages_info);                                  mandoc_ohash_init(&mpages, 6,
                                 ohash_init(&mlinks, 6, &mlinks_info);                                      offsetof(struct mpage, inodev));
                                   mandoc_ohash_init(&mlinks, 6,
                                       offsetof(struct mlink, file));
                         }                          }
   
                         if ( ! set_basedir(conf.manpath.paths[j], argc > 0))                          if ( ! set_basedir(conf.manpath.paths[j], argc > 0))
Line 1099  static void
Line 1085  static void
 mpages_merge(struct mparse *mp)  mpages_merge(struct mparse *mp)
 {  {
         char                     any[] = "any";          char                     any[] = "any";
         struct ohash_info        str_info;  
         struct mpage            *mpage, *mpage_dest;          struct mpage            *mpage, *mpage_dest;
         struct mlink            *mlink, *mlink_dest;          struct mlink            *mlink, *mlink_dest;
         struct roff_man         *man;          struct roff_man         *man;
Line 1108  mpages_merge(struct mparse *mp)
Line 1093  mpages_merge(struct mparse *mp)
         int                      fd;          int                      fd;
         unsigned int             pslot;          unsigned int             pslot;
   
         str_info.alloc = hash_alloc;  
         str_info.calloc = hash_calloc;  
         str_info.free = hash_free;  
         str_info.data = NULL;  
         str_info.key_offset = offsetof(struct str, key);  
   
         if ( ! nodb)          if ( ! nodb)
                 SQL_EXEC("BEGIN TRANSACTION");                  SQL_EXEC("BEGIN TRANSACTION");
   
Line 1126  mpages_merge(struct mparse *mp)
Line 1105  mpages_merge(struct mparse *mp)
                 }                  }
   
                 name_mask = NAME_MASK;                  name_mask = NAME_MASK;
                 ohash_init(&names, 4, &str_info);                  mandoc_ohash_init(&names, 4, offsetof(struct str, key));
                 ohash_init(&strings, 6, &str_info);                  mandoc_ohash_init(&strings, 6, offsetof(struct str, key));
                 mparse_reset(mp);                  mparse_reset(mp);
                 man = NULL;                  man = NULL;
                 sodest = NULL;                  sodest = NULL;
Line 2382  prepare_statements:
Line 2361  prepare_statements:
 #endif  #endif
   
         return 1;          return 1;
 }  
   
 static void *  
 hash_calloc(size_t n, size_t sz, void *arg)  
 {  
   
         return mandoc_calloc(n, sz);  
 }  
   
 static void *  
 hash_alloc(size_t sz, void *arg)  
 {  
   
         return mandoc_malloc(sz);  
 }  
   
 static void  
 hash_free(void *p, void *arg)  
 {  
   
         free(p);  
 }  }
   
 static int  static int

Legend:
Removed from v.1.201  
changed lines
  Added in v.1.202

CVSweb