https://github.com/git/git
Raw File
Tip revision: d83a831bf4eca748f159b326d5a2562085013900 authored by Junio C Hamano on 03 April 2011, 07:12:31 UTC
Git 1.7.4.3
Tip revision: d83a831
strcasestr.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;
}
back to top