mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
make strcasecmp STABLE if passed a null string
git-svn-id: http://svn.code.sf.net/p/cjson/code@27 e3330c51-1366-4df0-8b21-3ccf24e3d50e
This commit is contained in:
1
cJSON.c
1
cJSON.c
@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
static int cJSON_strcasecmp(const char *s1,const char *s2)
|
static int cJSON_strcasecmp(const char *s1,const char *s2)
|
||||||
{
|
{
|
||||||
|
if (!s1) return (s1==s2)?0:1;if (!s2) return 1;
|
||||||
for(; tolower(*s1) == tolower(*s2); ++s1, ++s2) if(*s1 == 0) return 0;
|
for(; tolower(*s1) == tolower(*s2); ++s1, ++s2) if(*s1 == 0) return 0;
|
||||||
return tolower(*(const unsigned char *)s1) - tolower(*(const unsigned char *)s2);
|
return tolower(*(const unsigned char *)s1) - tolower(*(const unsigned char *)s2);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user