|
27 | 27 | * @brief The source file that implements the user-facing functions in core_json.h. |
28 | 28 | */ |
29 | 29 |
|
30 | | -#include <assert.h> |
31 | 30 | #include <limits.h> |
32 | 31 | #include <stddef.h> |
33 | 32 | #include <stdint.h> |
@@ -75,7 +74,7 @@ static void skipSpace( const char * buf, |
75 | 74 | { |
76 | 75 | size_t i = 0U; |
77 | 76 |
|
78 | | - assert( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
| 77 | + coreJSON_ASSERT( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
79 | 78 |
|
80 | 79 | for( i = *start; i < max; i++ ) |
81 | 80 | { |
@@ -133,7 +132,7 @@ static bool shortestUTF8( size_t length, |
133 | 132 | bool ret = false; |
134 | 133 | uint32_t min = 0U, max = 0U; |
135 | 134 |
|
136 | | - assert( ( length >= 2U ) && ( length <= 4U ) ); |
| 135 | + coreJSON_ASSERT( ( length >= 2U ) && ( length <= 4U ) ); |
137 | 136 |
|
138 | 137 | switch( length ) |
139 | 138 | { |
@@ -192,13 +191,13 @@ static bool skipUTF8MultiByte( const char * buf, |
192 | 191 | bool ret = false; |
193 | 192 | size_t i = 0U, bitCount = 0U, j = 0U; |
194 | 193 | uint32_t value = 0U; |
195 | | - char_ c = { 0 }; |
| 194 | + char_ c; |
196 | 195 |
|
197 | | - assert( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
| 196 | + coreJSON_ASSERT( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
198 | 197 |
|
199 | 198 | i = *start; |
200 | | - assert( i < max ); |
201 | | - assert( !isascii_( buf[ i ] ) ); |
| 199 | + coreJSON_ASSERT( i < max ); |
| 200 | + coreJSON_ASSERT( !isascii_( buf[ i ] ) ); |
202 | 201 |
|
203 | 202 | c.c = buf[ i ]; |
204 | 203 |
|
@@ -255,7 +254,7 @@ static bool skipUTF8( const char * buf, |
255 | 254 | { |
256 | 255 | bool ret = false; |
257 | 256 |
|
258 | | - assert( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
| 257 | + coreJSON_ASSERT( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
259 | 258 |
|
260 | 259 | if( *start < max ) |
261 | 260 | { |
@@ -283,7 +282,7 @@ static bool skipUTF8( const char * buf, |
283 | 282 | #define NOT_A_HEX_CHAR ( 0x10U ) |
284 | 283 | static uint8_t hexToInt( char c ) |
285 | 284 | { |
286 | | - char_ n = { 0 }; |
| 285 | + char_ n; |
287 | 286 |
|
288 | 287 | n.c = c; |
289 | 288 |
|
@@ -332,8 +331,8 @@ static bool skipOneHexEscape( const char * buf, |
332 | 331 | size_t i = 0U, end = 0U; |
333 | 332 | uint16_t value = 0U; |
334 | 333 |
|
335 | | - assert( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
336 | | - assert( outValue != NULL ); |
| 334 | + coreJSON_ASSERT( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
| 335 | + coreJSON_ASSERT( outValue != NULL ); |
337 | 336 |
|
338 | 337 | i = *start; |
339 | 338 | #define HEX_ESCAPE_LENGTH ( 6U ) /* e.g., \u1234 */ |
@@ -395,7 +394,7 @@ static bool skipHexEscape( const char * buf, |
395 | 394 | size_t i = 0U; |
396 | 395 | uint16_t value = 0U; |
397 | 396 |
|
398 | | - assert( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
| 397 | + coreJSON_ASSERT( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
399 | 398 |
|
400 | 399 | i = *start; |
401 | 400 |
|
@@ -446,7 +445,7 @@ static bool skipEscape( const char * buf, |
446 | 445 | bool ret = false; |
447 | 446 | size_t i = 0U; |
448 | 447 |
|
449 | | - assert( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
| 448 | + coreJSON_ASSERT( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
450 | 449 |
|
451 | 450 | i = *start; |
452 | 451 |
|
@@ -513,7 +512,7 @@ static bool skipString( const char * buf, |
513 | 512 | bool ret = false; |
514 | 513 | size_t i = 0; |
515 | 514 |
|
516 | | - assert( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
| 515 | + coreJSON_ASSERT( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
517 | 516 |
|
518 | 517 | i = *start; |
519 | 518 |
|
@@ -577,7 +576,7 @@ static bool strnEq( const char * a, |
577 | 576 | { |
578 | 577 | size_t i = 0U; |
579 | 578 |
|
580 | | - assert( ( a != NULL ) && ( b != NULL ) ); |
| 579 | + coreJSON_ASSERT( ( a != NULL ) && ( b != NULL ) ); |
581 | 580 |
|
582 | 581 | for( i = 0; i < n; i++ ) |
583 | 582 | { |
@@ -610,8 +609,8 @@ static bool skipLiteral( const char * buf, |
610 | 609 | { |
611 | 610 | bool ret = false; |
612 | 611 |
|
613 | | - assert( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
614 | | - assert( literal != NULL ); |
| 612 | + coreJSON_ASSERT( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
| 613 | + coreJSON_ASSERT( literal != NULL ); |
615 | 614 |
|
616 | 615 | if( ( *start < max ) && ( length <= ( max - *start ) ) ) |
617 | 616 | { |
@@ -690,7 +689,7 @@ static bool skipDigits( const char * buf, |
690 | 689 | size_t i = 0U, saveStart = 0U; |
691 | 690 | int32_t value = 0; |
692 | 691 |
|
693 | | - assert( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
| 692 | + coreJSON_ASSERT( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
694 | 693 |
|
695 | 694 | saveStart = *start; |
696 | 695 |
|
@@ -743,7 +742,7 @@ static void skipDecimals( const char * buf, |
743 | 742 | { |
744 | 743 | size_t i = 0U; |
745 | 744 |
|
746 | | - assert( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
| 745 | + coreJSON_ASSERT( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
747 | 746 |
|
748 | 747 | i = *start; |
749 | 748 |
|
@@ -771,7 +770,7 @@ static void skipExponent( const char * buf, |
771 | 770 | { |
772 | 771 | size_t i = 0U; |
773 | 772 |
|
774 | | - assert( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
| 773 | + coreJSON_ASSERT( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
775 | 774 |
|
776 | 775 | i = *start; |
777 | 776 |
|
@@ -808,7 +807,7 @@ static bool skipNumber( const char * buf, |
808 | 807 | bool ret = false; |
809 | 808 | size_t i = 0U; |
810 | 809 |
|
811 | | - assert( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
| 810 | + coreJSON_ASSERT( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
812 | 811 |
|
813 | 812 | i = *start; |
814 | 813 |
|
@@ -904,7 +903,7 @@ static bool skipSpaceAndComma( const char * buf, |
904 | 903 | bool ret = false; |
905 | 904 | size_t i = 0U; |
906 | 905 |
|
907 | | - assert( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
| 906 | + coreJSON_ASSERT( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
908 | 907 |
|
909 | 908 | skipSpace( buf, start, max ); |
910 | 909 | i = *start; |
@@ -939,7 +938,7 @@ static void skipArrayScalars( const char * buf, |
939 | 938 | { |
940 | 939 | size_t i = 0U; |
941 | 940 |
|
942 | | - assert( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
| 941 | + coreJSON_ASSERT( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
943 | 942 |
|
944 | 943 | i = *start; |
945 | 944 |
|
@@ -981,7 +980,7 @@ static void skipObjectScalars( const char * buf, |
981 | 980 | size_t i = 0U; |
982 | 981 | bool comma = false; |
983 | 982 |
|
984 | | - assert( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
| 983 | + coreJSON_ASSERT( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
985 | 984 |
|
986 | 985 | i = *start; |
987 | 986 |
|
@@ -1036,7 +1035,7 @@ static void skipScalars( const char * buf, |
1036 | 1035 | size_t max, |
1037 | 1036 | char mode ) |
1038 | 1037 | { |
1039 | | - assert( isOpenBracket_( mode ) ); |
| 1038 | + coreJSON_ASSERT( isOpenBracket_( mode ) ); |
1040 | 1039 |
|
1041 | 1040 | skipSpace( buf, start, max ); |
1042 | 1041 |
|
@@ -1077,7 +1076,7 @@ static JSONStatus_t skipCollection( const char * buf, |
1077 | 1076 | int16_t depth = -1; |
1078 | 1077 | size_t i = 0U; |
1079 | 1078 |
|
1080 | | - assert( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
| 1079 | + coreJSON_ASSERT( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
1081 | 1080 |
|
1082 | 1081 | i = *start; |
1083 | 1082 |
|
@@ -1222,8 +1221,8 @@ static bool nextValue( const char * buf, |
1222 | 1221 | bool ret = true; |
1223 | 1222 | size_t i = 0U, valueStart = 0U; |
1224 | 1223 |
|
1225 | | - assert( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
1226 | | - assert( ( value != NULL ) && ( valueLength != NULL ) ); |
| 1224 | + coreJSON_ASSERT( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
| 1225 | + coreJSON_ASSERT( ( value != NULL ) && ( valueLength != NULL ) ); |
1227 | 1226 |
|
1228 | 1227 | i = *start; |
1229 | 1228 | valueStart = i; |
@@ -1279,9 +1278,9 @@ static bool nextKeyValuePair( const char * buf, |
1279 | 1278 | bool ret = true; |
1280 | 1279 | size_t i = 0U, keyStart = 0U; |
1281 | 1280 |
|
1282 | | - assert( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
1283 | | - assert( ( key != NULL ) && ( keyLength != NULL ) ); |
1284 | | - assert( ( value != NULL ) && ( valueLength != NULL ) ); |
| 1281 | + coreJSON_ASSERT( ( buf != NULL ) && ( start != NULL ) && ( max > 0U ) ); |
| 1282 | + coreJSON_ASSERT( ( key != NULL ) && ( keyLength != NULL ) ); |
| 1283 | + coreJSON_ASSERT( ( value != NULL ) && ( valueLength != NULL ) ); |
1285 | 1284 |
|
1286 | 1285 | i = *start; |
1287 | 1286 | keyStart = i; |
@@ -1352,8 +1351,8 @@ static bool objectSearch( const char * buf, |
1352 | 1351 |
|
1353 | 1352 | size_t i = 0U, key = 0U, keyLength = 0U, value = 0U, valueLength = 0U; |
1354 | 1353 |
|
1355 | | - assert( ( buf != NULL ) && ( query != NULL ) ); |
1356 | | - assert( ( outValue != NULL ) && ( outValueLength != NULL ) ); |
| 1354 | + coreJSON_ASSERT( ( buf != NULL ) && ( query != NULL ) ); |
| 1355 | + coreJSON_ASSERT( ( outValue != NULL ) && ( outValueLength != NULL ) ); |
1357 | 1356 |
|
1358 | 1357 | skipSpace( buf, &i, max ); |
1359 | 1358 |
|
@@ -1419,8 +1418,8 @@ static bool arraySearch( const char * buf, |
1419 | 1418 | size_t i = 0U, value = 0U, valueLength = 0U; |
1420 | 1419 | uint32_t currentIndex = 0U; |
1421 | 1420 |
|
1422 | | - assert( buf != NULL ); |
1423 | | - assert( ( outValue != NULL ) && ( outValueLength != NULL ) ); |
| 1421 | + coreJSON_ASSERT( buf != NULL ); |
| 1422 | + coreJSON_ASSERT( ( outValue != NULL ) && ( outValueLength != NULL ) ); |
1424 | 1423 |
|
1425 | 1424 | skipSpace( buf, &i, max ); |
1426 | 1425 |
|
@@ -1487,8 +1486,8 @@ static bool skipQueryPart( const char * buf, |
1487 | 1486 | bool ret = false; |
1488 | 1487 | size_t i = 0U; |
1489 | 1488 |
|
1490 | | - assert( ( buf != NULL ) && ( start != NULL ) && ( outLength != NULL ) ); |
1491 | | - assert( max > 0U ); |
| 1489 | + coreJSON_ASSERT( ( buf != NULL ) && ( start != NULL ) && ( outLength != NULL ) ); |
| 1490 | + coreJSON_ASSERT( max > 0U ); |
1492 | 1491 |
|
1493 | 1492 | i = *start; |
1494 | 1493 |
|
@@ -1536,9 +1535,9 @@ static JSONStatus_t multiSearch( const char * buf, |
1536 | 1535 | JSONStatus_t ret = JSONSuccess; |
1537 | 1536 | size_t i = 0U, start = 0U, queryStart = 0U, value = 0U, length = max; |
1538 | 1537 |
|
1539 | | - assert( ( buf != NULL ) && ( query != NULL ) ); |
1540 | | - assert( ( outValue != NULL ) && ( outValueLength != NULL ) ); |
1541 | | - assert( ( max > 0U ) && ( queryLength > 0U ) ); |
| 1538 | + coreJSON_ASSERT( ( buf != NULL ) && ( query != NULL ) ); |
| 1539 | + coreJSON_ASSERT( ( outValue != NULL ) && ( outValueLength != NULL ) ); |
| 1540 | + coreJSON_ASSERT( ( max > 0U ) && ( queryLength > 0U ) ); |
1542 | 1541 |
|
1543 | 1542 | while( i < queryLength ) |
1544 | 1543 | { |
@@ -1747,10 +1746,10 @@ static JSONStatus_t iterate( const char * buf, |
1747 | 1746 | JSONStatus_t ret = JSONNotFound; |
1748 | 1747 | bool found = false; |
1749 | 1748 |
|
1750 | | - assert( ( buf != NULL ) && ( max > 0U ) ); |
1751 | | - assert( ( start != NULL ) && ( next != NULL ) ); |
1752 | | - assert( ( outKey != NULL ) && ( outKeyLength != NULL ) ); |
1753 | | - assert( ( outValue != NULL ) && ( outValueLength != NULL ) ); |
| 1749 | + coreJSON_ASSERT( ( buf != NULL ) && ( max > 0U ) ); |
| 1750 | + coreJSON_ASSERT( ( start != NULL ) && ( next != NULL ) ); |
| 1751 | + coreJSON_ASSERT( ( outKey != NULL ) && ( outKeyLength != NULL ) ); |
| 1752 | + coreJSON_ASSERT( ( outValue != NULL ) && ( outValueLength != NULL ) ); |
1754 | 1753 |
|
1755 | 1754 | if( *start < max ) |
1756 | 1755 | { |
|
0 commit comments