summaryrefslogtreecommitdiff
path: root/match.c
diff options
context:
space:
mode:
authorJohn Hawthorn <john.hawthorn@gmail.com>2014-07-12 15:18:56 -0700
committerJohn Hawthorn <john.hawthorn@gmail.com>2014-07-12 15:18:56 -0700
commit48c627b0603fe2bf061f520dae094afc0b1c3943 (patch)
tree136b400bf20ba63bcf105383a51df0c607ae3484 /match.c
parentafeeb5bb458042c353573c2b2f464d35123e5aad (diff)
Refactor into is_subset function
Diffstat (limited to 'match.c')
-rw-r--r--match.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/match.c b/match.c
index dc79660..abd928e 100644
--- a/match.c
+++ b/match.c
@@ -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;
}