swh:1:snp:47f1e8bb459169b0feb652a9c3d9cbabd8526d4a
Raw File
Tip revision: 6ab58895cd951f6f5c96fa432afb122cfeb12746 authored by Junio C Hamano on 24 December 2005, 08:02:08 UTC
GIT 1.0.4
Tip revision: 6ab5889
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