1#include <string.h>
2#include <ctype.h>
34
char *gitstrcasestr(const char *haystack, const char *needle)
5{
6int nlen = strlen(needle);
7int hlen = strlen(haystack) - nlen + 1;
8int i;
910
for (i = 0; i < hlen; i++) {
11int j;
12for (j = 0; j < nlen; j++) {
13unsigned char c1 = haystack[i+j];
14unsigned char c2 = needle[j];
15if (toupper(c1) != toupper(c2))
16goto next;
17}
18return (char *) haystack + i;
19next:
20;
21}
22return NULL;
23}