version 1.35, 2011/12/16 08:04:34 |
version 1.37, 2011/12/20 21:41:11 |
Line 525 index_merge(const struct of *of, struct mparse *mp, |
|
Line 525 index_merge(const struct of *of, struct mparse *mp, |
|
struct mdoc *mdoc; |
struct mdoc *mdoc; |
struct man *man; |
struct man *man; |
const char *fn, *msec, *mtitle, *arch; |
const char *fn, *msec, *mtitle, *arch; |
|
uint64_t mask; |
size_t sv; |
size_t sv; |
unsigned seq; |
unsigned seq; |
struct db_val vbuf; |
struct db_val vbuf; |
|
char type; |
|
|
for (rec = 0; of; of = of->next) { |
for (rec = 0; of; of = of->next) { |
fn = of->fname; |
fn = of->fname; |
Line 608 index_merge(const struct of *of, struct mparse *mp, |
|
Line 610 index_merge(const struct of *of, struct mparse *mp, |
|
*/ |
*/ |
|
|
dbuf->len = 0; |
dbuf->len = 0; |
buf_append(dbuf, mdoc ? "mdoc" : (man ? "man" : "cat")); |
type = mdoc ? 'd' : (man ? 'a' : 'c'); |
|
buf_appendb(dbuf, &type, 1); |
buf_appendb(dbuf, fn, strlen(fn) + 1); |
buf_appendb(dbuf, fn, strlen(fn) + 1); |
buf_appendb(dbuf, msec, strlen(msec) + 1); |
buf_appendb(dbuf, msec, strlen(msec) + 1); |
buf_appendb(dbuf, mtitle, strlen(mtitle) + 1); |
buf_appendb(dbuf, mtitle, strlen(mtitle) + 1); |
Line 653 index_merge(const struct of *of, struct mparse *mp, |
|
Line 656 index_merge(const struct of *of, struct mparse *mp, |
|
seq = R_FIRST; |
seq = R_FIRST; |
while (0 == (ch = (*hash->seq)(hash, &key, &val, seq))) { |
while (0 == (ch = (*hash->seq)(hash, &key, &val, seq))) { |
seq = R_NEXT; |
seq = R_NEXT; |
vbuf.mask = htobe64(*(uint64_t *)val.data); |
assert(sizeof(uint64_t) == val.size); |
|
memcpy(&mask, val.data, val.size); |
|
vbuf.mask = htobe64(mask); |
val.size = sizeof(struct db_val); |
val.size = sizeof(struct db_val); |
val.data = &vbuf; |
val.data = &vbuf; |
dbt_put(db, dbf, &key, &val); |
dbt_put(db, dbf, &key, &val); |
Line 696 index_prune(const struct of *ofile, DB *db, const char |
|
Line 701 index_prune(const struct of *ofile, DB *db, const char |
|
recno_t **recs, size_t *recsz, size_t *reccur) |
recno_t **recs, size_t *recsz, size_t *reccur) |
{ |
{ |
const struct of *of; |
const struct of *of; |
const char *fn, *cp; |
const char *fn; |
struct db_val *vbuf; |
struct db_val *vbuf; |
unsigned seq, sseq; |
unsigned seq, sseq; |
DBT key, val; |
DBT key, val; |
Line 706 index_prune(const struct of *ofile, DB *db, const char |
|
Line 711 index_prune(const struct of *ofile, DB *db, const char |
|
seq = R_FIRST; |
seq = R_FIRST; |
while (0 == (ch = (*idx->seq)(idx, &key, &val, seq))) { |
while (0 == (ch = (*idx->seq)(idx, &key, &val, seq))) { |
seq = R_NEXT; |
seq = R_NEXT; |
*maxrec = *(recno_t *)key.data; |
assert(sizeof(recno_t) == key.size); |
cp = val.data; |
memcpy(maxrec, key.data, key.size); |
|
|
/* Deleted records are zero-sized. Skip them. */ |
/* Deleted records are zero-sized. Skip them. */ |
|
|
Line 721 index_prune(const struct of *ofile, DB *db, const char |
|
Line 726 index_prune(const struct of *ofile, DB *db, const char |
|
* Failing any of these, we go into our error handler. |
* Failing any of these, we go into our error handler. |
*/ |
*/ |
|
|
if (NULL == (fn = memchr(cp, '\0', val.size))) |
fn = (char *)val.data + 1; |
|
if (NULL == memchr(fn, '\0', val.size - 1)) |
break; |
break; |
if (++fn - cp >= (int)val.size) |
|
break; |
|
if (NULL == memchr(fn, '\0', val.size - (fn - cp))) |
|
break; |
|
|
|
/* |
/* |
* Search for the file in those we care about. |
* Search for the file in those we care about. |
Line 1070 pmdoc_Sh(MDOC_ARGS) |
|
Line 1072 pmdoc_Sh(MDOC_ARGS) |
|
static void |
static void |
hash_put(DB *db, const struct buf *buf, uint64_t mask) |
hash_put(DB *db, const struct buf *buf, uint64_t mask) |
{ |
{ |
|
uint64_t oldmask; |
DBT key, val; |
DBT key, val; |
int rc; |
int rc; |
|
|
Line 1082 hash_put(DB *db, const struct buf *buf, uint64_t mask) |
|
Line 1085 hash_put(DB *db, const struct buf *buf, uint64_t mask) |
|
if ((rc = (*db->get)(db, &key, &val, 0)) < 0) { |
if ((rc = (*db->get)(db, &key, &val, 0)) < 0) { |
perror("hash"); |
perror("hash"); |
exit((int)MANDOCLEVEL_SYSERR); |
exit((int)MANDOCLEVEL_SYSERR); |
} else if (0 == rc) |
} else if (0 == rc) { |
mask |= *(uint64_t *)val.data; |
assert(sizeof(uint64_t) == val.size); |
|
memcpy(&oldmask, val.data, val.size); |
|
mask |= oldmask; |
|
} |
|
|
val.data = &mask; |
val.data = &mask; |
val.size = sizeof(uint64_t); |
val.size = sizeof(uint64_t); |