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

Diff for /mandoc/mandocdb.c between version 1.164 and 1.168

version 1.164, 2014/09/07 03:08:47 version 1.168, 2014/10/28 17:36:19
Line 169  static void  putmdockey(const struct mpage *,
Line 169  static void  putmdockey(const struct mpage *,
                         const struct mdoc_node *, uint64_t);                          const struct mdoc_node *, uint64_t);
 static  void     render_key(struct mchars *, struct str *);  static  void     render_key(struct mchars *, struct str *);
 static  void     say(const char *, const char *, ...);  static  void     say(const char *, const char *, ...);
 static  int      set_basedir(const char *);  static  int      set_basedir(const char *, int);
 static  int      treescan(void);  static  int      treescan(void);
 static  size_t   utf8(unsigned int, char [7]);  static  size_t   utf8(unsigned int, char [7]);
   
Line 315  static const struct mdoc_handler mdocs[MDOC_MAX] = {
Line 315  static const struct mdoc_handler mdocs[MDOC_MAX] = {
         { NULL, 0 },  /* sp */          { NULL, 0 },  /* sp */
         { NULL, 0 },  /* %U */          { NULL, 0 },  /* %U */
         { NULL, 0 },  /* Ta */          { NULL, 0 },  /* Ta */
           { NULL, 0 },  /* ll */
 };  };
   
   
Line 424  main(int argc, char *argv[])
Line 425  main(int argc, char *argv[])
         }          }
   
         exitcode = (int)MANDOCLEVEL_OK;          exitcode = (int)MANDOCLEVEL_OK;
         mp = mparse_alloc(mparse_options, MANDOCLEVEL_FATAL, NULL, NULL);  
         mc = mchars_alloc();          mc = mchars_alloc();
           mp = mparse_alloc(mparse_options, MANDOCLEVEL_FATAL, NULL,
               mc, NULL);
         ohash_init(&mpages, 6, &mpages_info);          ohash_init(&mpages, 6, &mpages_info);
         ohash_init(&mlinks, 6, &mlinks_info);          ohash_init(&mlinks, 6, &mlinks_info);
   
Line 436  main(int argc, char *argv[])
Line 437  main(int argc, char *argv[])
                  * Most of these deal with a specific directory.                   * Most of these deal with a specific directory.
                  * Jump into that directory first.                   * Jump into that directory first.
                  */                   */
                 if (OP_TEST != op && 0 == set_basedir(path_arg))                  if (OP_TEST != op && 0 == set_basedir(path_arg, 1))
                         goto out;                          goto out;
   
                 if (dbopen(1)) {                  if (dbopen(1)) {
Line 502  main(int argc, char *argv[])
Line 503  main(int argc, char *argv[])
                                 ohash_init(&mlinks, 6, &mlinks_info);                                  ohash_init(&mlinks, 6, &mlinks_info);
                         }                          }
   
                         if (0 == set_basedir(dirs.paths[j]))                          if (0 == set_basedir(dirs.paths[j], argc > 0))
                                 goto out;                                  continue;
                         if (0 == treescan())                          if (0 == treescan())
                                 goto out;                                  continue;
                         if (0 == dbopen(0))                          if (0 == dbopen(0))
                                 goto out;                                  continue;
   
                         mpages_merge(mc, mp);                          mpages_merge(mc, mp);
                         if (warnings && !nodb &&                          if (warnings && !nodb &&
Line 524  main(int argc, char *argv[])
Line 525  main(int argc, char *argv[])
         }          }
 out:  out:
         manpath_free(&dirs);          manpath_free(&dirs);
         mchars_free(mc);  
         mparse_free(mp);          mparse_free(mp);
           mchars_free(mc);
         mpages_free();          mpages_free();
         ohash_delete(&mpages);          ohash_delete(&mpages);
         ohash_delete(&mlinks);          ohash_delete(&mlinks);
Line 1902  render_key(struct mchars *mc, struct str *key)
Line 1903  render_key(struct mchars *mc, struct str *key)
                  */                   */
   
                 if (write_utf8) {                  if (write_utf8) {
                         if (0 == (u = mchars_spec2cp(mc, seq, len)))                          if ((u = mchars_spec2cp(mc, seq, len)) <= 0)
                                 continue;                                  continue;
                         cpp = utfbuf;                          cpp = utfbuf;
                         if (0 == (sz = utf8(u, utfbuf)))                          if (0 == (sz = utf8(u, utfbuf)))
Line 2343  hash_free(void *p, void *arg)
Line 2344  hash_free(void *p, void *arg)
 }  }
   
 static int  static int
 set_basedir(const char *targetdir)  set_basedir(const char *targetdir, int report_baddir)
 {  {
         static char      startdir[PATH_MAX];          static char      startdir[PATH_MAX];
         static int       getcwd_status;  /* 1 = ok, 2 = failure */          static int       getcwd_status;  /* 1 = ok, 2 = failure */
Line 2396  set_basedir(const char *targetdir)
Line 2397  set_basedir(const char *targetdir)
          * we can reliably check whether files are inside.           * we can reliably check whether files are inside.
          */           */
         if (NULL == realpath(targetdir, basedir)) {          if (NULL == realpath(targetdir, basedir)) {
                 exitcode = (int)MANDOCLEVEL_BADARG;                  if (report_baddir || errno != ENOENT) {
                 say("", "&%s: realpath", targetdir);                          exitcode = (int)MANDOCLEVEL_BADARG;
                           say("", "&%s: realpath", targetdir);
                   }
                 return(0);                  return(0);
         } else if (-1 == chdir(basedir)) {          } else if (-1 == chdir(basedir)) {
                 exitcode = (int)MANDOCLEVEL_BADARG;                  if (report_baddir || errno != ENOENT) {
                 say("", "&chdir");                          exitcode = (int)MANDOCLEVEL_BADARG;
                           say("", "&chdir");
                   }
                 return(0);                  return(0);
         }          }
         chdir_status = 1;          chdir_status = 1;

Legend:
Removed from v.1.164  
changed lines
  Added in v.1.168

CVSweb