fzy
terminal fuzzy finder picker
git clone https://9o.is/git/fzy.git
commit 0480cad800f3dd2aa5aea1c5d7392d847636a7a6 parent acacebff38e3954421be605da02ffc15cceb9e13 Author: John Hawthorn <john.hawthorn@gmail.com> Date: Sat, 26 Jul 2014 22:53:33 -0700 debug: fix mat_print Diffstat:
| M | match.c | | | 24 | +++++++++++++++++------- |
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/match.c b/match.c @@ -16,23 +16,28 @@ int has_match(const char *needle, const char *haystack){ return 1; } +#define max(a, b) (((a) > (b)) ? (a) : (b)) +typedef double score_t; +#define SCORE_MAX DBL_MAX +#define SCORE_MIN -DBL_MAX + /* print one of the internal matrices */ -void mat_print(int *mat, int n, int m){ +void mat_print(score_t *mat, int n, int m){ int i, j; for(i = 0; i < n; i++){ for(j = 0; j < m; j++){ - fprintf(stderr, " %3i", mat[i*m + j]); + score_t val = mat[i*m + j]; + if(val == SCORE_MIN){ + fprintf(stderr, " -inf"); + }else{ + fprintf(stderr, " %.2f", val); + } } fprintf(stderr, "\n"); } fprintf(stderr, "\n\n"); } -#define max(a, b) (((a) > (b)) ? (a) : (b)) -typedef double score_t; -#define SCORE_MAX DBL_MAX -#define SCORE_MIN -DBL_MAX - double calculate_score(const char *needle, const char *haystack, size_t *positions){ if(!*haystack || !*needle) return SCORE_MIN; @@ -89,6 +94,11 @@ double calculate_score(const char *needle, const char *haystack, size_t *positio } } +#if 0 + mat_print(&D[0][0], n, m); + mat_print(&M[0][0], n, m); +#endif + /* backtrace to find the positions of optimal matching */ if(positions){ for(int i = n-1, j = m-1; i >= 0; i--){