diff options
author | John Hawthorn <john.hawthorn@gmail.com> | 2014-07-12 15:18:56 -0700 |
---|---|---|
committer | John Hawthorn <john.hawthorn@gmail.com> | 2014-07-12 15:18:56 -0700 |
commit | 48c627b0603fe2bf061f520dae094afc0b1c3943 (patch) | |
tree | 136b400bf20ba63bcf105383a51df0c607ae3484 /match.c | |
parent | afeeb5bb458042c353573c2b2f464d35123e5aad (diff) |
Refactor into is_subset function
Diffstat (limited to 'match.c')
-rw-r--r-- | match.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -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; } |