OK, I give up. Where did you come up with _stricmp?
Todd
OK, sorry for throwing that out there.
I thought it was part of the standard C library, but it isn't. It just appears, unofficially, under different names, in various implementations of the C library. So a case-insensitive compare isn't an official part of the official C library either. Geeze. It seems like such a huge omission. Under VS, it's _stricmp() or stricmp(), under CodeWarrior for Mac it's stricmp() or strcasecmp(), and under OS X 10.4/Xcode it's strcasecmp().
Come to think of it, the leading underscore should have given me the hint.
I guess if you want to conform to the C standard you have to implement your own using tolower() (or toupper()) in a loop.
Let's see a first pass might be (This is off the top of my head, NOT tested code):
Code:
#include <ctype.h>
...
int mystricmp(const char* str1, const char* str2)
{
if (str1 == str2)
return 0;
else if (str1 == NULL)
return -1;
else if (str2 == NULL)
return 1;
else {
while (tolower(*str1) == tolower(*str2) && *str1 != 0 && *str2 != 0)
{
++str1;
++str2;
}
if (*str1 < *str2)
return -1;
else if (*str1 > *str2)
return 1;
else
return 0;
}
}
Anyway, again, sorry for the bad advice. I guess I haven't really done a lot of C/C++ coding on Mac OS X where I wanted to avoid the OS API (CFString, etc.) since the CodeWarrior days...