fzy
terminal fuzzy finder picker
git clone https://9o.is/git/fzy.git
commit 8f6c6da12e99fce1b05eaab63273803bab150abb parent e685e39fbfc63db4f6b5e957cecd58ee55c5f01b Author: John Hawthorn <john.hawthorn@gmail.com> Date: Wed, 3 Aug 2016 23:43:36 -0700 Fix segfault when encountering utf-8 characters Diffstat:
| M | CHANGELOG.md | | | 2 | ++ |
| M | src/bonus.h | | | 2 | +- |
| M | test/fzytest.c | | | 12 | ++++++++++++ |
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md @@ -1,6 +1,8 @@ ## 0.7 (unreleased) Bugfixes: + + - Fixed a segfault when encountering non-ascii characters - Fixed building against musl libc ## 0.6 (2016-07-26) diff --git a/src/bonus.h b/src/bonus.h @@ -103,6 +103,6 @@ const size_t bonus_index[256] = { ASSIGN_DIGIT(1) }; -#define COMPUTE_BONUS(last_ch, ch) (bonus_states[bonus_index[(size_t)(ch)]][(size_t)(last_ch)]) +#define COMPUTE_BONUS(last_ch, ch) (bonus_states[bonus_index[(unsigned char)(ch)]][(unsigned char)(last_ch)]) #endif diff --git a/test/fzytest.c b/test/fzytest.c @@ -268,6 +268,17 @@ void test_choices_without_search() { choices_destroy(&choices); } +/* Regression test for segfault */ +void test_choices_unicode() { + choices_t choices; + choices_init(&choices); + + choices_add(&choices, "Edmund Husserl - Méditations cartésiennes - Introduction a la phénoménologie.pdf"); + choices_search(&choices, "e"); + + choices_destroy(&choices); +} + void summary() { printf("%i tests, %i assertions, %i failures\n", testsrun, assertionsrun, testsfailed); } @@ -298,6 +309,7 @@ int main(int argc, char *argv[]) { runtest(test_choices_1); runtest(test_choices_2); runtest(test_choices_without_search); + runtest(test_choices_unicode); summary();