summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-06-21 23:37:27 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-06-21 23:37:27 +0000
commit4def41caaee51f9c08eab6ff3c620779f1255460 (patch)
treec5c13d241def5f73a6e72779003f5c45ac46968c
parentfeb50473b097bcdbce1303c55276ea473426c0be (diff)
downloadmandoc-4def41caaee51f9c08eab6ff3c620779f1255460.tar.gz
Fix broken transfer from hashtable to btree for makewhatis.c.
-rw-r--r--makewhatis.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/makewhatis.c b/makewhatis.c
index 0523d4b6..363182d9 100644
--- a/makewhatis.c
+++ b/makewhatis.c
@@ -416,16 +416,17 @@ main(int argc, char *argv[])
seq = R_FIRST;
while (0 == (ch = (*hash->seq)(hash, &key, &val, seq))) {
+ seq = R_NEXT;
+
memcpy(vbuf, val.data, sizeof(uint32_t));
val.size = sizeof(vbuf);
val.data = vbuf;
+
dbt_put(db, fbbuf, &key, &val);
- if ((*hash->del)(hash, &key, 0) < 0) {
- perror("hash");
- exit((int)MANDOCLEVEL_SYSERR);
- }
- seq = R_NEXT;
+ ch = (*hash->del)(hash, &key, R_CURSOR);
+ if (ch < 0)
+ break;
}
if (ch < 0) {
@@ -746,11 +747,12 @@ hash_put(DB *db, const struct buf *buf, int mask)
DBT key, val;
int rc;
- key.data = buf->cp;
-
- if ((key.size = buf->len) < 2)
+ if (buf->len < 2)
return;
+ key.data = buf->cp;
+ key.size = buf->len;
+
if ((rc = (*db->get)(db, &key, &val, 0)) < 0) {
perror("hash");
exit((int)MANDOCLEVEL_SYSERR);
@@ -760,9 +762,6 @@ hash_put(DB *db, const struct buf *buf, int mask)
val.data = &mask;
val.size = sizeof(int);
- /*fprintf(stderr, "Hashing: [%s] (0x%x)\n",
- (char *)key.data, mask);*/
-
if ((rc = (*db->put)(db, &key, &val, 0)) < 0) {
perror("hash");
exit((int)MANDOCLEVEL_SYSERR);