summaryrefslogtreecommitdiff
path: root/match.c
diff options
context:
space:
mode:
authorJohn Hawthorn <john.hawthorn@gmail.com>2014-07-12 15:07:22 -0700
committerJohn Hawthorn <john.hawthorn@gmail.com>2014-07-12 15:17:04 -0700
commitafeeb5bb458042c353573c2b2f464d35123e5aad (patch)
tree5e81c336692403148e8d77c915f066191d66ae2a /match.c
parente550feae6dd230ceff8ebaab91f7e41ea333d1c7 (diff)
Add tests and split matching into match.c
Diffstat (limited to 'match.c')
-rw-r--r--match.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/match.c b/match.c
new file mode 100644
index 0000000..dc79660
--- /dev/null
+++ b/match.c
@@ -0,0 +1,12 @@
+#include <ctype.h>
+
+double match(const char *needle, const char *haystack){
+ while(*needle){
+ if(!*haystack)
+ return 0.0;
+ while(*haystack && tolower(*needle) == tolower(*haystack++)){
+ needle++;
+ }
+ }
+ return 1.0;
+}