From cb6445f47b9e38405601f012e2c1458c30c51cc0 Mon Sep 17 00:00:00 2001 From: Max Bruckner Date: Thu, 13 Oct 2016 23:26:53 +0700 Subject: [PATCH] reformatting: cJSON_strcasecmp --- cJSON_Utils.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/cJSON_Utils.c b/cJSON_Utils.c index 82aafee..d421161 100644 --- a/cJSON_Utils.c +++ b/cJSON_Utils.c @@ -4,11 +4,25 @@ #include #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; - for(; tolower(*s1) == tolower(*s2); ++s1, ++s2) if(*s1 == 0) return 0; - return tolower(*(const unsigned char *)s1) - tolower(*(const unsigned char *)s2); + if (!s1) + { + 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: */ @@ -392,4 +406,4 @@ cJSON *cJSONUtils_GenerateMergePatch(cJSON *from,cJSON *to) } if (!patch->child) {cJSON_Delete(patch);return 0;} return patch; -} \ No newline at end of file +} -- GitLab