1
0
Fork 0

Maintenance: cJSON

unguarded if statements... suppress warnings
This commit is contained in:
Scott Giese 2021-02-20 23:15:29 -06:00
parent 98e9c45287
commit 3c0d5661b5

View file

@ -38,7 +38,8 @@ const char *cJSON_GetErrorPtr(void) {return ep;}
static int cJSON_strcasecmp(const char *s1,const char *s2)
{
if (!s1) return (s1==s2)?0:1;if (!s2) return 1;
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);
}
@ -496,8 +497,10 @@ static char *print_object(cJSON *item,int depth,int fmt)
*ptr++=':';if (fmt) *ptr++='\t';
strcpy(ptr,entries[i]);ptr+=strlen(entries[i]);
if (i!=numentries-1) *ptr++=',';
if (fmt) *ptr++='\n';*ptr=0;
cJSON_free(names[i]);cJSON_free(entries[i]);
if (fmt) *ptr++='\n';
*ptr=0;
cJSON_free(names[i]);
cJSON_free(entries[i]);
}
cJSON_free(names);cJSON_free(entries);
@ -523,7 +526,11 @@ void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) {cJSON_AddIte
void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item) {cJSON_AddItemToObject(object,string,create_reference(item));}
cJSON *cJSON_DetachItemFromArray(cJSON *array,int which) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return 0;
if (c->prev) c->prev->next=c->next;if (c->next) c->next->prev=c->prev;if (c==array->child) array->child=c->next;c->prev=c->next=0;return c;}
if (c->prev) c->prev->next=c->next;
if (c->next) c->next->prev=c->prev;
if (c==array->child) array->child=c->next;
c->prev=c->next=0;
return c;}
void cJSON_DeleteItemFromArray(cJSON *array,int which) {cJSON_Delete(cJSON_DetachItemFromArray(array,which));}
cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string) {int i=0;cJSON *c=object->child;while (c && cJSON_strcasecmp(c->string,string)) i++,c=c->next;if (c) return cJSON_DetachItemFromArray(object,i);return 0;}
void cJSON_DeleteItemFromObject(cJSON *object,const char *string) {cJSON_Delete(cJSON_DetachItemFromObject(object,string));}