blob: 26896deca64c531f57b4c48ea92134f876b8e537 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#include "../git-compat-util.h"
char *gitstrcasestr(const char *haystack, const char *needle)
{
int nlen = strlen(needle);
int hlen = strlen(haystack) - nlen + 1;
int i;
for (i = 0; i < hlen; i++) {
int j;
for (j = 0; j < nlen; j++) {
unsigned char c1 = haystack[i+j];
unsigned char c2 = needle[j];
if (toupper(c1) != toupper(c2))
goto next;
}
return (char *) haystack + i;
next:
;
}
return NULL;
}
|