mirror of
https://github.com/DaveGamble/cJSON.git
synced 2026-11-14 19:03:32 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d2735278ed | ||
|
|
8e84db4c4e | ||
|
|
8e357f825b | ||
|
|
2e5171d8d6 | ||
|
|
c8ca78a3cc | ||
|
|
0b13220419 | ||
|
|
23f027139e | ||
|
|
60c3b0a571 | ||
|
|
857c037ccc | ||
|
|
3fb9d929e1 | ||
|
|
cf97c6f066 | ||
|
|
1ef4deec06 | ||
|
|
4578d3a9e1 | ||
|
|
b95a4c56b0 | ||
|
|
7db005e028 | ||
|
|
1fc755ac09 | ||
|
|
a82449fa3e | ||
|
|
2a6299d904 | ||
|
|
43f471bff1 | ||
|
|
7103844037 | ||
|
|
3442b36672 | ||
|
|
cb4661cd91 | ||
|
|
a65abf2f4f | ||
|
|
3999b12848 |
No files matched your search
+7
-1
@@ -1,2 +1,8 @@
|
|||||||
* text=auto
|
* text=auto
|
||||||
/tests/inputs/* text eol=lf
|
/tests/inputs/* text eol=lf
|
||||||
|
|
||||||
|
.gitattributes export-ignore
|
||||||
|
.gitignore export-ignore
|
||||||
|
.github export-ignore
|
||||||
|
.editorconfig export-ignore
|
||||||
|
.travis.yml export-ignore
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
- 'LICENSE'
|
||||||
|
pull_request:
|
||||||
|
types: [opened, synchronize]
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
- 'LICENSE'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
linux:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: "!contains(github.event.head_commit.message, 'ci skip')"
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
mem_check:
|
||||||
|
- ENABLE_VALGRIND
|
||||||
|
- ENABLE_SANITIZERS
|
||||||
|
- NONE_MEM_CHECK
|
||||||
|
compiler:
|
||||||
|
- GCC
|
||||||
|
- CLANG
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: install build dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install clang-8 valgrind
|
||||||
|
- name: build and test
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if [ "${{ matrix.mem_check }}" == "ENABLE_VALGRIND" ]; then
|
||||||
|
EVENT_CMAKE_OPTIONS="-DENABLE_CJSON_UTILS=ON -DENABLE_VALGRIND=ON -DENABLE_SAFE_STACK=ON -DENABLE_SANITIZERS=OFF"
|
||||||
|
elif [ "${{ matrix.mem_check }}" == "ENABLE_SANITIZERS" ]; then
|
||||||
|
EVENT_CMAKE_OPTIONS="-DENABLE_CJSON_UTILS=ON -DENABLE_VALGRIND=OFF -DENABLE_SAFE_STACK=OFF -DENABLE_SANITIZERS=ON"
|
||||||
|
else
|
||||||
|
EVENT_CMAKE_OPTIONS="-DENABLE_CJSON_UTILS=ON -DENABLE_VALGRIND=OFF -DENABLE_SAFE_STACK=OFF -DENABLE_SANITIZERS=OFF"
|
||||||
|
fi
|
||||||
|
if [ "${{ matrix.compiler }}" == "GCC" ]; then
|
||||||
|
export CC=gcc
|
||||||
|
else
|
||||||
|
export CC=clang
|
||||||
|
fi
|
||||||
|
#run build and test
|
||||||
|
JOBS=20
|
||||||
|
export CTEST_PARALLEL_LEVEL=$JOBS
|
||||||
|
export CTEST_OUTPUT_ON_FAILURE=1
|
||||||
|
mkdir -p build
|
||||||
|
cd build
|
||||||
|
echo [cmake]: cmake .. $EVENT_CMAKE_OPTIONS
|
||||||
|
cmake .. $EVENT_CMAKE_OPTIONS || (rm -rf * && cmake .. $EVENT_CMAKE_OPTIONS)
|
||||||
|
cmake --build .
|
||||||
|
make
|
||||||
|
make test
|
||||||
|
|
||||||
|
macos:
|
||||||
|
runs-on: macos-latest
|
||||||
|
if: "!contains(github.event.head_commit.message, 'ci skip')"
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
mem_check:
|
||||||
|
- ENABLE_VALGRIND
|
||||||
|
- ENABLE_SANITIZERS
|
||||||
|
- NONE_MEM_CHECK
|
||||||
|
compiler:
|
||||||
|
- GCC
|
||||||
|
- CLANG
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: build and test
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if [ "${{ matrix.mem_check }}" == "ENABLE_VALGRIND" ]; then
|
||||||
|
EVENT_CMAKE_OPTIONS="-DENABLE_CJSON_UTILS=ON -DENABLE_VALGRIND=ON -DENABLE_SAFE_STACK=ON -DENABLE_SANITIZERS=OFF"
|
||||||
|
elif [ "${{ matrix.mem_check }}" == "ENABLE_SANITIZERS" ]; then
|
||||||
|
EVENT_CMAKE_OPTIONS="-DENABLE_CJSON_UTILS=ON -DENABLE_VALGRIND=OFF -DENABLE_SAFE_STACK=OFF -DENABLE_SANITIZERS=ON"
|
||||||
|
else
|
||||||
|
EVENT_CMAKE_OPTIONS="-DENABLE_CJSON_UTILS=ON -DENABLE_VALGRIND=OFF -DENABLE_SAFE_STACK=OFF -DENABLE_SANITIZERS=OFF"
|
||||||
|
fi
|
||||||
|
if [ "${{ matrix.compiler }}" == "GCC" ]; then
|
||||||
|
export CC=gcc
|
||||||
|
else
|
||||||
|
export CC=clang
|
||||||
|
fi
|
||||||
|
#run build and test
|
||||||
|
JOBS=20
|
||||||
|
export CTEST_PARALLEL_LEVEL=$JOBS
|
||||||
|
export CTEST_OUTPUT_ON_FAILURE=1
|
||||||
|
mkdir -p build
|
||||||
|
cd build
|
||||||
|
echo [cmake]: cmake .. $EVENT_CMAKE_OPTIONS
|
||||||
|
cmake .. $EVENT_CMAKE_OPTIONS || (rm -rf * && cmake .. $EVENT_CMAKE_OPTIONS)
|
||||||
|
cmake --build .
|
||||||
|
make
|
||||||
|
make test
|
||||||
@@ -1,3 +1,11 @@
|
|||||||
|
1.7.14 (Sep 3, 2020)
|
||||||
|
======
|
||||||
|
Fixes:
|
||||||
|
------
|
||||||
|
* optimize the way to find tail node, see [#503](https://github.com/DaveGamble/cJSON/pull/503)
|
||||||
|
* Fix WError error on macosx because NAN is a float. Thanks @sappo, see [#484](https://github.com/DaveGamble/cJSON/pull/484)
|
||||||
|
* Fix some bugs in detach and replace. Thanks @miaoerduo, see [#456](https://github.com/DaveGamble/cJSON/pull/456)
|
||||||
|
|
||||||
1.7.13 (Apr 2, 2020)
|
1.7.13 (Apr 2, 2020)
|
||||||
======
|
======
|
||||||
Features:
|
Features:
|
||||||
|
|||||||
+7
-6
@@ -7,7 +7,7 @@ include(GNUInstallDirs)
|
|||||||
|
|
||||||
set(PROJECT_VERSION_MAJOR 1)
|
set(PROJECT_VERSION_MAJOR 1)
|
||||||
set(PROJECT_VERSION_MINOR 7)
|
set(PROJECT_VERSION_MINOR 7)
|
||||||
set(PROJECT_VERSION_PATCH 13)
|
set(PROJECT_VERSION_PATCH 14)
|
||||||
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}")
|
||||||
@@ -68,7 +68,6 @@ if (ENABLE_SANITIZERS)
|
|||||||
-fno-omit-frame-pointer
|
-fno-omit-frame-pointer
|
||||||
-fsanitize=address
|
-fsanitize=address
|
||||||
-fsanitize=undefined
|
-fsanitize=undefined
|
||||||
-fsanitize=float-divide-by-zero
|
|
||||||
-fsanitize=float-cast-overflow
|
-fsanitize=float-cast-overflow
|
||||||
-fsanitize-address-use-after-scope
|
-fsanitize-address-use-after-scope
|
||||||
-fsanitize=integer
|
-fsanitize=integer
|
||||||
@@ -223,10 +222,12 @@ configure_file(
|
|||||||
"${CMAKE_CURRENT_SOURCE_DIR}/library_config/cJSONConfigVersion.cmake.in"
|
"${CMAKE_CURRENT_SOURCE_DIR}/library_config/cJSONConfigVersion.cmake.in"
|
||||||
${PROJECT_BINARY_DIR}/cJSONConfigVersion.cmake @ONLY)
|
${PROJECT_BINARY_DIR}/cJSONConfigVersion.cmake @ONLY)
|
||||||
|
|
||||||
# Install package config files
|
if(ENABLE_TARGET_EXPORT)
|
||||||
install(FILES ${PROJECT_BINARY_DIR}/cJSONConfig.cmake
|
# Install package config files
|
||||||
${PROJECT_BINARY_DIR}/cJSONConfigVersion.cmake
|
install(FILES ${PROJECT_BINARY_DIR}/cJSONConfig.cmake
|
||||||
DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/cmake/cJSON")
|
${PROJECT_BINARY_DIR}/cJSONConfigVersion.cmake
|
||||||
|
DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/cmake/cJSON")
|
||||||
|
endif()
|
||||||
|
|
||||||
option(ENABLE_CJSON_TEST "Enable building cJSON test" ON)
|
option(ENABLE_CJSON_TEST "Enable building cJSON test" ON)
|
||||||
if(ENABLE_CJSON_TEST)
|
if(ENABLE_CJSON_TEST)
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ Contributors:
|
|||||||
* [Fabrice Fontaine](https://github.com/ffontaine)
|
* [Fabrice Fontaine](https://github.com/ffontaine)
|
||||||
* Ian Mobley
|
* Ian Mobley
|
||||||
* Irwan Djadjadi
|
* Irwan Djadjadi
|
||||||
|
* [HuKeping](https://github.com/HuKeping)
|
||||||
* [IvanVoid](https://github.com/npi3pak)
|
* [IvanVoid](https://github.com/npi3pak)
|
||||||
* [Jakub Wilk](https://github.com/jwilk)
|
* [Jakub Wilk](https://github.com/jwilk)
|
||||||
* [Jiri Zouhar](https://github.com/loigu)
|
* [Jiri Zouhar](https://github.com/loigu)
|
||||||
@@ -36,12 +37,15 @@ Contributors:
|
|||||||
* [Julian Ste](https://github.com/julian-st)
|
* [Julian Ste](https://github.com/julian-st)
|
||||||
* [Julián Vásquez](https://github.com/juvasquezg)
|
* [Julián Vásquez](https://github.com/juvasquezg)
|
||||||
* [Kevin Branigan](https://github.com/kbranigan)
|
* [Kevin Branigan](https://github.com/kbranigan)
|
||||||
|
* [Kevin Sapper](https://github.com/sappo)
|
||||||
* [Kyle Chisholm](https://github.com/ChisholmKyle)
|
* [Kyle Chisholm](https://github.com/ChisholmKyle)
|
||||||
* [Linus Wallgren](https://github.com/ecksun)
|
* [Linus Wallgren](https://github.com/ecksun)
|
||||||
* [Mateusz Szafoni](https://github.com/raiden00pl)
|
* [Mateusz Szafoni](https://github.com/raiden00pl)
|
||||||
* Mike Pontillo
|
* Mike Pontillo
|
||||||
|
* [miaoerduo](https://github.com/miaoerduo)
|
||||||
* [Mike Jerris](https://github.com/mjerris)
|
* [Mike Jerris](https://github.com/mjerris)
|
||||||
* [Mike Robinson](https://github.com/mhrobinson)
|
* [Mike Robinson](https://github.com/mhrobinson)
|
||||||
|
* [Moorthy](https://github.com/moorthy-bs)
|
||||||
* [myd7349](https://github.com/myd7349)
|
* [myd7349](https://github.com/myd7349)
|
||||||
* [NancyLi1013](https://github.com/NancyLi1013)
|
* [NancyLi1013](https://github.com/NancyLi1013)
|
||||||
* Paulo Antonio Alvarez
|
* Paulo Antonio Alvarez
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ CJSON_TEST_SRC = cJSON.c test.c
|
|||||||
|
|
||||||
LDLIBS = -lm
|
LDLIBS = -lm
|
||||||
|
|
||||||
LIBVERSION = 1.7.13
|
LIBVERSION = 1.7.14
|
||||||
CJSON_SOVERSION = 1
|
CJSON_SOVERSION = 1
|
||||||
UTILS_SOVERSION = 1
|
UTILS_SOVERSION = 1
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void)
|
|||||||
return (const char*) (global_error.json + global_error.position);
|
return (const char*) (global_error.json + global_error.position);
|
||||||
}
|
}
|
||||||
|
|
||||||
CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item)
|
CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item)
|
||||||
{
|
{
|
||||||
if (!cJSON_IsString(item))
|
if (!cJSON_IsString(item))
|
||||||
{
|
{
|
||||||
@@ -102,18 +102,18 @@ CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item)
|
|||||||
return item->valuestring;
|
return item->valuestring;
|
||||||
}
|
}
|
||||||
|
|
||||||
CJSON_PUBLIC(double) cJSON_GetNumberValue(cJSON *item)
|
CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item)
|
||||||
{
|
{
|
||||||
if (!cJSON_IsNumber(item))
|
if (!cJSON_IsNumber(item))
|
||||||
{
|
{
|
||||||
return NAN;
|
return (double) NAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
return item->valuedouble;
|
return item->valuedouble;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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 != 7) || (CJSON_VERSION_PATCH != 13)
|
#if (CJSON_VERSION_MAJOR != 1) || (CJSON_VERSION_MINOR != 7) || (CJSON_VERSION_PATCH != 14)
|
||||||
#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
|
||||||
|
|
||||||
@@ -1509,6 +1509,10 @@ static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buf
|
|||||||
success:
|
success:
|
||||||
input_buffer->depth--;
|
input_buffer->depth--;
|
||||||
|
|
||||||
|
if (head != NULL) {
|
||||||
|
head->prev = current_item;
|
||||||
|
}
|
||||||
|
|
||||||
item->type = cJSON_Array;
|
item->type = cJSON_Array;
|
||||||
item->child = head;
|
item->child = head;
|
||||||
|
|
||||||
@@ -1681,6 +1685,10 @@ static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_bu
|
|||||||
success:
|
success:
|
||||||
input_buffer->depth--;
|
input_buffer->depth--;
|
||||||
|
|
||||||
|
if (head != NULL) {
|
||||||
|
head->prev = current_item;
|
||||||
|
}
|
||||||
|
|
||||||
item->type = cJSON_Object;
|
item->type = cJSON_Object;
|
||||||
item->child = head;
|
item->child = head;
|
||||||
|
|
||||||
@@ -1967,15 +1975,6 @@ static cJSON_bool add_item_to_array(cJSON *array, cJSON *item)
|
|||||||
suffix_object(child->prev, item);
|
suffix_object(child->prev, item);
|
||||||
array->child->prev = item;
|
array->child->prev = item;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
while (child->next)
|
|
||||||
{
|
|
||||||
child = child->next;
|
|
||||||
}
|
|
||||||
suffix_object(child, item);
|
|
||||||
array->child->prev = item;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -2202,6 +2201,12 @@ CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const it
|
|||||||
/* first element */
|
/* first element */
|
||||||
parent->child = item->next;
|
parent->child = item->next;
|
||||||
}
|
}
|
||||||
|
else if (item->next == NULL)
|
||||||
|
{
|
||||||
|
/* last element */
|
||||||
|
parent->child->prev = item->prev;
|
||||||
|
}
|
||||||
|
|
||||||
/* make sure the detached item doesn't point anywhere anymore */
|
/* make sure the detached item doesn't point anywhere anymore */
|
||||||
item->prev = NULL;
|
item->prev = NULL;
|
||||||
item->next = NULL;
|
item->next = NULL;
|
||||||
@@ -2299,6 +2304,10 @@ CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON
|
|||||||
}
|
}
|
||||||
if (parent->child == item)
|
if (parent->child == item)
|
||||||
{
|
{
|
||||||
|
if (parent->child->prev == parent->child)
|
||||||
|
{
|
||||||
|
replacement->prev = replacement;
|
||||||
|
}
|
||||||
parent->child = replacement;
|
parent->child = replacement;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -2310,6 +2319,10 @@ CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON
|
|||||||
{
|
{
|
||||||
replacement->prev->next = replacement;
|
replacement->prev->next = replacement;
|
||||||
}
|
}
|
||||||
|
if (replacement->next == NULL)
|
||||||
|
{
|
||||||
|
parent->child->prev = replacement;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
item->next = NULL;
|
item->next = NULL;
|
||||||
@@ -2549,6 +2562,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count)
|
|||||||
}
|
}
|
||||||
p = n;
|
p = n;
|
||||||
}
|
}
|
||||||
|
a->child->prev = n;
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
@@ -2585,6 +2599,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count)
|
|||||||
}
|
}
|
||||||
p = n;
|
p = n;
|
||||||
}
|
}
|
||||||
|
a->child->prev = n;
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
@@ -2621,6 +2636,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count)
|
|||||||
}
|
}
|
||||||
p = n;
|
p = n;
|
||||||
}
|
}
|
||||||
|
a->child->prev = n;
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
@@ -2657,6 +2673,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int co
|
|||||||
}
|
}
|
||||||
p = n;
|
p = n;
|
||||||
}
|
}
|
||||||
|
a->child->prev = n;
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
@@ -2729,6 +2746,10 @@ CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse)
|
|||||||
}
|
}
|
||||||
child = child->next;
|
child = child->next;
|
||||||
}
|
}
|
||||||
|
if (newitem && newitem->child)
|
||||||
|
{
|
||||||
|
newitem->child->prev = newchild;
|
||||||
|
}
|
||||||
|
|
||||||
return newitem;
|
return newitem;
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ then using the CJSON_API_VISIBILITY flag to "export" the same symbols the way CJ
|
|||||||
/* project version */
|
/* project version */
|
||||||
#define CJSON_VERSION_MAJOR 1
|
#define CJSON_VERSION_MAJOR 1
|
||||||
#define CJSON_VERSION_MINOR 7
|
#define CJSON_VERSION_MINOR 7
|
||||||
#define CJSON_VERSION_PATCH 13
|
#define CJSON_VERSION_PATCH 14
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
@@ -176,8 +176,8 @@ CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *st
|
|||||||
CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void);
|
CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void);
|
||||||
|
|
||||||
/* Check item type and return its value */
|
/* Check item type and return its value */
|
||||||
CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item);
|
CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item);
|
||||||
CJSON_PUBLIC(double) cJSON_GetNumberValue(cJSON *item);
|
CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item);
|
||||||
|
|
||||||
/* These functions check the type of an item */
|
/* These functions check the type of an item */
|
||||||
CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item);
|
CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item);
|
||||||
|
|||||||
+6
-2
@@ -403,7 +403,7 @@ static cJSON *detach_item_from_array(cJSON *array, size_t which)
|
|||||||
/* item doesn't exist */
|
/* item doesn't exist */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (c->prev)
|
if (c != array->child)
|
||||||
{
|
{
|
||||||
/* not the first element */
|
/* not the first element */
|
||||||
c->prev->next = c->next;
|
c->prev->next = c->next;
|
||||||
@@ -412,10 +412,14 @@ static cJSON *detach_item_from_array(cJSON *array, size_t which)
|
|||||||
{
|
{
|
||||||
c->next->prev = c->prev;
|
c->next->prev = c->prev;
|
||||||
}
|
}
|
||||||
if (c==array->child)
|
if (c == array->child)
|
||||||
{
|
{
|
||||||
array->child = c->next;
|
array->child = c->next;
|
||||||
}
|
}
|
||||||
|
else if (c->next == NULL)
|
||||||
|
{
|
||||||
|
array->child->prev = c->prev;
|
||||||
|
}
|
||||||
/* make sure the detached item doesn't point anywhere anymore */
|
/* make sure the detached item doesn't point anywhere anymore */
|
||||||
c->prev = c->next = NULL;
|
c->prev = c->next = NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -7,4 +7,4 @@ Description: Ultralightweight JSON parser in ANSI C
|
|||||||
URL: https://github.com/DaveGamble/cJSON
|
URL: https://github.com/DaveGamble/cJSON
|
||||||
Libs: -L${libdir} -lcjson
|
Libs: -L${libdir} -lcjson
|
||||||
Libs.private: -lm
|
Libs.private: -lm
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir} -I${includedir}/cjson
|
||||||
@@ -6,5 +6,5 @@ Version: @PROJECT_VERSION@
|
|||||||
Description: An implementation of JSON Pointer, Patch and Merge Patch based on cJSON.
|
Description: An implementation of JSON Pointer, Patch and Merge Patch based on cJSON.
|
||||||
URL: https://github.com/DaveGamble/cJSON
|
URL: https://github.com/DaveGamble/cJSON
|
||||||
Libs: -L${libdir} -lcjson_utils
|
Libs: -L${libdir} -lcjson_utils
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir} -I${includedir}/cjson
|
||||||
Requires: libcjson
|
Requires: libcjson
|
||||||
+2
-1
@@ -90,7 +90,8 @@ static void parse_array_should_parse_arrays_with_one_element(void)
|
|||||||
|
|
||||||
assert_parse_array("[[]]");
|
assert_parse_array("[[]]");
|
||||||
assert_has_child(item);
|
assert_has_child(item);
|
||||||
assert_is_array(item->child);
|
TEST_ASSERT_NOT_NULL(item->child);
|
||||||
|
assert_has_type(item->child, cJSON_Array);
|
||||||
assert_has_no_child(item->child);
|
assert_has_no_child(item->child);
|
||||||
reset(item);
|
reset(item);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user