aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/makewhatis.c
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
commitab1fd909bf6f9416911e5d92f01adf299d376de7 (patch)
treeee31a710330002ead11be342992273cb6e0610cf /makewhatis.c
parentbe71814b51a79b2a8ac3c2acc319cf793ab6afa6 (diff)
downloadmandoc-ab1fd909bf6f9416911e5d92f01adf299d376de7.tar.gz
mandoc-ab1fd909bf6f9416911e5d92f01adf299d376de7.tar.zst
mandoc-ab1fd909bf6f9416911e5d92f01adf299d376de7.zip
Fix broken transfer from hashtable to btree for makewhatis.c.
Diffstat (limited to 'makewhatis.c')
-rw-r--r--makewhatis.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/makewhatis.c b/makewhatis.c
index 0b767704..433dfcbb 100644
--- a/makewhatis.c
+++ b/makewhatis.c
@@ -1,4 +1,4 @@
-/* $Id: makewhatis.c,v 1.6 2011/06/21 14:16:05 kristaps Exp $ */
+/* $Id: makewhatis.c,v 1.7 2011/06/21 23:37:27 kristaps Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
*
@@ -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);