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

Diff for /mandoc/mandocdb.c between version 1.69 and 1.74

version 1.69, 2013/07/02 11:40:40 version 1.74, 2013/10/27 16:09:44
Line 140  static int  inocheck(const struct stat *);
Line 140  static int  inocheck(const struct stat *);
 static  void     ofadd(int, const char *, const char *, const char *,  static  void     ofadd(int, const char *, const char *, const char *,
                         const char *, const char *, const struct stat *);                          const char *, const char *, const struct stat *);
 static  void     offree(void);  static  void     offree(void);
 static  void     ofmerge(struct mchars *, struct mparse *,  static  void     ofmerge(struct mchars *, struct mparse *, int);
                         struct ohash_info*, int);  
 static  void     parse_catpage(struct of *);  static  void     parse_catpage(struct of *);
 static  void     parse_man(struct of *, const struct man_node *);  static  void     parse_man(struct of *, const struct man_node *);
 static  void     parse_mdoc(struct of *, const struct mdoc_node *);  static  void     parse_mdoc(struct of *, const struct mdoc_node *);
Line 316  main(int argc, char *argv[])
Line 315  main(int argc, char *argv[])
         struct mchars    *mc;          struct mchars    *mc;
         struct manpaths   dirs;          struct manpaths   dirs;
         struct mparse    *mp;          struct mparse    *mp;
         struct ohash_info ino_info, filename_info, str_info;          struct ohash_info ino_info, filename_info;
   
         memset(stmts, 0, STMT__MAX * sizeof(sqlite3_stmt *));          memset(stmts, 0, STMT__MAX * sizeof(sqlite3_stmt *));
         memset(&dirs, 0, sizeof(struct manpaths));          memset(&dirs, 0, sizeof(struct manpaths));
   
         ino_info.halloc = filename_info.halloc =          ino_info.alloc  = filename_info.alloc  = hash_alloc;
                 str_info.halloc = hash_halloc;          ino_info.halloc = filename_info.halloc = hash_halloc;
         ino_info.hfree = filename_info.hfree =          ino_info.hfree  = filename_info.hfree  = hash_free;
                 str_info.hfree = hash_free;  
         ino_info.alloc = filename_info.alloc =  
                 str_info.alloc = hash_alloc;  
   
         ino_info.key_offset = offsetof(struct of, id);          ino_info.key_offset = offsetof(struct of, id);
         filename_info.key_offset = offsetof(struct of, file);          filename_info.key_offset = offsetof(struct of, file);
         str_info.key_offset = offsetof(struct str, key);  
   
         progname = strrchr(argv[0], '/');          progname = strrchr(argv[0], '/');
         if (progname == NULL)          if (progname == NULL)
Line 427  main(int argc, char *argv[])
Line 422  main(int argc, char *argv[])
                 if (OP_TEST != op)                  if (OP_TEST != op)
                         dbprune();                          dbprune();
                 if (OP_DELETE != op)                  if (OP_DELETE != op)
                         ofmerge(mc, mp, &str_info, 0);                          ofmerge(mc, mp, 0);
                 dbclose(1);                  dbclose(1);
         } else {          } else {
                 /*                  /*
Line 471  main(int argc, char *argv[])
Line 466  main(int argc, char *argv[])
                         if (0 == dbopen(0))                          if (0 == dbopen(0))
                                 goto out;                                  goto out;
   
                         /*                          ofmerge(mc, mp, warnings && !use_all);
                          * Since we're opening up a new database, we can  
                          * turn off synchronous mode for much better  
                          * performance.  
                          */  
 #ifndef __APPLE__  
                         SQL_EXEC("PRAGMA synchronous = OFF");  
 #endif  
   
                         ofmerge(mc, mp, &str_info, warnings && !use_all);  
                         dbclose(0);                          dbclose(0);
   
                         if (j + 1 < dirs.sz) {                          if (j + 1 < dirs.sz) {
Line 699  filescan(const char *file)
Line 685  filescan(const char *file)
                 exitcode = (int)MANDOCLEVEL_BADARG;                  exitcode = (int)MANDOCLEVEL_BADARG;
                 say(file, NULL);                  say(file, NULL);
                 return;                  return;
         } else if (strstr(buf, basedir) != buf) {          } else if (OP_TEST != op && strstr(buf, basedir) != buf) {
                 exitcode = (int)MANDOCLEVEL_BADARG;                  exitcode = (int)MANDOCLEVEL_BADARG;
                 say("", "%s: outside base directory", buf);                  say("", "%s: outside base directory", buf);
                 return;                  return;
Line 850  ofadd(int dform, const char *file, const char *name, c
Line 836  ofadd(int dform, const char *file, const char *name, c
         if (NULL == arch)          if (NULL == arch)
                 arch = "";                  arch = "";
   
         sform = FORM_NONE;          if ('0' == *sec) {
         if (NULL != sec && *sec <= '9' && *sec >= '1')  
                 sform = FORM_SRC;  
         else if (NULL != sec && *sec == '0') {  
                 sec = dsec;                  sec = dsec;
                 sform = FORM_CAT;                  sform = FORM_CAT;
         }          } else if ('1' <= *sec && '9' >= *sec)
                   sform = FORM_SRC;
           else
                   sform = FORM_NONE;
   
         of = mandoc_calloc(1, sizeof(struct of));          of = mandoc_calloc(1, sizeof(struct of));
         strlcpy(of->file, file, PATH_MAX);          strlcpy(of->file, file, PATH_MAX);
Line 901  offree(void)
Line 887  offree(void)
  * and filename to determine whether the file is parsable or not.   * and filename to determine whether the file is parsable or not.
  */   */
 static void  static void
 ofmerge(struct mchars *mc, struct mparse *mp,  ofmerge(struct mchars *mc, struct mparse *mp, int check_reachable)
                 struct ohash_info *infop, int check_reachable)  
 {  {
         struct ohash             title_table;          struct ohash             title_table;
         struct ohash_info        title_info;          struct ohash_info        title_info, str_info;
         char                     buf[PATH_MAX];          char                     buf[PATH_MAX];
         struct of               *of;          struct of               *of;
         struct mdoc             *mdoc;          struct mdoc             *mdoc;
Line 919  ofmerge(struct mchars *mc, struct mparse *mp,
Line 904  ofmerge(struct mchars *mc, struct mparse *mp,
         unsigned int             slot;          unsigned int             slot;
         enum mandoclevel         lvl;          enum mandoclevel         lvl;
   
           str_info.alloc = hash_alloc;
           str_info.halloc = hash_halloc;
           str_info.hfree = hash_free;
           str_info.key_offset = offsetof(struct str, key);
   
         if (check_reachable) {          if (check_reachable) {
                 title_info.alloc = hash_alloc;                  title_info.alloc = hash_alloc;
                 title_info.halloc = hash_halloc;                  title_info.halloc = hash_halloc;
Line 956  ofmerge(struct mchars *mc, struct mparse *mp,
Line 946  ofmerge(struct mchars *mc, struct mparse *mp,
                         }                          }
                 }                  }
   
                 ohash_init(&strings, 6, infop);                  ohash_init(&strings, 6, &str_info);
                 mparse_reset(mp);                  mparse_reset(mp);
                 mdoc = NULL;                  mdoc = NULL;
                 man = NULL;                  man = NULL;
Line 1802  dbindex(struct mchars *mc, int form, const struct of *
Line 1792  dbindex(struct mchars *mc, int form, const struct of *
                 return;                  return;
   
         desc = "";          desc = "";
         if (NULL != of->desc) {          if (NULL != of->desc && '\0' != *of->desc) {
                 key = ohash_find(&strings,                  key = ohash_find(&strings,
                         ohash_qlookup(&strings, of->desc));                          ohash_qlookup(&strings, of->desc));
                 assert(NULL != key);                  assert(NULL != key);
Line 1972  prepare_statements:
Line 1962  prepare_statements:
         sql = "INSERT INTO keys "          sql = "INSERT INTO keys "
                 "(bits,key,docid) VALUES (?,?,?)";                  "(bits,key,docid) VALUES (?,?,?)";
         sqlite3_prepare_v2(db, sql, -1, &stmts[STMT_INSERT_KEY], NULL);          sqlite3_prepare_v2(db, sql, -1, &stmts[STMT_INSERT_KEY], NULL);
   
   #ifndef __APPLE__
           /*
            * When opening a new database, we can turn off
            * synchronous mode for much better performance.
            */
   
           if (real)
                   SQL_EXEC("PRAGMA synchronous = OFF");
   #endif
   
         return(1);          return(1);
 }  }
   

Legend:
Removed from v.1.69  
changed lines
  Added in v.1.74

CVSweb