From 0aaef1a8fadec0dfeb7fd5f070382a0398506784 Mon Sep 17 00:00:00 2001 From: Max Bruckner Date: Sun, 30 Apr 2017 19:44:55 +0200 Subject: [PATCH] sort_list: configurable case sensitivity --- cJSON_Utils.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cJSON_Utils.c b/cJSON_Utils.c index c07167d..48aeb07 100644 --- a/cJSON_Utils.c +++ b/cJSON_Utils.c @@ -1045,7 +1045,7 @@ CJSON_PUBLIC(cJSON *) cJSONUtils_GeneratePatches(cJSON * const from, cJSON * con } /* sort lists using mergesort */ -static cJSON *sort_list(cJSON *list) +static cJSON *sort_list(cJSON *list, const cJSON_bool case_sensitive) { cJSON *first = list; cJSON *second = list; @@ -1059,7 +1059,7 @@ static cJSON *sort_list(cJSON *list) return result; } - while ((current_item != NULL) && (current_item->next != NULL) && (compare_strings((unsigned char*)current_item->string, (unsigned char*)current_item->next->string, false) < 0)) + while ((current_item != NULL) && (current_item->next != NULL) && (compare_strings((unsigned char*)current_item->string, (unsigned char*)current_item->next->string, case_sensitive) < 0)) { /* Test for list sorted. */ current_item = current_item->next; @@ -1090,8 +1090,8 @@ static cJSON *sort_list(cJSON *list) } /* Recursively sort the sub-lists. */ - first = sort_list(first); - second = sort_list(second); + first = sort_list(first, case_sensitive); + second = sort_list(second, case_sensitive); result = NULL; /* Merge the sub-lists */ @@ -1157,7 +1157,7 @@ static cJSON *sort_list(cJSON *list) CJSON_PUBLIC(void) cJSONUtils_SortObject(cJSON * const object) { - object->child = sort_list(object->child); + object->child = sort_list(object->child, false); } CJSON_PUBLIC(cJSON *) cJSONUtils_MergePatch(cJSON *target, const cJSON * const patch) -- GitLab