version 1.60, 2015/10/13 15:53:05 |
version 1.63, 2015/11/26 07:42:11 |
|
|
#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 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 766 exprterm(const struct mansearch *search, char *buf, in |
|
Line 771 exprterm(const struct mansearch *search, char *buf, in |
|
if (search->argmode == ARG_WORD) { |
if (search->argmode == ARG_WORD) { |
e->bits = TYPE_Nm; |
e->bits = TYPE_Nm; |
e->substr = NULL; |
e->substr = NULL; |
|
#if HAVE_REWB_BSD |
mandoc_asprintf(&val, "[[:<:]]%s[[:>:]]", buf); |
mandoc_asprintf(&val, "[[:<:]]%s[[:>:]]", buf); |
|
#elif HAVE_REWB_SYSV |
|
mandoc_asprintf(&val, "\\<%s\\>", buf); |
|
#else |
|
mandoc_asprintf(&val, |
|
"(^|[^a-zA-Z01-9_])%s([^a-zA-Z01-9_]|$)", buf); |
|
#endif |
cs = 0; |
cs = 0; |
} else if ((val = strpbrk(buf, "=~")) == NULL) { |
} else if ((val = strpbrk(buf, "=~")) == NULL) { |
e->bits = TYPE_Nm | TYPE_Nd; |
e->bits = TYPE_Nm | TYPE_Nd; |