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

Diff for /mandoc/main.c between version 1.273 and 1.274

version 1.273, 2016/07/19 13:36:13 version 1.274, 2016/07/19 21:31:55
Line 82  struct curparse {
Line 82  struct curparse {
 };  };
   
   
 #if HAVE_SQLITE3  
 int                       mandocdb(int, char *[]);  int                       mandocdb(int, char *[]);
 #endif  
   
 static  int               fs_lookup(const struct manpaths *,  static  int               fs_lookup(const struct manpaths *,
                                 size_t ipath, const char *,                                  size_t ipath, const char *,
Line 147  main(int argc, char *argv[])
Line 145  main(int argc, char *argv[])
         setprogname(progname);          setprogname(progname);
 #endif  #endif
   
 #if HAVE_SQLITE3  
         if (strncmp(progname, "mandocdb", 8) == 0 ||          if (strncmp(progname, "mandocdb", 8) == 0 ||
             strcmp(progname, BINM_MAKEWHATIS) == 0)              strcmp(progname, BINM_MAKEWHATIS) == 0)
                 return mandocdb(argc, argv);                  return mandocdb(argc, argv);
 #endif  
   
 #if HAVE_PLEDGE  #if HAVE_PLEDGE
         if (pledge("stdio rpath tmppath tty proc exec flock", NULL) == -1)          if (pledge("stdio rpath tmppath tty proc exec flock", NULL) == -1)
Line 349  main(int argc, char *argv[])
Line 345  main(int argc, char *argv[])
         /* man(1), whatis(1), apropos(1) */          /* man(1), whatis(1), apropos(1) */
   
         if (search.argmode != ARG_FILE) {          if (search.argmode != ARG_FILE) {
                 if (argc == 0)  
                         usage(search.argmode);  
   
                 if (search.argmode == ARG_NAME &&                  if (search.argmode == ARG_NAME &&
                     outmode == OUTMODE_ONE)                      outmode == OUTMODE_ONE)
                         search.firstmatch = 1;                          search.firstmatch = 1;
Line 359  main(int argc, char *argv[])
Line 352  main(int argc, char *argv[])
                 /* Access the mandoc database. */                  /* Access the mandoc database. */
   
                 manconf_parse(&conf, conf_file, defpaths, auxpaths);                  manconf_parse(&conf, conf_file, defpaths, auxpaths);
 #if HAVE_SQLITE3  
                 mansearch_setup(1);  
                 if ( ! mansearch(&search, &conf.manpath,                  if ( ! mansearch(&search, &conf.manpath,
                     argc, argv, &res, &sz))                      argc, argv, &res, &sz))
                         usage(search.argmode);                          usage(search.argmode);
 #else  
                 if (search.argmode != ARG_NAME) {  
                         fputs("mandoc: database support not compiled in\n",  
                             stderr);  
                         return (int)MANDOCLEVEL_BADARG;  
                 }  
                 sz = 0;  
 #endif  
   
                 if (sz == 0) {                  if (sz == 0) {
                         if (search.argmode == ARG_NAME)                          if (search.argmode == ARG_NAME)
Line 474  main(int argc, char *argv[])
Line 457  main(int argc, char *argv[])
   
                         if (resp == NULL)                          if (resp == NULL)
                                 parse(&curp, fd, *argv);                                  parse(&curp, fd, *argv);
                         else if (resp->form & FORM_SRC) {                          else if (resp->form == FORM_SRC) {
                                 /* For .so only; ignore failure. */                                  /* For .so only; ignore failure. */
                                 chdir(conf.manpath.paths[resp->ipath]);                                  chdir(conf.manpath.paths[resp->ipath]);
                                 parse(&curp, fd, resp->file);                                  parse(&curp, fd, resp->file);
Line 522  main(int argc, char *argv[])
Line 505  main(int argc, char *argv[])
 out:  out:
         if (search.argmode != ARG_FILE) {          if (search.argmode != ARG_FILE) {
                 manconf_free(&conf);                  manconf_free(&conf);
 #if HAVE_SQLITE3  
                 mansearch_free(res, sz);                  mansearch_free(res, sz);
                 mansearch_setup(0);  
 #endif  
         }          }
   
         free(defos);          free(defos);
Line 629  fs_lookup(const struct manpaths *paths, size_t ipath,
Line 609  fs_lookup(const struct manpaths *paths, size_t ipath,
         glob_t           globinfo;          glob_t           globinfo;
         struct manpage  *page;          struct manpage  *page;
         char            *file;          char            *file;
         int              form, globres;          int              globres;
           enum form        form;
   
         form = FORM_SRC;          form = FORM_SRC;
         mandoc_asprintf(&file, "%s/man%s/%s.%s",          mandoc_asprintf(&file, "%s/man%s/%s.%s",
Line 667  fs_lookup(const struct manpaths *paths, size_t ipath,
Line 648  fs_lookup(const struct manpaths *paths, size_t ipath,
                 return 0;                  return 0;
   
 found:  found:
 #if HAVE_SQLITE3  
         warnx("outdated mandoc.db lacks %s(%s) entry, run %s %s",          warnx("outdated mandoc.db lacks %s(%s) entry, run %s %s",
             name, sec, BINM_MAKEWHATIS, paths->paths[ipath]);              name, sec, BINM_MAKEWHATIS, paths->paths[ipath]);
 #endif  
         *res = mandoc_reallocarray(*res, ++*ressz, sizeof(struct manpage));          *res = mandoc_reallocarray(*res, ++*ressz, sizeof(struct manpage));
         page = *res + (*ressz - 1);          page = *res + (*ressz - 1);
         page->file = file;          page->file = file;

Legend:
Removed from v.1.273  
changed lines
  Added in v.1.274

CVSweb