Squashed 'third_party/git/' content from commit cb71568594
git-subtree-dir: third_party/git git-subtree-split: cb715685942260375e1eb8153b0768a376e4ece7
This commit is contained in:
commit
1b593e1ea4
3629 changed files with 1139935 additions and 0 deletions
22
compat/strcasestr.c
Normal file
22
compat/strcasestr.c
Normal file
|
|
@ -0,0 +1,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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue