Fixes bug 3482222 filed in the bug tracker.

This commit is contained in:
Fabiano C. Botelho 2013-04-16 00:50:24 -07:00
parent 9e434d41d0
commit c1a9eb164e
2 changed files with 7 additions and 7 deletions

View File

@ -530,7 +530,7 @@ cmph_uint32 bmz_search(cmph_t *mphf, const char *key, cmph_uint32 keylen)
cmph_uint32 h1 = hash(bmz->hashes[0], key, keylen) % bmz->n; cmph_uint32 h1 = hash(bmz->hashes[0], key, keylen) % bmz->n;
cmph_uint32 h2 = hash(bmz->hashes[1], key, keylen) % bmz->n; cmph_uint32 h2 = hash(bmz->hashes[1], key, keylen) % bmz->n;
DEBUGP("key: %.*s h1: %u h2: %u\n", keylen, key, h1, h2); DEBUGP("key: %.*s h1: %u h2: %u\n", keylen, key, h1, h2);
if (h1 == h2 && ++h2 > bmz->n) h2 = 0; if (h1 == h2 && ++h2 >= bmz->n) h2 = 0;
DEBUGP("key: %.*s g[h1]: %u g[h2]: %u edges: %u\n", keylen, key, bmz->g[h1], bmz->g[h2], bmz->m); DEBUGP("key: %.*s g[h1]: %u g[h2]: %u edges: %u\n", keylen, key, bmz->g[h1], bmz->g[h2], bmz->m);
return bmz->g[h1] + bmz->g[h2]; return bmz->g[h1] + bmz->g[h2];
} }
@ -620,6 +620,6 @@ cmph_uint32 bmz_search_packed(void *packed_mphf, const char *key, cmph_uint32 ke
register cmph_uint32 h1 = hash_packed(h1_ptr, h1_type, key, keylen) % n; register cmph_uint32 h1 = hash_packed(h1_ptr, h1_type, key, keylen) % n;
register cmph_uint32 h2 = hash_packed(h2_ptr, h2_type, key, keylen) % n; register cmph_uint32 h2 = hash_packed(h2_ptr, h2_type, key, keylen) % n;
if (h1 == h2 && ++h2 > n) h2 = 0; if (h1 == h2 && ++h2 >= n) h2 = 0;
return (g_ptr[h1] + g_ptr[h2]); return (g_ptr[h1] + g_ptr[h2]);
} }

View File

@ -157,11 +157,11 @@ static cmph_uint32 count_nlfile_keys(FILE *fd)
{ {
char buf[BUFSIZ]; char buf[BUFSIZ];
ptr = fgets(buf, BUFSIZ, fd); ptr = fgets(buf, BUFSIZ, fd);
if (feof(fd)) break; if (feof(fd)) break;
if (ferror(fd) || ptr == NULL) { if (ferror(fd) || ptr == NULL) {
perror("Error reading input file"); perror("Error reading input file");
return 0; return 0;
} }
if (buf[strlen(buf) - 1] != '\n') continue; if (buf[strlen(buf) - 1] != '\n') continue;
++count; ++count;
} }