Diff clean-up.
[git/jnareb-git.git] / compat / strcasestr.c
blobb96414d36b4d246f6adf47c14335052119bd0269
1 #include <string.h>
2 #include <ctype.h>
4 char *gitstrcasestr(const char *haystack, const char *needle)
6 int nlen = strlen(needle);
7 int hlen = strlen(haystack) - nlen + 1;
8 int i;
10 for (i = 0; i < hlen; i++) {
11 int j;
12 for (j = 0; j < nlen; j++) {
13 unsigned char c1 = haystack[i+j];
14 unsigned char c2 = needle[j];
15 if (toupper(c1) != toupper(c2))
16 goto next;
18 return (char *) haystack + i;
19 next:
22 return NULL;