diff --git a/lib/trie.c b/lib/trie.c index 0e5dd6e4b..0ecef6390 100644 --- a/lib/trie.c +++ b/lib/trie.c @@ -64,8 +64,8 @@ static void trie_destroy_node(struct trie_node *node); * characters are stored in reverse to make accessing the * more common case (non-control chars) more space efficient. */ -#define TRIE_CHAR2INDEX(ch) (126 - ch) -#define TRIE_INDEX2CHAR(idx) (126 - idx) +#define TRIE_CHAR2INDEX(ch) (127 - (signed char)ch) +#define TRIE_INDEX2CHAR(idx) (127 - (signed char)idx) static int32_t diff --git a/tests/check_map.c b/tests/check_map.c index e73c832ec..5a98f757c 100644 --- a/tests/check_map.c +++ b/tests/check_map.c @@ -41,6 +41,21 @@ const char *chars2[] = { NULL, }; +const char *composers[] = { + "Béla Bartók", + "Zoltán Kodály", + "Ludwig van Beethoven", + "Wolfgang Amadeus Mozart", + "Leoš Janáček", + "Benjamin Britten", + "Josef Haydn", + "Claude Debussy", + "Charles Ives", + /* Maybe in an alien language ... but they can cause trie crashes & conflicts */ + "\x7e\x7f\x80\x81", "\x7e", "\x7e\x7f", "\x7e\x7f\x80", +}; + + static char *notified_key = NULL; static void *notified_value = NULL; static void *notified_new_value = NULL; @@ -717,6 +732,45 @@ test_map_load(qb_map_t *m, const char* test_name) qb_log(LOG_INFO, "%25s %12.2f dels/sec (%d/%fs)\n", test_name, ops, count2, secs); } +static void test_accents_load(qb_map_t *m, const char* test_name) +{ + int i; + int32_t res = 0; + int32_t count = 0; + int32_t count2; + void *value; + + ck_assert(m != NULL); + /* + * Load accented names + */ + for (i=0; i