Browse code

Add some special cases

John Hawthorn authored on 12/07/2014 22:22:44
Showing 1 changed files

  • match.c index abd928e..8ef15a1 100644
... ...
@@ -1,4 +1,5 @@
1 1
 #include <ctype.h>
2
+#include <string.h>
2 3
 
3 4
 static int is_subset(const char *needle, const char *haystack){
4 5
 	while(*needle){
... ...
@@ -11,8 +12,13 @@ static int is_subset(const char *needle, const char *haystack){
11 12
 }
12 13
 
13 14
 double match(const char *needle, const char *haystack){
14
-	if(!is_subset(needle, haystack)){
15
+	if(!*needle){
16
+		return 1.0;
17
+	}else if(!is_subset(needle, haystack)){
15 18
 		return 0.0;
19
+	}else if(!strcasecmp(needle, haystack)){
20
+		return 1.0;
21
+	}else{
22
+		return 0.9;
16 23
 	}
17
-	return 1.0;
18 24
 }