From 8e3b07fe006abdd4316fe8adacdb6a471183a685 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Thu, 11 Sep 2008 14:26:49 +0200 Subject: [PATCH] Fix duplicate management. Signed-off-by: Florent Bruneau --- common/trie.c | 3 +++ common/tst-trie.c | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/common/trie.c b/common/trie.c index 947a817..3ac0c69 100644 --- a/common/trie.c +++ b/common/trie.c @@ -258,6 +258,9 @@ static inline void trie_compile_aux(trie_t *trie, int id, current = trie->keys[i][offset]; } } + if (fork_pos == 0 && current == '\0') { + return; + } } forks[fork_pos] = last_key; diff --git a/common/tst-trie.c b/common/tst-trie.c index 4202261..77fd208 100644 --- a/common/tst-trie.c +++ b/common/tst-trie.c @@ -104,8 +104,6 @@ static trie_t *create_trie_from_file(const char *file) } munmap((void*)map, st.st_size); trie_compile(db, false); - printf("OK\n"); - sleep(10); return db; } @@ -140,6 +138,7 @@ int main(int argc, char *argv[]) ASSERT_FALSE("abcde"); ASSERT_FALSE("coucou chez vous tous"); ASSERT_TRUE("abcde123456789"); + ASSERT_TRUE("abcde123456789"); ASSERT_TRUE("abcde123654789"); ASSERT_TRUE("abcdefghi"); ASSERT_TRUE("coucou"); @@ -152,7 +151,7 @@ int main(int argc, char *argv[]) */ if (argc > 1) { trie = create_trie_from_file(argv[1]); - trie_inspect(trie); +// trie_inspect(trie); trie_delete(&trie); } return 0; -- 2.20.1