[fix] Tokenized trie search

This commit is contained in:
Al
2015-12-05 15:21:52 -05:00
parent 24208c209f
commit 596c5ffdd3

View File

@@ -192,6 +192,8 @@ int trie_node_search_tail_tokens(trie_t *self, trie_node_t node, char *str, toke
trie_data_node_t old_data_node = self->data->a[data_index];
uint32_t current_tail_pos = old_data_node.tail;
log_debug("tail_index = %zu\n", tail_index);
unsigned char *tail_ptr = self->tail->a + current_tail_pos + tail_index;
if (!(*tail_ptr)) {
@@ -213,14 +215,19 @@ int trie_node_search_tail_tokens(trie_t *self, trie_node_t node, char *str, toke
if (token.type == WHITESPACE) continue;
if (i < tokens->n - 1 && *tail_ptr == ' ') {
if (*tail_ptr == ' ') {
tail_ptr++;
log_debug("Got space, advancing pointer, tail_ptr=%s\n", tail_ptr);
}
log_debug("Tail string compare: %s with %.*s\n", tail_ptr, (int)token_length, ptr);
if (strncmp((char *)tail_ptr, ptr, token_length) == 0) {
tail_ptr += token_length;
log_debug("tail comparison successful\n");
if (i == tokens->n - 1) {
return i;
}
} else {
return -1;
}