version 1.110, 2014/01/18 08:55:17 |
version 1.113, 2014/01/19 22:48:16 |
|
|
#include "manpath.h" |
#include "manpath.h" |
#include "mansearch.h" |
#include "mansearch.h" |
|
|
|
extern int mansearch_keymax; |
|
extern const char *const mansearch_keynames[]; |
|
|
#define SQL_EXEC(_v) \ |
#define SQL_EXEC(_v) \ |
if (SQLITE_OK != sqlite3_exec(db, (_v), NULL, NULL, NULL)) \ |
if (SQLITE_OK != sqlite3_exec(db, (_v), NULL, NULL, NULL)) \ |
fprintf(stderr, "%s\n", sqlite3_errmsg(db)) |
fprintf(stderr, "%s\n", sqlite3_errmsg(db)) |
Line 154 static int parse_mdoc_Nd(struct mpage *, const struct |
|
Line 157 static int parse_mdoc_Nd(struct mpage *, const struct |
|
static int parse_mdoc_Nm(struct mpage *, const struct mdoc_node *); |
static int parse_mdoc_Nm(struct mpage *, const struct mdoc_node *); |
static int parse_mdoc_Sh(struct mpage *, const struct mdoc_node *); |
static int parse_mdoc_Sh(struct mpage *, const struct mdoc_node *); |
static int parse_mdoc_Xr(struct mpage *, const struct mdoc_node *); |
static int parse_mdoc_Xr(struct mpage *, const struct mdoc_node *); |
static void putkey(const struct mpage *, |
static void putkey(const struct mpage *, char *, uint64_t); |
const char *, uint64_t); |
|
static void putkeys(const struct mpage *, |
static void putkeys(const struct mpage *, |
const char *, size_t, uint64_t); |
const char *, size_t, uint64_t); |
static void putmdockey(const struct mpage *, |
static void putmdockey(const struct mpage *, |
Line 954 mlink_check(struct mpage *mpage, struct mlink *mlink) |
|
Line 956 mlink_check(struct mpage *mpage, struct mlink *mlink) |
|
static void |
static void |
mpages_merge(struct mchars *mc, struct mparse *mp) |
mpages_merge(struct mchars *mc, struct mparse *mp) |
{ |
{ |
|
char any[] = "any"; |
struct ohash_info str_info; |
struct ohash_info str_info; |
struct mpage *mpage; |
struct mpage *mpage; |
struct mlink *mlink; |
struct mlink *mlink; |
struct mdoc *mdoc; |
struct mdoc *mdoc; |
struct man *man; |
struct man *man; |
const char *cp; |
char *cp; |
int match; |
int match; |
unsigned int pslot; |
unsigned int pslot; |
enum mandoclevel lvl; |
enum mandoclevel lvl; |
Line 1025 mpages_merge(struct mchars *mc, struct mparse *mp) |
|
Line 1028 mpages_merge(struct mchars *mc, struct mparse *mp) |
|
} |
} |
putkey(mpage, mpage->sec, TYPE_sec); |
putkey(mpage, mpage->sec, TYPE_sec); |
putkey(mpage, '\0' == *mpage->arch ? |
putkey(mpage, '\0' == *mpage->arch ? |
"any" : mpage->arch, TYPE_arch); |
any : mpage->arch, TYPE_arch); |
|
|
for (mlink = mpage->mlinks; mlink; mlink = mlink->next) { |
for (mlink = mpage->mlinks; mlink; mlink = mlink->next) { |
if ('\0' != *mlink->dsec) |
if ('\0' != *mlink->dsec) |
Line 1033 mpages_merge(struct mchars *mc, struct mparse *mp) |
|
Line 1036 mpages_merge(struct mchars *mc, struct mparse *mp) |
|
if ('\0' != *mlink->fsec) |
if ('\0' != *mlink->fsec) |
putkey(mpage, mlink->fsec, TYPE_sec); |
putkey(mpage, mlink->fsec, TYPE_sec); |
putkey(mpage, '\0' == *mlink->arch ? |
putkey(mpage, '\0' == *mlink->arch ? |
"any" : mlink->arch, TYPE_arch); |
any : mlink->arch, TYPE_arch); |
putkey(mpage, mlink->name, TYPE_Nm); |
putkey(mpage, mlink->name, TYPE_Nm); |
} |
} |
|
|
Line 1183 parse_cat(struct mpage *mpage) |
|
Line 1186 parse_cat(struct mpage *mpage) |
|
* Put a type/word pair into the word database for this particular file. |
* Put a type/word pair into the word database for this particular file. |
*/ |
*/ |
static void |
static void |
putkey(const struct mpage *mpage, const char *value, uint64_t type) |
putkey(const struct mpage *mpage, char *value, uint64_t type) |
{ |
{ |
|
char *cp; |
|
|
assert(NULL != value); |
assert(NULL != value); |
|
if (TYPE_arch == type) |
|
for (cp = value; *cp; cp++) |
|
if (isupper((unsigned char)*cp)) |
|
*cp = _tolower((unsigned char)*cp); |
putkeys(mpage, value, strlen(value), type); |
putkeys(mpage, value, strlen(value), type); |
} |
} |
|
|
Line 1440 parse_mdoc_Fd(struct mpage *mpage, const struct mdoc_n |
|
Line 1448 parse_mdoc_Fd(struct mpage *mpage, const struct mdoc_n |
|
static int |
static int |
parse_mdoc_Fn(struct mpage *mpage, const struct mdoc_node *n) |
parse_mdoc_Fn(struct mpage *mpage, const struct mdoc_node *n) |
{ |
{ |
const char *cp; |
char *cp; |
|
|
if (NULL == (n = n->child) || MDOC_TEXT != n->type) |
if (NULL == (n = n->child) || MDOC_TEXT != n->type) |
return(0); |
return(0); |
Line 1562 putkeys(const struct mpage *mpage, |
|
Line 1570 putkeys(const struct mpage *mpage, |
|
const char *cp, size_t sz, uint64_t v) |
const char *cp, size_t sz, uint64_t v) |
{ |
{ |
struct str *s; |
struct str *s; |
unsigned int slot; |
|
const char *end; |
const char *end; |
|
uint64_t mask; |
|
unsigned int slot; |
|
int i; |
|
|
if (0 == sz) |
if (0 == sz) |
return; |
return; |
|
|
|
if (verb > 1) { |
|
for (i = 0, mask = 1; |
|
i < mansearch_keymax; |
|
i++, mask <<= 1) |
|
if (mask & v) |
|
break; |
|
say(mpage->mlinks->file, "Adding key %s=%*s", |
|
mansearch_keynames[i], sz, cp); |
|
} |
|
|
end = cp + sz; |
end = cp + sz; |
slot = ohash_qlookupi(&strings, cp, &end); |
slot = ohash_qlookupi(&strings, cp, &end); |