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

Diff for /mandoc/mansearch.c between version 1.61 and 1.64

version 1.61, 2015/11/06 21:19:09 version 1.64, 2016/01/08 15:02:54
Line 21 
Line 21 
 #include <sys/types.h>  #include <sys/types.h>
   
 #include <assert.h>  #include <assert.h>
   #if HAVE_ERR
 #include <err.h>  #include <err.h>
   #endif
 #include <errno.h>  #include <errno.h>
 #include <fcntl.h>  #include <fcntl.h>
 #include <getopt.h>  #include <getopt.h>
Line 52  extern const char *const mansearch_keynames[];
Line 54  extern const char *const mansearch_keynames[];
 #define SQL_BIND_TEXT(_db, _s, _i, _v) \  #define SQL_BIND_TEXT(_db, _s, _i, _v) \
         do { if (SQLITE_OK != sqlite3_bind_text \          do { if (SQLITE_OK != sqlite3_bind_text \
                 ((_s), (_i)++, (_v), -1, SQLITE_STATIC)) \                  ((_s), (_i)++, (_v), -1, SQLITE_STATIC)) \
                 warnx("%s", sqlite3_errmsg((_db))); \                  errx((int)MANDOCLEVEL_SYSERR, "%s", sqlite3_errmsg((_db))); \
         } while (0)          } while (0)
 #define SQL_BIND_INT64(_db, _s, _i, _v) \  #define SQL_BIND_INT64(_db, _s, _i, _v) \
         do { if (SQLITE_OK != sqlite3_bind_int64 \          do { if (SQLITE_OK != sqlite3_bind_int64 \
                 ((_s), (_i)++, (_v))) \                  ((_s), (_i)++, (_v))) \
                 warnx("%s", sqlite3_errmsg((_db))); \                  errx((int)MANDOCLEVEL_SYSERR, "%s", sqlite3_errmsg((_db))); \
         } while (0)          } while (0)
 #define SQL_BIND_BLOB(_db, _s, _i, _v) \  #define SQL_BIND_BLOB(_db, _s, _i, _v) \
         do { if (SQLITE_OK != sqlite3_bind_blob \          do { if (SQLITE_OK != sqlite3_bind_blob \
                 ((_s), (_i)++, (&_v), sizeof(_v), SQLITE_STATIC)) \                  ((_s), (_i)++, (&_v), sizeof(_v), SQLITE_STATIC)) \
                 warnx("%s", sqlite3_errmsg((_db))); \                  errx((int)MANDOCLEVEL_SYSERR, "%s", sqlite3_errmsg((_db))); \
         } while (0)          } while (0)
   
 struct  expr {  struct  expr {
Line 123  mansearch_setup(int start)
Line 125  mansearch_setup(int start)
                     MAP_SHARED | MAP_ANON, -1, 0);                      MAP_SHARED | MAP_ANON, -1, 0);
   
                 if (MAP_FAILED == pagecache) {                  if (MAP_FAILED == pagecache) {
                         perror("mmap");                          warn("mmap");
                         pagecache = NULL;                          pagecache = NULL;
                         return (int)MANDOCLEVEL_SYSERR;                          return (int)MANDOCLEVEL_SYSERR;
                 }                  }
Line 142  mansearch_setup(int start)
Line 144  mansearch_setup(int start)
         }          }
   
         if (-1 == munmap(pagecache, PC_PAGESIZE * PC_NUMPAGES)) {          if (-1 == munmap(pagecache, PC_PAGESIZE * PC_NUMPAGES)) {
                 perror("munmap");                  warn("munmap");
                 pagecache = NULL;                  pagecache = NULL;
                 return (int)MANDOCLEVEL_SYSERR;                  return (int)MANDOCLEVEL_SYSERR;
         }          }
Line 224  mansearch(const struct mansearch *search,
Line 226  mansearch(const struct mansearch *search,
                                 warnx("%s: getcwd: %s", paths->paths[i], buf);                                  warnx("%s: getcwd: %s", paths->paths[i], buf);
                                 continue;                                  continue;
                         } else if (chdir(buf) == -1) {                          } else if (chdir(buf) == -1) {
                                 perror(buf);                                  warn("%s", buf);
                                 continue;                                  continue;
                         }                          }
                 }                  }
                 if (chdir(paths->paths[i]) == -1) {                  if (chdir(paths->paths[i]) == -1) {
                         perror(paths->paths[i]);                          warn("%s", paths->paths[i]);
                         continue;                          continue;
                 }                  }
                 chdir_status = 1;                  chdir_status = 1;
Line 260  mansearch(const struct mansearch *search,
Line 262  mansearch(const struct mansearch *search,
                 j = 1;                  j = 1;
                 c = sqlite3_prepare_v2(db, sql, -1, &s, NULL);                  c = sqlite3_prepare_v2(db, sql, -1, &s, NULL);
                 if (SQLITE_OK != c)                  if (SQLITE_OK != c)
                         warnx("%s", sqlite3_errmsg(db));                          errx((int)MANDOCLEVEL_SYSERR,
                               "%s", sqlite3_errmsg(db));
   
                 for (ep = e; NULL != ep; ep = ep->next) {                  for (ep = e; NULL != ep; ep = ep->next) {
                         if (NULL == ep->substr) {                          if (NULL == ep->substr) {
Line 310  mansearch(const struct mansearch *search,
Line 313  mansearch(const struct mansearch *search,
                     "WHERE pageid=? ORDER BY sec, arch, name",                      "WHERE pageid=? ORDER BY sec, arch, name",
                     -1, &s, NULL);                      -1, &s, NULL);
                 if (SQLITE_OK != c)                  if (SQLITE_OK != c)
                         warnx("%s", sqlite3_errmsg(db));                          errx((int)MANDOCLEVEL_SYSERR,
                               "%s", sqlite3_errmsg(db));
   
                 c = sqlite3_prepare_v2(db,                  c = sqlite3_prepare_v2(db,
                     "SELECT bits, key, pageid FROM keys "                      "SELECT bits, key, pageid FROM keys "
                     "WHERE pageid=? AND bits & ?",                      "WHERE pageid=? AND bits & ?",
                     -1, &s2, NULL);                      -1, &s2, NULL);
                 if (SQLITE_OK != c)                  if (SQLITE_OK != c)
                         warnx("%s", sqlite3_errmsg(db));                          errx((int)MANDOCLEVEL_SYSERR,
                               "%s", sqlite3_errmsg(db));
   
                 for (mp = ohash_first(&htab, &idx);                  for (mp = ohash_first(&htab, &idx);
                                 NULL != mp;                                  NULL != mp;
Line 359  mansearch(const struct mansearch *search,
Line 364  mansearch(const struct mansearch *search,
         }          }
         qsort(*res, cur, sizeof(struct manpage), manpage_compare);          qsort(*res, cur, sizeof(struct manpage), manpage_compare);
         if (chdir_status && getcwd_status && chdir(buf) == -1)          if (chdir_status && getcwd_status && chdir(buf) == -1)
                 perror(buf);                  warn("%s", buf);
         exprfree(e);          exprfree(e);
         free(sql);          free(sql);
         *sz = cur;          *sz = cur;

Legend:
Removed from v.1.61  
changed lines
  Added in v.1.64

CVSweb