summaryrefslogtreecommitdiff
path: root/match.c
diff options
context:
space:
mode:
authorJohn Hawthorn <john.hawthorn@gmail.com>2014-07-12 15:22:44 -0700
committerJohn Hawthorn <john.hawthorn@gmail.com>2014-07-12 15:22:44 -0700
commit306443765cce8dfe9a81187fc100ae4d447660af (patch)
treef2c1ae94dcf993f559f52e1d3ca79fb9a1a7018a /match.c
parent48c627b0603fe2bf061f520dae094afc0b1c3943 (diff)
Add some special cases
Diffstat (limited to 'match.c')
-rw-r--r--match.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/match.c b/match.c
index abd928e..8ef15a1 100644
--- a/match.c
+++ b/match.c
@@ -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;
}