7ef0d62730
Merge commit '1b593e1ea4d2af0f6444d9a7788d5d99abd6fde5' as 'third_party/git'
22 lines
431 B
C
22 lines
431 B
C
#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;
|
|
}
|