| ... | ... |
@@ -1,12 +1,18 @@ |
| 1 | 1 |
#include <ctype.h> |
| 2 | 2 |
|
| 3 |
-double match(const char *needle, const char *haystack){
|
|
| 3 |
+static int is_subset(const char *needle, const char *haystack){
|
|
| 4 | 4 |
while(*needle){
|
| 5 | 5 |
if(!*haystack) |
| 6 |
- return 0.0; |
|
| 7 |
- while(*haystack && tolower(*needle) == tolower(*haystack++)){
|
|
| 6 |
+ return 0; |
|
| 7 |
+ while(*haystack && tolower(*needle) == tolower(*haystack++)) |
|
| 8 | 8 |
needle++; |
| 9 |
- } |
|
| 9 |
+ } |
|
| 10 |
+ return 1; |
|
| 11 |
+} |
|
| 12 |
+ |
|
| 13 |
+double match(const char *needle, const char *haystack){
|
|
| 14 |
+ if(!is_subset(needle, haystack)){
|
|
| 15 |
+ return 0.0; |
|
| 10 | 16 |
} |
| 11 | 17 |
return 1.0; |
| 12 | 18 |
} |