mirror of
https://github.com/DaveGamble/cJSON.git
synced 2024-12-26 21:04:24 +08:00
reformatting: cJSON_strcasecmp
This commit is contained in:
parent
c42b774f9f
commit
542ed727d7
23
cJSON.c
23
cJSON.c
@ -39,11 +39,26 @@ const char *cJSON_GetErrorPtr(void)
|
|||||||
return global_ep;
|
return global_ep;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cJSON_strcasecmp(const char *s1,const char *s2)
|
/* case insensitive strcmp */
|
||||||
|
static int cJSON_strcasecmp(const char *s1, const char *s2)
|
||||||
{
|
{
|
||||||
if (!s1) return (s1==s2)?0:1;if (!s2) return 1;
|
if (!s1)
|
||||||
for(; tolower(*s1) == tolower(*s2); ++s1, ++s2) if(*s1 == 0) return 0;
|
{
|
||||||
return tolower(*(const unsigned char *)s1) - tolower(*(const unsigned char *)s2);
|
return (s1 == s2) ? 0 : 1; /* both NULL? */
|
||||||
|
}
|
||||||
|
if (!s2)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
for(; tolower(*s1) == tolower(*s2); ++s1, ++s2)
|
||||||
|
{
|
||||||
|
if (*s1 == 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tolower(*(const unsigned char *)s1) - tolower(*(const unsigned char *)s2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *(*cJSON_malloc)(size_t sz) = malloc;
|
static void *(*cJSON_malloc)(size_t sz) = malloc;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user