1
0
mirror of https://github.com/DaveGamble/cJSON synced 2024-12-26 00:22:04 +00:00

reformatting: cJSON_strcasecmp

This commit is contained in:
Max Bruckner 2016-10-13 23:26:53 +07:00
parent 526d6b1312
commit cb6445f47b

View File

@ -4,11 +4,25 @@
#include <stdio.h> #include <stdio.h>
#include "cJSON_Utils.h" #include "cJSON_Utils.h"
static int cJSONUtils_strcasecmp(const char *s1,const char *s2) static int cJSONUtils_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);
} }
/* JSON Pointer implementation: */ /* JSON Pointer implementation: */