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

Diff for /mandoc/mandocdb.c between version 1.186 and 1.187

version 1.186, 2015/03/13 00:19:41 version 1.187, 2015/03/27 17:37:25
Line 7 
Line 7 
  * purpose with or without fee is hereby granted, provided that the above   * purpose with or without fee is hereby granted, provided that the above
  * copyright notice and this permission notice appear in all copies.   * copyright notice and this permission notice appear in all copies.
  *   *
  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES   * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF   * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR   * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES   * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN   * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF   * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
Line 50 
Line 50 
 #include "man.h"  #include "man.h"
 #include "mandoc.h"  #include "mandoc.h"
 #include "mandoc_aux.h"  #include "mandoc_aux.h"
 #include "manpath.h"  #include "manconf.h"
 #include "mansearch.h"  #include "mansearch.h"
   
 extern int mansearch_keymax;  extern int mansearch_keymax;
Line 338  static const struct mdoc_handler mdocs[MDOC_MAX] = {
Line 338  static const struct mdoc_handler mdocs[MDOC_MAX] = {
 int  int
 mandocdb(int argc, char *argv[])  mandocdb(int argc, char *argv[])
 {  {
         int               ch, i;          struct manconf    conf;
         size_t            j, sz;  
         const char       *path_arg;  
         struct manpaths   dirs;  
         struct mparse    *mp;  
         struct ohash_info mpages_info, mlinks_info;          struct ohash_info mpages_info, mlinks_info;
           struct mparse    *mp;
           const char       *path_arg;
           size_t            j, sz;
           int               ch, i;
   
           memset(&conf, 0, sizeof(conf));
         memset(stmts, 0, STMT__MAX * sizeof(sqlite3_stmt *));          memset(stmts, 0, STMT__MAX * sizeof(sqlite3_stmt *));
         memset(&dirs, 0, sizeof(struct manpaths));  
   
         mpages_info.alloc  = mlinks_info.alloc  = hash_alloc;          mpages_info.alloc  = mlinks_info.alloc  = hash_alloc;
         mpages_info.calloc = mlinks_info.calloc = hash_calloc;          mpages_info.calloc = mlinks_info.calloc = hash_calloc;
Line 485  mandocdb(int argc, char *argv[])
Line 485  mandocdb(int argc, char *argv[])
                 /*                  /*
                  * If we have arguments, use them as our manpaths.                   * If we have arguments, use them as our manpaths.
                  * If we don't, grok from manpath(1) or however else                   * If we don't, grok from manpath(1) or however else
                  * manpath_parse() wants to do it.                   * manconf_parse() wants to do it.
                  */                   */
                 if (argc > 0) {                  if (argc > 0) {
                         dirs.paths = mandoc_reallocarray(NULL,                          conf.manpath.paths = mandoc_reallocarray(NULL,
                             argc, sizeof(char *));                              argc, sizeof(char *));
                         dirs.sz = (size_t)argc;                          conf.manpath.sz = (size_t)argc;
                         for (i = 0; i < argc; i++)                          for (i = 0; i < argc; i++)
                                 dirs.paths[i] = mandoc_strdup(argv[i]);                                  conf.manpath.paths[i] = mandoc_strdup(argv[i]);
                 } else                  } else
                         manpath_parse(&dirs, path_arg, NULL, NULL);                          manconf_parse(&conf, path_arg, NULL, NULL);
   
                 if (0 == dirs.sz) {                  if (conf.manpath.sz == 0) {
                         exitcode = (int)MANDOCLEVEL_BADARG;                          exitcode = (int)MANDOCLEVEL_BADARG;
                         say("", "Empty manpath");                          say("", "Empty manpath");
                 }                  }
Line 507  mandocdb(int argc, char *argv[])
Line 507  mandocdb(int argc, char *argv[])
                  * Ignore zero-length directories and strip trailing                   * Ignore zero-length directories and strip trailing
                  * slashes.                   * slashes.
                  */                   */
                 for (j = 0; j < dirs.sz; j++) {                  for (j = 0; j < conf.manpath.sz; j++) {
                         sz = strlen(dirs.paths[j]);                          sz = strlen(conf.manpath.paths[j]);
                         if (sz && '/' == dirs.paths[j][sz - 1])                          if (sz && conf.manpath.paths[j][sz - 1] == '/')
                                 dirs.paths[j][--sz] = '\0';                                  conf.manpath.paths[j][--sz] = '\0';
                         if (0 == sz)                          if (0 == sz)
                                 continue;                                  continue;
   
Line 519  mandocdb(int argc, char *argv[])
Line 519  mandocdb(int argc, char *argv[])
                                 ohash_init(&mlinks, 6, &mlinks_info);                                  ohash_init(&mlinks, 6, &mlinks_info);
                         }                          }
   
                         if (0 == set_basedir(dirs.paths[j], argc > 0))                          if ( ! set_basedir(conf.manpath.paths[j], argc > 0))
                                 continue;                                  continue;
                         if (0 == treescan())                          if (0 == treescan())
                                 continue;                                  continue;
Line 532  mandocdb(int argc, char *argv[])
Line 532  mandocdb(int argc, char *argv[])
                                 names_check();                                  names_check();
                         dbclose(0);                          dbclose(0);
   
                         if (j + 1 < dirs.sz) {                          if (j + 1 < conf.manpath.sz) {
                                 mpages_free();                                  mpages_free();
                                 ohash_delete(&mpages);                                  ohash_delete(&mpages);
                                 ohash_delete(&mlinks);                                  ohash_delete(&mlinks);
Line 540  mandocdb(int argc, char *argv[])
Line 540  mandocdb(int argc, char *argv[])
                 }                  }
         }          }
 out:  out:
         manpath_free(&dirs);          manconf_free(&conf);
         mparse_free(mp);          mparse_free(mp);
         mchars_free(mchars);          mchars_free(mchars);
         mpages_free();          mpages_free();

Legend:
Removed from v.1.186  
changed lines
  Added in v.1.187

CVSweb