mirror of
https://github.com/git/git.git
synced 2024-12-14 04:18:16 +08:00
4050c0df8e
This attempts to clean up the way various compatibility functions are defined and used. - A new header file, git-compat-util.h, is introduced. This looks at various NO_XXX and does necessary function name replacements, equivalent of -Dstrcasestr=gitstrcasestr in the Makefile. - Those function name replacements are removed from the Makefile. - Common features such as usage(), die(), xmalloc() are moved from cache.h to git-compat-util.h; cache.h includes git-compat-util.h itself. Signed-off-by: Junio C Hamano <junkio@cox.net>
23 lines
431 B
C
23 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;
|
|
}
|