mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
refactor cJSONUtils_strcasecmp
This commit is contained in:
parent
055c7007e5
commit
44d313212b
@ -46,25 +46,28 @@ static unsigned char* cJSONUtils_strdup(const unsigned char* const string)
|
|||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cJSONUtils_strcasecmp(const unsigned char *s1, const unsigned char *s2)
|
/* Case insensitive string comparison, doesn't consider two NULL pointers equal though */
|
||||||
|
static int cJSONUtils_strcasecmp(const unsigned char *string1, const unsigned char *string2)
|
||||||
{
|
{
|
||||||
if (!s1)
|
if ((string1 == NULL) || (string2 == NULL))
|
||||||
{
|
|
||||||
return (s1 == s2) ? 0 : 1; /* both NULL? */
|
|
||||||
}
|
|
||||||
if (!s2)
|
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
for(; tolower(*s1) == tolower(*s2); (void)++s1, ++s2)
|
|
||||||
|
if (string1 == string2)
|
||||||
{
|
{
|
||||||
if(*s1 == 0)
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(; tolower(*string1) == tolower(*string2); (void)string1++, string2++)
|
||||||
|
{
|
||||||
|
if (*string1 == '\0')
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return tolower(*s1) - tolower(*s2);
|
return tolower(*string1) - tolower(*string2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* JSON Pointer implementation: */
|
/* JSON Pointer implementation: */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user