You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
438 B
24 lines
438 B
20 years ago
|
#include <string.h>
|
||
|
#include <ctype.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;
|
||
|
}
|