Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b7ce06224b | ||
|
|
227d3398d6 | ||
|
|
466eb8e3f8 | ||
|
|
4ec6e76ea2 |
@@ -7,7 +7,7 @@ project(cJSON C)
|
|||||||
|
|
||||||
set(PROJECT_VERSION_MAJOR 1)
|
set(PROJECT_VERSION_MAJOR 1)
|
||||||
set(PROJECT_VERSION_MINOR 4)
|
set(PROJECT_VERSION_MINOR 4)
|
||||||
set(PROJECT_VERSION_PATCH 2)
|
set(PROJECT_VERSION_PATCH 3)
|
||||||
set(CJSON_VERSION_SO 1)
|
set(CJSON_VERSION_SO 1)
|
||||||
set(CJSON_UTILS_VERSION_SO 1)
|
set(CJSON_UTILS_VERSION_SO 1)
|
||||||
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
|
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
|
||||||
|
|||||||
2
Makefile
2
Makefile
@@ -10,7 +10,7 @@ UTILS_TEST_SRC = cJSON.c cJSON_Utils.c test_utils.c
|
|||||||
|
|
||||||
LDLIBS = -lm
|
LDLIBS = -lm
|
||||||
|
|
||||||
LIBVERSION = 1.4.2
|
LIBVERSION = 1.4.3
|
||||||
CJSON_SOVERSION = 1
|
CJSON_SOVERSION = 1
|
||||||
UTILS_SOVERSION = 1
|
UTILS_SOVERSION = 1
|
||||||
|
|
||||||
|
|||||||
20
cJSON.c
20
cJSON.c
@@ -47,7 +47,7 @@ CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* This is a safeguard to prevent copy-pasters from using incompatible C and header files */
|
/* This is a safeguard to prevent copy-pasters from using incompatible C and header files */
|
||||||
#if (CJSON_VERSION_MAJOR != 1) || (CJSON_VERSION_MINOR != 4) || (CJSON_VERSION_PATCH != 2)
|
#if (CJSON_VERSION_MAJOR != 1) || (CJSON_VERSION_MINOR != 4) || (CJSON_VERSION_PATCH != 3)
|
||||||
#error cJSON.h and cJSON.c have different versions. Make sure that both have the same.
|
#error cJSON.h and cJSON.c have different versions. Make sure that both have the same.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1226,7 +1226,7 @@ static cJSON_bool print_array(const cJSON * const item, const size_t depth, cons
|
|||||||
update_offset(output_buffer);
|
update_offset(output_buffer);
|
||||||
if (current_element->next)
|
if (current_element->next)
|
||||||
{
|
{
|
||||||
length = format ? 2 : 1;
|
length = (size_t) (format ? 2 : 1);
|
||||||
output_pointer = ensure(output_buffer, length + 1, hooks);
|
output_pointer = ensure(output_buffer, length + 1, hooks);
|
||||||
if (output_pointer == NULL)
|
if (output_pointer == NULL)
|
||||||
{
|
{
|
||||||
@@ -1362,7 +1362,7 @@ static cJSON_bool print_object(const cJSON * const item, const size_t depth, con
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Compose the output: */
|
/* Compose the output: */
|
||||||
length = format ? 2 : 1; /* fmt: {\n */
|
length = (size_t) (format ? 2 : 1); /* fmt: {\n */
|
||||||
output_pointer = ensure(output_buffer, length + 1, hooks);
|
output_pointer = ensure(output_buffer, length + 1, hooks);
|
||||||
if (output_pointer == NULL)
|
if (output_pointer == NULL)
|
||||||
{
|
{
|
||||||
@@ -1400,7 +1400,7 @@ static cJSON_bool print_object(const cJSON * const item, const size_t depth, con
|
|||||||
}
|
}
|
||||||
update_offset(output_buffer);
|
update_offset(output_buffer);
|
||||||
|
|
||||||
length = format ? 2 : 1;
|
length = (size_t) (format ? 2 : 1);
|
||||||
output_pointer = ensure(output_buffer, length, hooks);
|
output_pointer = ensure(output_buffer, length, hooks);
|
||||||
if (output_pointer == NULL)
|
if (output_pointer == NULL)
|
||||||
{
|
{
|
||||||
@@ -1421,7 +1421,7 @@ static cJSON_bool print_object(const cJSON * const item, const size_t depth, con
|
|||||||
update_offset(output_buffer);
|
update_offset(output_buffer);
|
||||||
|
|
||||||
/* print comma if not last */
|
/* print comma if not last */
|
||||||
length = (size_t) (format ? 1 : 0) + (current_item->next ? 1 : 0);
|
length = (size_t) ((format ? 1 : 0) + (current_item->next ? 1 : 0));
|
||||||
output_pointer = ensure(output_buffer, length + 1, hooks);
|
output_pointer = ensure(output_buffer, length + 1, hooks);
|
||||||
if (output_pointer == NULL)
|
if (output_pointer == NULL)
|
||||||
{
|
{
|
||||||
@@ -1580,6 +1580,10 @@ CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSO
|
|||||||
item->type &= ~cJSON_StringIsConst;
|
item->type &= ~cJSON_StringIsConst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined (__clang__) || ((__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5))))
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#endif
|
||||||
|
#pragma GCC diagnostic ignored "-Wcast-qual"
|
||||||
/* Add an item to an object with constant string as key */
|
/* Add an item to an object with constant string as key */
|
||||||
CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item)
|
CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item)
|
||||||
{
|
{
|
||||||
@@ -1591,13 +1595,13 @@ CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJ
|
|||||||
{
|
{
|
||||||
global_hooks.deallocate(item->string);
|
global_hooks.deallocate(item->string);
|
||||||
}
|
}
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Wcast-qual"
|
|
||||||
item->string = (char*)string;
|
item->string = (char*)string;
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
item->type |= cJSON_StringIsConst;
|
item->type |= cJSON_StringIsConst;
|
||||||
cJSON_AddItemToArray(object, item);
|
cJSON_AddItemToArray(object, item);
|
||||||
}
|
}
|
||||||
|
#if defined (__clang__) || ((__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5))))
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item)
|
CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item)
|
||||||
{
|
{
|
||||||
|
|||||||
2
cJSON.h
2
cJSON.h
@@ -31,7 +31,7 @@ extern "C"
|
|||||||
/* project version */
|
/* project version */
|
||||||
#define CJSON_VERSION_MAJOR 1
|
#define CJSON_VERSION_MAJOR 1
|
||||||
#define CJSON_VERSION_MINOR 4
|
#define CJSON_VERSION_MINOR 4
|
||||||
#define CJSON_VERSION_PATCH 2
|
#define CJSON_VERSION_PATCH 3
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
|||||||
@@ -230,11 +230,11 @@ static void cJSONUtils_InplaceDecodePointerString(unsigned char *string)
|
|||||||
|
|
||||||
for (; *string; (void)s2++, string++)
|
for (; *string; (void)s2++, string++)
|
||||||
{
|
{
|
||||||
*s2 = (*string != '~')
|
*s2 = (unsigned char) ((*string != '~')
|
||||||
? (*string)
|
? (*string)
|
||||||
: ((*(++string) == '0')
|
: ((*(++string) == '0')
|
||||||
? '~'
|
? '~'
|
||||||
: '/');
|
: '/'));
|
||||||
}
|
}
|
||||||
|
|
||||||
*s2 = '\0';
|
*s2 = '\0';
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ static void print_number_should_print_negative_integers(void)
|
|||||||
{
|
{
|
||||||
assert_print_number("-1", -1);
|
assert_print_number("-1", -1);
|
||||||
assert_print_number("-32768", -32768);
|
assert_print_number("-32768", -32768);
|
||||||
assert_print_number("-2147483648", -2147483648);
|
assert_print_number("-2147483648", -2147483648.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_number_should_print_positive_integers(void)
|
static void print_number_should_print_positive_integers(void)
|
||||||
|
|||||||
Reference in New Issue
Block a user