We don't want to add keys when there are no keys in the previous list,
we want to only add new keys on the first pass. Otherwise if we end up
with an empty list we'll start again as if none of the previous words
where specified.
struct ll *curword = NULL;
struct keyarray keylist = { NULL, 0, 0 };
struct keyarray newkeylist = { NULL, 0, 0 };
struct ll *curword = NULL;
struct keyarray keylist = { NULL, 0, 0 };
struct keyarray newkeylist = { NULL, 0, 0 };
numkeys = 0;
searchtext = strdup(search);
numkeys = 0;
searchtext = strdup(search);
- if (keylist.count == 0 ||
- array_find(&keylist, keyid)) {
+ /*
+ * Only add the keys containing this word if this is
+ * our first pass (ie we have no existing key list),
+ * or the key contained a previous word.
+ */
+ if (firstpass || array_find(&keylist, keyid)) {
array_add(&newkeylist, keyid);
}
array_add(&newkeylist, keyid);
}
}
ret = cursor->c_close(cursor);
cursor = NULL;
}
ret = cursor->c_close(cursor);
cursor = NULL;
db4_endtrans();
}
llfree(wordlist, NULL);
db4_endtrans();
}
llfree(wordlist, NULL);