fzy

terminal fuzzy finder picker

git clone https://9o.is/git/fzy.git

commit bf14373ba814938183799f6a0bf5e39e3047e192
parent a0267abc51586b531ab37a7951c211d43c0c4044
Author: John Hawthorn <john.hawthorn@gmail.com>
Date:   Sat, 12 Jul 2014 15:18:56 -0700

Refactor into is_subset function

Diffstat:
Mmatch.c | 14++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/match.c b/match.c @@ -1,12 +1,18 @@ #include <ctype.h> -double match(const char *needle, const char *haystack){ +static int is_subset(const char *needle, const char *haystack){ while(*needle){ if(!*haystack) - return 0.0; - while(*haystack && tolower(*needle) == tolower(*haystack++)){ + return 0; + while(*haystack && tolower(*needle) == tolower(*haystack++)) needle++; - } + } + return 1; +} + +double match(const char *needle, const char *haystack){ + if(!is_subset(needle, haystack)){ + return 0.0; } return 1.0; }