version 1.18, 2011/12/01 23:55:58 |
version 1.24, 2011/12/16 12:06:35 |
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
*/ |
*/ |
|
#ifdef HAVE_CONFIG_H |
|
#include "config.h" |
|
#endif |
|
|
#include <assert.h> |
#include <assert.h> |
#include <fcntl.h> |
#include <fcntl.h> |
#include <regex.h> |
#include <regex.h> |
|
|
#include <string.h> |
#include <string.h> |
#include <unistd.h> |
#include <unistd.h> |
|
|
#ifdef __linux__ |
#if defined(__linux__) |
|
# include <endian.h> |
# include <db_185.h> |
# include <db_185.h> |
|
#elif defined(__APPLE__) |
|
# include <libkern/OSByteOrder.h> |
|
# include <db.h> |
#else |
#else |
# include <db.h> |
# include <db.h> |
#endif |
#endif |
Line 357 index_read(const DBT *key, const DBT *val, int index, |
|
Line 365 index_read(const DBT *key, const DBT *val, int index, |
|
{ |
{ |
size_t left; |
size_t left; |
char *np, *cp; |
char *np, *cp; |
|
char type; |
|
|
#define INDEX_BREAD(_dst) \ |
#define INDEX_BREAD(_dst) \ |
do { \ |
do { \ |
Line 367 index_read(const DBT *key, const DBT *val, int index, |
|
Line 376 index_read(const DBT *key, const DBT *val, int index, |
|
cp = np + 1; \ |
cp = np + 1; \ |
} while (/* CONSTCOND */ 0) |
} while (/* CONSTCOND */ 0) |
|
|
left = val->size; |
if (0 == (left = val->size)) |
cp = (char *)val->data; |
return(0); |
|
|
|
cp = val->data; |
rec->res.rec = *(recno_t *)key->data; |
rec->res.rec = *(recno_t *)key->data; |
rec->res.volume = index; |
rec->res.volume = index; |
|
|
INDEX_BREAD(rec->res.type); |
if ('d' == (type = *cp++)) |
|
rec->res.type = RESTYPE_MDOC; |
|
else if ('a' == type) |
|
rec->res.type = RESTYPE_MAN; |
|
else if ('c' == type) |
|
rec->res.type = RESTYPE_CAT; |
|
else |
|
return(0); |
|
|
|
left--; |
INDEX_BREAD(rec->res.file); |
INDEX_BREAD(rec->res.file); |
INDEX_BREAD(rec->res.cat); |
INDEX_BREAD(rec->res.cat); |
INDEX_BREAD(rec->res.title); |
INDEX_BREAD(rec->res.title); |
Line 533 single_search(struct rectree *tree, const struct opts |
|
Line 552 single_search(struct rectree *tree, const struct opts |
|
|
|
if (opts->cat && strcasecmp(opts->cat, r.res.cat)) |
if (opts->cat && strcasecmp(opts->cat, r.res.cat)) |
continue; |
continue; |
if (opts->arch && strcasecmp(opts->arch, r.res.arch)) |
|
continue; |
|
|
|
|
if (opts->arch && *r.res.arch) |
|
if (strcasecmp(opts->arch, r.res.arch)) |
|
continue; |
|
|
tree->node = rs = mandoc_realloc |
tree->node = rs = mandoc_realloc |
(rs, (tree->len + 1) * sizeof(struct rec)); |
(rs, (tree->len + 1) * sizeof(struct rec)); |
|
|
memcpy(&rs[tree->len], &r, sizeof(struct rec)); |
memcpy(&rs[tree->len], &r, sizeof(struct rec)); |
|
memset(&r, 0, sizeof(struct rec)); |
rs[tree->len].matches = |
rs[tree->len].matches = |
mandoc_calloc(terms, sizeof(int)); |
mandoc_calloc(terms, sizeof(int)); |
|
|
Line 555 single_search(struct rectree *tree, const struct opts |
|
Line 577 single_search(struct rectree *tree, const struct opts |
|
} else |
} else |
root = tree->len; |
root = tree->len; |
|
|
memset(&r, 0, sizeof(struct rec)); |
|
tree->len++; |
tree->len++; |
} |
} |
|
|
Line 563 single_search(struct rectree *tree, const struct opts |
|
Line 584 single_search(struct rectree *tree, const struct opts |
|
(*idx->close)(idx); |
(*idx->close)(idx); |
|
|
free(buf); |
free(buf); |
|
recfree(&r); |
return(1 == ch); |
return(1 == ch); |
} |
} |
|
|
|
|
recfree(struct rec *rec) |
recfree(struct rec *rec) |
{ |
{ |
|
|
free(rec->res.type); |
|
free(rec->res.file); |
free(rec->res.file); |
free(rec->res.cat); |
free(rec->res.cat); |
free(rec->res.title); |
free(rec->res.title); |