Well, I needed it, and so i wrote it.
Sort of fun.
Any 'optimizers' can have a go now :-)
char *strcasestr(char *haystack, char *needle)
{
/* case independent strstr */
char *hptr;
char *nptr;
char *pptr;
/* start at the beginning of haystack */
pptr = haystack;
/* for each position in haystack */
while(1)
{
/* starting at this position in haystack */
hptr = pptr;
nptr = needle;
/* test if strings match from here on */
while(1)
{
/* test for end of needle */
if(*nptr == 0)
{
/* found match */
return pptr;
}
/* test for end of haystack */
if(*hptr == 0) break;
/* test for any differences */
if( toupper(*hptr) != toupper(*nptr) ) break;
/* increment positions in strings */
hptr++;
nptr++;
}/* end while all characters in needle */
/* try next position in haystack */
pptr++;
/* test for end of haystack */
if(*pptr == 0) break;
}/* end while all positions in haystack */
return 0;
Quote:}/* end function strcasestr */