diff options
author | John Hawthorn <john.hawthorn@gmail.com> | 2014-07-12 15:22:44 -0700 |
---|---|---|
committer | John Hawthorn <john.hawthorn@gmail.com> | 2014-07-12 15:22:44 -0700 |
commit | 306443765cce8dfe9a81187fc100ae4d447660af (patch) | |
tree | f2c1ae94dcf993f559f52e1d3ca79fb9a1a7018a /match.c | |
parent | 48c627b0603fe2bf061f520dae094afc0b1c3943 (diff) |
Add some special cases
Diffstat (limited to 'match.c')
-rw-r--r-- | match.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -1,4 +1,5 @@ #include <ctype.h> +#include <string.h> static int is_subset(const char *needle, const char *haystack){ while(*needle){ @@ -11,8 +12,13 @@ static int is_subset(const char *needle, const char *haystack){ } double match(const char *needle, const char *haystack){ - if(!is_subset(needle, haystack)){ + if(!*needle){ + return 1.0; + }else if(!is_subset(needle, haystack)){ return 0.0; + }else if(!strcasecmp(needle, haystack)){ + return 1.0; + }else{ + return 0.9; } - return 1.0; } |