commit 5779d49fe3cc39d2466dbe22c2175c069e26ab3a
parent f1b0fc4f8175b71280fad399be6fceb72399432e
Author: Remy Noulin <loader2x@gmail.com>
Date: Fri, 6 Aug 2021 14:21:47 +0000
Compiled with more gcc(10.2) warnings enabled and removed them
The code is more explicit and easier to update in the future
I use this compile options:
-g3 -std=gnu99 -fPIC -pipe -mrdrnd -rdynamic -pthread -Wall -Wextra
-Wdouble-promotion -Wformat-security -Wformat-signedness -Winit-self
-Wno-return-local-addr -Wshift-overflow=2 -Wswitch-default -Wstrict-overflow=4
-Walloca -Warith-conversion -Wduplicated-branches -Wduplicated-cond
-Wshadow -Wcast-qual -Wconversion -Wdate-time -Wstrict-prototypes
-Wmissing-prototypes -Winvalid-pch
add functions for const lists
change return value for typeStringsSmallArray to const char** since the strings in the array are readonly
make integer casts explicit
change char* to const char* where needed
change how progName and defaultProgName handle to respect readonly strings
add default labels in all switches
compare stack limit to RLIM_INFINITY in getStackLimit and return -1 when the stack is unlimited
add attribute warn_unused_result to all functions returning a value that should be used, it is disabled with the gcc option -Wno-unused-result
check all function results
fix error in error message in rmADir function
remove alloca in copyADir function to avoid being limited by the stack size (default 8mb in linux)
replace strcpy and strncpy with memmove to avoid wrong results when the buffers are overlaping (when buffers are overlaping memmove shoulb be used, the issue was first detected with glibc 2.31)
increase maximum number of test cases to 16384, enough for smallJson test
remove shadowing variables
The new libcheck version is not compatible with the tests, switch to CuTest framework which is stored in this repo and will always work.
release/json/libsheepyCSmallArray.h | 38 +-
release/json/libsheepyCSmallArrayTest.sh | 10 +-
release/json/libsheepyCSmallBoolTest.sh | 10 +-
release/json/libsheepyCSmallBytesTest.sh | 10 +-
release/json/libsheepyCSmallContainerCuTest.c | 3 +
release/json/libsheepyCSmallContainerTest.c | 3 +
release/json/libsheepyCSmallContainerTest.sh | 10 +-
release/json/libsheepyCSmallContainerTestMem.c | 3 +
release/json/libsheepyCSmallDict.h | 60 +-
release/json/libsheepyCSmallDictTest.sh | 11 +-
release/json/libsheepyCSmallDoubleTest.sh | 11 +-
release/json/libsheepyCSmallIntTest.sh | 10 +-
release/json/libsheepyCSmallJson.h | 94 +-
release/json/libsheepyCSmallJsonTest.sh | 12 +-
release/json/libsheepyCSmallString.h | 4 +-
release/json/libsheepyCSmallStringTest.sh | 10 +-
release/json/libsheepyObjectFuncTest.sh | 10 +-
release/libsheepy.c | 2595 +++++++++++++++--------
release/libsheepy.h | 1239 +++++------
release/libsheepyObject.h | 97 +-
release/libsheepySmall.c | 83 +-
release/libsheepySmall.h | 104 +-
src/CuTest/CuTest.h | 2 +-
src/json/laxjson.c | 61 +-
src/json/libsheepyCSmallArray.c | 1405 +++++++++----
src/json/libsheepyCSmallArray.h | 38 +-
src/json/libsheepyCSmallBytes.c | 20 +-
src/json/libsheepyCSmallDict.c | 542 ++++-
src/json/libsheepyCSmallDict.h | 60 +-
src/json/libsheepyCSmallDouble.c | 4 +-
src/json/libsheepyCSmallInt.c | 4 +-
src/json/libsheepyCSmallJson.c | 2296 +++++++++++++-------
src/json/libsheepyCSmallJson.h | 94 +-
src/json/libsheepyCSmallJsonInternal.h | 39 +-
src/json/libsheepyCSmallString.c | 216 +-
src/json/libsheepyCSmallString.h | 4 +-
src/json/libsheepyObject.c | 267 ++-
src/json/libsheepyObjectCuTest.c | 34 +-
src/json/libsheepyObjectTest.c | 34 +-
src/json/runCuTest.sh | 3 +-
src/libsheepy.c | 2655 ++++++++++++++++--------
src/libsheepy.h | 1239 +++++------
src/libsheepyCuTest.c | 2 +
src/libsheepyObject.h | 97 +-
src/libsheepySmall.c | 83 +-
src/libsheepySmall.h | 104 +-
src/libsheepyTest.c | 2 +
src/runCuTest.sh | 2 +-
src/runSmallCuTest.sh | 4 +-
src/tpool.c | 2 +-
50 files changed, 8819 insertions(+), 4921 deletions(-)
Diffstat:
50 files changed, 8819 insertions(+), 4921 deletions(-)
diff --git a/release/json/libsheepyCSmallArray.h b/release/json/libsheepyCSmallArray.h
@@ -116,6 +116,7 @@ typedef smallArrayt* (*mirrorSmallArrayFt) (smallArrayt *self);
* NULL when array is NULL
*/
typedef smallArrayt* (*fromArraySmallArrayFt)(smallArrayt *self, char **array, size_t size);
+typedef smallArrayt* (*fromCArraySmallArrayFt)(smallArrayt *self, const char **array, size_t size);
typedef smallArrayt* (*fromArrayNFreeSmallArrayFt)(smallArrayt *self, char **array, size_t size);
/**
@@ -154,6 +155,7 @@ typedef smallArrayt* (*pushCharSmallArrayFt) (smallArrayt
typedef smallArrayt* (*pushDictSmallArrayFt) (smallArrayt *self, smallDictt *dict);
typedef smallArrayt* (*pushArraySmallArrayFt) (smallArrayt *self, smallArrayt *array);
typedef smallArrayt* (*pushArraycSmallArrayFt) (smallArrayt *self, char **array);
+typedef smallArrayt* (*pushCArraycSmallArrayFt) (smallArrayt *self, const char **array);
typedef smallArrayt* (*pushSmallBoolSmallArrayFt) (smallArrayt *self, smallBoolt *value);
typedef smallArrayt* (*pushSmallBytesSmallArrayFt) (smallArrayt *self, smallBytest *value);
typedef smallArrayt* (*pushSmallDoubleSmallArrayFt) (smallArrayt *self, smallDoublet *value);
@@ -293,6 +295,7 @@ typedef smallArrayt* (*prependCharSmallArrayFt) (smallAr
typedef smallArrayt* (*prependDictSmallArrayFt) (smallArrayt *self, smallDictt *dict);
typedef smallArrayt* (*prependArraySmallArrayFt) (smallArrayt *self, smallArrayt *array);
typedef smallArrayt* (*prependArraycSmallArrayFt) (smallArrayt *self, char **array);
+typedef smallArrayt* (*prependCArraycSmallArrayFt) (smallArrayt *self, const char **array);
typedef smallArrayt* (*prependSmallBoolSmallArrayFt) (smallArrayt *self, smallBoolt *value);
typedef smallArrayt* (*prependSmallBytesSmallArrayFt) (smallArrayt *self, smallBytest *value);
typedef smallArrayt* (*prependSmallDoubleSmallArrayFt) (smallArrayt *self, smallDoublet *value);
@@ -396,6 +399,7 @@ typedef smallArrayt* (*appendSmallJsonSmallArrayFt) (smallArrayt *
typedef smallArrayt* (*appendNSmashSmallArrayFt) (smallArrayt *self, smallArrayt *array);
typedef smallArrayt* (*appendNSmashSmallJsonSmallArrayFt)(smallArrayt *self, smallJsont *json);
typedef smallArrayt* (*appendArraySmallArrayFt) (smallArrayt *self, char **array);
+typedef smallArrayt* (*appendCArraySmallArrayFt) (smallArrayt *self, const char **array);
typedef smallArrayt* (*appendNSmashArraySmallArrayFt) (smallArrayt *self, char **array);
/**
@@ -565,6 +569,7 @@ typedef smallArrayt* (*injectCharSmallArrayFt) (smallArrayt *self, int64_t i
typedef smallArrayt* (*injectDictSmallArrayFt) (smallArrayt *self, int64_t index, smallDictt *toInject);
typedef smallArrayt* (*injectArraySmallArrayFt) (smallArrayt *self, int64_t index, smallArrayt *toInject);
typedef smallArrayt* (*injectArraycSmallArrayFt) (smallArrayt *self, int64_t index, char **toInject);
+typedef smallArrayt* (*injectCArraycSmallArrayFt) (smallArrayt *self, int64_t index, const char **toInject);
typedef smallArrayt* (*injectSmallBoolSmallArrayFt) (smallArrayt *self, int64_t index, smallBoolt *toInject);
typedef smallArrayt* (*injectSmallBytesSmallArrayFt) (smallArrayt *self, int64_t index, smallBytest *toInject);
typedef smallArrayt* (*injectSmallDoubleSmallArrayFt) (smallArrayt *self, int64_t index, smallDoublet *toInject);
@@ -711,6 +716,7 @@ typedef smallArrayt* (*icSortSmallArrayFt) (smallArrayt *self);
typedef bool (*equalSmallArrayFt) (smallArrayt *self, smallArrayt *array);
typedef bool (*equalSmallArraySmallJsonFt)(smallArrayt *self, smallJsont *array);
typedef bool (*equalSmallArrayArrayFt) (smallArrayt* self, char ** p2);
+typedef bool (*equalSmallArrayCArrayFt) (smallArrayt* self, const char ** p2);
typedef bool (*equalSmallArrayBaseFt) (smallArrayt* self, baset* p2);
/**
@@ -725,6 +731,7 @@ typedef bool (*equalSmallArrayBaseFt) (smallArrayt* self, baset* p2
typedef bool (*icEqualSmallArrayFt) (smallArrayt *self, smallArrayt *array);
typedef bool (*icEqualSmallArraySmallJsonFt)(smallArrayt *self, smallJsont *array);
typedef bool (*icEqualSmallArrayArrayFt) (smallArrayt* self, char ** p2);
+typedef bool (*icEqualSmallArrayCArrayFt) (smallArrayt* self, const char ** p2);
typedef bool (*icEqualSmallArrayBaseFt) (smallArrayt* self, baset* p2);
/**
@@ -846,6 +853,7 @@ typedef smallArrayt* (*setAtCharSmallArrayFt) (smallArrayt *self, in
typedef smallArrayt* (*setAtDictSmallArrayFt) (smallArrayt *self, int64_t index, smallDictt *dict);
typedef smallArrayt* (*setAtArraySmallArrayFt) (smallArrayt *self, int64_t index, smallArrayt *array);
typedef smallArrayt* (*setAtArraycSmallArrayFt) (smallArrayt *self, int64_t index, char **array);
+typedef smallArrayt* (*setAtCArraycSmallArrayFt) (smallArrayt *self, int64_t index, const char **array);
typedef smallArrayt* (*setAtSmallBoolSmallArrayFt) (smallArrayt *self, int64_t index, smallBoolt *value);
typedef smallArrayt* (*setAtSmallBytesSmallArrayFt) (smallArrayt *self, int64_t index, smallBytest *value);
typedef smallArrayt* (*setAtSmallDoubleSmallArrayFt) (smallArrayt *self, int64_t index, smallDoublet *value);
@@ -939,6 +947,7 @@ typedef bool (*hasCharSmallArrayFt) (smallArrayt *self, char c);
typedef bool (*hasDictSmallArrayFt) (smallArrayt *self, smallDictt *dict);
typedef bool (*hasArraySmallArrayFt) (smallArrayt *self, smallArrayt *array);
typedef bool (*hasArraycSmallArrayFt) (smallArrayt *self, char **array);
+typedef bool (*hasCArraycSmallArrayFt) (smallArrayt *self, const char **array);
typedef bool (*hasSmallBoolSmallArrayFt) (smallArrayt *self, smallBoolt *value);
typedef bool (*hasSmallBytesSmallArrayFt) (smallArrayt *self, smallBytest *value);
typedef bool (*hasSmallDoubleSmallArrayFt) (smallArrayt *self, smallDoublet *value);
@@ -967,6 +976,7 @@ typedef ssize_t (*indexOfCharSmallArrayFt) (smallArrayt *self, char c)
typedef ssize_t (*indexOfDictSmallArrayFt) (smallArrayt *self, smallDictt *dict);
typedef ssize_t (*indexOfArraySmallArrayFt) (smallArrayt *self, smallArrayt *array);
typedef ssize_t (*indexOfArraycSmallArrayFt) (smallArrayt *self, char **array);
+typedef ssize_t (*indexOfCArraycSmallArrayFt) (smallArrayt *self, const char **array);
typedef ssize_t (*indexOfSmallBoolSmallArrayFt) (smallArrayt *self, smallBoolt *value);
typedef ssize_t (*indexOfSmallBytesSmallArrayFt) (smallArrayt *self, smallBytest *value);
typedef ssize_t (*indexOfSmallDoubleSmallArrayFt) (smallArrayt *self, smallDoublet *value);
@@ -995,6 +1005,7 @@ typedef ssize_t (*binarySearchCharSmallArrayFt) (smallArrayt *self, ch
typedef ssize_t (*binarySearchDictSmallArrayFt) (smallArrayt *self, smallDictt *dict);
typedef ssize_t (*binarySearchArraySmallArrayFt) (smallArrayt *self, smallArrayt *array);
typedef ssize_t (*binarySearchArraycSmallArrayFt) (smallArrayt *self, char **array);
+typedef ssize_t (*binarySearchCArraycSmallArrayFt) (smallArrayt *self, const char **array);
typedef ssize_t (*binarySearchSmallBoolSmallArrayFt) (smallArrayt *self, smallBoolt *value);
typedef ssize_t (*binarySearchSmallBytesSmallArrayFt) (smallArrayt *self, smallBytest *value);
typedef ssize_t (*binarySearchSmallDoubleSmallArrayFt) (smallArrayt *self, smallDoublet *value);
@@ -1029,6 +1040,7 @@ typedef bool (*icHasCharSmallArrayFt) (smallArrayt *self, char c);
typedef bool (*icHasDictSmallArrayFt) (smallArrayt *self, smallDictt *dict);
typedef bool (*icHasArraySmallArrayFt) (smallArrayt *self, smallArrayt *array);
typedef bool (*icHasArraycSmallArrayFt) (smallArrayt *self, char **array);
+typedef bool (*icHasCArraycSmallArrayFt) (smallArrayt *self, const char **array);
typedef bool (*icHasSmallJsonSmallArrayFt) (smallArrayt *self, smallJsont *string);
typedef bool (*icHasSmallStringSmallArrayFt)(smallArrayt *self, smallStringt *string);
@@ -1048,6 +1060,7 @@ typedef ssize_t (*icIndexOfCharSmallArrayFt) (smallArrayt *self, cha
typedef ssize_t (*icIndexOfDictSmallArrayFt) (smallArrayt *self, smallDictt *dict);
typedef ssize_t (*icIndexOfArraySmallArrayFt) (smallArrayt *self, smallArrayt *array);
typedef ssize_t (*icIndexOfArraycSmallArrayFt) (smallArrayt *self, char **array);
+typedef ssize_t (*icIndexOfCArraycSmallArrayFt) (smallArrayt *self, const char **array);
typedef ssize_t (*icIndexOfSmallJsonSmallArrayFt) (smallArrayt *self, smallJsont *string);
typedef ssize_t (*icIndexOfSmallStringSmallArrayFt)(smallArrayt *self, smallStringt *string);
@@ -1067,6 +1080,7 @@ typedef ssize_t (*icBinarySearchCharSmallArrayFt) (smallArrayt *self
typedef ssize_t (*icBinarySearchDictSmallArrayFt) (smallArrayt *self, smallDictt *dict);
typedef ssize_t (*icBinarySearchArraySmallArrayFt) (smallArrayt *self, smallArrayt *array);
typedef ssize_t (*icBinarySearchArraycSmallArrayFt) (smallArrayt *self, char **array);
+typedef ssize_t (*icBinarySearchCArraycSmallArrayFt) (smallArrayt *self, const char **array);
typedef ssize_t (*icBinarySearchSmallJsonSmallArrayFt) (smallArrayt *self, smallJsont *string);
typedef ssize_t (*icBinarySearchSmallStringSmallArrayFt)(smallArrayt *self, smallStringt *string);
@@ -1344,7 +1358,7 @@ typedef char (*typeSmallArrayFt) (smallArrayt *self, int64_t index
* \return
* list of object type strings
*/
-typedef char** (*typeStringsSmallArrayFt)(smallArrayt *self);
+typedef const char** (*typeStringsSmallArrayFt)(smallArrayt *self);
typedef smallArrayt* (*typeSmallStringsSmallArrayFt)(smallArrayt *self);
/**
@@ -1411,6 +1425,7 @@ typedef bool (*areAllEBytesSmallArrayFt) (smallArrayt *self);
getAtNDupSmallArrayFt getNDup;\
setAtSmallArrayFt set;\
fromArraySmallArrayFt fromArray;\
+ fromCArraySmallArrayFt fromCArray;\
fromArrayNFreeSmallArrayFt fromArrayNFree;\
pushSmallArrayFt push;\
pushUndefinedSmallArrayFt pushUndefined;\
@@ -1422,6 +1437,7 @@ typedef bool (*areAllEBytesSmallArrayFt) (smallArrayt *self);
pushDictSmallArrayFt pushDict;\
pushArraySmallArrayFt pushArray;\
pushArraycSmallArrayFt pushArrayc;\
+ pushCArraycSmallArrayFt pushCArrayc;\
pushSmallBoolSmallArrayFt pushSmallBool;\
pushSmallBytesSmallArrayFt pushSmallBytes;\
pushSmallDoubleSmallArrayFt pushSmallDouble;\
@@ -1476,6 +1492,7 @@ typedef bool (*areAllEBytesSmallArrayFt) (smallArrayt *self);
prependDictSmallArrayFt prependDict;\
prependArraySmallArrayFt prependArray;\
prependArraycSmallArrayFt prependArrayc;\
+ prependCArraycSmallArrayFt prependCArrayc;\
prependSmallBoolSmallArrayFt prependSmallBool;\
prependSmallBytesSmallArrayFt prependSmallBytes;\
prependSmallDoubleSmallArrayFt prependSmallDouble;\
@@ -1523,6 +1540,7 @@ typedef bool (*areAllEBytesSmallArrayFt) (smallArrayt *self);
appendNSmashSmallArrayFt appendNSmash;\
appendNSmashSmallJsonSmallArrayFt appendNSmashSmallJson;\
appendArraySmallArrayFt appendArray;\
+ appendCArraySmallArrayFt appendCArray;\
appendNSmashArraySmallArrayFt appendNSmashArray;\
shiftSmallArrayFt shift;\
shiftSmallJsonSmallArrayFt shiftSmallJson;\
@@ -1565,6 +1583,7 @@ typedef bool (*areAllEBytesSmallArrayFt) (smallArrayt *self);
injectDictSmallArrayFt injectDict;\
injectArraySmallArrayFt injectArray;\
injectArraycSmallArrayFt injectArrayc;\
+ injectCArraycSmallArrayFt injectCArrayc;\
injectSmallBoolSmallArrayFt injectSmallBool;\
injectSmallBytesSmallArrayFt injectSmallBytes;\
injectSmallDoubleSmallArrayFt injectSmallDouble;\
@@ -1595,10 +1614,12 @@ typedef bool (*areAllEBytesSmallArrayFt) (smallArrayt *self);
equalSmallArrayFt equal;\
equalSmallArraySmallJsonFt equalSmallJson;\
equalSmallArrayArrayFt equalArray;\
+ equalSmallArrayCArrayFt equalCArray;\
equalSmallArrayBaseFt equalBase;\
icEqualSmallArrayFt icEqual;\
icEqualSmallArraySmallJsonFt icEqualSmallJson;\
icEqualSmallArrayArrayFt icEqualArray;\
+ icEqualSmallArrayCArrayFt icEqualCArray;\
icEqualSmallArrayBaseFt icEqualBase;\
lenSmallArrayFt len;\
trimSmallArrayFt trim;\
@@ -1656,6 +1677,7 @@ typedef bool (*areAllEBytesSmallArrayFt) (smallArrayt *self);
setAtDictSmallArrayFt setAtDict;\
setAtArraySmallArrayFt setAtArray;\
setAtArraycSmallArrayFt setAtArrayc;\
+ setAtCArraycSmallArrayFt setAtCArrayc;\
setAtSmallBoolSmallArrayFt setAtSmallBool;\
setAtSmallBytesSmallArrayFt setAtSmallBytes;\
setAtSmallDoubleSmallArrayFt setAtSmallDouble;\
@@ -1695,6 +1717,7 @@ typedef bool (*areAllEBytesSmallArrayFt) (smallArrayt *self);
hasDictSmallArrayFt hasDict;\
hasArraySmallArrayFt hasArray;\
hasArraycSmallArrayFt hasArrayc;\
+ hasCArraycSmallArrayFt hasCArrayc;\
hasSmallBoolSmallArrayFt hasSmallBool;\
hasSmallBytesSmallArrayFt hasSmallBytes;\
hasSmallDoubleSmallArrayFt hasSmallDouble;\
@@ -1712,6 +1735,7 @@ typedef bool (*areAllEBytesSmallArrayFt) (smallArrayt *self);
indexOfDictSmallArrayFt indexOfDict;\
indexOfArraySmallArrayFt indexOfArray;\
indexOfArraycSmallArrayFt indexOfArrayc;\
+ indexOfCArraycSmallArrayFt indexOfCArrayc;\
indexOfSmallBoolSmallArrayFt indexOfSmallBool;\
indexOfSmallBytesSmallArrayFt indexOfSmallBytes;\
indexOfSmallDoubleSmallArrayFt indexOfSmallDouble;\
@@ -1729,6 +1753,7 @@ typedef bool (*areAllEBytesSmallArrayFt) (smallArrayt *self);
binarySearchDictSmallArrayFt binarySearchDict;\
binarySearchArraySmallArrayFt binarySearchArray;\
binarySearchArraycSmallArrayFt binarySearchArrayc;\
+ binarySearchCArraycSmallArrayFt binarySearchCArrayc;\
binarySearchSmallBoolSmallArrayFt binarySearchSmallBool;\
binarySearchSmallBytesSmallArrayFt binarySearchSmallBytes;\
binarySearchSmallDoubleSmallArrayFt binarySearchSmallDouble;\
@@ -1743,6 +1768,7 @@ typedef bool (*areAllEBytesSmallArrayFt) (smallArrayt *self);
icHasDictSmallArrayFt icHasDict;\
icHasArraySmallArrayFt icHasArray;\
icHasArraycSmallArrayFt icHasArrayc;\
+ icHasCArraycSmallArrayFt icHasCArrayc;\
icHasSmallJsonSmallArrayFt icHasSmallJson;\
icHasSmallStringSmallArrayFt icHasSmallString;\
icIndexOfSmallArrayFt icIndexOf;\
@@ -1751,6 +1777,7 @@ typedef bool (*areAllEBytesSmallArrayFt) (smallArrayt *self);
icIndexOfDictSmallArrayFt icIndexOfDict;\
icIndexOfArraySmallArrayFt icIndexOfArray;\
icIndexOfArraycSmallArrayFt icIndexOfArrayc;\
+ icIndexOfCArraycSmallArrayFt icIndexOfCArrayc;\
icIndexOfSmallJsonSmallArrayFt icIndexOfSmallJson;\
icIndexOfSmallStringSmallArrayFt icIndexOfSmallString;\
icBinarySearchSmallArrayFt icBinarySearch;\
@@ -1759,6 +1786,7 @@ typedef bool (*areAllEBytesSmallArrayFt) (smallArrayt *self);
icBinarySearchDictSmallArrayFt icBinarySearchDict;\
icBinarySearchArraySmallArrayFt icBinarySearchArray;\
icBinarySearchArraycSmallArrayFt icBinarySearchArrayc;\
+ icBinarySearchCArraycSmallArrayFt icBinarySearchCArrayc;\
icBinarySearchSmallJsonSmallArrayFt icBinarySearchSmallJson;\
icBinarySearchSmallStringSmallArrayFt icBinarySearchSmallString;\
icUniqSmallArrayFt icUniq;\
@@ -2219,7 +2247,7 @@ smallArrayt* injectCharSmallArrayG(smallArrayt *self, int64_t index, char c);
smallArrayt* injectDictSmallArrayG (smallArrayt *self, int64_t index, smallDictt *dict);
smallArrayt* injectArraySmallArrayG (smallArrayt *self, int64_t index, smallArrayt *array);
smallArrayt* injectArraycSmallArrayG (smallArrayt *self, int64_t index, char **array);
-smallArrayt* injectCArraycSmallArrayG (smallArrayt *self, int64_t index, const char **array);
+smallArrayt* injectCArraycSmallArrayG (smallArrayt *self, int64_t index, const char **array);
smallArrayt* injectVoidSmallArrayG (smallArrayt *self, int64_t index, void *value);
smallArrayt* injectSmallBoolSmallArrayG (smallArrayt *self, int64_t index, smallBoolt *value);
smallArrayt* injectSmallBytesSmallArrayG (smallArrayt *self, int64_t index, smallBytest *value);
@@ -2393,7 +2421,7 @@ smallArrayt* typeSmallStringsSmallArrayG(smallArrayt *self);
*/
#define forEachSmallArray(array, element) \
size_t UNIQVAR(libsheepyInternalIndex) = 0; \
- for (baset *element = array->f->getAt(array, 0); UNIQVAR(libsheepyInternalIndex) < array->f->len(array) ; UNIQVAR(libsheepyInternalIndex)++, element = array->f->getAt(array, UNIQVAR(libsheepyInternalIndex))) \
+ for (baset *element = array->f->getAt(array, 0); UNIQVAR(libsheepyInternalIndex) < array->f->len(array) ; UNIQVAR(libsheepyInternalIndex)++, element = array->f->getAt(array, (int64_t)UNIQVAR(libsheepyInternalIndex))) \
if (element)
/**
@@ -2413,7 +2441,7 @@ smallArrayt* typeSmallStringsSmallArrayG(smallArrayt *self);
*/
#define enumerateSmallArray(array, element, index) \
size_t index = 0; \
- for (baset *element = array->f->getAt(array, 0); index < array->f->len(array) ; index++, element = array->f->getAt(array, index)) \
+ for (baset *element = array->f->getAt(array, 0); index < array->f->len(array) ; index++, element = array->f->getAt(array, (int64_t)index)) \
if (element)
/**
@@ -2424,7 +2452,7 @@ smallArrayt* typeSmallStringsSmallArrayG(smallArrayt *self);
*/
#define enumerateTypeSmallArray(type, array, element, index) \
size_t index = 0; \
- for (type element = getG(array, type, 0); index < array->f->len(array) ; index++, element = getG(array, type, index)) \
+ for (type element = getG(array, type, 0); index < array->f->len(array) ; index++, element = getG(array, type, (int64_t)index)) \
if (element)
// end class smallArray
diff --git a/release/json/libsheepyCSmallArrayTest.sh b/release/json/libsheepyCSmallArrayTest.sh
@@ -4,15 +4,19 @@
~/scripts/generators/cg_c.py libsheepyCSmallArray_cg.c
rm libsheepyCSmallArrayTest
-gcc -mrdrnd -g3 -std=gnu99 -o libsheepyCSmallArrayTest libsheepyCSmallArrayTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
+#gcc -mrdrnd -g3 -std=gnu99 -o libsheepyCSmallArrayTest libsheepyCSmallArrayTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
+#./libsheepyCSmallArrayTest
+
+../../utils/runMemtest libsheepyCSmallArrayTest.c memTest.c.template
+../../utils/genCuTest libsheepyCSmallArrayTest.c ../../utils/CuTest.c.template
+
+gcc -mrdrnd -g3 -std=gnu11 -o libsheepyCSmallArrayTest libsheepyCSmallArrayCuTest.c CuTest/CuTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -rdynamic -fprofile-arcs -ftest-coverage
./libsheepyCSmallArrayTest
# GCOV
echo
gcov -b libsheepyCSmallArray.c
-../../utils/runMemtest libsheepyCSmallArrayTest.c memTest.c.template
-../../utils/genCuTest libsheepyCSmallArrayTest.c ../../utils/CuTest.c.template
gcc -mrdrnd -g3 -std=gnu99 -o libsheepyCSmallArrayTestMem libsheepyCSmallArrayTestMem.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
valgrind --leak-check=full --show-leak-kinds=all ./libsheepyCSmallArrayTestMem
diff --git a/release/json/libsheepyCSmallBoolTest.sh b/release/json/libsheepyCSmallBoolTest.sh
@@ -3,15 +3,19 @@
~/scripts/generators/cg_c.py libsheepyCSmallBool_cg.c
rm libsheepyCSmallBoolTest
-gcc -mrdrnd -g3 -std=gnu99 -o libsheepyCSmallBoolTest libsheepyCSmallBoolTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
+#gcc -mrdrnd -g3 -std=gnu99 -o libsheepyCSmallBoolTest libsheepyCSmallBoolTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
+#./libsheepyCSmallBoolTest
+
+../../utils/runMemtest libsheepyCSmallBoolTest.c memTest.c.template
+../../utils/genCuTest libsheepyCSmallBoolTest.c ../../utils/CuTest.c.template
+
+gcc -mrdrnd -g3 -std=gnu11 -o libsheepyCSmallBoolTest libsheepyCSmallBoolCuTest.c CuTest/CuTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -rdynamic -fprofile-arcs -ftest-coverage
./libsheepyCSmallBoolTest
# GCOV
echo
gcov -b libsheepyCSmallBool.c
-../../utils/runMemtest libsheepyCSmallBoolTest.c memTest.c.template
-../../utils/genCuTest libsheepyCSmallBoolTest.c ../../utils/CuTest.c.template
gcc -mrdrnd -g3 -std=gnu99 -o libsheepyCSmallBoolTestMem libsheepyCSmallBoolTestMem.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
valgrind --leak-check=full --show-leak-kinds=all ./libsheepyCSmallBoolTestMem
diff --git a/release/json/libsheepyCSmallBytesTest.sh b/release/json/libsheepyCSmallBytesTest.sh
@@ -3,15 +3,19 @@
~/scripts/generators/cg_c.py libsheepyCSmallBytes_cg.c
rm libsheepyCSmallBytesTest
-gcc -mrdrnd -g3 -std=gnu99 -o libsheepyCSmallBytesTest libsheepyCSmallBytesTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
+#gcc -mrdrnd -g3 -std=gnu99 -o libsheepyCSmallBytesTest libsheepyCSmallBytesTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
+#./libsheepyCSmallBytesTest
+
+../../utils/runMemtest libsheepyCSmallBytesTest.c memTest.c.template
+../../utils/genCuTest libsheepyCSmallBytesTest.c ../../utils/CuTest.c.template
+
+gcc -mrdrnd -g3 -std=gnu11 -o libsheepyCSmallBytesTest libsheepyCSmallBytesCuTest.c CuTest/CuTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -rdynamic -fprofile-arcs -ftest-coverage
./libsheepyCSmallBytesTest
# GCOV
echo
gcov -b libsheepyCSmallBytes.c
-../../utils/runMemtest libsheepyCSmallBytesTest.c memTest.c.template
-../../utils/genCuTest libsheepyCSmallBytesTest.c ../../utils/CuTest.c.template
gcc -mrdrnd -g3 -std=gnu99 -o libsheepyCSmallBytesTestMem libsheepyCSmallBytesTestMem.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
valgrind --leak-check=full --show-leak-kinds=all ./libsheepyCSmallBytesTestMem
diff --git a/release/json/libsheepyCSmallContainerCuTest.c b/release/json/libsheepyCSmallContainerCuTest.c
@@ -165,6 +165,7 @@ void setObjectDataFreeSmallContainerT(CuTest *tc UNUSED) {
ck_assert_int_eq(freeResult, 1);
freeResult = 0;
// free sContainer in an array without the free function in sContainer
+ setClassDataFreeO(self, NULL);
setValO(self, &r);
createAllocateSmallArray(a);
a->f->pushNFreeSmallContainer(a, self);
@@ -210,6 +211,8 @@ void setObjectDataToStringSmallContainerT(CuTest *tc UNUSED) {
smallContainert* r;
smallContainert *self = allocSmallContainer(&something);
+ // remove class toString function
+ setClassDataToStringO(self, NULL);
char *s = toStringO(self);
ck_assert_ptr_ne(s, null);
diff --git a/release/json/libsheepyCSmallContainerTest.c b/release/json/libsheepyCSmallContainerTest.c
@@ -154,6 +154,7 @@ START_TEST(setObjectDataFreeSmallContainerT)
ck_assert_int_eq(freeResult, 1);
freeResult = 0;
// free sContainer in an array without the free function in sContainer
+ setClassDataFreeO(self, NULL);
setValO(self, &r);
createAllocateSmallArray(a);
a->f->pushNFreeSmallContainer(a, self);
@@ -199,6 +200,8 @@ START_TEST(setObjectDataToStringSmallContainerT)
smallContainert* r;
smallContainert *self = allocSmallContainer(&something);
+ // remove class toString function
+ setClassDataToStringO(self, NULL);
char *s = toStringO(self);
ck_assert_ptr_ne(s, null);
diff --git a/release/json/libsheepyCSmallContainerTest.sh b/release/json/libsheepyCSmallContainerTest.sh
@@ -3,15 +3,19 @@
~/scripts/generators/cg_c.py libsheepyCSmallContainer_cg.c
rm libsheepyCSmallContainerTest
-gcc -mrdrnd -g3 -std=gnu99 -o libsheepyCSmallContainerTest libsheepyCSmallContainerTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
+#gcc -mrdrnd -g3 -std=gnu99 -o libsheepyCSmallContainerTest libsheepyCSmallContainerTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
+#./libsheepyCSmallContainerTest
+
+../../utils/runMemtest libsheepyCSmallContainerTest.c memTest.c.template
+../../utils/genCuTest libsheepyCSmallContainerTest.c ../../utils/CuTest.c.template
+
+gcc -mrdrnd -g3 -std=gnu11 -o libsheepyCSmallContainerTest libsheepyCSmallContainerCuTest.c CuTest/CuTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -rdynamic -fprofile-arcs -ftest-coverage
./libsheepyCSmallContainerTest
# GCOV
echo
gcov -b libsheepyCSmallContainer.c
-../../utils/runMemtest libsheepyCSmallContainerTest.c memTest.c.template
-../../utils/genCuTest libsheepyCSmallContainerTest.c ../../utils/CuTest.c.template
gcc -mrdrnd -g3 -std=gnu99 -o libsheepyCSmallContainerTestMem libsheepyCSmallContainerTestMem.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
valgrind --leak-check=full --show-leak-kinds=all ./libsheepyCSmallContainerTestMem
diff --git a/release/json/libsheepyCSmallContainerTestMem.c b/release/json/libsheepyCSmallContainerTestMem.c
@@ -163,6 +163,7 @@ void setObjectDataFreeSmallContainerT(void) {
ck_assert_int_eq(freeResult, 1);
freeResult = 0;
// free sContainer in an array without the free function in sContainer
+ setClassDataFreeO(self, NULL);
setValO(self, &r);
createAllocateSmallArray(a);
a->f->pushNFreeSmallContainer(a, self);
@@ -208,6 +209,8 @@ void setObjectDataToStringSmallContainerT(void) {
smallContainert* r;
smallContainert *self = allocSmallContainer(&something);
+ // remove class toString function
+ setClassDataToStringO(self, NULL);
char *s = toStringO(self);
ck_assert_ptr_ne(s, null);
diff --git a/release/json/libsheepyCSmallDict.h b/release/json/libsheepyCSmallDict.h
@@ -134,6 +134,7 @@ typedef smallDictt* (*setCharSmallDictFt) (smallDictt *self, const c
typedef smallDictt* (*setDictSmallDictFt) (smallDictt *self, const char *key, smallDictt *dict);
typedef smallDictt* (*setArraySmallDictFt) (smallDictt *self, const char *key, smallArrayt *array);
typedef smallDictt* (*setArraycSmallDictFt) (smallDictt *self, const char *key, char **array);
+typedef smallDictt* (*setCArraycSmallDictFt) (smallDictt *self, const char *key, const char **array);
typedef smallDictt* (*setSmallBoolSmallDictFt) (smallDictt *self, const char *key, smallBoolt *value);
typedef smallDictt* (*setSmallBytesSmallDictFt) (smallDictt *self, const char *key, smallBytest *value);
typedef smallDictt* (*setSmallDoubleSmallDictFt) (smallDictt *self, const char *key, smallDoublet *value);
@@ -152,6 +153,7 @@ typedef smallDictt* (*setCharKCharSmallDictFt) (smallDictt *self, ch
typedef smallDictt* (*setDictKCharSmallDictFt) (smallDictt *self, char key, smallDictt *dict);
typedef smallDictt* (*setArrayKCharSmallDictFt) (smallDictt *self, char key, smallArrayt *array);
typedef smallDictt* (*setArraycKCharSmallDictFt) (smallDictt *self, char key, char **array);
+typedef smallDictt* (*setCArraycKCharSmallDictFt) (smallDictt *self, char key, const char **array);
typedef smallDictt* (*setSmallBoolKCharSmallDictFt) (smallDictt *self, char key, smallBoolt *value);
typedef smallDictt* (*setSmallBytesKCharSmallDictFt) (smallDictt *self, char key, smallBytest *value);
typedef smallDictt* (*setSmallDoubleKCharSmallDictFt) (smallDictt *self, char key, smallDoublet *value);
@@ -360,25 +362,25 @@ typedef double (*getNumSmallDictFt) (smallDictt *se
* element for key (you must free the pointer (terminate libsheepy objects))
* NULL error
*/
-typedef baset* (*cropElemSmallDictFt) (smallDictt *self, char* key);
-typedef undefinedt* (*cropElemUndefinedSmallDictFt) (smallDictt *self, char* key);
-typedef bool (*cropElemBoolSmallDictFt) (smallDictt *self, char* key);
-typedef double (*cropElemDoubleSmallDictFt) (smallDictt *self, char* key);
-typedef int64_t (*cropElemIntSmallDictFt) (smallDictt *self, char* key);
-typedef int32_t (*cropElemInt32SmallDictFt) (smallDictt *self, char* key);
-typedef uint64_t (*cropElemUintSmallDictFt) (smallDictt *self, char* key);
-typedef uint32_t (*cropElemUint32SmallDictFt) (smallDictt *self, char* key);
-typedef char* (*cropElemSSmallDictFt) (smallDictt *self, char* key);
-typedef smallDictt* (*cropElemDictSmallDictFt) (smallDictt *self, char* key);
-typedef smallArrayt* (*cropElemArraySmallDictFt) (smallDictt *self, char* key);
-typedef smallBoolt* (*cropElemSmallBoolSmallDictFt) (smallDictt *self, char* key);
-typedef smallBytest* (*cropElemSmallBytesSmallDictFt) (smallDictt *self, char* key);
-typedef smallDoublet* (*cropElemSmallDoubleSmallDictFt) (smallDictt *self, char* key);
-typedef smallIntt* (*cropElemSmallIntSmallDictFt) (smallDictt *self, char* key);
-typedef smallJsont* (*cropElemSmallJsonSmallDictFt) (smallDictt *self, char* key);
-typedef smallStringt* (*cropElemSmallStringSmallDictFt) (smallDictt *self, char* key);
-typedef void* (*cropElemVoidSmallDictFt) (smallDictt *self, char* key);
-typedef smallContainert* (*cropElemSmallContainerSmallDictFt) (smallDictt *self, char* key);
+typedef baset* (*cropElemSmallDictFt) (smallDictt *self, const char* key);
+typedef undefinedt* (*cropElemUndefinedSmallDictFt) (smallDictt *self, const char* key);
+typedef bool (*cropElemBoolSmallDictFt) (smallDictt *self, const char* key);
+typedef double (*cropElemDoubleSmallDictFt) (smallDictt *self, const char* key);
+typedef int64_t (*cropElemIntSmallDictFt) (smallDictt *self, const char* key);
+typedef int32_t (*cropElemInt32SmallDictFt) (smallDictt *self, const char* key);
+typedef uint64_t (*cropElemUintSmallDictFt) (smallDictt *self, const char* key);
+typedef uint32_t (*cropElemUint32SmallDictFt) (smallDictt *self, const char* key);
+typedef char* (*cropElemSSmallDictFt) (smallDictt *self, const char* key);
+typedef smallDictt* (*cropElemDictSmallDictFt) (smallDictt *self, const char* key);
+typedef smallArrayt* (*cropElemArraySmallDictFt) (smallDictt *self, const char* key);
+typedef smallBoolt* (*cropElemSmallBoolSmallDictFt) (smallDictt *self, const char* key);
+typedef smallBytest* (*cropElemSmallBytesSmallDictFt) (smallDictt *self, const char* key);
+typedef smallDoublet* (*cropElemSmallDoubleSmallDictFt) (smallDictt *self, const char* key);
+typedef smallIntt* (*cropElemSmallIntSmallDictFt) (smallDictt *self, const char* key);
+typedef smallJsont* (*cropElemSmallJsonSmallDictFt) (smallDictt *self, const char* key);
+typedef smallStringt* (*cropElemSmallStringSmallDictFt) (smallDictt *self, const char* key);
+typedef void* (*cropElemVoidSmallDictFt) (smallDictt *self, const char* key);
+typedef smallContainert* (*cropElemSmallContainerSmallDictFt) (smallDictt *self, const char* key);
/**
* delete element
@@ -457,6 +459,7 @@ typedef char* (*keyByCharSmallDictFt) (smallDictt *self, char c);
typedef char* (*keyByDictSmallDictFt) (smallDictt *self, smallDictt *dict);
typedef char* (*keyByArraySmallDictFt) (smallDictt *self, smallArrayt *array);
typedef char* (*keyByArraycSmallDictFt) (smallDictt *self, char **array);
+typedef char* (*keyByCArraycSmallDictFt) (smallDictt *self, const char **array);
typedef char* (*keyBySmallBoolSmallDictFt) (smallDictt *self, smallBoolt *value);
typedef char* (*keyBySmallBytesSmallDictFt) (smallDictt *self, smallBytest *value);
typedef char* (*keyBySmallDoubleSmallDictFt) (smallDictt *self, smallDoublet *value);
@@ -481,6 +484,7 @@ typedef char* (*icKeyByCharSmallDictFt) (smallDictt *self, char c);
typedef char* (*icKeyByDictSmallDictFt) (smallDictt *self, smallDictt *dict);
typedef char* (*icKeyByArraySmallDictFt) (smallDictt *self, smallArrayt *array);
typedef char* (*icKeyByArraycSmallDictFt) (smallDictt *self, char **array);
+typedef char* (*icKeyByCArraycSmallDictFt) (smallDictt *self, const char **array);
typedef char* (*icKeyBySmallJsonSmallDictFt) (smallDictt *self, smallJsont *string);
typedef char* (*icKeyBySmallStringSmallDictFt) (smallDictt *self, smallStringt *string);
@@ -596,10 +600,17 @@ typedef smallDictt* (*zipSmallJsonSmallDictFt) (smallDictt *se
typedef smallDictt* (*zipSmallJsonSmallArraySmallDictFt)(smallDictt *self, smallJsont *keys, smallArrayt *values);
typedef smallDictt* (*zipSmallJsonSmallJsonSmallDictFt) (smallDictt *self, smallJsont *keys, smallJsont *values);
typedef smallDictt* (*zipSmallJsonVArraySmallDictFt) (smallDictt *self, smallJsont *keys, char** values);
+typedef smallDictt* (*zipSmallJsonVCArraySmallDictFt) (smallDictt *self, smallJsont *keys, const char** values);
typedef smallDictt* (*zipArraySmallDictFt) (smallDictt *self, char** keys, smallArrayt *values);
+typedef smallDictt* (*zipCArraySmallDictFt) (smallDictt *self, const char** keys, smallArrayt *values);
typedef smallDictt* (*zipArraySmallJsonSmallDictFt) (smallDictt *self, char** keys, smallJsont *values);
+typedef smallDictt* (*zipCArraySmallJsonSmallDictFt) (smallDictt *self, const char** keys, smallJsont *values);
typedef smallDictt* (*zipArrayArraySmallDictFt) (smallDictt *self, char** keys, char** values);
+typedef smallDictt* (*zipCArrayArraySmallDictFt) (smallDictt *self, const char** keys, char** values);
+typedef smallDictt* (*zipArrayCArraySmallDictFt) (smallDictt *self, char** keys, const char** values);
+typedef smallDictt* (*zipCArrayCArraySmallDictFt) (smallDictt *self, const char** keys, const char** values);
typedef smallDictt* (*zipVArraySmallDictFt) (smallDictt *self, smallArrayt *keys, char** values);
+typedef smallDictt* (*zipVCArraySmallDictFt) (smallDictt *self, smallArrayt *keys, const char** values);
/**
* convert array to dictionary
@@ -748,6 +759,7 @@ typedef bool (*areAllEBytesSmallDictFt) (smallDictt *self);
setDictSmallDictFt setDict;\
setArraySmallDictFt setArray;\
setArraycSmallDictFt setArrayc;\
+ setCArraycSmallDictFt setCArrayc;\
setSmallBoolSmallDictFt setSmallBool;\
setSmallBytesSmallDictFt setSmallBytes;\
setSmallDoubleSmallDictFt setSmallDouble;\
@@ -765,6 +777,7 @@ typedef bool (*areAllEBytesSmallDictFt) (smallDictt *self);
setDictKCharSmallDictFt setDictKChar;\
setArrayKCharSmallDictFt setArrayKChar;\
setArraycKCharSmallDictFt setArraycKChar;\
+ setCArraycKCharSmallDictFt setCArraycKChar;\
setSmallBoolKCharSmallDictFt setSmallBoolKChar;\
setSmallBytesKCharSmallDictFt setSmallBytesKChar;\
setSmallDoubleKCharSmallDictFt setSmallDoubleKChar;\
@@ -938,6 +951,7 @@ typedef bool (*areAllEBytesSmallDictFt) (smallDictt *self);
keyByDictSmallDictFt keyByDict;\
keyByArraySmallDictFt keyByArray;\
keyByArraycSmallDictFt keyByArrayc;\
+ keyByCArraycSmallDictFt keyByCArrayc;\
keyBySmallBoolSmallDictFt keyBySmallBool;\
keyBySmallBytesSmallDictFt keyBySmallBytes;\
keyBySmallDoubleSmallDictFt keyBySmallDouble;\
@@ -951,6 +965,7 @@ typedef bool (*areAllEBytesSmallDictFt) (smallDictt *self);
icKeyByDictSmallDictFt icKeyByDict;\
icKeyByArraySmallDictFt icKeyByArray;\
icKeyByArraycSmallDictFt icKeyByArrayc;\
+ icKeyByCArraycSmallDictFt icKeyByCArrayc;\
icKeyBySmallJsonSmallDictFt icKeyBySmallJson;\
icKeyBySmallStringSmallDictFt icKeyBySmallString;\
trimSmallDictFt trim;\
@@ -984,10 +999,17 @@ typedef bool (*areAllEBytesSmallDictFt) (smallDictt *self);
zipSmallJsonSmallArraySmallDictFt zipSmallJsonSmallArray;\
zipSmallJsonSmallJsonSmallDictFt zipSmallJsonSmallJson;\
zipSmallJsonVArraySmallDictFt zipSmallJsonVArray;\
+ zipSmallJsonVCArraySmallDictFt zipSmallJsonVCArray;\
zipArraySmallDictFt zipArray;\
+ zipCArraySmallDictFt zipCArray;\
zipArraySmallJsonSmallDictFt zipArraySmallJson;\
+ zipCArraySmallJsonSmallDictFt zipCArraySmallJson;\
zipArrayArraySmallDictFt zipArrayArray;\
+ zipCArrayArraySmallDictFt zipCArrayArray;\
+ zipArrayCArraySmallDictFt zipArrayCArray;\
+ zipCArrayCArraySmallDictFt zipCArrayCArray;\
zipVArraySmallDictFt zipVArray;\
+ zipVCArraySmallDictFt zipVCArray;\
fromArraySmallDictFt fromArray;\
toArraySmallDictFt toArray;\
writeFileSmallDictFt writeFile;\
diff --git a/release/json/libsheepyCSmallDictTest.sh b/release/json/libsheepyCSmallDictTest.sh
@@ -1,16 +1,21 @@
# generate help comments
~/scripts/generators/cg_c.py libsheepyCSmallDict_cg.c
+
rm libsheepyCSmallDictTest
-gcc -mrdrnd -g3 -std=gnu99 -o libsheepyCSmallDictTest libsheepyCSmallDictTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
+#gcc -mrdrnd -g3 -std=gnu99 -o libsheepyCSmallDictTest libsheepyCSmallDictTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
+#./libsheepyCSmallDictTest
+
+../../utils/runMemtest libsheepyCSmallDictTest.c memTest.c.template
+../../utils/genCuTest libsheepyCSmallDictTest.c ../../utils/CuTest.c.template
+
+gcc -mrdrnd -g3 -std=gnu11 -o libsheepyCSmallDictTest libsheepyCSmallDictCuTest.c CuTest/CuTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -rdynamic -fprofile-arcs -ftest-coverage
./libsheepyCSmallDictTest
# GCOV
echo
gcov -b libsheepyCSmallDict.c
-../../utils/runMemtest libsheepyCSmallDictTest.c memTest.c.template
-../../utils/genCuTest libsheepyCSmallDictTest.c ../../utils/CuTest.c.template
gcc -mrdrnd -g3 -std=gnu99 -o libsheepyCSmallDictTestMem libsheepyCSmallDictTestMem.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
valgrind --leak-check=full --show-leak-kinds=all ./libsheepyCSmallDictTestMem
diff --git a/release/json/libsheepyCSmallDoubleTest.sh b/release/json/libsheepyCSmallDoubleTest.sh
@@ -3,14 +3,19 @@
~/scripts/generators/cg_c.py libsheepyCSmallDouble_cg.c
rm libsheepyCSmallDoubleTest
-gcc -mrdrnd -g3 -std=gnu99 -o libsheepyCSmallDoubleTest libsheepyCSmallDoubleTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
+#
+#gcc -mrdrnd -g3 -std=gnu99 -o libsheepyCSmallDoubleTest libsheepyCSmallDoubleTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
./libsheepyCSmallDoubleTest
+../../utils/runMemtest libsheepyCSmallDoubleTest.c memTest.c.template
+
+gcc -mrdrnd -g3 -std=gnu11 -o libsheepyCSmallDoubleTest libsheepyCSmallDoubleCuTest.c CuTest/CuTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -rdynamic -fprofile-arcs -ftest-coverage
+./libsheepyCSmallDoubleTest
+
+
# GCOV
echo
gcov -b libsheepyCSmallDouble.c
-
-../../utils/runMemtest libsheepyCSmallDoubleTest.c memTest.c.template
../../utils/genCuTest libsheepyCSmallDoubleTest.c ../../utils/CuTest.c.template
gcc -mrdrnd -g3 -std=gnu99 -o libsheepyCSmallDoubleTestMem libsheepyCSmallDoubleTestMem.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
diff --git a/release/json/libsheepyCSmallIntTest.sh b/release/json/libsheepyCSmallIntTest.sh
@@ -3,15 +3,19 @@
~/scripts/generators/cg_c.py libsheepyCSmallInt_cg.c
rm libsheepyCSmallIntTest
-gcc -mrdrnd -g3 -std=gnu99 -o libsheepyCSmallIntTest libsheepyCSmallIntTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
+#gcc -mrdrnd -g3 -std=gnu99 -o libsheepyCSmallIntTest libsheepyCSmallIntTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
+#./libsheepyCSmallIntTest
+
+../../utils/runMemtest libsheepyCSmallIntTest.c memTest.c.template
+../../utils/genCuTest libsheepyCSmallIntTest.c ../../utils/CuTest.c.template
+
+gcc -mrdrnd -g3 -std=gnu11 -o libsheepyCSmallIntTest libsheepyCSmallIntCuTest.c CuTest/CuTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -rdynamic -fprofile-arcs -ftest-coverage
./libsheepyCSmallIntTest
# GCOV
echo
gcov -b libsheepyCSmallInt.c
-../../utils/runMemtest libsheepyCSmallIntTest.c memTest.c.template
-../../utils/genCuTest libsheepyCSmallIntTest.c ../../utils/CuTest.c.template
gcc -mrdrnd -g3 -std=gnu99 -o libsheepyCSmallIntTestMem libsheepyCSmallIntTestMem.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
valgrind --leak-check=full --show-leak-kinds=all ./libsheepyCSmallIntTestMem
diff --git a/release/json/libsheepyCSmallJson.h b/release/json/libsheepyCSmallJson.h
@@ -160,6 +160,7 @@ typedef smallJsont* (*setTopCharSmallJsonFt) (smallJsont *self, char c);
typedef smallJsont* (*setTopDictSmallJsonFt) (smallJsont *self, smallDictt *value);
typedef smallJsont* (*setTopArraySmallJsonFt) (smallJsont *self, smallArrayt *value);
typedef smallJsont* (*setTopArraycSmallJsonFt) (smallJsont *self, char **value);
+typedef smallJsont* (*setTopCArraycSmallJsonFt) (smallJsont *self, const char **value);
typedef smallJsont* (*setTopSmallBoolSmallJsonFt) (smallJsont *self, smallBoolt *value);
typedef smallJsont* (*setTopSmallDoubleSmallJsonFt)(smallJsont *self, smallDoublet *value);
typedef smallJsont* (*setTopSmallIntSmallJsonFt) (smallJsont *self, smallIntt *value);
@@ -199,8 +200,9 @@ typedef smallJsont* (*setTopNFreeSmallStringSmallJsonFt)(smallJsont *self, sma
* empty list when size is 0
* NULL when array is NULL
*/
-typedef smallJsont* (*fromArraySmallJsonFt)(smallJsont *self, char **array, size_t size);
-typedef smallJsont* (*fromArrayNFreeSmallJsonFt)(smallJsont *self, char **array, size_t size);
+typedef smallJsont* (*fromArraySmallJsonFt) (smallJsont *self, char **array, size_t size);
+typedef smallJsont* (*fromCArraySmallJsonFt) (smallJsont *self, const char **array, size_t size);
+typedef smallJsont* (*fromArrayNFreeSmallJsonFt)(smallJsont *self, char **array, size_t size);
/**
* convert array to dictionary
@@ -370,6 +372,7 @@ typedef smallJsont* (*setCharSmallJsonFt) (smallJsont *self, const char *k
typedef smallJsont* (*setDictSmallJsonFt) (smallJsont *self, const char *key, smallDictt *dict);
typedef smallJsont* (*setArraySmallJsonFt) (smallJsont *self, const char *key, smallArrayt *array);
typedef smallJsont* (*setArraycSmallJsonFt) (smallJsont *self, const char *key, char **array);
+typedef smallJsont* (*setCArraycSmallJsonFt) (smallJsont *self, const char *key, const char **array);
typedef smallJsont* (*setSmallBoolSmallJsonFt) (smallJsont *self, const char *key, smallBoolt *value);
typedef smallJsont* (*setSmallBytesSmallJsonFt) (smallJsont *self, const char *key, smallBytest *value);
typedef smallJsont* (*setSmallDoubleSmallJsonFt) (smallJsont *self, const char *key, smallDoublet *value);
@@ -456,6 +459,7 @@ typedef smallJsont* (*setAtCharSmallJsonFt) (smallJsont *self, int64
typedef smallJsont* (*setAtDictSmallJsonFt) (smallJsont *self, int64_t index, smallDictt *dict);
typedef smallJsont* (*setAtArraySmallJsonFt) (smallJsont *self, int64_t index, smallArrayt *array);
typedef smallJsont* (*setAtArraycSmallJsonFt) (smallJsont *self, int64_t index, char **array);
+typedef smallJsont* (*setAtCArraycSmallJsonFt) (smallJsont *self, int64_t index, const char **array);
typedef smallJsont* (*setAtSmallBoolSmallJsonFt) (smallJsont *self, int64_t index, smallBoolt *value);
typedef smallJsont* (*setAtSmallBytesSmallJsonFt) (smallJsont *self, int64_t index, smallBytest *value);
typedef smallJsont* (*setAtSmallDoubleSmallJsonFt) (smallJsont *self, int64_t index, smallDoublet *value);
@@ -800,6 +804,7 @@ typedef smallJsont* (*pushCharSmallJsonFt) (smallJsont *self, char c
typedef smallJsont* (*pushDictSmallJsonFt) (smallJsont *self, smallDictt *dict);
typedef smallJsont* (*pushArraySmallJsonFt) (smallJsont *self, smallArrayt *array);
typedef smallJsont* (*pushArraycSmallJsonFt) (smallJsont *self, char **array);
+typedef smallJsont* (*pushCArraycSmallJsonFt) (smallJsont *self, const char **array);
typedef smallJsont* (*pushSmallBoolSmallJsonFt) (smallJsont *self, smallBoolt *value);
typedef smallJsont* (*pushSmallBytesSmallJsonFt) (smallJsont *self, smallBytest *value);
typedef smallJsont* (*pushSmallDoubleSmallJsonFt) (smallJsont *self, smallDoublet *value);
@@ -935,6 +940,7 @@ typedef smallJsont* (*prependCharSmallJsonFt) (smallJson
typedef smallJsont* (*prependDictSmallJsonFt) (smallJsont *self, smallDictt *dict);
typedef smallJsont* (*prependArraySmallJsonFt) (smallJsont *self, smallArrayt *array);
typedef smallJsont* (*prependArraycSmallJsonFt) (smallJsont *self, char **array);
+typedef smallJsont* (*prependCArraycSmallJsonFt) (smallJsont *self, const char **array);
typedef smallJsont* (*prependSmallBoolSmallJsonFt) (smallJsont *self, smallBoolt *value);
typedef smallJsont* (*prependSmallBytesSmallJsonFt) (smallJsont *self, smallBytest *value);
typedef smallJsont* (*prependSmallDoubleSmallJsonFt) (smallJsont *self, smallDoublet *value);
@@ -1045,6 +1051,7 @@ typedef smallJsont* (*appendNSmashSmallJsonFt) (smallJsont *self, s
// not used, included in mergeSmallJson - typedef smallJsont* (*appendSmallJsonSmallJsonFt) (smallJsont *self, smallJsont *array);
// not used, included in mergeSmallJson - typedef smallJsont* (*appendSmallJsonNSmashSmallJsonFt)(smallJsont *self, smallJsont *array);
typedef smallJsont* (*appendArraySmallJsonFt) (smallJsont *self, char **array);
+typedef smallJsont* (*appendCArraySmallJsonFt) (smallJsont *self, const char **array);
typedef smallJsont* (*appendNSmashArraySmallJsonFt)(smallJsont *self, char **array);
/**
@@ -1167,25 +1174,25 @@ typedef smallContainert* (*cropElemAtSmallContainerSmallJsonFt) (smallJsont *se
* element for key (you must free the pointer (terminate libsheepy objects))
* NULL error
*/
-typedef baset* (*cropElemKeySmallJsonFt) (smallJsont *self, char* key);
-typedef undefinedt* (*cropElemKeyUndefinedSmallJsonFt) (smallJsont *self, char* key);
-typedef bool (*cropElemKeyBoolSmallJsonFt) (smallJsont *self, char* key);
-typedef double (*cropElemKeyDoubleSmallJsonFt) (smallJsont *self, char* key);
-typedef int64_t (*cropElemKeyIntSmallJsonFt) (smallJsont *self, char* key);
-typedef int32_t (*cropElemKeyInt32SmallJsonFt) (smallJsont *self, char* key);
-typedef uint64_t (*cropElemKeyUintSmallJsonFt) (smallJsont *self, char* key);
-typedef uint32_t (*cropElemKeyUint32SmallJsonFt) (smallJsont *self, char* key);
-typedef char* (*cropElemKeySSmallJsonFt) (smallJsont *self, char* key);
-typedef smallDictt* (*cropElemKeyDictSmallJsonFt) (smallJsont *self, char* key);
-typedef smallArrayt* (*cropElemKeyArraySmallJsonFt) (smallJsont *self, char* key);
-typedef smallBoolt* (*cropElemKeySmallBoolSmallJsonFt) (smallJsont *self, char* key);
-typedef smallBytest* (*cropElemKeySmallBytesSmallJsonFt) (smallJsont *self, char* key);
-typedef smallDoublet* (*cropElemKeySmallDoubleSmallJsonFt) (smallJsont *self, char* key);
-typedef smallIntt* (*cropElemKeySmallIntSmallJsonFt) (smallJsont *self, char* key);
-typedef smallJsont* (*cropElemKeySmallJsonSmallJsonFt) (smallJsont *self, char* key);
-typedef smallStringt* (*cropElemKeySmallStringSmallJsonFt) (smallJsont *self, char* key);
-typedef void* (*cropElemKeyVoidSmallJsonFt) (smallJsont *self, char* key);
-typedef smallContainert* (*cropElemKeySmallContainerSmallJsonFt) (smallJsont *self, char* key);
+typedef baset* (*cropElemKeySmallJsonFt) (smallJsont *self, const char* key);
+typedef undefinedt* (*cropElemKeyUndefinedSmallJsonFt) (smallJsont *self, const char* key);
+typedef bool (*cropElemKeyBoolSmallJsonFt) (smallJsont *self, const char* key);
+typedef double (*cropElemKeyDoubleSmallJsonFt) (smallJsont *self, const char* key);
+typedef int64_t (*cropElemKeyIntSmallJsonFt) (smallJsont *self, const char* key);
+typedef int32_t (*cropElemKeyInt32SmallJsonFt) (smallJsont *self, const char* key);
+typedef uint64_t (*cropElemKeyUintSmallJsonFt) (smallJsont *self, const char* key);
+typedef uint32_t (*cropElemKeyUint32SmallJsonFt) (smallJsont *self, const char* key);
+typedef char* (*cropElemKeySSmallJsonFt) (smallJsont *self, const char* key);
+typedef smallDictt* (*cropElemKeyDictSmallJsonFt) (smallJsont *self, const char* key);
+typedef smallArrayt* (*cropElemKeyArraySmallJsonFt) (smallJsont *self, const char* key);
+typedef smallBoolt* (*cropElemKeySmallBoolSmallJsonFt) (smallJsont *self, const char* key);
+typedef smallBytest* (*cropElemKeySmallBytesSmallJsonFt) (smallJsont *self, const char* key);
+typedef smallDoublet* (*cropElemKeySmallDoubleSmallJsonFt) (smallJsont *self, const char* key);
+typedef smallIntt* (*cropElemKeySmallIntSmallJsonFt) (smallJsont *self, const char* key);
+typedef smallJsont* (*cropElemKeySmallJsonSmallJsonFt) (smallJsont *self, const char* key);
+typedef smallStringt* (*cropElemKeySmallStringSmallJsonFt) (smallJsont *self, const char* key);
+typedef void* (*cropElemKeyVoidSmallJsonFt) (smallJsont *self, const char* key);
+typedef smallContainert* (*cropElemKeySmallContainerSmallJsonFt) (smallJsont *self, const char* key);
/**
* keep elements from start and end in list, free the other elements
@@ -1270,6 +1277,7 @@ typedef smallJsont* (*injectCharSmallJsonFt) (smallJsont *self, int64_t inde
typedef smallJsont* (*injectDictSmallJsonFt) (smallJsont *self, int64_t index, smallDictt *toInject);
typedef smallJsont* (*injectArraySmallJsonFt) (smallJsont *self, int64_t index, smallArrayt *toInject);
typedef smallJsont* (*injectArraycSmallJsonFt) (smallJsont *self, int64_t index, char **toInject);
+typedef smallJsont* (*injectCArraycSmallJsonFt) (smallJsont *self, int64_t index, const char **toInject);
typedef smallJsont* (*injectSmallBoolSmallJsonFt) (smallJsont *self, int64_t index, smallBoolt *toInject);
typedef smallJsont* (*injectSmallBytesSmallJsonFt) (smallJsont *self, int64_t index, smallBytest *toInject);
typedef smallJsont* (*injectSmallDoubleSmallJsonFt) (smallJsont *self, int64_t index, smallDoublet *toInject);
@@ -1405,6 +1413,7 @@ typedef bool (*hasCharSmallJsonFt) (smallJsont *self, char c);
typedef bool (*hasDictSmallJsonFt) (smallJsont *self, smallDictt *dict);
typedef bool (*hasArraySmallJsonFt) (smallJsont *self, smallArrayt *array);
typedef bool (*hasArraycSmallJsonFt) (smallJsont *self, char **array);
+typedef bool (*hasCArraycSmallJsonFt) (smallJsont *self, const char **array);
typedef bool (*hasSmallBoolSmallJsonFt) (smallJsont *self, smallBoolt *value);
typedef bool (*hasSmallBytesSmallJsonFt) (smallJsont *self, smallBytest *value);
typedef bool (*hasSmallDoubleSmallJsonFt) (smallJsont *self, smallDoublet *value);
@@ -1448,6 +1457,7 @@ typedef ssize_t (*indexOfCharSmallJsonFt) (smallJsont *self, char c);
typedef ssize_t (*indexOfDictSmallJsonFt) (smallJsont *self, smallDictt *dict);
typedef ssize_t (*indexOfArraySmallJsonFt) (smallJsont *self, smallArrayt *array);
typedef ssize_t (*indexOfArraycSmallJsonFt) (smallJsont *self, char **array);
+typedef ssize_t (*indexOfCArraycSmallJsonFt) (smallJsont *self, const char **array);
typedef ssize_t (*indexOfSmallBoolSmallJsonFt) (smallJsont *self, smallBoolt *value);
typedef ssize_t (*indexOfSmallBytesSmallJsonFt) (smallJsont *self, smallBytest *value);
typedef ssize_t (*indexOfSmallDoubleSmallJsonFt) (smallJsont *self, smallDoublet *value);
@@ -1476,6 +1486,7 @@ typedef ssize_t (*binarySearchCharSmallJsonFt) (smallJsont *self, char
typedef ssize_t (*binarySearchDictSmallJsonFt) (smallJsont *self, smallDictt *dict);
typedef ssize_t (*binarySearchArraySmallJsonFt) (smallJsont *self, smallArrayt *array);
typedef ssize_t (*binarySearchArraycSmallJsonFt) (smallJsont *self, char **array);
+typedef ssize_t (*binarySearchCArraycSmallJsonFt) (smallJsont *self, const char **array);
typedef ssize_t (*binarySearchSmallBoolSmallJsonFt) (smallJsont *self, smallBoolt *value);
typedef ssize_t (*binarySearchSmallBytesSmallJsonFt) (smallJsont *self, smallBytest *value);
typedef ssize_t (*binarySearchSmallDoubleSmallJsonFt) (smallJsont *self, smallDoublet *value);
@@ -1498,6 +1509,7 @@ typedef bool (*icHasCharSmallJsonFt) (smallJsont *self, char c);
typedef bool (*icHasDictSmallJsonFt) (smallJsont *self, smallDictt *dict);
typedef bool (*icHasArraySmallJsonFt) (smallJsont *self, smallArrayt *array);
typedef bool (*icHasArraycSmallJsonFt) (smallJsont *self, char **array);
+typedef bool (*icHasCArraycSmallJsonFt) (smallJsont *self, const char **array);
typedef bool (*icHasSmallStringSmallJsonFt) (smallJsont *self, smallStringt *string);
/**
@@ -1531,6 +1543,7 @@ typedef ssize_t (*icIndexOfCharSmallJsonFt) (smallJsont *self, char c)
typedef ssize_t (*icIndexOfDictSmallJsonFt) (smallJsont *self, smallDictt *dict);
typedef ssize_t (*icIndexOfArraySmallJsonFt) (smallJsont *self, smallArrayt *array);
typedef ssize_t (*icIndexOfArraycSmallJsonFt) (smallJsont *self, char **array);
+typedef ssize_t (*icIndexOfCArraycSmallJsonFt) (smallJsont *self, const char **array);
typedef ssize_t (*icIndexOfSmallStringSmallJsonFt) (smallJsont *self, smallStringt *string);
/**
@@ -1549,6 +1562,7 @@ typedef ssize_t (*icBinarySearchCharSmallJsonFt) (smallJsont *self, ch
typedef ssize_t (*icBinarySearchDictSmallJsonFt) (smallJsont *self, smallDictt *dict);
typedef ssize_t (*icBinarySearchArraySmallJsonFt) (smallJsont *self, smallArrayt *array);
typedef ssize_t (*icBinarySearchArraycSmallJsonFt) (smallJsont *self, char **array);
+typedef ssize_t (*icBinarySearchCArraycSmallJsonFt) (smallJsont *self, const char **array);
typedef ssize_t (*icBinarySearchSmallStringSmallJsonFt) (smallJsont *self, smallStringt *string);
/**
@@ -1571,6 +1585,7 @@ typedef char* (*keyByCharSmallJsonFt) (smallJsont *self, char c);
typedef char* (*keyByDictSmallJsonFt) (smallJsont *self, smallDictt *dict);
typedef char* (*keyByArraySmallJsonFt) (smallJsont *self, smallArrayt *array);
typedef char* (*keyByArraycSmallJsonFt) (smallJsont *self, char **array);
+typedef char* (*keyByCArraycSmallJsonFt) (smallJsont *self, const char **array);
typedef char* (*keyBySmallBoolSmallJsonFt) (smallJsont *self, smallBoolt *value);
typedef char* (*keyBySmallBytesSmallJsonFt) (smallJsont *self, smallBytest *value);
typedef char* (*keyBySmallDoubleSmallJsonFt) (smallJsont *self, smallDoublet *value);
@@ -1595,6 +1610,7 @@ typedef char* (*icKeyByCharSmallJsonFt) (smallJsont *self, char c);
typedef char* (*icKeyByDictSmallJsonFt) (smallJsont *self, smallDictt *dict);
typedef char* (*icKeyByArraySmallJsonFt) (smallJsont *self, smallArrayt *array);
typedef char* (*icKeyByArraycSmallJsonFt) (smallJsont *self, char **array);
+typedef char* (*icKeyByCArraycSmallJsonFt) (smallJsont *self, const char **array);
typedef char* (*icKeyBySmallStringSmallJsonFt) (smallJsont *self, smallStringt *string);
/**
@@ -1718,6 +1734,7 @@ typedef smallJsont* (*icReplaceManySmallJsonFt)(smallJsont *self, const cha
*/
typedef bool (*equalSmallJsonSmallArrayFt) (smallJsont *self, smallArrayt *array);
typedef bool (*equalSmallJsonArrayFt) (smallJsont *self, char ** p2);
+typedef bool (*equalSmallJsonCArrayFt) (smallJsont *self, const char ** p2);
typedef bool (*equalSmallJsonBaseFt) (smallJsont *self, baset* p2);
typedef bool (*equalSmallJsonChaFt) (smallJsont* self, char p2);
typedef bool (*equalSmallJsonCharFt) (smallJsont* self, const char * p2);
@@ -1746,6 +1763,7 @@ typedef bool (*equalSmallJsonSmallDictFt) (smallJsont* self, smallDictt* p2);
*/
typedef bool (*icEqualSmallJsonSmallArrayFt) (smallJsont *self, smallArrayt *array);
typedef bool (*icEqualSmallJsonArrayFt) (smallJsont *self, char ** p2);
+typedef bool (*icEqualSmallJsonCArrayFt) (smallJsont *self, const char ** p2);
typedef bool (*icEqualSmallJsonBaseFt) (smallJsont *self, baset* p2);
typedef bool (*icEqualSmallJsonSmallDictFt) (smallJsont* self, smallDictt* p2);
typedef bool (*icEqualSmallJsonSmallJsonFt) (smallJsont *self, smallJsont *string);
@@ -2310,14 +2328,14 @@ typedef smallStringt* (*toYMLSmallStringSmallJsonFt) (smallJsont *self, int ind
/**
* parse a smallJson string
*/
-typedef bool (*parseSmallJsonFt) (smallJsont *self, char *input);
+typedef bool (*parseSmallJsonFt) (smallJsont *self, const char *input);
typedef bool (*parseSmallJsonSmallJsonFt) (smallJsont *self, smallJsont *input);
typedef bool (*parseSmallStringSmallJsonFt)(smallJsont *self, smallStringt *input);
/**
* parse a yml string
*/
-typedef bool (*parseYMLSmallJsonFt) (smallJsont *self, char *input);
+typedef bool (*parseYMLSmallJsonFt) (smallJsont *self, const char *input);
typedef bool (*parseYMLSmallJsonSmallJsonFt) (smallJsont *self, smallJsont *input);
typedef bool (*parseYMLSmallStringSmallJsonFt)(smallJsont *self, smallStringt *input);
@@ -2617,6 +2635,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
setTopDictSmallJsonFt setTopDict;\
setTopArraySmallJsonFt setTopArray;\
setTopArraycSmallJsonFt setTopArrayc;\
+ setTopCArraycSmallJsonFt setTopCArrayc;\
setTopSmallBoolSmallJsonFt setTopSmallBool;\
setTopSmallDoubleSmallJsonFt setTopSmallDouble;\
setTopSmallIntSmallJsonFt setTopSmallInt;\
@@ -2636,6 +2655,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
setTopNFreeSmallJsonSmallJsonFt setTopNFreeSmallJson;\
setTopNFreeSmallStringSmallJsonFt setTopNFreeSmallString;\
fromArraySmallJsonFt fromArray;\
+ fromCArraySmallJsonFt fromCArray;\
fromArrayNFreeSmallJsonFt fromArrayNFree;\
fromArrayDictSmallJsonFt fromArrayDict;\
toArrayDictSmallJsonFt toArrayDict;\
@@ -2677,6 +2697,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
setDictSmallJsonFt setDict;\
setArraySmallJsonFt setArray;\
setArraycSmallJsonFt setArrayc;\
+ setCArraycSmallJsonFt setCArrayc;\
setSmallBoolSmallJsonFt setSmallBool;\
setSmallBytesSmallJsonFt setSmallBytes;\
setSmallDoubleSmallJsonFt setSmallDouble;\
@@ -2715,6 +2736,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
setAtDictSmallJsonFt setAtDict;\
setAtArraySmallJsonFt setAtArray;\
setAtArraycSmallJsonFt setAtArrayc;\
+ setAtCArraycSmallJsonFt setAtCArrayc;\
setAtSmallBoolSmallJsonFt setAtSmallBool;\
setAtSmallBytesSmallJsonFt setAtSmallBytes;\
setAtSmallDoubleSmallJsonFt setAtSmallDouble;\
@@ -2849,6 +2871,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
pushDictSmallJsonFt pushDict;\
pushArraySmallJsonFt pushArray;\
pushArraycSmallJsonFt pushArrayc;\
+ pushCArraycSmallJsonFt pushCArrayc;\
pushSmallBoolSmallJsonFt pushSmallBool;\
pushSmallBytesSmallJsonFt pushSmallBytes;\
pushSmallDoubleSmallJsonFt pushSmallDouble;\
@@ -2904,6 +2927,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
prependDictSmallJsonFt prependDict;\
prependArraySmallJsonFt prependArray;\
prependArraycSmallJsonFt prependArrayc;\
+ prependCArraycSmallJsonFt prependCArrayc;\
prependSmallBoolSmallJsonFt prependSmallBool;\
prependSmallBytesSmallJsonFt prependSmallBytes;\
prependSmallDoubleSmallJsonFt prependSmallDouble;\
@@ -2953,6 +2977,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
appendSmallJsonFt append;\
appendNSmashSmallJsonFt appendNSmash;\
appendArraySmallJsonFt appendArray;\
+ appendCArraySmallJsonFt appendCArray;\
appendNSmashArraySmallJsonFt appendNSmashArray;\
shiftSmallJsonFt shift;\
shiftNSmashSmallJsonFt shiftNSmash;\
@@ -3022,6 +3047,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
injectDictSmallJsonFt injectDict;\
injectArraySmallJsonFt injectArray;\
injectArraycSmallJsonFt injectArrayc;\
+ injectCArraycSmallJsonFt injectCArrayc;\
injectSmallBoolSmallJsonFt injectSmallBool;\
injectSmallBytesSmallJsonFt injectSmallBytes;\
injectSmallDoubleSmallJsonFt injectSmallDouble;\
@@ -3059,6 +3085,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
hasDictSmallJsonFt hasDict;\
hasArraySmallJsonFt hasArray;\
hasArraycSmallJsonFt hasArrayc;\
+ hasCArraycSmallJsonFt hasCArrayc;\
hasSmallBoolSmallJsonFt hasSmallBool;\
hasSmallBytesSmallJsonFt hasSmallBytes;\
hasSmallDoubleSmallJsonFt hasSmallDouble;\
@@ -3080,6 +3107,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
indexOfDictSmallJsonFt indexOfDict;\
indexOfArraySmallJsonFt indexOfArray;\
indexOfArraycSmallJsonFt indexOfArrayc;\
+ indexOfCArraycSmallJsonFt indexOfCArrayc;\
indexOfSmallBoolSmallJsonFt indexOfSmallBool;\
indexOfSmallBytesSmallJsonFt indexOfSmallBytes;\
indexOfSmallDoubleSmallJsonFt indexOfSmallDouble;\
@@ -3097,6 +3125,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
binarySearchDictSmallJsonFt binarySearchDict;\
binarySearchArraySmallJsonFt binarySearchArray;\
binarySearchArraycSmallJsonFt binarySearchArrayc;\
+ binarySearchCArraycSmallJsonFt binarySearchCArrayc;\
binarySearchSmallBoolSmallJsonFt binarySearchSmallBool;\
binarySearchSmallBytesSmallJsonFt binarySearchSmallBytes;\
binarySearchSmallDoubleSmallJsonFt binarySearchSmallDouble;\
@@ -3110,6 +3139,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
icHasDictSmallJsonFt icHasDict;\
icHasArraySmallJsonFt icHasArray;\
icHasArraycSmallJsonFt icHasArrayc;\
+ icHasCArraycSmallJsonFt icHasCArrayc;\
icHasSmallStringSmallJsonFt icHasSmallString;\
icFindSmallJsonFt icFind;\
icFindCharSmallJsonFt icFindChar;\
@@ -3121,6 +3151,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
icIndexOfDictSmallJsonFt icIndexOfDict;\
icIndexOfArraySmallJsonFt icIndexOfArray;\
icIndexOfArraycSmallJsonFt icIndexOfArrayc;\
+ icIndexOfCArraycSmallJsonFt icIndexOfCArrayc;\
icIndexOfSmallStringSmallJsonFt icIndexOfSmallString;\
icBinarySearchSmallJsonFt icBinarySearch;\
icBinarySearchSSmallJsonFt icBinarySearchS;\
@@ -3128,6 +3159,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
icBinarySearchDictSmallJsonFt icBinarySearchDict;\
icBinarySearchArraySmallJsonFt icBinarySearchArray;\
icBinarySearchArraycSmallJsonFt icBinarySearchArrayc;\
+ icBinarySearchCArraycSmallJsonFt icBinarySearchCArrayc;\
icBinarySearchSmallStringSmallJsonFt icBinarySearchSmallString;\
keyBySmallJsonFt keyBy;\
keyByUndefinedSmallJsonFt keyByUndefined;\
@@ -3138,7 +3170,8 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
keyByCharSmallJsonFt keyByChar;\
keyByDictSmallJsonFt keyByDict;\
keyByArraySmallJsonFt keyByArray;\
- keyByArraycSmallJsonFt keyByArrayc;\
+ keyByArraycSmallJsonFt keyByArrayc;\
+ keyByCArraycSmallJsonFt keyByCArrayc;\
keyBySmallBoolSmallJsonFt keyBySmallBool;\
keyBySmallBytesSmallJsonFt keyBySmallBytes;\
keyBySmallDoubleSmallJsonFt keyBySmallDouble;\
@@ -3152,6 +3185,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
icKeyByDictSmallJsonFt icKeyByDict;\
icKeyByArraySmallJsonFt icKeyByArray;\
icKeyByArraycSmallJsonFt icKeyByArrayc;\
+ icKeyByCArraycSmallJsonFt icKeyByCArrayc;\
icKeyBySmallStringSmallJsonFt icKeyBySmallString;\
replaceSmallJsonFt replace;\
replaceCharSSmallJsonFt replaceCharS;\
@@ -3189,6 +3223,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
icReplaceManySmallJsonFt icReplaceMany;\
equalSmallJsonSmallArrayFt equalSmallArray;\
equalSmallJsonArrayFt equalArray;\
+ equalSmallJsonCArrayFt equalCArray;\
equalSmallJsonBaseFt equalBase;\
equalSmallJsonChaFt equalCha;\
equalSmallJsonCharFt equalChar;\
@@ -3207,6 +3242,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
equalSmallJsonSmallDictFt equalSmallDict;\
icEqualSmallJsonSmallArrayFt icEqualSmallArray;\
icEqualSmallJsonArrayFt icEqualArray;\
+ icEqualSmallJsonCArrayFt icEqualCArray;\
icEqualSmallJsonBaseFt icEqualBase;\
icEqualSmallJsonSmallDictFt icEqualSmallDict;\
icEqualSmallJsonSmallJsonFt icEqualSmallJson;\
@@ -3589,7 +3625,7 @@ smallJsont* setTopNFreeSmallIntSmallJsonG (smallJsont *self, smallIntt *value)
smallJsont* setTopNFreeSmallJsonSmallJsonG (smallJsont *self, smallJsont *value);
smallJsont* setTopNFreeSmallStringSmallJsonG(smallJsont *self, smallStringt *value);
-smallJsont* fromArraySmallJsonG(smallJsont *self, char **array, size_t size);
+smallJsont* fromArraySmallJsonG (smallJsont *self, char **array, size_t size);
smallJsont* fromCArraySmallJsonG(smallJsont *self, const char **array, size_t size);
baset* getTopSmallJsonG (smallJsont *self,baset* retType UNUSED);
@@ -3625,7 +3661,7 @@ smallJsont* pushSSmallJsonG (smallJsont *self, const char *string);
smallJsont* pushCharSmallJsonG (smallJsont *self, char c);
smallJsont* pushDictSmallJsonG (smallJsont *self, smallDictt *dict);
smallJsont* pushArraySmallJsonG (smallJsont *self, smallArrayt *array);
-smallJsont* pushArraycSmallJsonG (smallJsont *self, char **array);
+smallJsont* pushArraycSmallJsonG (smallJsont *self, char **array);
smallJsont* pushCArraycSmallJsonG (smallJsont *self, const char **array);
smallJsont* pushVoidSmallJsonG (smallJsont *self, void *value);
smallJsont* pushSmallBoolSmallJsonG (smallJsont *self, smallBoolt *value);
@@ -4078,7 +4114,7 @@ ssize_t binarySearchCharSmallJsonG (smallJsont *self, char c);
ssize_t binarySearchDictSmallJsonG (smallJsont *self, smallDictt *dict);
ssize_t binarySearchArraySmallJsonG (smallJsont *self, smallArrayt *array);
ssize_t binarySearchArraycSmallJsonG (smallJsont *self, char **array);
-ssize_t binarySearchCArraycSmallJsonG (smallJsont *self, const char **array);
+ssize_t binarySearchCArraycSmallJsonG (smallJsont *self, const char **array);
ssize_t binarySearchSmallBoolSmallJsonG (smallJsont *self, smallBoolt *value);
ssize_t binarySearchSmallBytesSmallJsonG (smallJsont *self, smallBytest *value);
ssize_t binarySearchSmallDoubleSmallJsonG (smallJsont *self, smallDoublet *value);
@@ -4358,7 +4394,7 @@ bool appendTextJsonSmallJsonG (smallJsont *self, smallJsont *filePath);
*/
#define forEachSmallJson(array, element) \
size_t UNIQVAR(libsheepyInternalIndex) = 0; \
- for (baset *element = array->f->getAt(array, 0); UNIQVAR(libsheepyInternalIndex) < array->f->len(array) ; UNIQVAR(libsheepyInternalIndex)++, element = array->f->getAt(array, UNIQVAR(libsheepyInternalIndex))) \
+ for (baset *element = array->f->getAt(array, 0); UNIQVAR(libsheepyInternalIndex) < array->f->len(array) ; UNIQVAR(libsheepyInternalIndex)++, element = array->f->getAt(array, (int64_t)UNIQVAR(libsheepyInternalIndex))) \
if (element)
/**
@@ -4376,7 +4412,7 @@ bool appendTextJsonSmallJsonG (smallJsont *self, smallJsont *filePath);
*/
#define enumerateSmallJson(array, element, index) \
size_t index = 0; \
- for (baset *element = array->f->getAt(array, 0); index < array->f->len(array) ; index++, element = array->f->getAt(array, index)) \
+ for (baset *element = array->f->getAt(array, 0); index < array->f->len(array) ; index++, element = array->f->getAt(array, (int64_t)index)) \
if (element)
// end class smallJson
diff --git a/release/json/libsheepyCSmallJsonTest.sh b/release/json/libsheepyCSmallJsonTest.sh
@@ -1,19 +1,21 @@
# generate help comments
~/scripts/generators/pp.py libsheepyCSmallJson_pp.h > libsheepyCSmallJson.h
-
~/scripts/generators/cg_c.py libsheepyCSmallJson_cg.c
rm libsheepyCSmallJsonTest
-#gcc -mrdrnd -g3 -std=gnu99 -o libsheepyCSmallJsonTest libsheepyCSmallJsonTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
-gcc -mrdrnd -g3 -std=gnu99 -o libsheepyCSmallJsonTest libsheepyCSmallJsonTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
+#gcc -mrdrnd -g3 -std=gnu99 -o libsheepyCSmallJsonTest libsheepyCSmallJsonTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
+#./libsheepyCSmallJsonTest
+
+../../utils/runMemtest libsheepyCSmallJsonTest.c memTest.c.template
+../../utils/genCuTest libsheepyCSmallJsonTest.c ../../utils/CuTest.c.template
+
+gcc -mrdrnd -g3 -std=gnu11 -o libsheepyCSmallJsonTest libsheepyCSmallJsonCuTest.c CuTest/CuTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -rdynamic -fprofile-arcs -ftest-coverage
./libsheepyCSmallJsonTest
# GCOV
echo
gcov -b libsheepyCSmallJson.c
-../../utils/runMemtest libsheepyCSmallJsonTest.c memTest.c.template
-../../utils/genCuTest libsheepyCSmallJsonTest.c ../../utils/CuTest.c.template
gcc -mrdrnd -g3 -std=gnu99 -o libsheepyCSmallJsonTestMem libsheepyCSmallJsonTestMem.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
valgrind --leak-check=full --show-leak-kinds=all ./libsheepyCSmallJsonTestMem
diff --git a/release/json/libsheepyCSmallString.h b/release/json/libsheepyCSmallString.h
@@ -98,7 +98,7 @@ typedef smallStringt* (*setSmallStringSmallStringFt)(smallStringt* self, sma
*/
typedef smallStringt* (*appendSmallStringFt) (smallStringt *self, smallStringt *string);
typedef smallStringt* (*appendSmallJsonSmallStringFt) (smallStringt *self, smallJsont *string);
-typedef smallStringt* (*appendSSmallStringFt) (smallStringt *self, char *string);
+typedef smallStringt* (*appendSSmallStringFt) (smallStringt *self, const char *string);
typedef smallStringt* (*appendCharSmallStringFt) (smallStringt *self, char c);
typedef smallStringt* (*appendNSmashSmallStringFt) (smallStringt *self, smallStringt *string);
typedef smallStringt* (*appendNSmashSmallJsonSmallStringFt)(smallStringt *self, smallJsont *string);
@@ -114,7 +114,7 @@ typedef smallStringt* (*appendNSmashSSmallStringFt) (smallStringt *se
*/
typedef smallStringt* (*prependSmallStringFt) (smallStringt *self, smallStringt *string);
typedef smallStringt* (*prependSmallJsonSmallStringFt) (smallStringt *self, smallJsont *json);
-typedef smallStringt* (*prependSSmallStringFt) (smallStringt *self, char *string);
+typedef smallStringt* (*prependSSmallStringFt) (smallStringt *self, const char *string);
typedef smallStringt* (*prependCharSmallStringFt) (smallStringt *self, char c);
typedef smallStringt* (*prependNSmashSmallStringFt) (smallStringt *self, smallStringt *string);
typedef smallStringt* (*prependNSmashSmallJsonSmallStringFt)(smallStringt *self, smallJsont *json);
diff --git a/release/json/libsheepyCSmallStringTest.sh b/release/json/libsheepyCSmallStringTest.sh
@@ -3,15 +3,19 @@
~/scripts/generators/cg_c.py libsheepyCSmallString_cg.c
rm libsheepyCSmallStringTest
-gcc -mrdrnd -g3 -std=gnu99 -o libsheepyCSmallStringTest libsheepyCSmallStringTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
+#gcc -mrdrnd -g3 -std=gnu99 -o libsheepyCSmallStringTest libsheepyCSmallStringTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
+#./libsheepyCSmallStringTest
+
+../../utils/runMemtest libsheepyCSmallStringTest.c memTest.c.template
+../../utils/genCuTest libsheepyCSmallStringTest.c ../../utils/CuTest.c.template
+
+gcc -mrdrnd -g3 -std=gnu11 -o libsheepyCSmallStringTest libsheepyCSmallStringCuTest.c CuTest/CuTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -rdynamic -fprofile-arcs -ftest-coverage
./libsheepyCSmallStringTest
# GCOV
echo
gcov -b libsheepyCSmallString.c
-../../utils/runMemtest libsheepyCSmallStringTest.c memTest.c.template
-../../utils/genCuTest libsheepyCSmallStringTest.c ../../utils/CuTest.c.template
gcc -mrdrnd -g3 -std=gnu99 -o libsheepyCSmallStringTestMem libsheepyCSmallStringTestMem.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
valgrind --leak-check=full --show-leak-kinds=all ./libsheepyCSmallStringTestMem
diff --git a/release/json/libsheepyObjectFuncTest.sh b/release/json/libsheepyObjectFuncTest.sh
@@ -3,15 +3,19 @@
~/scripts/generators/cg_c.py libsheepyObject_cg.c
rm libsheepyObjectFuncTest
-gcc -mrdrnd -g3 -std=gnu99 -DunitTest -o libsheepyObjectFuncTest libsheepyObjectFuncTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
+#gcc -mrdrnd -g3 -std=gnu99 -DunitTest -o libsheepyObjectFuncTest libsheepyObjectFuncTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
+#./libsheepyObjectFuncTest
+
+../../utils/runMemtest libsheepyObjectFuncTest.c memTest.c.template
+../../utils/genCuTest libsheepyObjectFuncTest.c ../../utils/CuTest.c.template
+
+gcc -mrdrnd -g3 -std=gnu11 -DunitTest -o libsheepyObjectFuncTest libsheepyObjectFuncCuTest.c CuTest/CuTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -rdynamic -fprofile-arcs -ftest-coverage
./libsheepyObjectFuncTest
# GCOV
echo
gcov -b libsheepyObject.c
-../../utils/runMemtest libsheepyObjectFuncTest.c memTest.c.template
-../../utils/genCuTest libsheepyObjectFuncTest.c ../../utils/CuTest.c.template
gcc -mrdrnd -g3 -std=gnu99 -DunitTest -o libsheepyObjectFuncTestMem libsheepyObjectFuncTestMem.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -pthread -lcheck_pic -lrt -lm -fprofile-arcs -ftest-coverage -lsubunit
valgrind --leak-check=full --show-leak-kinds=all ./libsheepyObjectFuncTestMem
diff --git a/release/libsheepy.c b/release/libsheepy.c
@@ -209,7 +209,7 @@ char **readDirDir(const char *dirPath);
char **walkDirAll(const char* dirPath);
internal void walkADirAll(const char *dirPath, char ***list);
char **readDirAll(const char *dirPath);
-mode_t getumask(void);
+mode_t getUmask(void);
mode_t getCurrentPermissions(void);
int mkdirParents(const char* path);
int rmAll(const char* path);
@@ -248,13 +248,13 @@ void loghex(const void *buf, size_t len);
char *toHexS(const void *buf, size_t len);
char *toHexSepS(const void *buf, size_t len, const char *separator);
char *toHexHeadSepS(const void *buf, size_t len, const char *head, const char *separator);
-char *strCpy(char *dst, const char *src);
-char *strNCpy(char *dst, const char *src, size_t srcSize);
-char *strLCpy(char *dst, size_t dstSize, const char *src);
-char *strCat(char *dst, const char *src);
-char *strNCat(char *dst, const char *src, size_t srcLen);
-char *strLCat(char *dst, size_t dstSize, const char *src);
-char *strLNCat(char *dst, size_t dstSize, const char *src, size_t srcLen);
+char *strCpy(char *restrict dst, const char *restrict src);
+char *strNCpy(char *restrict dst, const char *restrict src, size_t srcSize);
+char *strLCpy(char *restrict dst, size_t dstSize, const char *restrict src);
+char *strCat(char *restrict dst, const char *restrict src);
+char *strNCat(char *restrict dst, const char *restrict src, size_t srcLen);
+char *strLCat(char *restrict dst, size_t dstSize, const char *restrict src);
+char *strLNCat(char *restrict dst, size_t dstSize, const char *restrict src, size_t srcLen);
char *catSF(const char *paramType, ...);
char *iCatSF(char *dst, const char *paramType, ...);
char *bLCatSF(char *dst, size_t dstSize, const char *paramType, ...);
@@ -461,21 +461,23 @@ ssize_t icIndexOfS(const char *string, const char *needle);
ssize_t icIndexOfCharS(const char *string, char c);
bool icHasS(const char *string, const char *needle);
bool icHasCharS(const char *string, char c);
-char *tokS(const char *s, const char *delim, char **saveptr);
-char *icTokS(const char *s, const char *delim, char **saveptr);
+char *tokS(char *s, const char *delim, char **saveptr);
+char *icTokS(char *s, const char *delim, char **saveptr);
size_t lenUTF8(const char *s);
size_t bLLenUTF8(const char *s, size_t maxSize);
bool isUTF8(const char * string);
bool bLIsUTF8(const char * string, size_t stringSize);
bool isCodeUTF8(const char *code);
-char *nextUTF8(const char *utf8);
-char *bLNextUTF8(const char *string, size_t utf8Size, const char *utf8);
-char *findNextUTF8(const char *string, size_t utf8Size, const char *utf8);
-char *prevUTF8(const char *utf8);
-char *bPrevUTF8(const char *string, const char *utf8);
-local char *bPrevUTF8Tiny(const char *string, const char *utf8);
-char *idx2PtrUTF8(const char *utf8, int64_t index);
-char *bLIdx2PtrUTF8(const char *utf8, size_t utf8Size, int64_t index);
+const char *nextUTF8(const char *utf8);
+const char *bLNextUTF8(const char *string, size_t utf8Size, const char *utf8);
+const char *findNextUTF8(const char *string, size_t utf8Size, const char *utf8);
+const char *prevUTF8(const char *utf8);
+const char *bPrevUTF8(const char *string, const char *utf8);
+local const char *bPrevUTF8Tiny(const char *string, const char *utf8);
+local char *bPrevRWUTF8Tiny(const char *string, char *utf8);
+const char *idx2PtrUTF8(const char *utf8, int64_t index);
+local char *idx2PtrRWUTF8(char *utf8, int64_t index);
+const char *bLIdx2PtrUTF8(const char *utf8, size_t utf8Size, int64_t index);
int64_t ptr2IdxUTF8(const char *utf8, const char *pos);
int64_t bPtr2IdxUTF8(const char *start, const char *utf8, const char *pos);
int64_t bLPtr2IdxUTF8(const char *utf8, size_t utf8Size, const char *pos);
@@ -524,8 +526,8 @@ uint8_t runeLenUTF8(rune r);
internal size_t decompose_hangul(rune s, rune *r);
internal const char *find_decomposition (rune ch);
internal size_t runeFullyDecompose(rune ch, rune *result, size_t resultLen);
-internal int output_marks(const char **p_inout, char *dst, bool remove_dot);
-internal int output_special_case(char *dst, int offset, int type, int which);
+internal size_t output_marks(const char **p_inout, char *dst, bool remove_dot);
+internal size_t output_special_case(char *dst, int offset, int type, int which);
rune toupperUTF8(rune c);
internal size_t _upperUTF8(char *dst, const char *utf8, localeType lcl);
char *upperUTF8(const char *utf8);
@@ -589,6 +591,7 @@ bool listIsEmptyS(char **list);
bool listIsBlankS(char **list);
char **listCreateSF(const char *paramType, ...);
char **listFromArrayS(char **array, size_t size);
+char **listFromCArrayS(const char **array, size_t size);
char **listPushS(char ***list, const char *s);
char **listPushCharS(char ***list, char c);
char **iListPushS(char ***list, char *s);
@@ -600,22 +603,29 @@ char *listDequeueS(char ***list);
void listFreeS(char **list);
void listFreeManySF(char **paramType, ...);
size_t listLengthS(char **list);
+size_t listLengthCS(const char **list);
ssize_t listStrLengthS(char **list);
ssize_t listIntIndexS(char **list, int64_t index);
char **listAddrS(char **list, int64_t index);
char *listGetS(char **list, int64_t index);
char *iListGetS(char **list, int64_t index);
+char *listGetCS(const char **list, int64_t index);
+const char *iListGetCS(const char **list, int64_t index);
char **listSetS(char **list, int64_t index, const char *s);
char **listSetCharS(char **list, int64_t index, char c);
char **iListSetS(char **list, int64_t index, char *s);
char **listSwapS(char **list, int64_t index1, int64_t index2);
char **iListSwapS(char **list, int64_t index1, int64_t index2);
char **split(const char *string, const char* delim);
+char **splitS(const char *string, const char* delim);
char **splitChar(const char *string, char delim);
char **icSplit(const char *string, const char* delim);
+char **icSplitS(const char *string, const char* delim);
char **icSplitChar(const char *string, char delim);
ssize_t joinLength(char **list, const char* delim);
char *join(char **list, const char* delim);
+char *joinS(char **list, const char* delim);
+char *joinCS(const char **list, const char* delim);
char *joinChar(char **list, char delim);
char *bJoin(char *string, char **list, const char* delim);
char *bJoinChar(char *string, char **list, char delim);
@@ -630,6 +640,7 @@ char **icExtractCharSS(const char *string, char delim1, const char* delim2);
char **icExtractSCharS(const char *string, const char* delim1, char delim2);
char **icExtractCharCharS(const char *string, char delim1, char delim2);
char **listDupS(char **list);
+char **listDupCS(const char **list);
char **iListDupS(char **list);
char **listReverseS(char **list);
char **iListReverseS(char ***list);
@@ -641,6 +652,7 @@ char **listShiftS(char ***list1, char **list2);
char **iListShiftS(char ***list1, char **list2);
char **iListShiftNSmashS(char ***list1, char **list2);
char **listAddS(char **list1, char **list2);
+char **listAddCS(char **list1, const char **list2);
char **listSliceS(char **list, int64_t start, int64_t end);
char **iListCopyS(char **list, int64_t start, int64_t end);
char **iListSliceS(char ***list, int64_t start, int64_t end);
@@ -662,6 +674,7 @@ char **listDelElemS(char **list, int64_t index);
char **iListDelElemS(char ***list, int64_t index);
char **iListRemoveElemS(char ***list, int64_t index);
int listPrintS(char **list);
+int listPrintCS(const char **list);
internal int listSortSCmp(const void * a, const void * b);
char **listSortS(char **list);
char **iListSortS(char ***list);
@@ -673,8 +686,11 @@ char **iicListSortS(char ***list);
char **readText(const char *filePath);
char **readStream(FILE *fp);
bool writeText(const char *filePath, char **list);
+bool writeCText(const char *filePath, const char **list);
bool writeStream(FILE *fp, char **list);
+bool writeCStream(FILE *fp, const char **list);
bool appendText(const char *filePath, char **list);
+bool appendCText(const char *filePath, const char **list);
char **execOut(const char *cmd);
char **systemOutf(const char *fmt, ...);
int systemf(const char *fmt, ...);
@@ -682,19 +698,33 @@ int commandF(const char *cmd, int line, const char *thisFunc, const char *thisFi
int commandfF(int line, const char *thisFunc, const char *thisFileName, const char *fmt, ...);
int commandNFreeF(char *cmd, int line, const char *thisFunc, const char *thisFileName);
bool listEqS(char **list1, char **list2);
+bool listEqCS(char **list1, const char **list2);
+bool listEqC1S(const char **list1, char **list2);
+bool listEqCCS(const char **list1, const char **list2);
bool listHasS(char **list, const char *string);
+bool listHasCS(const char **list, const char *string);
bool listHasCharS(char **list, char c);
+bool listHasCharCS(const char **list, char c);
ssize_t listIndexOfS(char **list, const char *string);
+ssize_t listIndexOfCS(const char **list, const char *string);
ssize_t listIndexOfCharS(char **list, char c);
+ssize_t listIndexOfCharCS(const char **list, char c);
ssize_t listBinarySearchS(char **list, const char *string);
ssize_t listBinarySearchCharS(char **list, char c);
char **listUniqS(char **list);
char **iListUniqS(char ***list);
bool icListEqS(char **list1, char **list2);
+bool icListEqCS(char **list1, const char **list2);
+bool icListEqC1S(const char **list1, char **list2);
+bool icListEqCCS(const char **list1, const char **list2);
bool icListHasS(char **list, const char *string);
bool icListHasCharS(char **list, char c);
+bool icListHasCS(const char **list, const char *string);
+bool icListHasCharCS(const char **list, char c);
ssize_t icListIndexOfS(char **list, const char *string);
+ssize_t icListIndexOfCS(const char **list, const char *string);
ssize_t icListIndexOfCharS(char **list, char c);
+ssize_t icListIndexOfCharCS(const char **list, char c);
ssize_t icListBinarySearchS(char **list, const char *string);
ssize_t icListBinarySearchCharS(char **list, char c);
char **icListUniqS(char **list);
@@ -997,7 +1027,7 @@ FILE *setLogFile(char *filename) {
return(NULL);
}
- if (_current_log_file+1 > 16) {
+ if (_current_log_file >= 16) {
// we only support 16 different files
return(NULL);
}
@@ -1104,12 +1134,12 @@ void setLogStdout(bool state) {
*/
bool openProgLogFile(void) {
- if (!progName) {
+ if (!progName && !defaultProgName) {
logME(libsheepyErrorMask, "Program name is not set, call initLibsheepy or set prog name with setProgName");
return(false);
}
- char *s = formatS("%s.log", progName);;
+ char *s = formatS("%s.log", progName ? progName : defaultProgName);;
if (!setLogFile(s)) {
logME(libsheepyErrorMask, "Couldn't open log file: %s", s);
@@ -1207,6 +1237,7 @@ void _pLog(int loglevel, const char *file, const char *func, int line, const cha
printf(BLD CYN);
break;
case LOG_INVALID:
+ default:
printf(MGT);
break;
}
@@ -1245,12 +1276,7 @@ void _pLog(int loglevel, const char *file, const char *func, int line, const cha
}
}
- int tagSymbols = logSymbols;;
- switch(logSymbols) {
- case LOG_INVALID_MODE:
- tagSymbols = _log_current_mode;;
- break;
- }
+ int tagSymbols = logSymbols != LOG_INVALID_MODE ? logSymbols : _log_current_mode;
// print the log tag
int firstLogFile = _logToStdout ? 0 : 1;
@@ -1279,12 +1305,12 @@ void _pLog(int loglevel, const char *file, const char *func, int line, const cha
break;
case LOG_PROG:
for (i=firstLogFile; i < _current_log_file; i++) {
- fprintf(_logging_files[i], "%s: ", progName);
+ fprintf(_logging_files[i], "%s: ", progName ? progName : defaultProgName);
}
break;
case LOG_PROGNDATE:
for (i=firstLogFile; i < _current_log_file; i++) {
- fprintf(_logging_files[i], "%s %s: ", progName, clock);
+ fprintf(_logging_files[i], "%s %s: ", progName ? progName : defaultProgName, clock);
}
break;
case LOG_DATE:
@@ -1292,6 +1318,8 @@ void _pLog(int loglevel, const char *file, const char *func, int line, const cha
fprintf(_logging_files[i], "%s ", clock);
}
break;
+ default:;
+ // don't print anything
}
@@ -1318,7 +1346,7 @@ void _pLog(int loglevel, const char *file, const char *func, int line, const cha
}
}
- rangeFrom(i, 1, _current_log_file) {
+ for(i = 1; i <_current_log_file; i++) {;
// write log files immediately
fflush(_logging_files[i]);
}
@@ -1348,10 +1376,10 @@ void _pLog(int loglevel, const char *file, const char *func, int line, const cha
int print_k(FILE *stream, const struct printf_info *info, const void *const *args) {
u32 rgbColor;
char b[20];
- size_t len;
+ int len;
- rgbColor = *((u32*) args[0]);
- snprintf(b, sizeof(b), TERMRGB "%d;%d;%dm", rgbColor>>16, (rgbColor&0xFF00)>>8, rgbColor&0xFF);
+ rgbColor = *((const u32*) args[0]);
+ snprintf(b, sizeof(b), TERMRGB "%u;%u;%um", rgbColor>>16, (rgbColor&0xFF00)>>8, rgbColor&0xFF);
/* Pad to the minimum field width and print to the stream. */
//len = fprintf(stream, "%*s", (info->left ? -info->width : info->width), b)
@@ -1366,10 +1394,10 @@ int print_k(FILE *stream, const struct printf_info *info, const void *const *arg
int print_K(FILE *stream, const struct printf_info *info, const void *const *args) {
u32 rgbColor;
char b[20];
- size_t len;
+ int len;
- rgbColor = *((u32*) args[0]);
- snprintf(b, sizeof(b), BGTERMRGB "%d;%d;%dm", rgbColor>>16, (rgbColor&0xFF00)>>8, rgbColor&0xFF);
+ rgbColor = *((const u32*) args[0]);
+ snprintf(b, sizeof(b), BGTERMRGB "%u;%u;%um", rgbColor>>16, (rgbColor&0xFF00)>>8, rgbColor&0xFF);
/* Pad to the minimum field width and print to the stream. */
//len = fprintf(stream, "%*s", (info->left ? -info->width : info->width), b)
@@ -1394,9 +1422,9 @@ int print_k_arginfo(const struct printf_info *info UNUSED, size_t n, int *argtyp
*/
int print_b(FILE *stream, const struct printf_info *info, const void *const *args) {
bool value;
- size_t len;
+ int len;
- value = *((bool*) args[0]);
+ value = *((const bool*) args[0]);
/* Pad to the minimum field width and print to the stream. */
//len = fprintf(stream, "%*s", (info->left ? -info->width : info->width), boolS(value))
@@ -1452,18 +1480,17 @@ void initLibsheepyF(const char *progPath, initLibsheepyObjectP initF) {
libSheepyProgPath += sizeof(sheepyBuild)-1;
}
- // set progName as basename progPath
- // progName is the string after the last /
- rangeDown(i, strlen(libSheepyProgPath)) {
+ // set defaultProgName as basename progPath
+ // defaultProgName is the string after the last /
+ rangeDown(i, (ssize_t)strlen(libSheepyProgPath)) {
if (libSheepyProgPath[i] == '/') {
- progName = (char*)(libSheepyProgPath + i + 1);
+ defaultProgName = libSheepyProgPath + i + 1;
break;
}
}
- if (!progName) {
- progName = (char*)libSheepyProgPath;
+ if (!defaultProgName) {
+ defaultProgName = libSheepyProgPath;
}
- defaultProgName = progName;
// segfault signal
struct sigaction sa;
@@ -1513,18 +1540,17 @@ void initLibsheepyF(const char *progPath, initLibsheepyObjectP initF) {
libSheepyProgPath += sizeof(sheepyBuild)-1;
}
- // set progName as basename progPath
- // progName is the string after the last /
- rangeDown(i, strlen(libSheepyProgPath)) {
+ // set defaultProgName as basename progPath
+ // defaultProgName is the string after the last /
+ rangeDown(i, (ssize_t)strlen(libSheepyProgPath)) {
if (libSheepyProgPath[i] == '/') {
- progName = (char*)(libSheepyProgPath + i + 1);
+ defaultProgName = (libSheepyProgPath + i + 1);
break;
}
}
- if (!progName) {
- progName = (char*)libSheepyProgPath;
+ if (!defaultProgName) {
+ defaultProgName = libSheepyProgPath;
}
- defaultProgName = progName;
// segfault signal
struct sigaction sa;
@@ -1570,7 +1596,7 @@ void initLibsheepyF(const char *progPath, initLibsheepyObjectP initF) {
*/
void finalizeLibsheepyCharAtExit(void) {
- freeProgName();
+ free(progName);
freeRealProgPath();
randomUrandomClose();
}
@@ -1590,7 +1616,7 @@ int64_t getStackLimit(void) {
pFuncError
return(0);
}
- return(limit.rlim_cur);
+ return(limit.rlim_cur != RLIM_INFINITY ? (i64) limit.rlim_cur : -1);;
}
/**
@@ -1614,7 +1640,7 @@ int setStackLimit(int64_t stackSize) {
limit.rlim_cur = RLIM_INFINITY;
}
else {
- limit.rlim_cur = stackSize;
+ limit.rlim_cur = (u64)stackSize;
}
if (setrlimit(RLIMIT_STACK, &limit) == -1) {
@@ -1633,7 +1659,7 @@ int setStackLimit(int64_t stackSize) {
*/
const char *getProgName(void) {
- return(progName);
+ return(progName ? progName : defaultProgName);
}
/**
@@ -1648,7 +1674,7 @@ bool setProgName(const char *name) {
return(false);
}
- freeProgName();
+ free(progName);
progName = strdup(name);
return(true);
@@ -1661,12 +1687,8 @@ bool setProgName(const char *name) {
*/
void setDefaultProgName(void) {
- if (defaultProgName != progName) {
- // progName has been set by the user with setProgName, free it
- free(progName);
- progName = (char*)defaultProgName;
+ freen(progName);
}
- }
/**
* free ProgName
@@ -1674,11 +1696,8 @@ void setDefaultProgName(void) {
*/
void freeProgName(void) {
- if (defaultProgName != progName) {
- // progName has been set by the user with setProgName, free it
- freen(progName);
+ freen(progName);
}
- }
/**
* get program path
@@ -2156,7 +2175,7 @@ char *bDirname(char *path) {
if (isBlankS(path) || !strchr(path, '/')) {
// the path is blank or a filename
// set dir to pwd when dirname is empty
- strCpy(path, "./");
+ strcpy(path, "./");
return(path);
}
@@ -2278,13 +2297,13 @@ char *expandHome(const char* path) {
if (!slash) {
// no slash found, path is in the form: ~USER
// copy string after ~ to the end of the string
- strLCpy(user, sizeof(user)-1, path+1);
+ pErrorNULL(strLCpy(user, sizeof(user)-1, path+1));
pathStart = strlen(path);
}
else {
// copy string after ~ to first slash
pathStart = slash - path;
- strLNCat(user, sizeof(user)-1, path+1, pathStart-1);
+ pErrorNULL(strLNCat(user, sizeof(user)-1, path+1, pathStart-1));
}
}
@@ -2468,13 +2487,13 @@ char *iExpandHome(char **path) {
if (!slash) {
// no slash found, path is in the form: ~USER
// copy string after ~ to the end of the string
- strLCpy(user, sizeof(user)-1, (*path)+1);
+ pErrorNULL(strLCpy(user, sizeof(user)-1, (*path)+1));
pathStart = strlen(*path);
}
else {
// copy string after ~ to first slash
pathStart = slash - (*path);
- strLNCat(user, sizeof(user)-1, (*path)+1, pathStart-1);
+ pErrorNULL(strLNCat(user, sizeof(user)-1, (*path)+1, pathStart-1));
}
}
@@ -2652,13 +2671,13 @@ char *bExpandHome(char *path) {
if (!slash) {
// no slash found, path is in the form: ~USER
// copy string after ~ to the end of the string
- strLCpy(user, sizeof(user)-1, path+1);
+ pErrorNULL(strLCpy(user, sizeof(user)-1, path+1));
pathStart = strlen(path);
}
else {
// copy string after ~ to first slash
pathStart = slash - path;
- strLNCat(user, sizeof(user)-1, path+1, pathStart-1);
+ pErrorNULL(strLNCat(user, sizeof(user)-1, path+1, pathStart-1));
}
}
@@ -2829,7 +2848,7 @@ char *bLExpandHome(char *path, size_t pathSize) {
if (!slash) {
// no slash found, path is in the form: ~USER
// copy string after ~ to the end of the string
- strLCpy(user, sizeof(user)-1, path+1);
+ pErrorNULL(strLCpy(user, sizeof(user)-1, path+1));
pathStart = strlen(path);
}
else {
@@ -2876,7 +2895,7 @@ char *bLExpandHome(char *path, size_t pathSize) {
// append rest of the path to the result
iAppendS(&r, path + pathStart);
- strLCpy(path, pathSize, r);
+ pErrorNULL(strLCpy(path, pathSize, r));
free(r);
return(path);
}
@@ -2927,7 +2946,7 @@ char *bLExpandHome(char *path, size_t pathSize) {
default:
break;
}
- strLCpy(path, pathSize, exp_result.we_wordv[0]);
+ pErrorNULL(strLCpy(path, pathSize, exp_result.we_wordv[0]));
wordfree(&exp_result);
#else
bLReplaceS(path, pathSize, "~", "/data/data/com.termux/files/home", 1);
@@ -2967,7 +2986,7 @@ char *normalizePath(const char *path) {
char **pathL = split(path, "/");
// remove empty elements
- iListCompactS(&pathL);
+ pErrorNULL(iListCompactS(&pathL));
if (listIsEmptyS(pathL)) {
listFreeS(pathL);
@@ -2986,7 +3005,7 @@ char *normalizePath(const char *path) {
if (strEq(*level, "..")) {
if (onlyLeadingDoubleDots) {
// keep leading ..
- listPushS(&list, "..");
+ pErrorNULL(listPushS(&list, ".."));
}
else {
// remove .. in path
@@ -2996,7 +3015,7 @@ char *normalizePath(const char *path) {
}
else if (!strEq(*level, ".")) {
// remove . and add elements
- listPushS(&list, *level);
+ pErrorNULL(listPushS(&list, *level));
// an element is pushed, so this is the end of leading double dots
onlyLeadingDoubleDots = false;
}
@@ -3009,7 +3028,7 @@ char *normalizePath(const char *path) {
// handle /.: add empty string
if (strEq(path, "/.")) {
- listPushS(&list, "");
+ pErrorNULL(listPushS(&list, ""));
}
// keep leading /
@@ -3019,7 +3038,7 @@ char *normalizePath(const char *path) {
listFreeManyS(pathL, list);
return(strdup("/"));
}
- listPrependS(&list, "");
+ pErrorNULL(listPrependS(&list, ""));
}
// create new path
@@ -3058,7 +3077,7 @@ char *iNormalizePath(char **path) {
}
if (isEmptyS(*path)) {
- iEmptySF(path);
+ pErrorNULL(iEmptySF(path));
return(*path);
}
@@ -3066,7 +3085,7 @@ char *iNormalizePath(char **path) {
char **pathL = split(*path, "/");
// remove empty elements
- iListCompactS(&pathL);
+ pErrorNULL(iListCompactS(&pathL));
if (listIsEmptyS(pathL)) {
listFreeS(pathL);
@@ -3087,7 +3106,7 @@ char *iNormalizePath(char **path) {
if (strEq(*level, "..")) {
if (onlyLeadingDoubleDots) {
// keep leading ..
- listPushS(&list, "..");
+ pErrorNULL(listPushS(&list, ".."));
}
else {
// remove .. in path
@@ -3097,7 +3116,7 @@ char *iNormalizePath(char **path) {
}
else if (!strEq(*level, ".")) {
// remove . and add elements
- listPushS(&list, *level);
+ pErrorNULL(listPushS(&list, *level));
// an element is pushed, so this is the end of leading double dots
onlyLeadingDoubleDots = false;
}
@@ -3110,7 +3129,7 @@ char *iNormalizePath(char **path) {
// handle /.: add empty string
if (strEq(*path, "/.")) {
- listPushS(&list, "");
+ pErrorNULL(listPushS(&list, ""));
}
// keep leading /
@@ -3122,7 +3141,7 @@ char *iNormalizePath(char **path) {
*path = strdup("/");
return(*path);
}
- listPrependS(&list, "");
+ pErrorNULL(listPrependS(&list, ""));
}
// create new path
@@ -3171,7 +3190,7 @@ char *bNormalizePath(char *path) {
char **pathL = split(path, "/");
// remove empty elements
- iListCompactS(&pathL);
+ pErrorNULL(iListCompactS(&pathL));
if (listIsEmptyS(pathL)) {
listFreeS(pathL);
@@ -3191,7 +3210,7 @@ char *bNormalizePath(char *path) {
if (strEq(*level, "..")) {
if (onlyLeadingDoubleDots) {
// keep leading ..
- listPushS(&list, "..");
+ pErrorNULL(listPushS(&list, ".."));
}
else {
// remove .. in path
@@ -3201,7 +3220,7 @@ char *bNormalizePath(char *path) {
}
else if (!strEq(*level, ".")) {
// remove . and add elements
- listPushS(&list, *level);
+ pErrorNULL(listPushS(&list, *level));
// an element is pushed, so this is the end of leading double dots
onlyLeadingDoubleDots = false;
}
@@ -3214,7 +3233,7 @@ char *bNormalizePath(char *path) {
// handle /.: add empty string
if (strEq(path, "/.")) {
- listPushS(&list, "");
+ pErrorNULL(listPushS(&list, ""));
}
// keep leading /
@@ -3225,7 +3244,7 @@ char *bNormalizePath(char *path) {
strcpy(path, "/");
return(path);
}
- listPrependS(&list, "");
+ pErrorNULL(listPrependS(&list, ""));
}
// create new path
@@ -3282,7 +3301,7 @@ char *bLNormalizePath(char *path, size_t pathSize) {
char **pathL = split(path, "/");
// remove empty elements
- iListCompactS(&pathL);
+ pErrorNULL(iListCompactS(&pathL));
if (listIsEmptyS(pathL)) {
listFreeS(pathL);
@@ -3302,7 +3321,7 @@ char *bLNormalizePath(char *path, size_t pathSize) {
if (strEq(*level, "..")) {
if (onlyLeadingDoubleDots) {
// keep leading ..
- listPushS(&list, "..");
+ pErrorNULL(listPushS(&list, ".."));
}
else {
// remove .. in path
@@ -3312,7 +3331,7 @@ char *bLNormalizePath(char *path, size_t pathSize) {
}
else if (!strEq(*level, ".")) {
// remove . and add elements
- listPushS(&list, *level);
+ pErrorNULL(listPushS(&list, *level));
// an element is pushed, so this is the end of leading double dots
onlyLeadingDoubleDots = false;
}
@@ -3325,7 +3344,7 @@ char *bLNormalizePath(char *path, size_t pathSize) {
// handle /.: add empty string
if (strEq(path, "/.")) {
- listPushS(&list, "");
+ pErrorNULL(listPushS(&list, ""));
}
// keep leading /
@@ -3336,7 +3355,7 @@ char *bLNormalizePath(char *path, size_t pathSize) {
strcpy(path, "/");
return(path);
}
- listPrependS(&list, "");
+ pErrorNULL(listPrependS(&list, ""));
}
// create new path
@@ -3348,7 +3367,7 @@ char *bLNormalizePath(char *path, size_t pathSize) {
bEmptyS(path);
return(path);
}
- strLCpy(path, pathSize, r);
+ pErrorNULL(strLCpy(path, pathSize, r));
free(r);
return(path);
}
@@ -3392,7 +3411,7 @@ char *relPath(const char *path, const char *start) {
// normalize path and start
char *npath = expandHome(path);
- iNormalizePath(&npath);
+ pErrorNULL(iNormalizePath(&npath));
char *nstart;
char *cwd = getCwd();
@@ -3404,7 +3423,7 @@ char *relPath(const char *path, const char *start) {
else {
// use start in argument
nstart = expandHome(start);;
- iNormalizePath(&nstart);
+ pErrorNULL(iNormalizePath(&nstart));
}
// when path and start are equal, return "."
@@ -3416,29 +3435,29 @@ char *relPath(const char *path, const char *start) {
// if path is relative path and start is absolute path
// then path is relative to nstart
if (npath[0] != '/' and nstart[0] == '/') {
- iPrependS(&npath, "/");
- iPrependS(&npath, nstart);
- iNormalizePath(&npath);
+ pErrorNULL(iPrependS(&npath, "/"));
+ pErrorNULL(iPrependS(&npath, nstart));
+ pErrorNULL(iNormalizePath(&npath));
}
// if path is absolute path and start is relative path
// then start is relative to cwd
if (npath[0] == '/' and nstart[0] != '/') {
- iPrependS(&nstart, "/");
- iPrependS(&nstart, cwd);
- iNormalizePath(&nstart);
+ pErrorNULL(iPrependS(&nstart, "/"));
+ pErrorNULL(iPrependS(&nstart, cwd));
+ pErrorNULL(iNormalizePath(&nstart));
}
// when path starts with nstart, slice path to only keep the string
// after the end of nstart
if (startsWithS(npath, nstart)) {
if (npath[strlen(nstart)] == '/') {
- r = sliceS(npath, strlen(nstart)+1, 0);
+ r = sliceS(npath, (i64)strlen(nstart)+1, 0);
goto end;
}
// handle case when nstart is "/" after normalize
if (npath[strlen(nstart)-1] == '/') {
- r = sliceS(npath, strlen(nstart), 0);
+ r = sliceS(npath, (i64)strlen(nstart), 0);
goto end;
}
// fallthrough: npath starts with nstart but is a different path
@@ -3471,7 +3490,7 @@ char *relPath(const char *path, const char *start) {
// go up directories to last common directory between npath and nstart
r = repeatS("../", slash);;
- iAppendS(&r, npath+from);
+ pErrorNULL(iAppendS(&r, npath+from));
end:
free(npath);
@@ -3519,7 +3538,7 @@ char *iRelPath(char **path, const char *start) {
// normalize path and start
char *npath = expandHome(*path);
- iNormalizePath(&npath);
+ pErrorNULL(iNormalizePath(&npath));
char *nstart;
char *cwd = getCwd();
@@ -3531,7 +3550,7 @@ char *iRelPath(char **path, const char *start) {
else {
// use start in argument
nstart = expandHome(start);;
- iNormalizePath(&nstart);
+ pErrorNULL(iNormalizePath(&nstart));
}
// when path and start are equal, return "."
@@ -3543,29 +3562,29 @@ char *iRelPath(char **path, const char *start) {
// if path is relative path and start is absolute path
// then path is relative to nstart
if (npath[0] != '/' and nstart[0] == '/') {
- iPrependS(&npath, "/");
- iPrependS(&npath, nstart);
- iNormalizePath(&npath);
+ pErrorNULL(iPrependS(&npath, "/"));
+ pErrorNULL(iPrependS(&npath, nstart));
+ pErrorNULL(iNormalizePath(&npath));
}
// if path is absolute path and start is relative path
// then start is relative to cwd
if (npath[0] == '/' and nstart[0] != '/') {
- iPrependS(&nstart, "/");
- iPrependS(&nstart, cwd);
- iNormalizePath(&nstart);
+ pErrorNULL(iPrependS(&nstart, "/"));
+ pErrorNULL(iPrependS(&nstart, cwd));
+ pErrorNULL(iNormalizePath(&nstart));
}
// when path starts with nstart, slice path to only keep the string
// after the end of nstart
if (startsWithS(npath, nstart)) {
if (npath[strlen(nstart)] == '/') {
- r = sliceS(npath, strlen(nstart)+1, 0);
+ r = sliceS(npath, (i64)strlen(nstart)+1, 0);
goto end;
}
// handle case when nstart is "/" after normalize
if (npath[strlen(nstart)-1] == '/') {
- r = sliceS(npath, strlen(nstart), 0);
+ r = sliceS(npath, (i64)strlen(nstart), 0);
goto end;
}
// fallthrough: npath starts with nstart but is a different path
@@ -3599,7 +3618,7 @@ char *iRelPath(char **path, const char *start) {
// go up directories to last common directory between npath and nstart
r = repeatS("../", slash);;
- iAppendS(&r, npath+from);
+ pErrorNULL(iAppendS(&r, npath+from));
end:
free(npath);
@@ -3650,7 +3669,7 @@ char *bRelPath(char *dest, const char *path, const char *start) {
// normalize path and start
char *npath = expandHome(path);
- iNormalizePath(&npath);
+ pErrorNULL(iNormalizePath(&npath));
char *nstart;
char *cwd = getCwd();
@@ -3662,7 +3681,7 @@ char *bRelPath(char *dest, const char *path, const char *start) {
else {
// use start in argument
nstart = expandHome(start);;
- iNormalizePath(&nstart);
+ pErrorNULL(iNormalizePath(&nstart));
}
// when path and start are equal, return "."
@@ -3674,29 +3693,29 @@ char *bRelPath(char *dest, const char *path, const char *start) {
// if path is relative path and start is absolute path
// then path is relative to nstart
if (npath[0] != '/' and nstart[0] == '/') {
- iPrependS(&npath, "/");
- iPrependS(&npath, nstart);
- iNormalizePath(&npath);
+ pErrorNULL(iPrependS(&npath, "/"));
+ pErrorNULL(iPrependS(&npath, nstart));
+ pErrorNULL(iNormalizePath(&npath));
}
// if path is absolute path and start is relative path
// then start is relative to cwd
if (npath[0] == '/' and nstart[0] != '/') {
- iPrependS(&nstart, "/");
- iPrependS(&nstart, cwd);
- iNormalizePath(&nstart);
+ pErrorNULL(iPrependS(&nstart, "/"));
+ pErrorNULL(iPrependS(&nstart, cwd));
+ pErrorNULL(iNormalizePath(&nstart));
}
// when path starts with nstart, slice path to only keep the string
// after the end of nstart
if (startsWithS(npath, nstart)) {
if (npath[strlen(nstart)] == '/') {
- r = sliceS(npath, strlen(nstart)+1, 0);
+ r = sliceS(npath, (i64)strlen(nstart)+1, 0);
goto end;
}
// handle case when nstart is "/" after normalize
if (npath[strlen(nstart)-1] == '/') {
- r = sliceS(npath, strlen(nstart), 0);
+ r = sliceS(npath, (i64)strlen(nstart), 0);
goto end;
}
// fallthrough: npath starts with nstart but is a different path
@@ -3729,7 +3748,7 @@ char *bRelPath(char *dest, const char *path, const char *start) {
// go up directories to last common directory between npath and nstart
r = repeatS("../", slash);;
- iAppendS(&r, npath+from);
+ pErrorNULL(iAppendS(&r, npath+from));
end:
free(npath);
@@ -3780,7 +3799,7 @@ char *bLRelPath(char *dest, size_t destSize, char *path, const char *start) {
// normalize path and start
char *npath = expandHome(path);
- iNormalizePath(&npath);
+ pErrorNULL(iNormalizePath(&npath));
char *nstart;
char *cwd = getCwd();
@@ -3792,7 +3811,7 @@ char *bLRelPath(char *dest, size_t destSize, char *path, const char *start) {
else {
// use start in argument
nstart = expandHome(start);;
- iNormalizePath(&nstart);
+ pErrorNULL(iNormalizePath(&nstart));
}
// when path and start are equal, return "."
@@ -3804,29 +3823,29 @@ char *bLRelPath(char *dest, size_t destSize, char *path, const char *start) {
// if path is relative path and start is absolute path
// then path is relative to nstart
if (npath[0] != '/' and nstart[0] == '/') {
- iPrependS(&npath, "/");
- iPrependS(&npath, nstart);
- iNormalizePath(&npath);
+ pErrorNULL(iPrependS(&npath, "/"));
+ pErrorNULL(iPrependS(&npath, nstart));
+ pErrorNULL(iNormalizePath(&npath));
}
// if path is absolute path and start is relative path
// then start is relative to cwd
if (npath[0] == '/' and nstart[0] != '/') {
- iPrependS(&nstart, "/");
- iPrependS(&nstart, cwd);
- iNormalizePath(&nstart);
+ pErrorNULL(iPrependS(&nstart, "/"));
+ pErrorNULL(iPrependS(&nstart, cwd));
+ pErrorNULL(iNormalizePath(&nstart));
}
// when path starts with nstart, slice path to only keep the string
// after the end of nstart
if (startsWithS(npath, nstart)) {
if (npath[strlen(nstart)] == '/') {
- r = sliceS(npath, strlen(nstart)+1, 0);
+ r = sliceS(npath, (i64)strlen(nstart)+1, 0);
goto end;
}
// handle case when nstart is "/" after normalize
if (npath[strlen(nstart)-1] == '/') {
- r = sliceS(npath, strlen(nstart), 0);
+ r = sliceS(npath, (i64)strlen(nstart), 0);
goto end;
}
// fallthrough: npath starts with nstart but is a different path
@@ -3858,14 +3877,14 @@ char *bLRelPath(char *dest, size_t destSize, char *path, const char *start) {
// go up directories to last common directory between npath and nstart
r = repeatS("../", slash);;
- iAppendS(&r, npath+from);
+ pErrorNULL(iAppendS(&r, npath+from));
end:
free(npath);
free(nstart);
free(cwd);
- strLCpy(dest, destSize, r);
+ pErrorNULL(strLCpy(dest, destSize, r));
free(r);
return(dest);
}
@@ -3924,7 +3943,7 @@ char *bLGetHomePath(char *path, size_t pathSize) {
if (strlen(pw->pw_dir)+1 > pathSize) {
return(NULL);
}
- strLCpy(path, pathSize, pw->pw_dir);
+ pErrorNULL(strLCpy(path, pathSize, pw->pw_dir));
return(path);
}
@@ -4072,7 +4091,7 @@ char *shReadlink(const char *path) {
bufSize = PATH_MAX;
}
else {
- bufSize = st.st_size + 1;
+ bufSize = (size_t)st.st_size + 1;
}
linked = MALLOC(bufSize);
@@ -4136,10 +4155,10 @@ char *endlink(const char *path) {
bufSize = PATH_MAX;
}
else {
- bufSize = st.st_size + 1;
+ bufSize = (size_t)st.st_size + 1;
}
- strLCpy(from, sizeof from, path);
+ pErrorNULL(strLCpy(from, sizeof from, path));
while (S_ISLNK(st.st_mode)) {
r = readlink(from, to, bufSize);
@@ -4153,9 +4172,9 @@ char *endlink(const char *path) {
to[r] = 0;
if (to[0] != '/') {
- bDirname(from);
- bLAppendManyS(from, PATH_MAX, "/", to);
- bNormalizePath(from);
+ pErrorNULL(bDirname(from));
+ pErrorNULL(bLAppendManyS(from, PATH_MAX, "/", to));
+ pErrorNULL(bNormalizePath(from));
}
else {
// copy absolute path
@@ -4171,7 +4190,7 @@ char *endlink(const char *path) {
bufSize = PATH_MAX;
}
else {
- bufSize = st.st_size + 1;
+ bufSize = (size_t)st.st_size + 1;
}
}
@@ -4339,7 +4358,7 @@ void *readFileToS(const char *filePath) {
}
// +1 to add \0 at the end
- r = MALLOC(len+1);
+ r = MALLOC((size_t)len+1);
if (!r) {
return(NULL);
}
@@ -4351,7 +4370,7 @@ void *readFileToS(const char *filePath) {
shEPrintfS("The path was: \"%s\"\n", filePath);
return(NULL);
}
- readStatus = fread(r, 1, len , f);
+ readStatus = fread(r, 1, (size_t)len , f);
fclose(f);
if (readStatus != (size_t)len) {
@@ -4393,12 +4412,12 @@ void *readStreamToS(FILE *fp) {
}
// +1 to add \0 at the end
- r = MALLOC(len+1);
+ r = MALLOC((size_t)len+1);
if (!r) {
return(NULL);
}
- readStatus = fread(r, 1, len , fp);
+ readStatus = fread(r, 1, (size_t)len , fp);
if (readStatus != (size_t)len) {
free(r);
@@ -4447,7 +4466,7 @@ void *bReadFileToS(const char *filePath, void *dst) {
return(NULL);
}
- readStatus = fread(dst, 1, len , f);
+ readStatus = fread(dst, 1, (size_t)len , f);
fclose(f);
if (readStatus != (size_t)len) {
@@ -4488,7 +4507,7 @@ void *bReadStreamToS(FILE *fp, void *dst) {
return(NULL);
}
- readStatus = fread(dst, 1, len , fp);
+ readStatus = fread(dst, 1, (size_t)len , fp);
if (readStatus != (size_t)len) {
pFuncError
@@ -4537,7 +4556,7 @@ void *bLReadFileToS(const char *filePath, void *dst, size_t dstSize) {
}
// truncate if necessary
- len = ((size_t)len < dstSize) ? (size_t)len : dstSize-1;
+ len = ((size_t)len < dstSize) ? len : (ssize_t)dstSize-1;
f = fopen(filePath, "r");
if (!f) {
@@ -4546,7 +4565,7 @@ void *bLReadFileToS(const char *filePath, void *dst, size_t dstSize) {
return(NULL);
}
- readStatus = fread(dst, 1, len , f);
+ readStatus = fread(dst, 1, (size_t)len , f);
fclose(f);
if (readStatus != (size_t)len) {
@@ -4593,9 +4612,9 @@ void *bLReadStreamToS(FILE *fp, void *dst, size_t dstSize) {
}
// truncate if necessary
- len = ((size_t)len < dstSize) ? (size_t)len : dstSize-1;
+ len = ((size_t)len < dstSize) ? len : (ssize_t)dstSize-1;
- readStatus = fread(dst, 1, len , fp);
+ readStatus = fread(dst, 1, (size_t)len , fp);
if (readStatus != (size_t)len) {
pFuncError
@@ -4637,7 +4656,7 @@ ssize_t readFile(const char *filePath, void **buffer) {
}
// +1 to add \0 at the end
- *buffer = MALLOC(len);
+ *buffer = MALLOC((size_t)len);
if (!*buffer) {
return(-1);
}
@@ -4649,7 +4668,7 @@ ssize_t readFile(const char *filePath, void **buffer) {
shEPrintfS("The path was: \"%s\"\n", filePath);
return(-1);
}
- readStatus = fread(*buffer, 1, len , f);
+ readStatus = fread(*buffer, 1, (size_t)len , f);
fclose(f);
if (readStatus != (size_t)len) {
@@ -4698,7 +4717,7 @@ ssize_t bReadFile(const char *filePath, void *buffer) {
shEPrintfS("The path was: \"%s\"\n", filePath);
return(-1);
}
- readStatus = fread(buffer, 1, len , f);
+ readStatus = fread(buffer, 1, (size_t)len , f);
fclose(f);
if (readStatus != (size_t)len) {
@@ -4747,7 +4766,7 @@ ssize_t bLReadFile(const char *filePath, void *buffer, size_t dstSize) {
}
// truncate if necessary
- len = ((size_t)len < dstSize) ? (size_t)len : dstSize;
+ len = ((size_t)len < dstSize) ? len : (ssize_t)dstSize;
f = fopen(filePath, "r");
if (!f) {
@@ -4755,7 +4774,7 @@ ssize_t bLReadFile(const char *filePath, void *buffer, size_t dstSize) {
shEPrintfS("The path was: \"%s\"\n", filePath);
return(-1);
}
- readStatus = fread(buffer, 1, len , f);
+ readStatus = fread(buffer, 1, (size_t)len , f);
fclose(f);
if (readStatus != (size_t)len) {
@@ -5008,7 +5027,7 @@ char **walkDir(const char* dirPath) {
walkADir(dirPath, &list);
- iListSortS(&list);
+ pErrorNULL(iListSortS(&list));
return(list);
}
@@ -5040,7 +5059,7 @@ internal void walkADir(const char *dirPath, char ***list) {
}
}
else {
- listPushS(list, sPath);
+ pErrorNULL(listPushS(list, sPath));
}
free(sPath);
dp = readdir(d);
@@ -5071,7 +5090,7 @@ char **walkDirDir(const char* dirPath) {
walkADirDir(dirPath, &list);
- iListSortS(&list);
+ pErrorNULL(iListSortS(&list));
return(list);
}
@@ -5098,7 +5117,7 @@ internal void walkADirDir(const char *dirPath, char ***list) {
sPath = catS(dirPath, "/", dp->d_name);
if (isDir(sPath)) {
- listPushS(list, sPath);
+ pErrorNULL(listPushS(list, sPath));
if (!isLink(sPath)) {
walkADirDir(sPath, list);
}
@@ -5149,7 +5168,7 @@ char **readDir(const char *dirPath) {
char *sPath = catS(dirPath, "/", dp->d_name);
if (!isDir(sPath)) {
- listPushS(&list, dp->d_name);
+ pErrorNULL(listPushS(&list, dp->d_name));
}
free(sPath);
dp = readdir(d);
@@ -5157,7 +5176,7 @@ char **readDir(const char *dirPath) {
closedir(d);
- iListSortS(&list);
+ pErrorNULL(iListSortS(&list));
return(list);
}
@@ -5201,7 +5220,7 @@ char **readDirDir(const char *dirPath) {
char *sPath = catS(dirPath, "/", dp->d_name);
if (isDir(sPath)) {
- listPushS(&list, dp->d_name);
+ pErrorNULL(listPushS(&list, dp->d_name));
}
free(sPath);
dp = readdir(d);
@@ -5209,7 +5228,7 @@ char **readDirDir(const char *dirPath) {
closedir(d);
- iListSortS(&list);
+ pErrorNULL(iListSortS(&list));
return(list);
}
@@ -5236,7 +5255,7 @@ char **walkDirAll(const char* dirPath) {
walkADirAll(dirPath, &list);
- iListSortS(&list);
+ pErrorNULL(iListSortS(&list));
return(list);
}
@@ -5262,7 +5281,7 @@ internal void walkADirAll(const char *dirPath, char ***list) {
sPath = catS(dirPath, "/", dp->d_name);
- iListPushS(list, sPath);
+ pErrorNULL(iListPushS(list, sPath));
if (isDir(sPath)) {
if (!isLink(sPath)) {
@@ -5313,14 +5332,14 @@ char **readDirAll(const char *dirPath) {
char *sPath = catS(dirPath, "/", dp->d_name);
- listPushS(&list, dp->d_name);
+ pErrorNULL(listPushS(&list, dp->d_name));
free(sPath);
dp = readdir(d);
}
closedir(d);
- iListSortS(&list);
+ pErrorNULL(iListSortS(&list));
return(list);
}
@@ -5328,7 +5347,7 @@ char **readDirAll(const char *dirPath) {
/**
* get umask
*/
-mode_t getumask(void) {
+mode_t getUmask(void) {
mode_t mask = umask(0);
umask(mask);
@@ -5340,7 +5359,7 @@ mode_t getumask(void) {
*/
mode_t getCurrentPermissions(void) {
- return(0777 & ~getumask());
+ return(0777 & ~getUmask());
}
/**
@@ -5435,8 +5454,6 @@ int rmADir(const char *dirPath) {
return(0);
}
- size_t dirPathLen = strlen(dirPath);
-
dp = readdir(d);
while (dp) {
if (eqS(dp->d_name, ".") || eqS(dp->d_name, "..")) {
@@ -5444,23 +5461,30 @@ int rmADir(const char *dirPath) {
continue;
}
- sPath = alloca( dirPathLen + 1 + strlen(dp->d_name) + 1 );
- sprintf(sPath, "%s/%s", dirPath, dp->d_name);
+ int e = asprintf(&sPath, "%s/%s", dirPath, dp->d_name);
+ if (e == -1) {
+ pFuncError;
+ shEPrintfS("The path was: \"%s\"\n", dirPath);
+ closedir(d);
+ return(0);
+ }
+
if (isDir(sPath)) {
r = rmADir(sPath);;
}
else {
- pErrorResultCmd(r, remove(sPath), == -1, pFuncError; shEPrintfS("The path was: \"%s\"\n", sPath); r=0; break);
+ pErrorResultCmd(r, remove(sPath), == -1, pFuncError; shEPrintfS("The path was: \"%s\"\n", sPath); r=0; free(sPath); break);
r = 1;
}
dp = readdir(d);
+ free(sPath);
}
closedir(d);
int rd;
- pErrorResultCmd(rd, rmdir(dirPath), == -1, pFuncError; shEPrintfS("The path was: \"%s\"\n", sPath); return(0));;
+ pErrorResultCmd(rd, rmdir(dirPath), == -1, pFuncError; shEPrintfS("The path was: \"%s\"\n", dirPath); return(0));;
return(r);
}
@@ -5497,9 +5521,9 @@ int copy(const char* src, const char* dst) {
// dst name is a directory, add src basename to dst
char *csrc = strdup(src);
char *path = basename(csrc);
- free(csrc);
char *dPath = alloca(strlen(dst) + 1 + strlen(path) + 1);
sprintf(dPath, "%s/%s", dst, path);
+ free(csrc);
return(copyFile(src, dPath));
}
else {
@@ -5521,10 +5545,10 @@ int copy(const char* src, const char* dst) {
}
else {
char *csrc = strdup(src);
- char *path = basename((char*)src);
- free(csrc);
+ char *path = basename(csrc);
char *dPath = alloca(strlen(dst) + 1 + strlen(path) + 1);
sprintf(dPath, "%s/%s", dst, path);
+ free(csrc);
if (!mkdirParents(dPath)) {
if (errno != EEXIST) {
@@ -5611,22 +5635,16 @@ int copyADir(const char *src, const char *dst, const char *path) {
int r = 1;;
char *currentSrc = NULL;
char *currentDst = NULL;
- size_t cSrcLen;
- size_t cDstLen;
- cSrcLen = strlen(src) + 1 + strlen(path);
- cDstLen = strlen(dst) + 1 + strlen(path);
-
- currentSrc = alloca(cSrcLen + 1);
- currentDst = alloca(cDstLen + 1);
-
- sprintf(currentSrc, "%s/%s", src, path);
- sprintf(currentDst, "%s/%s", dst, path);
+ asprintf(¤tSrc, "%s/%s", src, path);
+ asprintf(¤tDst, "%s/%s", dst, path);
d = opendir(currentSrc);
if (!d) {
pFuncError
shEPrintfS("The path was: \"%s\"\n", currentSrc);
+ free(currentSrc);
+ free(currentDst);
return(0);
}
@@ -5637,15 +5655,14 @@ int copyADir(const char *src, const char *dst, const char *path) {
continue;
}
- sPath = alloca(cSrcLen + 1 + strlen(dp->d_name) + 1);
- dPath = alloca(cDstLen + 1 + strlen(dp->d_name) + 1);
-
- sprintf(sPath, "%s/%s", currentSrc, dp->d_name);
- sprintf(dPath, "%s/%s", currentDst, dp->d_name);
+ asprintf(&sPath, "%s/%s", currentSrc, dp->d_name);
+ asprintf(&dPath, "%s/%s", currentDst, dp->d_name);
if (isDir(sPath)) {
if (isLink(sPath)) {
dp = readdir(d);
+ free(sPath);
+ free(dPath);
continue;
}
mode_t mode = getCurrentPermissions();
@@ -5654,34 +5671,44 @@ int copyADir(const char *src, const char *dst, const char *path) {
pFuncError
shEPrintfS("The path was: \"%s\"\n", dPath);
r = 0;
+ free(sPath);
+ }
+ free(dPath);
break;
}
- }
- currentPath = alloca(strlen(path) + 1 + strlen(dp->d_name) + 1);
- sprintf(currentPath, "%s/%s", path, dp->d_name);
+ asprintf(¤tPath, "%s/%s", path, dp->d_name);
r = copyADir(src, dst, currentPath);;
+ free(currentPath);
// copy permissions
struct stat st;
if (stat(sPath, &st)) {
pFuncError
shEPrintfS("The path was: \"%s\"\n", sPath);
r = 0;
+ free(sPath);
+ free(dPath);
break;
}
if (chmod(dPath, st.st_mode & 07777)) {
pFuncError
shEPrintfS("The path was: \"%s\"\n", dPath);
r = 0;
+ free(sPath);
+ free(dPath);
break;
}
}
else {
- pErrorResultCmd(r, copyFile(sPath, dPath), == 0, pFuncError; shEPrintfS("The path was: \"%s\"\n", sPath); break);
+ pErrorResultCmd(r, copyFile(sPath, dPath), == 0, pFuncError; shEPrintfS("The path was: \"%s\"\n", sPath); free(sPath); free(dPath); break);
}
dp = readdir(d);
+ free(sPath);
+ free(dPath);
}
closedir(d);
+ free(currentSrc);
+ free(currentDst);
return(r);
}
@@ -5759,7 +5786,7 @@ static randomWordFt randomWordF = randomWord;
void setSoftwareRandom(void) {
randomWordF = randomWord;
- randomUrandomOpen();
+ pError0(randomUrandomOpen());
}
/**
@@ -6134,7 +6161,7 @@ char *bRandomAlphaNumS(char *dst, size_t dstSize) {
char *readS(void) {
int max = startMax;;
- char *s = MALLOC(max);
+ char *s = MALLOC((size_t)max);
if (!s) {
return(NULL);
}
@@ -6156,11 +6183,11 @@ char *readS(void) {
s[i] = 0;
break;
}
- s[i] = c;
+ s[i] = (char)c;
if (i == max-1) {
// buffer full
max += max;
- char *tmp = REALLOC(s, max);
+ char *tmp = REALLOC(s, (size_t)max);
if (!tmp) {
free(s);
return(NULL);
@@ -6207,7 +6234,7 @@ char *bLReadS(char *dst, size_t dstSize) {
dst[i] = 0;
break;
}
- dst[i] = c;
+ dst[i] = (char)c;
i++;
}
return(dst);
@@ -6239,7 +6266,7 @@ UNUSED local char *shGetpass(void) {
return(NULL);
}
new = old;
- new.c_lflag &= ~ECHO;
+ new.c_lflag &= ~(tcflag_t)ECHO;
if (tcsetattr (fileno (stream), TCSAFLUSH, &new) != 0) {
fclose(stream);
return(NULL);
@@ -6658,7 +6685,7 @@ char *toHexHeadSepS(const void *buf, size_t len, const char *head, const char *s
* dst string
* NULL error
*/
-char *strCpy(char *dst, const char *src) {
+char *strCpy(char *restrict dst, const char *restrict src) {
if (!dst || !src) {
return(NULL);
@@ -6683,7 +6710,7 @@ char *strCpy(char *dst, const char *src) {
* dst string
* NULL error
*/
-char *strNCpy(char *dst, const char *src, size_t srcSize) {
+char *strNCpy(char *restrict dst, const char *restrict src, size_t srcSize) {
if (!dst || !src) {
return(NULL);
@@ -6709,7 +6736,7 @@ char *strNCpy(char *dst, const char *src, size_t srcSize) {
* dst string
* NULL error
*/
-char *strLCpy(char *dst, size_t dstSize, const char *src) {
+char *strLCpy(char *restrict dst, size_t dstSize, const char *restrict src) {
if (!dst || !src) {
return(NULL);
@@ -6735,7 +6762,7 @@ char *strLCpy(char *dst, size_t dstSize, const char *src) {
* string with input strings concatenated
* NULL error
*/
-char *strCat(char *dst, const char *src) {
+char *strCat(char *restrict dst, const char *restrict src) {
if (!dst || !src) {
return(NULL);
@@ -6759,7 +6786,7 @@ char *strCat(char *dst, const char *src) {
* string with input strings concatenated
* NULL error
*/
-char *strNCat(char *dst, const char *src, size_t srcLen) {
+char *strNCat(char *restrict dst, const char *restrict src, size_t srcLen) {
if (!dst || !src) {
return(NULL);
@@ -6784,7 +6811,7 @@ char *strNCat(char *dst, const char *src, size_t srcLen) {
* NULL error
*/
/* same/slower than the other implementation with -O2 and kaby lake */
-char *strLCat(char *dst, size_t dstSize, const char *src) {
+char *strLCat(char *restrict dst, size_t dstSize, const char *restrict src) {
if (!dst || !src) {
return(NULL);
@@ -6853,7 +6880,7 @@ char *strLCat(char *dst, size_t dstSize, const char *src) {
* string with input strings concatenated
* NULL error
*/
-char *strLNCat(char *dst, size_t dstSize, const char *src, size_t srcLen) {
+char *strLNCat(char *restrict dst, size_t dstSize, const char *restrict src, size_t srcLen) {
if (!dst || !src) {
return(NULL);
@@ -6894,7 +6921,7 @@ char *catSF(const char *paramType, ...) {
va_start(pl, paramType);
paramType = va_arg(pl, char *);
while (paramType) {
- listPushS(&l, paramType);
+ pErrorNULL(listPushS(&l, paramType));
paramType = va_arg(pl, char *);
}
va_end(pl);
@@ -6962,7 +6989,7 @@ char *bLCatSF(char *dst, size_t dstSize, const char *paramType, ...) {
va_start(pl, paramType);
paramType = va_arg(pl, char *);
while (paramType) {
- strLCat(dst, dstSize, paramType);
+ pErrorNULL(strLCat(dst, dstSize, paramType));
paramType = va_arg(pl, char *);
}
va_end(pl);
@@ -7284,14 +7311,14 @@ char *iAppendManySF(char **string, const char *paramType, ...) {
return(NULL);
}
- iListPushS(&l, *string);
- listPushS(&l, paramType);
+ pErrorNULL(iListPushS(&l, *string));
+ pErrorNULL(listPushS(&l, paramType));
// add arguments to a list
va_start(pl, paramType);
paramType = va_arg(pl, char *);
while (paramType) {
- listPushS(&l, paramType);
+ pErrorNULL(listPushS(&l, paramType));
paramType = va_arg(pl, char *);
}
va_end(pl);
@@ -7323,14 +7350,14 @@ char *bAppendManySF(char *string, const char *paramType, ...) {
return(NULL);
}
- listPushS(&l, string);
- listPushS(&l, paramType);
+ pErrorNULL(listPushS(&l, string));
+ pErrorNULL(listPushS(&l, paramType));
// add arguments to a list
va_start(pl, paramType);
paramType = va_arg(pl, char *);
while (paramType) {
- listPushS(&l, paramType);
+ pErrorNULL(listPushS(&l, paramType));
paramType = va_arg(pl, char *);
}
va_end(pl);
@@ -7367,14 +7394,14 @@ char *bLAppendManySF(char *string, size_t stringSize, const char *paramType, ...
return(string);
}
- listPushS(&l, string);
- listPushS(&l, paramType);
+ pErrorNULL(listPushS(&l, string));
+ pErrorNULL(listPushS(&l, paramType));
// add arguments to a list
va_start(pl, paramType);
paramType = va_arg(pl, char *);
while (paramType) {
- listPushS(&l, paramType);
+ pErrorNULL(listPushS(&l, paramType));
paramType = va_arg(pl, char *);
}
va_end(pl);
@@ -7382,7 +7409,7 @@ char *bLAppendManySF(char *string, size_t stringSize, const char *paramType, ...
r = join(l, "");
listFreeS(l);
- strLCpy(string, stringSize, r);
+ pErrorNULL(strLCpy(string, stringSize, r));
free(r);
return(string);
}
@@ -7586,7 +7613,7 @@ char *bLPrependS(char *string1, size_t string1Size, const char *string2) {
}
if (!*string1) {
- strLCpy(string1, string1Size, string2);
+ pErrorNULL(strLCpy(string1, string1Size, string2));
return(string1);
}
@@ -7625,8 +7652,6 @@ char* replaceS(const char *s, const char *olds, const char *news, size_t max ) {
const char *ins = NULL;
size_t count;
size_t lfront;
- bool freeNewsStatus = false;;
- char *internalNews = NULL;
// sanity checks and initialization
// count the number of replacements needed
@@ -7653,11 +7678,7 @@ char* replaceS(const char *s, const char *olds, const char *news, size_t max ) {
}
if (!news) {
// empty string for NULL
- freeNewsStatus = true;
- emptyS(internalNews)
- }
- else {
- internalNews = (char *) news;
+ news = "";
}
// count the number of replacements needed
@@ -7672,14 +7693,11 @@ char* replaceS(const char *s, const char *olds, const char *news, size_t max ) {
size_t lnews;
- lnews = strlen(internalNews);
+ lnews = strlen(news);
// allocate result
tmp = r = MALLOC(strlen(s) + (lnews - lolds) * count + 1);
if (!r) {
- if (freeNewsStatus) {
- free(internalNews);
- }
return(NULL);//LCOV_EXCL_LINE
}
@@ -7690,17 +7708,14 @@ char* replaceS(const char *s, const char *olds, const char *news, size_t max ) {
// s is the remainder of s after end of olds
while (count--) {
ins = strstr(s, olds);
- lfront = ins - s;
+ lfront = (size_t)(ins - s);
tmp = strncpy(tmp, s, lfront) + lfront;
- tmp = strcpy(tmp, internalNews) + lnews;
+ tmp = strcpy(tmp, news) + lnews;
s += lfront + lolds;
}
// copy end of string
strcpy(tmp, s);
- if (freeNewsStatus) {
- free(internalNews);
- }
return(r);
}
@@ -7746,8 +7761,6 @@ char* iReplaceS(char **s, const char *olds, const char *news, size_t max ) {
char *ins = NULL;
size_t count;
size_t lfront;
- bool freeNewsStatus = false;;
- char *internalNews = NULL;
// sanity checks and initialization
// count the number of replacements needed
@@ -7774,11 +7787,7 @@ char* iReplaceS(char **s, const char *olds, const char *news, size_t max ) {
}
if (!news) {
// empty string for NULL
- freeNewsStatus = true;
- emptyS(internalNews)
- }
- else {
- internalNews = (char *) news;
+ news = "";
}
// count the number of replacements needed
@@ -7793,15 +7802,12 @@ char* iReplaceS(char **s, const char *olds, const char *news, size_t max ) {
size_t lnews;
- lnews = strlen(internalNews);
+ lnews = strlen(news);
// allocate result
size_t rLen = strlen(*s) + (lnews - lolds) * count + 1;;
tmp = r = MALLOC(rLen);
if (!r) {
- if (freeNewsStatus) {
- free(internalNews);
- }
return(NULL);
}
@@ -7812,17 +7818,14 @@ char* iReplaceS(char **s, const char *olds, const char *news, size_t max ) {
// s is the remainder of s after end of olds
while (count--) {
ins = strstr(workingS, olds);
- lfront = ins - workingS;
+ lfront = (size_t)(ins - workingS);
tmp = strncpy(tmp, workingS, lfront) + lfront;
- tmp = strcpy(tmp, internalNews) + lnews;
+ tmp = strcpy(tmp, news) + lnews;
workingS += lfront + lolds;
}
// copy end of string
strcpy(tmp, workingS);
- if (freeNewsStatus) {
- free(internalNews);
- }
free(*s);
*s = r;
@@ -7870,8 +7873,6 @@ char* bReplaceS(char *s, const char *olds, const char *news, size_t max ) {
char *ins = NULL;
size_t count;
size_t lfront;
- bool freeNewsStatus = false;;
- char *internalNews = NULL;
// sanity checks and initialization
// count the number of replacements needed
@@ -7898,11 +7899,7 @@ char* bReplaceS(char *s, const char *olds, const char *news, size_t max ) {
}
if (!news) {
// empty string for NULL
- freeNewsStatus = true;
- emptyS(internalNews)
- }
- else {
- internalNews = (char *) news;
+ news = "";
}
// count the number of replacements needed
@@ -7917,15 +7914,12 @@ char* bReplaceS(char *s, const char *olds, const char *news, size_t max ) {
size_t lnews;
- lnews = strlen(internalNews);
+ lnews = strlen(news);
// allocate result
size_t rLen = strlen(s) + (lnews - lolds) * count + 1;;
tmp = r = MALLOC(rLen);
if (!r) {
- if (freeNewsStatus) {
- free(internalNews);
- }
return(NULL);
}
@@ -7936,17 +7930,14 @@ char* bReplaceS(char *s, const char *olds, const char *news, size_t max ) {
// s is the remainder of s after end of olds
while (count--) {
ins = strstr(workingS, olds);
- lfront = ins - workingS;
+ lfront = (size_t)(ins - workingS);
tmp = strncpy(tmp, workingS, lfront) + lfront;
- tmp = strcpy(tmp, internalNews) + lnews;
+ tmp = strcpy(tmp, news) + lnews;
workingS += lfront + lolds;
}
// copy end of string
strcpy(tmp, workingS);
- if (freeNewsStatus) {
- free(internalNews);
- }
strcpy(s, r);
free(r);
@@ -7975,8 +7966,6 @@ char* bLReplaceS(char *s, size_t sSize, const char *olds, const char *news, size
char *ins = NULL;
size_t count;
size_t lfront;
- bool freeNewsStatus = false;;
- char *internalNews = NULL;
// sanity checks and initialization
// count the number of replacements needed
@@ -8007,11 +7996,7 @@ char* bLReplaceS(char *s, size_t sSize, const char *olds, const char *news, size
}
if (!news) {
// empty string for NULL
- freeNewsStatus = true;
- emptyS(internalNews)
- }
- else {
- internalNews = (char *) news;
+ news = "";
}
// count the number of replacements needed
@@ -8026,15 +8011,12 @@ char* bLReplaceS(char *s, size_t sSize, const char *olds, const char *news, size
size_t lnews;
- lnews = strlen(internalNews);
+ lnews = strlen(news);
// allocate result
size_t rLen = strlen(s) + (lnews - lolds) * count + 1;;
tmp = r = MALLOC(rLen);
if (!r) {
- if (freeNewsStatus) {
- free(internalNews);
- }
return(NULL);
}
@@ -8045,19 +8027,16 @@ char* bLReplaceS(char *s, size_t sSize, const char *olds, const char *news, size
// s is the remainder of s after end of olds
while (count--) {
ins = strstr(workingS, olds);
- lfront = ins - workingS;
+ lfront = (size_t)(ins - workingS);
tmp = strncpy(tmp, workingS, lfront) + lfront;
- tmp = strcpy(tmp, internalNews) + lnews;
+ tmp = strcpy(tmp, news) + lnews;
workingS += lfront + lolds;
}
// copy end of string
strcpy(tmp, workingS);
- if (freeNewsStatus) {
- free(internalNews);
- }
- strLCpy(s, sSize, r);
+ pErrorNULL(strLCpy(s, sSize, r));
free(r);
return(s);
}
@@ -8086,11 +8065,11 @@ char* bLReplaceS(char *s, size_t sSize, const char *olds, const char *news, size
*/
char *replaceManySF(const char *paramType, ...) {
va_list pl;
+ char *param = NULL;
char *r = NULL;
char *workingS = NULL;
char *olds = NULL;
char *news = NULL;
- bool freeWorkingS = false;;
// sanity checks
if (!paramType) {
@@ -8101,31 +8080,29 @@ char *replaceManySF(const char *paramType, ...) {
return(emptySF());
}
- workingS = (char *) paramType;
+ workingS = strdup(paramType);
// add arguments to a list
va_start(pl, paramType);
- paramType = va_arg(pl, char *);
- while (paramType) {
+ param = va_arg(pl, char *);
+ while (param) {
if (!olds) {
- olds = (char *) paramType;
+ olds = param;
}
else if (!news) {
- news = (char *) paramType;
- r = replaceS(workingS, olds, news, 0);
+ news = param;
+ r = replaceS(workingS, olds, news, 0);
+ free(workingS);
olds = NULL;
news = NULL;
- if (!freeWorkingS) {
- freeWorkingS = true;
- }
- else {
- free(workingS);
- }
workingS = r;
}
- paramType = va_arg(pl, char *);
+ param = va_arg(pl, char *);
}
va_end(pl);
+ if (!r) {
+ free(workingS);
+ }
return(r);
}
@@ -8172,7 +8149,7 @@ char *iReplaceManySF(char **s, char *paramType, ...) {
}
else if (!news) {
news = (char *) paramType;
- iReplaceS(s, olds, news, 0);
+ pErrorNULL(iReplaceS(s, olds, news, 0));
olds = NULL;
news = NULL;
}
@@ -8215,18 +8192,18 @@ char *bReplaceManySF(char *s, char *paramType, ...) {
return(NULL);
}
- olds = (char *) paramType;;
+ olds = paramType;;
// add arguments to a list
va_start(pl, paramType);
paramType = va_arg(pl, char *);
while (paramType) {
if (!olds) {
- olds = (char *) paramType;
+ olds = paramType;
}
else if (!news) {
- news = (char *) paramType;
- bReplaceS(s, olds, news, 0);
+ news = paramType;
+ pErrorNULL(bReplaceS(s, olds, news, 0));
olds = NULL;
news = NULL;
}
@@ -8273,18 +8250,18 @@ char *bLReplaceManySF(char *s, size_t sSize, char *paramType, ...) {
return(NULL);
}
- olds = (char *) paramType;;
+ olds = paramType;;
// add arguments to a list
va_start(pl, paramType);
paramType = va_arg(pl, char *);
while (paramType) {
if (!olds) {
- olds = (char *) paramType;
+ olds = paramType;
}
else if (!news) {
- news = (char *) paramType;
- bLReplaceS(s, sSize, olds, news, 0);
+ news = paramType;
+ pErrorNULL(bLReplaceS(s, sSize, olds, news, 0));
olds = NULL;
news = NULL;
}
@@ -8320,8 +8297,6 @@ char* icReplaceS(const char *s, const char *olds, const char *news, size_t max )
const char *ins = NULL;
size_t count;
size_t lfront;
- bool freeNewsStatus = false;;
- char *internalNews = NULL;
// sanity checks and initialization
// count the number of replacements needed
@@ -8348,11 +8323,7 @@ char* icReplaceS(const char *s, const char *olds, const char *news, size_t max )
}
if (!news) {
// empty string for NULL
- freeNewsStatus = true;
- emptyS(internalNews)
- }
- else {
- internalNews = (char *) news;
+ news = "";
}
// count the number of replacements needed
@@ -8367,14 +8338,11 @@ char* icReplaceS(const char *s, const char *olds, const char *news, size_t max )
size_t lnews;
- lnews = strlen(internalNews);
+ lnews = strlen(news);
// allocate result
tmp = r = MALLOC(strlen(s) + (lnews - lolds) * count + 1);
if (!r) {
- if (freeNewsStatus) {
- free(internalNews);
- }
return(NULL);//LCOV_EXCL_LINE
}
@@ -8385,17 +8353,14 @@ char* icReplaceS(const char *s, const char *olds, const char *news, size_t max )
// s is the remainder of s after end of olds
while (count--) {
ins = strcasestr(s, olds);
- lfront = ins - s;
+ lfront = (size_t)(ins - s);
tmp = strncpy(tmp, s, lfront) + lfront;
- tmp = strcpy(tmp, internalNews) + lnews;
+ tmp = strcpy(tmp, news) + lnews;
s += lfront + lolds;
}
// copy end of string
strcpy(tmp, s);
- if (freeNewsStatus) {
- free(internalNews);
- }
return(r);
}
@@ -8441,8 +8406,6 @@ char* iicReplaceS(char **s, const char *olds, const char *news, size_t max ) {
char *ins = NULL;
size_t count;
size_t lfront;
- bool freeNewsStatus = false;;
- char *internalNews = NULL;
// sanity checks and initialization
// count the number of replacements needed
@@ -8469,11 +8432,7 @@ char* iicReplaceS(char **s, const char *olds, const char *news, size_t max ) {
}
if (!news) {
// empty string for NULL
- freeNewsStatus = true;
- emptyS(internalNews)
- }
- else {
- internalNews = (char *) news;
+ news = "";
}
// count the number of replacements needed
@@ -8488,15 +8447,12 @@ char* iicReplaceS(char **s, const char *olds, const char *news, size_t max ) {
size_t lnews;
- lnews = strlen(internalNews);
+ lnews = strlen(news);
// allocate result
size_t rLen = strlen(*s) + (lnews - lolds) * count + 1;;
tmp = r = MALLOC(rLen);
if (!r) {
- if (freeNewsStatus) {
- free(internalNews);
- }
return(NULL);
}
@@ -8507,17 +8463,14 @@ char* iicReplaceS(char **s, const char *olds, const char *news, size_t max ) {
// s is the remainder of s after end of olds
while (count--) {
ins = strcasestr(workingS, olds);
- lfront = ins - workingS;
+ lfront = (size_t)(ins - workingS);
tmp = strncpy(tmp, workingS, lfront) + lfront;
- tmp = strcpy(tmp, internalNews) + lnews;
+ tmp = strcpy(tmp, news) + lnews;
workingS += lfront + lolds;
}
// copy end of string
strcpy(tmp, workingS);
- if (freeNewsStatus) {
- free(internalNews);
- }
free(*s);
*s = r;
@@ -8565,8 +8518,6 @@ char* bicReplaceS(char *s, const char *olds, const char *news, size_t max ) {
char *ins = NULL;
size_t count;
size_t lfront;
- bool freeNewsStatus = false;;
- char *internalNews = NULL;
// sanity checks and initialization
// count the number of replacements needed
@@ -8593,11 +8544,7 @@ char* bicReplaceS(char *s, const char *olds, const char *news, size_t max ) {
}
if (!news) {
// empty string for NULL
- freeNewsStatus = true;
- emptyS(internalNews)
- }
- else {
- internalNews = (char *) news;
+ news = "";
}
// count the number of replacements needed
@@ -8612,15 +8559,12 @@ char* bicReplaceS(char *s, const char *olds, const char *news, size_t max ) {
size_t lnews;
- lnews = strlen(internalNews);
+ lnews = strlen(news);
// allocate result
size_t rLen = strlen(s) + (lnews - lolds) * count + 1;;
tmp = r = MALLOC(rLen);
if (!r) {
- if (freeNewsStatus) {
- free(internalNews);
- }
return(NULL);
}
@@ -8631,17 +8575,14 @@ char* bicReplaceS(char *s, const char *olds, const char *news, size_t max ) {
// s is the remainder of s after end of olds
while (count--) {
ins = strcasestr(workingS, olds);
- lfront = ins - workingS;
+ lfront = (size_t)(ins - workingS);
tmp = strncpy(tmp, workingS, lfront) + lfront;
- tmp = strcpy(tmp, internalNews) + lnews;
+ tmp = strcpy(tmp, news) + lnews;
workingS += lfront + lolds;
}
// copy end of string
strcpy(tmp, workingS);
- if (freeNewsStatus) {
- free(internalNews);
- }
strcpy(s, r);
free(r);
@@ -8670,8 +8611,6 @@ char* bLicReplaceS(char *s, size_t sSize, const char *olds, const char *news, si
char *ins = NULL;
size_t count;
size_t lfront;
- bool freeNewsStatus = false;;
- char *internalNews = NULL;
// sanity checks and initialization
// count the number of replacements needed
@@ -8702,11 +8641,7 @@ char* bLicReplaceS(char *s, size_t sSize, const char *olds, const char *news, si
}
if (!news) {
// empty string for NULL
- freeNewsStatus = true;
- emptyS(internalNews)
- }
- else {
- internalNews = (char *) news;
+ news = "";
}
// count the number of replacements needed
@@ -8721,15 +8656,12 @@ char* bLicReplaceS(char *s, size_t sSize, const char *olds, const char *news, si
size_t lnews;
- lnews = strlen(internalNews);
+ lnews = strlen(news);
// allocate result
size_t rLen = strlen(s) + (lnews - lolds) * count + 1;;
tmp = r = MALLOC(rLen);
if (!r) {
- if (freeNewsStatus) {
- free(internalNews);
- }
return(NULL);
}
@@ -8740,19 +8672,16 @@ char* bLicReplaceS(char *s, size_t sSize, const char *olds, const char *news, si
// s is the remainder of s after end of olds
while (count--) {
ins = strcasestr(workingS, olds);
- lfront = ins - workingS;
+ lfront = (size_t)(ins - workingS);
tmp = strncpy(tmp, workingS, lfront) + lfront;
- tmp = strcpy(tmp, internalNews) + lnews;
+ tmp = strcpy(tmp, news) + lnews;
workingS += lfront + lolds;
}
// copy end of string
strcpy(tmp, workingS);
- if (freeNewsStatus) {
- free(internalNews);
- }
- strLCpy(s, sSize, r);
+ pErrorNULL(strLCpy(s, sSize, r));
free(r);
return(s);
}
@@ -8764,8 +8693,8 @@ char* bLicReplaceS(char *s, size_t sSize, const char *olds, const char *news, si
* the olds string is replaced with the news string max times in the result
*
* Example:
- * r = replaceManyS("asd", "s", "BNM", "a", "AAA")
- * ^olds ^news ^olds ^news
+ * r = icReplaceManyS("asd", "s", "BNM", "a", "AAA")
+ * ^olds ^news ^olds ^news
*
* \param
* s: string
@@ -8782,10 +8711,10 @@ char* bLicReplaceS(char *s, size_t sSize, const char *olds, const char *news, si
char *icReplaceManySF(const char *paramType, ...) {
va_list pl;
char *r = NULL;
+ char *param = NULL;
char *workingS = NULL;
char *olds = NULL;
char *news = NULL;
- bool freeWorkingS = false;;
// sanity checks
if (!paramType) {
@@ -8796,31 +8725,29 @@ char *icReplaceManySF(const char *paramType, ...) {
return(emptySF());
}
- workingS = (char *) paramType;
+ workingS = strdup(paramType);
// add arguments to a list
va_start(pl, paramType);
- paramType = va_arg(pl, char *);
- while (paramType) {
+ param = va_arg(pl, char *);
+ while (param) {
if (!olds) {
- olds = (char *) paramType;
+ olds = param;
}
else if (!news) {
- news = (char *) paramType;
- r = icReplaceS(workingS, olds, news, 0);
+ news = param;
+ r = icReplaceS(workingS, olds, news, 0);
+ free(workingS);
olds = NULL;
news = NULL;
- if (!freeWorkingS) {
- freeWorkingS = true;
- }
- else {
- free(workingS);
- }
workingS = r;
}
- paramType = va_arg(pl, char *);
+ param = va_arg(pl, char *);
}
va_end(pl);
+ if (!r) {
+ free(workingS);
+ }
return(r);
}
@@ -8856,18 +8783,18 @@ char *iicReplaceManySF(char **s, char *paramType, ...) {
return(NULL);
}
- olds = (char *) paramType;;
+ olds = paramType;;
// add arguments to a list
va_start(pl, paramType);
paramType = va_arg(pl, char *);
while (paramType) {
if (!olds) {
- olds = (char *) paramType;
+ olds = paramType;
}
else if (!news) {
- news = (char *) paramType;
- iicReplaceS(s, olds, news, 0);
+ news = paramType;
+ pErrorNULL(iicReplaceS(s, olds, news, 0));
olds = NULL;
news = NULL;
}
@@ -8910,18 +8837,18 @@ char *bicReplaceManySF(char *s, char *paramType, ...) {
return(NULL);
}
- olds = (char *) paramType;;
+ olds = paramType;;
// add arguments to a list
va_start(pl, paramType);
paramType = va_arg(pl, char *);
while (paramType) {
if (!olds) {
- olds = (char *) paramType;
+ olds = paramType;
}
else if (!news) {
- news = (char *) paramType;
- bicReplaceS(s, olds, news, 0);
+ news = paramType;
+ pErrorNULL(bicReplaceS(s, olds, news, 0));
olds = NULL;
news = NULL;
}
@@ -8968,18 +8895,18 @@ char *bLicReplaceManySF(char *s, size_t sSize, char *paramType, ...) {
return(NULL);
}
- olds = (char *) paramType;;
+ olds = paramType;;
// add arguments to a list
va_start(pl, paramType);
paramType = va_arg(pl, char *);
while (paramType) {
if (!olds) {
- olds = (char *) paramType;
+ olds = paramType;
}
else if (!news) {
- news = (char *) paramType;
- bLicReplaceS(s, sSize, olds, news, 0);
+ news = paramType;
+ pErrorNULL(bLicReplaceS(s, sSize, olds, news, 0));
olds = NULL;
news = NULL;
}
@@ -9048,7 +8975,7 @@ bool eqIS(const char *string1, const char *string2, int64_t index) {
return(false);
}
- int64_t len = strlen(string1);
+ int64_t len = (int64_t)strlen(string1);
if (index >= len && len) {
// && len: string1 is empty, check below if string2 is also empty
// when string1 and string2 are empty and index is 0, the result is true
@@ -9073,7 +9000,7 @@ bool eqIS(const char *string1, const char *string2, int64_t index) {
return(false);
}
- return(strncmp(string1 + index, string2, len2) == 0);;
+ return(strncmp(string1 + index, string2, (size_t)len2) == 0);;
}
bool eqICharS(const char *string1, char c, int64_t index) {
@@ -9264,7 +9191,7 @@ bool icEqIS(const char *string1, const char *string2, int64_t index) {
return(false);
}
- int64_t len = strlen(string1);
+ int64_t len = (int64_t)strlen(string1);
if (index >= len && len) {
// && len: string1 is empty, check below if string2 is also empty
// when string1 and string2 are empty and index is 0, the result is true
@@ -9289,7 +9216,7 @@ bool icEqIS(const char *string1, const char *string2, int64_t index) {
return(false);
}
- return(strncasecmp(string1 + index, string2, len2) == 0);;
+ return(strncasecmp(string1 + index, string2, (size_t)len2) == 0);;
}
bool icEqICharS(const char *string1, char c, int64_t index) {
@@ -9413,7 +9340,7 @@ ssize_t icCountCharS(const char *s, char c) {
ssize_t r = 0;
- c = tolower(c);
+ c = (char)tolower(c);
while (*s != 0) {
if (tolower(*s) == c) {
@@ -9896,7 +9823,7 @@ char *upperS(const char *string) {
// upper case
size_t i = 0;
while (r[i] != 0) {
- r[i] = toupper(r[i]);
+ r[i] = (char)toupper(r[i]);
i++;
}
return(r);
@@ -9921,7 +9848,7 @@ char *iUpperS(char **string) {
// upper case
size_t i = 0;
while ((*string)[i] != 0) {
- (*string)[i] = toupper((*string)[i]);
+ (*string)[i] = (char)toupper((*string)[i]);
i++;
}
return(*string);
@@ -9946,7 +9873,7 @@ char *bUpperS(char *string) {
// upper case
size_t i = 0;
while (string[i] != 0) {
- string[i] = toupper(string[i]);
+ string[i] = (char)toupper(string[i]);
i++;
}
return(string);
@@ -9977,7 +9904,7 @@ char *lowerS(const char *string) {
// lower case
size_t i = 0;
while (r[i] != 0) {
- r[i] = tolower(r[i]);
+ r[i] = (char)tolower(r[i]);
i++;
}
return(r);
@@ -10002,7 +9929,7 @@ char *iLowerS(char **string) {
// lower case
size_t i = 0;
while ((*string)[i] != 0) {
- (*string)[i] = tolower((*string)[i]);
+ (*string)[i] = (char)tolower((*string)[i]);
i++;
}
return(*string);
@@ -10027,7 +9954,7 @@ char *bLowerS(char *string) {
// lower case
size_t i = 0;
while (string[i] != 0) {
- string[i] = tolower(string[i]);
+ string[i] = (char)tolower(string[i]);
i++;
}
return(string);
@@ -10070,7 +9997,7 @@ char *trimS(const char *string) {
}
// copy range to new string
- len = end - string + 2;
+ len = (size_t)(end - string + 2);
r = MALLOC(len);
if (!r) {
return(NULL);
@@ -10121,7 +10048,7 @@ char *iTrimS(char **string) {
}
// copy range to new string
- len = end - workingS + 2;
+ len = (size_t)(end - workingS + 2);
r = MALLOC(len);
if (!r) {
return(NULL);
@@ -10173,7 +10100,7 @@ char *bTrimS(char *string) {
}
// copy range to new string
- len = end - workingS + 2;
+ len = (size_t)(end - workingS + 2);
r = MALLOC(len);
if (!r) {
return(NULL);
@@ -10276,10 +10203,7 @@ char *bLTrimS(char *string) {
workingS++;
}
- // valgrind warning - Source and destination overlap in strcpy
- // keep strcpy because string always < workingS
- strcpy(string, workingS);
- //memmove(string, workingS, strlen(workingS)+1);
+ memmove(string, workingS, strlen(workingS)+1);
return(string);
}
@@ -10309,7 +10233,7 @@ char *rTrimS(const char *string) {
}
// copy range to new string
- len = end - string + 2;
+ len = (size_t)(end - string + 2);
r = MALLOC(len);
if (!r) {
return(NULL);
@@ -10543,7 +10467,7 @@ char *icUniqS(const char *string, char c) {
return(r);
}
- c = tolower(c);
+ c = (char)tolower(c);
// index in r
size_t j = 1;;
@@ -10589,7 +10513,7 @@ char *iicUniqS(char **string, char c) {
return(*string);
}
- c = tolower(c);
+ c = (char)tolower(c);
// index in r
size_t j = 1;;
@@ -10635,7 +10559,7 @@ char *bicUniqS(char *string, char c) {
return(string);
}
- c = tolower(c);
+ c = (char)tolower(c);
// index in r
size_t j = 1;;
@@ -10903,7 +10827,7 @@ ssize_t repeatLenS(const char *string, size_t count) {
return(0);
}
- ssize_t r = strlen(string) * count;
+ ssize_t r = (ssize_t)(strlen(string) * count);
return(r);
}
@@ -10946,9 +10870,9 @@ char *ellipsisStartS(const char *string, size_t targetLength, const char *ellips
// truncate string
char *ellip = strdup(ellipsisString);
string += ((len - targetLength) + strlen(ellipsisString)) <= len ? (len - targetLength) + strlen(ellipsisString) : len;
- iAppendS(&ellip, string);
+ pErrorNULL(iAppendS(&ellip, string));
// make sure the result is target length
- iSliceS(&ellip, 0, targetLength);
+ pErrorNULL(iSliceS(&ellip, 0, (int64_t)targetLength));
return(ellip);
}
}
@@ -10990,9 +10914,9 @@ char *iEllipsisStartS(char **string, size_t targetLength, const char *ellipsisSt
// truncate string
char *ellip = strdup(ellipsisString);
char *str = *string + (((len - targetLength) + strlen(ellipsisString)) <= len ? (len - targetLength) + strlen(ellipsisString) : len);
- iAppendS(&ellip, str);
+ pErrorNULL(iAppendS(&ellip, str));
// make sure the result is target length
- iSliceS(&ellip, 0, targetLength);
+ pErrorNULL(iSliceS(&ellip, 0, (int64_t)targetLength));
free(*string);
*string = ellip;
}
@@ -11038,9 +10962,9 @@ char *bEllipsisStartS(char *dest, const char *string, size_t targetLength, const
// truncate string
char *ellip = strdup(ellipsisString);
string += ((len - targetLength) + strlen(ellipsisString)) <= len ? (len - targetLength) + strlen(ellipsisString) : len;
- iAppendS(&ellip, string);
+ pErrorNULL(iAppendS(&ellip, string));
// make sure the result is target length
- iSliceS(&ellip, 0, targetLength);
+ pErrorNULL(iSliceS(&ellip, 0, (int64_t)targetLength));
strncpy(dest, ellip, targetLength+1);
free(ellip);
}
@@ -11086,16 +11010,16 @@ char *bLEllipsisStartS(char *dest, size_t destSize, const char *string, size_t t
size_t len = strlen(string);
if (len <= targetLength) {
- strLCpy(dest, destSize, string);
+ pErrorNULL(strLCpy(dest, destSize, string));
}
else {
// truncate string
char *ellip = strdup(ellipsisString);
string += ((len - targetLength) + strlen(ellipsisString)) <= len ? (len - targetLength) + strlen(ellipsisString) : len;
- iAppendS(&ellip, string);
+ pErrorNULL(iAppendS(&ellip, string));
// make sure the result is target length
- iSliceS(&ellip, 0, targetLength);
- strLCpy(dest, destSize, ellip);
+ pErrorNULL(iSliceS(&ellip, 0, (int64_t)targetLength));
+ pErrorNULL(strLCpy(dest, destSize, ellip));
free(ellip);
}
return(dest);
@@ -11141,9 +11065,9 @@ char *ellipsisStartCharS(const char *string, size_t targetLength, char ellipsisC
// truncate string
char *ellip = strdup(ellipsisString);
string += ((len - targetLength) + strlen(ellipsisString)) <= len ? (len - targetLength) + strlen(ellipsisString) : len;
- iAppendS(&ellip, string);
+ pErrorNULL(iAppendS(&ellip, string));
// make sure the result is target length
- iSliceS(&ellip, 0, targetLength);
+ pErrorNULL(iSliceS(&ellip, 0, (int64_t)targetLength));
return(ellip);
}
}
@@ -11186,9 +11110,9 @@ char *iEllipsisStartCharS(char **string, size_t targetLength, char ellipsisChar)
// truncate string
char *ellip = strdup(ellipsisString);
char *str = *string + (((len - targetLength) + strlen(ellipsisString)) <= len ? (len - targetLength) + strlen(ellipsisString) : len);
- iAppendS(&ellip, str);
+ pErrorNULL(iAppendS(&ellip, str));
// make sure the result is target length
- iSliceS(&ellip, 0, targetLength);
+ pErrorNULL(iSliceS(&ellip, 0, (int64_t)targetLength));
free(*string);
*string = ellip;
}
@@ -11236,9 +11160,9 @@ char *bEllipsisStartCharS(char *dest, const char *string, size_t targetLength, c
// truncate string
char *ellip = strdup(ellipsisString);
string += ((len - targetLength) + strlen(ellipsisString)) <= len ? (len - targetLength) + strlen(ellipsisString) : len;
- iAppendS(&ellip, string);
+ pErrorNULL(iAppendS(&ellip, string));
// make sure the result is target length
- iSliceS(&ellip, 0, targetLength);
+ pErrorNULL(iSliceS(&ellip, 0, (int64_t)targetLength));
strncpy(dest, ellip, targetLength+1);
free(ellip);
}
@@ -11286,16 +11210,16 @@ char *bLEllipsisStartCharS(char *dest, size_t destSize, const char *string, size
size_t len = strlen(string);
if (len <= targetLength) {
- strLCpy(dest, destSize, string);
+ pErrorNULL(strLCpy(dest, destSize, string));
}
else {
// truncate string
char *ellip = strdup(ellipsisString);
string += ((len - targetLength) + strlen(ellipsisString)) <= len ? (len - targetLength) + strlen(ellipsisString) : len;
- iAppendS(&ellip, string);
+ pErrorNULL(iAppendS(&ellip, string));
// make sure the result is target length
- iSliceS(&ellip, 0, targetLength);
- strLCpy(dest, destSize, ellip);
+ pErrorNULL(iSliceS(&ellip, 0, (int64_t)targetLength));
+ pErrorNULL(strLCpy(dest, destSize, ellip));
free(ellip);
}
return(dest);
@@ -11321,10 +11245,10 @@ ssize_t ellipsisLenS(const char *string, size_t targetLength, const char *ellips
size_t len = strlen(string);
if (len <= targetLength) {
- return(len);
+ return((ssize_t)len);
}
else {
- return(targetLength);
+ return((ssize_t)targetLength);
}
}
@@ -11366,12 +11290,12 @@ char *ellipsisEndS(const char *string, size_t targetLength, const char *ellipsis
// truncate string
char *ellip;
if ( strlen(ellipsisString) < targetLength) {
- ellip = sliceS(string, 0, targetLength - strlen(ellipsisString));
- iAppendS(&ellip, ellipsisString);
+ ellip = sliceS(string, 0, (int64_t)(targetLength - strlen(ellipsisString)));
+ pErrorNULL(iAppendS(&ellip, ellipsisString));
}
else {
// ellipsisString is longer than targetLength
- ellip = sliceS(ellipsisString, 0, targetLength);
+ ellip = sliceS(ellipsisString, 0, (int64_t)targetLength);
}
return(ellip);
}
@@ -11413,12 +11337,12 @@ char *iEllipsisEndS(char **string, size_t targetLength, const char *ellipsisStri
// truncate string
char *ellip;
if ( strlen(ellipsisString) < targetLength) {
- ellip = sliceS(*string, 0, targetLength - strlen(ellipsisString));
- iAppendS(&ellip, ellipsisString);
+ ellip = sliceS(*string, 0, (int64_t)(targetLength - strlen(ellipsisString)));
+ pErrorNULL(iAppendS(&ellip, ellipsisString));
}
else {
// ellipsisString is longer than targetLength
- ellip = sliceS(ellipsisString, 0, targetLength);
+ ellip = sliceS(ellipsisString, 0, (int64_t)targetLength);
}
free(*string);
*string = ellip;
@@ -11465,12 +11389,12 @@ char *bEllipsisEndS(char *dest, const char *string, size_t targetLength, const c
// truncate string
char *ellip;
if ( strlen(ellipsisString) < targetLength) {
- ellip = sliceS(string, 0, targetLength - strlen(ellipsisString));
- iAppendS(&ellip, ellipsisString);
+ ellip = sliceS(string, 0, (int64_t)(targetLength - strlen(ellipsisString)));
+ pErrorNULL(iAppendS(&ellip, ellipsisString));
}
else {
// ellipsisString is longer than targetLength
- ellip = sliceS(ellipsisString, 0, targetLength);
+ ellip = sliceS(ellipsisString, 0, (int64_t)targetLength);
}
if (!ellip) {
return(NULL);
@@ -11520,20 +11444,20 @@ char *bLEllipsisEndS(char *dest, size_t destSize, const char *string, size_t tar
size_t len = strlen(string);
if (len <= targetLength) {
- strLCpy(dest, destSize, string);
+ pErrorNULL(strLCpy(dest, destSize, string));
}
else {
// truncate string
char *ellip;
if ( strlen(ellipsisString) < targetLength) {
- ellip = sliceS(string, 0, targetLength - strlen(ellipsisString));
- iAppendS(&ellip, ellipsisString);
+ ellip = sliceS(string, 0, (int64_t)(targetLength - strlen(ellipsisString)));
+ pErrorNULL(iAppendS(&ellip, ellipsisString));
}
else {
// ellipsisString is longer than targetLength
- ellip = sliceS(ellipsisString, 0, targetLength);
+ ellip = sliceS(ellipsisString, 0, (int64_t)targetLength);
}
- strLCpy(dest, destSize, ellip);
+ pErrorNULL(strLCpy(dest, destSize, ellip));
free(ellip);
}
return(dest);
@@ -11578,8 +11502,8 @@ char *ellipsisEndCharS(const char *string, size_t targetLength, char ellipsisCha
else {
// truncate string
char *ellip;
- ellip = sliceS(string, 0, targetLength - strlen(ellipsisString));
- iAppendS(&ellip, ellipsisString);
+ ellip = sliceS(string, 0, (int64_t)(targetLength - strlen(ellipsisString)));
+ pErrorNULL(iAppendS(&ellip, ellipsisString));
return(ellip);
}
}
@@ -11621,8 +11545,8 @@ char *iEllipsisEndCharS(char **string, size_t targetLength, char ellipsisChar) {
if (len > targetLength) {
// truncate string
char *ellip;
- ellip = sliceS(*string, 0, targetLength - strlen(ellipsisString));
- iAppendS(&ellip, ellipsisString);
+ ellip = sliceS(*string, 0, (int64_t)(targetLength - strlen(ellipsisString)));
+ pErrorNULL(iAppendS(&ellip, ellipsisString));
free(*string);
*string = ellip;
}
@@ -11669,11 +11593,11 @@ char *bEllipsisEndCharS(char *dest, const char *string, size_t targetLength, cha
else {
// truncate string
char *ellip;
- ellip = sliceS(string, 0, targetLength - strlen(ellipsisString));
+ ellip = sliceS(string, 0, (int64_t)(targetLength - strlen(ellipsisString)));
if (!ellip) {
return(NULL);
}
- iAppendS(&ellip, ellipsisString);
+ pErrorNULL(iAppendS(&ellip, ellipsisString));
strncpy(dest, ellip, targetLength+1);
free(ellip);
}
@@ -11721,14 +11645,14 @@ char *bLEllipsisEndCharS(char *dest, size_t destSize, const char *string, size_t
size_t len = strlen(string);
if (len <= targetLength) {
- strLCpy(dest, destSize, string);
+ pErrorNULL(strLCpy(dest, destSize, string));
}
else {
// truncate string
char *ellip;
- ellip = sliceS(string, 0, targetLength - strlen(ellipsisString));
- iAppendS(&ellip, ellipsisString);
- strLCpy(dest, destSize, ellip);
+ ellip = sliceS(string, 0, (int64_t)(targetLength - strlen(ellipsisString)));
+ pErrorNULL(iAppendS(&ellip, ellipsisString));
+ pErrorNULL(strLCpy(dest, destSize, ellip));
free(ellip);
}
return(dest);
@@ -11778,10 +11702,10 @@ char *padStartS(const char *string, size_t targetLength, const char *padString)
return(NULL);
}
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
char *r = appendS(pads, string);
free(pads);
@@ -11829,12 +11753,12 @@ char *iPadStartS(char **string, size_t targetLength, const char *padString) {
char *pads = strdup(padString);;
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
- iAppendS(&pads, *string);
+ pErrorNULL(iAppendS(&pads, *string));
free(*string);
*string = pads;
@@ -11886,10 +11810,10 @@ char *bPadStartS(char *dest, const char *string, size_t targetLength, const char
return(NULL);
}
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
char *r = appendS(pads, string);
free(pads);
@@ -11930,14 +11854,14 @@ char *bLPadStartS(char *dest, size_t destSize, const char *string, size_t target
return(NULL);
}
if (strlen(string) >= targetLength) {
- strLCpy(dest, destSize, string);
+ pErrorNULL(strLCpy(dest, destSize, string));
return(dest);
}
if (!padString) {
return(NULL);
}
if (!strlen(padString)) {
- strLCpy(dest, destSize, string);
+ pErrorNULL(strLCpy(dest, destSize, string));
return(dest);
}
@@ -11948,10 +11872,10 @@ char *bLPadStartS(char *dest, size_t destSize, const char *string, size_t target
return(NULL);
}
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
char *r = appendS(pads, string);
free(pads);
@@ -11959,7 +11883,7 @@ char *bLPadStartS(char *dest, size_t destSize, const char *string, size_t target
return(NULL);
}
- strLCpy(dest, destSize, r);
+ pErrorNULL(strLCpy(dest, destSize, r));
free(r);
return(dest);
@@ -12002,10 +11926,10 @@ char *padStartCharS(const char *string, size_t targetLength, char padChar) {
return(NULL);
}
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
char *r = appendS(pads, string);
free(pads);
@@ -12047,12 +11971,12 @@ char *iPadStartCharS(char **string, size_t targetLength, char padChar) {
char *pads = strdup(padString);;
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
- iAppendS(&pads, *string);
+ pErrorNULL(iAppendS(&pads, *string));
free(*string);
*string = pads;
@@ -12097,10 +12021,10 @@ char *bPadStartCharS(char *dest, const char *string, size_t targetLength, char p
return(NULL);
}
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
char *r = appendS(pads, string);
free(pads);
@@ -12139,7 +12063,7 @@ char *bLPadStartCharS(char *dest, size_t destSize, const char *string, size_t ta
return(NULL);
}
if (strlen(string) >= targetLength) {
- strLCpy(dest, destSize, string);
+ pErrorNULL(strLCpy(dest, destSize, string));
return(dest);
}
@@ -12152,10 +12076,10 @@ char *bLPadStartCharS(char *dest, size_t destSize, const char *string, size_t ta
return(NULL);
}
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
char *r = appendS(pads, string);
free(pads);
@@ -12163,7 +12087,7 @@ char *bLPadStartCharS(char *dest, size_t destSize, const char *string, size_t ta
return(NULL);
}
- strLCpy(dest, destSize, r);
+ pErrorNULL(strLCpy(dest, destSize, r));
free(r);
return(dest);
@@ -12185,16 +12109,16 @@ ssize_t padStartLenS(const char *string, size_t targetLength, const char *padStr
return(-1);
}
if (strlen(string) >= targetLength) {
- return(strlen(string));
+ return((ssize_t)strlen(string));
}
if (!padString) {
return(-1);
}
if (!strlen(padString)) {
- return(strlen(string));
+ return((ssize_t)strlen(string));
}
- return(targetLength);
+ return((ssize_t)targetLength);
}
/**
@@ -12240,10 +12164,10 @@ char *padEndS(const char *string, size_t targetLength, const char *padString) {
return(NULL);
}
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
char *r = appendS(string, pads);
free(pads);
@@ -12296,12 +12220,12 @@ char *iPadEndS(char **string, size_t targetLength, const char *padString) {
return(NULL);
}
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
- iAppendS(string, pads);
+ pErrorNULL(iAppendS(string, pads));
free(pads);
return(*string);
@@ -12352,10 +12276,10 @@ char *bPadEndS(char *dest, const char *string, size_t targetLength, const char *
return(NULL);
}
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
char *r = appendS(string, pads);
free(pads);
@@ -12396,14 +12320,14 @@ char *bLPadEndS(char *dest, size_t destSize, const char *string, size_t targetLe
return(NULL);
}
if (strlen(string) > targetLength) {
- strLCpy(dest, destSize, string);
+ pErrorNULL(strLCpy(dest, destSize, string));
return(dest);
}
if (!padString) {
return(NULL);
}
if (!strlen(padString)) {
- strLCpy(dest, destSize, string);
+ pErrorNULL(strLCpy(dest, destSize, string));
return(dest);
}
@@ -12414,10 +12338,10 @@ char *bLPadEndS(char *dest, size_t destSize, const char *string, size_t targetLe
return(NULL);
}
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
char *r = appendS(string, pads);
free(pads);
@@ -12425,7 +12349,7 @@ char *bLPadEndS(char *dest, size_t destSize, const char *string, size_t targetLe
return(NULL);
}
- strLCpy(dest, destSize, r);
+ pErrorNULL(strLCpy(dest, destSize, r));
free(r);
return(dest);
@@ -12468,10 +12392,10 @@ char *padEndCharS(const char *string, size_t targetLength, char padChar) {
return(NULL);
}
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
char *r = appendS(string, pads);
free(pads);
@@ -12516,12 +12440,12 @@ char *iPadEndCharS(char **string, size_t targetLength, char padChar) {
return(NULL);
}
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
- iAppendS(string, pads);
+ pErrorNULL(iAppendS(string, pads));
free(pads);
return(*string);
@@ -12565,10 +12489,10 @@ char *bPadEndCharS(char *dest, const char *string, size_t targetLength, char pad
return(NULL);
}
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
char *r = appendS(string, pads);
free(pads);
@@ -12607,7 +12531,7 @@ char *bLPadEndCharS(char *dest, size_t destSize, const char *string, size_t targ
return(NULL);
}
if (strlen(string) > targetLength) {
- strLCpy(dest, destSize, string);
+ pErrorNULL(strLCpy(dest, destSize, string));
return(dest);
}
@@ -12620,10 +12544,10 @@ char *bLPadEndCharS(char *dest, size_t destSize, const char *string, size_t targ
return(NULL);
}
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
char *r = appendS(string, pads);
free(pads);
@@ -12631,7 +12555,7 @@ char *bLPadEndCharS(char *dest, size_t destSize, const char *string, size_t targ
return(NULL);
}
- strLCpy(dest, destSize, r);
+ pErrorNULL(strLCpy(dest, destSize, r));
free(r);
return(dest);
@@ -12654,16 +12578,16 @@ ssize_t padEndLenS(const char *string, size_t targetLength, const char *padStrin
return(-1);
}
if (strlen(string) > targetLength) {
- return(strlen(string));
+ return((ssize_t)strlen(string));
}
if (!padString) {
return(-1);
}
if (!strlen(padString)) {
- return(strlen(string));
+ return((ssize_t)strlen(string));
}
- return(targetLength);
+ return((ssize_t)targetLength);
}
/**
@@ -12679,7 +12603,7 @@ char getS(const char *string, int64_t index) {
return(0);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (index >= len) {
return(0);
}
@@ -12705,7 +12629,7 @@ char *setS(char *string, int64_t index, char c) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (index >= len) {
return(NULL);
}
@@ -12740,7 +12664,7 @@ char *swapS(char *string, int64_t index1, int64_t index2) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (index1 >= len) {
return(NULL);
}
@@ -12793,7 +12717,7 @@ char *iSwapS(char **string, int64_t index1, int64_t index2) {
return(NULL);
}
- len = strlen(*string);
+ len = (int64_t)strlen(*string);
if (index1 >= len) {
return(NULL);
}
@@ -12841,7 +12765,7 @@ char *bSwapS(char *string, int64_t index1, int64_t index2) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (index1 >= len) {
return(NULL);
}
@@ -12898,10 +12822,10 @@ char *bLSwapS(char *string, size_t size, int64_t index1, int64_t index2) {
return(string);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if ((size_t)len+1 > size) {
- len = size-1;
+ len = (int64_t)(size-1);
}
if (index1 >= len) {
@@ -12957,7 +12881,7 @@ char *sliceS(const char *string, int64_t start, int64_t end) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (start > len) {
return(NULL);
}
@@ -12988,11 +12912,11 @@ char *sliceS(const char *string, int64_t start, int64_t end) {
// copy range to a new string
int64_t n;
n = end - start;
- s = MALLOC(n+1);
+ s = MALLOC((size_t)(n+1));
if (!s) {
return(NULL);//LCOV_EXCL_LINE
}
- s = strncpy(s, string+start, n);
+ s = strncpy(s, string+start, (size_t)n);
s[n] = 0;
}
@@ -13022,7 +12946,7 @@ char *iSliceS(char **string, int64_t start, int64_t end) {
return(NULL);
}
- len = strlen(*string);
+ len = (int64_t)strlen(*string);
if (start > len) {
free(*string);
emptyS(*string);
@@ -13059,11 +12983,11 @@ char *iSliceS(char **string, int64_t start, int64_t end) {
// copy range to a new string
int64_t n;
n = end - start;
- s = MALLOC(n+1);
+ s = MALLOC((size_t)(n+1));
if (!s) {
return(NULL);
}
- s = strncpy(s, (*string)+start, n);
+ s = strncpy(s, (*string)+start, (size_t)n);
s[n] = 0;
}
@@ -13094,7 +13018,7 @@ char *bSliceS(char *string, int64_t start, int64_t end) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (start > len) {
bEmptyS(string);
return(NULL);
@@ -13129,7 +13053,7 @@ char *bSliceS(char *string, int64_t start, int64_t end) {
int64_t n;
n = end - start;
if (start) {
- strncpy(string, string+start, n);
+ memmove(string, string+start, (size_t)n);
}
string[n] = 0;
}
@@ -13163,9 +13087,9 @@ char *bLSliceS(char *string, size_t stringSize, int64_t start, int64_t end) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if ((size_t)len+1 > stringSize) {
- len = stringSize - 1;
+ len = (int64_t)(stringSize - 1);
}
// compute string length without NUL
@@ -13203,7 +13127,7 @@ char *bLSliceS(char *string, size_t stringSize, int64_t start, int64_t end) {
int64_t n;
n = end - start;
if (start) {
- strncpy(string, string+start, n);
+ memmove(string, string+start, (size_t)n);
}
string[n] = 0;
}
@@ -13239,7 +13163,7 @@ char *cropS(char *string, int64_t start, int64_t end) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (start > len) {
return(NULL);
@@ -13267,12 +13191,12 @@ char *cropS(char *string, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = MALLOC((n+1) * sizeof(char));
+ l = MALLOC((size_t)(n+1) * sizeof(char));
if (!l) {
return(NULL);
}
- strLCpy(l, (n+1) * sizeof(char), string+start);
- strLCpy(string+start, len-end+1, string+end);
+ pErrorNULL(strLCpy(l, (size_t)(n+1) * sizeof(char), string+start));
+ memmove(string+start, string+end, (size_t)(len-end+1));
}
else {
// start = end, return empty string
@@ -13310,7 +13234,7 @@ char *iCropS(char **string, int64_t start, int64_t end) {
return(NULL);
}
- len = strlen(*string);
+ len = (int64_t)strlen(*string);
if (start > len) {
return(NULL);
@@ -13338,12 +13262,12 @@ char *iCropS(char **string, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = MALLOC((n+1) * sizeof(char));
+ l = MALLOC((size_t)(n+1) * sizeof(char));
if (!l) {
return(NULL);
}
- strLCpy(l, (n+1) * sizeof(char), *string+start);
- strLCpy(*string+start, len-end+1, *string+end);
+ pErrorNULL(strLCpy(l, (size_t)(n+1) * sizeof(char), *string+start));
+ memmove(*string+start, *string+end, (size_t)(len-end+1));
}
else {
// start = end, return empty string
@@ -13360,7 +13284,7 @@ char cropElemS(char *string, int64_t index) {
return(0);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (index >= len) {
return(0);
}
@@ -13377,7 +13301,7 @@ char cropElemS(char *string, int64_t index) {
string[len-1] = 0;
}
else {
- strLCpy(string+index, len - index, string+index+1);
+ memmove(string+index, string+index+1, (size_t)(len - index));
}
return(r);
@@ -13424,7 +13348,7 @@ char *insertS(const char *string, int64_t index, const char *toInsert) {
return(strdup(string));
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
index = 0;
@@ -13495,7 +13419,7 @@ char *insertNFreeS(const char *string, int64_t index, char *toInsert) {
return(r);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
index = 0;
@@ -13573,7 +13497,7 @@ char *iInsertS(char **string, int64_t index, const char *toInsert) {
return(r);
}
- len = strlen(*string);
+ len = (int64_t)strlen(*string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -13653,7 +13577,7 @@ char *iInsertNFreeS(char **string, int64_t index, char *toInsert) {
return(r);
}
- len = strlen(*string);
+ len = (int64_t)strlen(*string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -13724,7 +13648,7 @@ char *bInsertS(char *string, int64_t index, const char *toInsert) {
if (!string) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -13755,16 +13679,16 @@ char *bInsertS(char *string, int64_t index, const char *toInsert) {
if (index == 0) {
// insert at beginning
- char *s = alloca(len+1);;
+ char *s = alloca((size_t)(len+1));;
strcpy(s, string);
- bCatS(string, toInsert, s);
+ pErrorNULL(bCatS(string, toInsert, s));
}
else {
- char *s1 = alloca(index+1);;
- strLCpy(s1, index+1, string);
- char *s2 = alloca(len-index+1);;
+ char *s1 = alloca((size_t)(index+1));;
+ pErrorNULL(strLCpy(s1, (size_t)(index+1), string));
+ char *s2 = alloca((size_t)(len-index+1));;
strcpy(s2, string+index);
- bCatS(string, s1, toInsert, s2);
+ pErrorNULL(bCatS(string, s1, toInsert, s2));
}
return(string);
}
@@ -13799,7 +13723,7 @@ char *bLInsertS(char *string, size_t stringSize, int64_t index, const char *toIn
return(string);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -13830,16 +13754,16 @@ char *bLInsertS(char *string, size_t stringSize, int64_t index, const char *toIn
if (index == 0) {
// insert at beginning
- char *s = alloca(len+1);;
+ char *s = alloca((size_t)(len+1));;
strcpy(s, string);
- bLCatS(string, stringSize, toInsert, s);
+ pErrorNULL(bLCatS(string, stringSize, toInsert, s));
}
else {
- char *s1 = alloca(index+1);;
- strLCpy(s1, index+1, string);
- char *s2 = alloca(len-index+1);;
+ char *s1 = alloca((size_t)(index+1));;
+ pErrorNULL(strLCpy(s1, (size_t)(index+1), string));
+ char *s2 = alloca((size_t)(len-index+1));;
strcpy(s2, string+index);
- bLCatS(string, stringSize, s1, toInsert, s2);
+ pErrorNULL(bLCatS(string, stringSize, s1, toInsert, s2));
}
return(string);
}
@@ -13874,7 +13798,7 @@ char *injectS(const char *string, int64_t index, char toInject) {
return(strdup(inject));
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -13948,7 +13872,7 @@ char *iInjectS(char **string, int64_t index, char toInject) {
return(*string);
}
- len = strlen(*string);
+ len = (int64_t)strlen(*string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -14016,7 +13940,7 @@ char *bInjectS(char *string, int64_t index, char toInject) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -14045,14 +13969,14 @@ char *bInjectS(char *string, int64_t index, char toInject) {
if (index == 0) {
// inject at beginning
- bPrependS(string, inject);
+ pErrorNULL(bPrependS(string, inject));
}
else {
- char *s1 = alloca(index+1);;
- strLCpy(s1, index+1, string);
- char *s2 = alloca(len-index+1);;
+ char *s1 = alloca((size_t)(index+1));;
+ pErrorNULL(strLCpy(s1, (size_t)(index+1), string));
+ char *s2 = alloca((size_t)(len-index+1));;
strcpy(s2, string+index);
- bCatS(string, s1, inject, s2);
+ pErrorNULL(bCatS(string, s1, inject, s2));
}
return(string);
}
@@ -14087,7 +14011,7 @@ char *bLInjectS(char *string, size_t stringSize, int64_t index, char toInject) {
return(string);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -14116,14 +14040,14 @@ char *bLInjectS(char *string, size_t stringSize, int64_t index, char toInject) {
if (index == 0) {
// inject at beginning
- bLPrependS(string, stringSize, inject);
+ pErrorNULL(bLPrependS(string, stringSize, inject));
}
else {
- char *s1 = alloca(index+1);;
- strLCpy(s1, index+1, string);
- char *s2 = alloca(len-index+1);;
+ char *s1 = alloca((size_t)(index+1));;
+ pErrorNULL(strLCpy(s1, (size_t)(index+1), string));
+ char *s2 = alloca((size_t)(len-index+1));;
strcpy(s2, string+index);
- bLCatS(string, stringSize, s1, inject, s2);
+ pErrorNULL(bLCatS(string, stringSize, s1, inject, s2));
}
return(string);
}
@@ -14154,7 +14078,7 @@ char *delS(const char *string, int64_t start, int64_t end) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (start >= len) {
start = len;
@@ -14186,12 +14110,12 @@ char *delS(const char *string, int64_t start, int64_t end) {
// copy range to a new string
int64_t n;
n = end - start;
- s = MALLOC(len-n+1);
+ s = MALLOC((size_t)(len-n+1));
if (!s) {
return(NULL);//LCOV_EXCL_LINE
}
- strncpy(s, string, start);
- strncpy(s+start, string+start+n, len-n-start);
+ strncpy(s, string, (size_t)start);
+ strncpy(s+start, string+start+n, (size_t)(len-n-start));
s[len-n] = 0;
return(s);
@@ -14224,7 +14148,7 @@ char *iDelS(char **string, int64_t start, int64_t end) {
return(NULL);
}
- len = strlen(*string);
+ len = (int64_t)strlen(*string);
if (start >= len) {
start = len;
@@ -14256,12 +14180,12 @@ char *iDelS(char **string, int64_t start, int64_t end) {
// copy range to a new string
int64_t n;
n = end - start;
- s = MALLOC(len-n+1);
+ s = MALLOC((size_t)(len-n+1));
if (!s) {
return(NULL);
}
- strncpy(s, *string, start);
- strncpy(s+start, (*string)+start+n, len-n-start);
+ strncpy(s, *string, (size_t)start);
+ strncpy(s+start, (*string)+start+n, (size_t)(len-n-start));
s[len-n] = 0;
free(*string);
@@ -14295,7 +14219,7 @@ char *bDelS(char *string, int64_t start, int64_t end) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (start >= len) {
start = len;
@@ -14327,7 +14251,7 @@ char *bDelS(char *string, int64_t start, int64_t end) {
// copy range to a new string
int64_t n;
n = end - start;
- strncpy(string+start, string+start+n, len-n-start);
+ memmove(string+start, string+start+n, (size_t)(len-n-start));
string[len-n] = 0;
return(string);
@@ -14361,9 +14285,9 @@ char *bLDelS(char *string, size_t stringSize, int64_t start, int64_t end) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if ((size_t)len+1 > stringSize) {
- len = stringSize - 1;
+ len = (int64_t)(stringSize - 1);
}
// compute string length without NUL
@@ -14397,7 +14321,7 @@ char *bLDelS(char *string, size_t stringSize, int64_t start, int64_t end) {
// copy range to a new string
int64_t n;
n = end - start;
- strncpy(string+start, string+start+n, len-n-start);
+ memmove(string+start, string+start+n, (size_t)(len-n-start));
string[len-n] = 0;
return(string);
@@ -14425,7 +14349,7 @@ char *delElemS(const char *string, int64_t index) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (index >= len) {
return(NULL);
}
@@ -14436,12 +14360,12 @@ char *delElemS(const char *string, int64_t index) {
index = len + index;
}
- s = MALLOC(len-1+1);
+ s = MALLOC((size_t)(len-1+1));
if (!s) {
return(NULL);//LCOV_EXCL_LINE
}
- strncpy(s, string, index);
- strncpy(s+index, string+index+1, len-1-index);
+ strncpy(s, string, (size_t)index);
+ strncpy(s+index, string+index+1, (size_t)(len-1-index));
s[len-1] = 0;
return(s);
}
@@ -14469,7 +14393,7 @@ char *iDelElemS(char **string, int64_t index) {
return(NULL);
}
- len = strlen(*string);
+ len = (int64_t)strlen(*string);
if (index >= len) {
return(NULL);
}
@@ -14480,12 +14404,12 @@ char *iDelElemS(char **string, int64_t index) {
index = len + index;
}
- s = MALLOC(len-1+1);
+ s = MALLOC((size_t)(len-1+1));
if (!s) {
return(NULL);//LCOV_EXCL_LINE
}
- strncpy(s, *string, index);
- strncpy(s+index, *string+index+1, len-1-index);
+ strncpy(s, *string, (size_t)index);
+ strncpy(s+index, *string+index+1, (size_t)(len-1-index));
s[len-1] = 0;
free(*string);
@@ -14515,7 +14439,7 @@ char *bDelElemS(char *string, int64_t index) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (index >= len) {
return(NULL);
}
@@ -14526,7 +14450,7 @@ char *bDelElemS(char *string, int64_t index) {
index = len + index;
}
- strncpy(string+index, string+index+1, len-1-index);
+ memmove(string+index, string+index+1, (size_t)(len-1-index));
string[len-1] = 0;
return(string);
@@ -14556,9 +14480,9 @@ char *bLDelElemS(char *string, size_t stringSize, int64_t index) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if ((size_t)len+1 > stringSize) {
- len = stringSize - 1;
+ len = (int64_t)(stringSize - 1);
}
// compute string length without NUL
@@ -14572,7 +14496,7 @@ char *bLDelElemS(char *string, size_t stringSize, int64_t index) {
index = (int64_t)len + index;
}
- strncpy(string+index, string+index+1, len-1-index);
+ memmove(string+index, string+index+1, (size_t)(len-1-index));
string[len-1] = 0;
return(string);
@@ -14796,7 +14720,7 @@ bool icHasCharS(const char *string, char c) {
* token
* *saveptr is set to NULL when the last token is found
*/
-char *tokS(const char *s, const char *delim, char **saveptr) {
+char *tokS(char *s, const char *delim, char **saveptr) {
char *r = NULL;
// sanity checks
@@ -14804,7 +14728,7 @@ char *tokS(const char *s, const char *delim, char **saveptr) {
return(NULL);
}
if (s) {
- *saveptr = (char *) s;
+ *saveptr = s;
}
else if (!*saveptr) {
return(NULL);
@@ -14838,7 +14762,7 @@ char *tokS(const char *s, const char *delim, char **saveptr) {
* token
* *saveptr is set to NULL when the last token is found
*/
-char *icTokS(const char *s, const char *delim, char **saveptr) {
+char *icTokS(char *s, const char *delim, char **saveptr) {
char *r = NULL;
// sanity checks
@@ -14846,7 +14770,7 @@ char *icTokS(const char *s, const char *delim, char **saveptr) {
return(NULL);
}
if (s) {
- *saveptr = (char *) s;
+ *saveptr = s;
}
else if (!*saveptr) {
return(NULL);
@@ -44837,14 +44761,14 @@ static const int16_t type_table_part2[768] = {
* pointer to next UTF-8 code point
* NULL when the end string is reached or utf8 is NULL
*/
-char *nextUTF8(const char *utf8) {
+const char *nextUTF8(const char *utf8) {
if (!utf8 || !*utf8) {
return(NULL);
}
nxCodeUTF8(utf8);
- return((char *)utf8);
+ return(utf8);
}
/**
@@ -44867,7 +44791,7 @@ char *nextUTF8(const char *utf8) {
* pointer to next UTF-8 code point
* NULL when the end string is reached or utf8 is NULL or the start of the next code point is outside the string
*/
-char *bLNextUTF8(const char *string, size_t utf8Size, const char *utf8) {
+const char *bLNextUTF8(const char *string, size_t utf8Size, const char *utf8) {
if (!string || !utf8 || !utf8Size || !*utf8 || (size_t)(utf8 - string) >= utf8Size) {
return(NULL);
@@ -44878,7 +44802,7 @@ char *bLNextUTF8(const char *string, size_t utf8Size, const char *utf8) {
return(NULL);
}
- return((char *)utf8);
+ return(utf8);
}
/**
@@ -44899,7 +44823,7 @@ char *bLNextUTF8(const char *string, size_t utf8Size, const char *utf8) {
* pointer to next UTF-8 code point
* NULL when the end string is reached or utf8 is NULL or the start of the next code point is outside the string
*/
-char *findNextUTF8(const char *string, size_t utf8Size, const char *utf8) {
+const char *findNextUTF8(const char *string, size_t utf8Size, const char *utf8) {
if (!string || !utf8 || !utf8Size || !*utf8 || (size_t)(utf8 - string) >= utf8Size) {
return(NULL);
@@ -44914,7 +44838,7 @@ char *findNextUTF8(const char *string, size_t utf8Size, const char *utf8) {
return(NULL);
}
- return((char *)utf8);
+ return(utf8);
}
/**
@@ -44932,7 +44856,7 @@ char *findNextUTF8(const char *string, size_t utf8Size, const char *utf8) {
* pointer to previous UTF-8 code point
* NULL when utf8 is NULL
*/
-char *prevUTF8(const char *utf8) {
+const char *prevUTF8(const char *utf8) {
if (!utf8) {
return(NULL);
@@ -44941,7 +44865,7 @@ char *prevUTF8(const char *utf8) {
forever {
utf8--;
if ((*utf8 & 0xC0) != 0x80) {
- return((char *)utf8);
+ return(utf8);
}
}
}
@@ -44961,7 +44885,7 @@ char *prevUTF8(const char *utf8) {
* pointer to previous UTF-8 code point
* NULL when utf8 is NULL
*/
-char *bPrevUTF8(const char *string, const char *utf8) {
+const char *bPrevUTF8(const char *string, const char *utf8) {
if (!string || !utf8) {
return(NULL);
@@ -44970,12 +44894,24 @@ char *bPrevUTF8(const char *string, const char *utf8) {
return(bPrevUTF8Tiny(string, utf8));
}
-local char *bPrevUTF8Tiny(const char *string, const char *utf8) {
+local const char *bPrevUTF8Tiny(const char *string, const char *utf8) {
while (utf8 > string) {
utf8--;
if ((*utf8 & 0xC0) != 0x80) {
- return((char *)utf8);
+ return(utf8);
+ }
+ }
+
+ return(NULL);
+}
+
+local char *bPrevRWUTF8Tiny(const char *string, char *utf8) {
+
+ while (utf8 > string) {
+ utf8--;
+ if ((*utf8 & 0xC0) != 0x80) {
+ return(utf8);
}
}
@@ -44995,13 +44931,13 @@ local char *bPrevUTF8Tiny(const char *string, const char *utf8) {
* pointer to character at index
* NULL when index is outside the string
*/
-char *idx2PtrUTF8(const char *utf8, int64_t index) {
+const char *idx2PtrUTF8(const char *utf8, int64_t index) {
if (!utf8 || !*utf8 || !index) {
- return((char *)utf8);
+ return(utf8);
}
- int64_t len = strlen(utf8);
+ int64_t len = (int64_t)strlen(utf8);
if (index > 0) {
if (index > len) {
@@ -45010,7 +44946,7 @@ char *idx2PtrUTF8(const char *utf8, int64_t index) {
}
// go forward
- char *end = (char *)utf8 + len;;
+ const char *end = utf8 + len;;
int64_t i = 0;;
while (i != index) {
nxCodeUTF8(utf8);
@@ -45027,7 +44963,7 @@ char *idx2PtrUTF8(const char *utf8, int64_t index) {
}
// go from the end
- char *start = (char *)utf8;;
+ const char *start = utf8;;
utf8 += len;;
int64_t i = 0;;
while (i != index) {
@@ -45035,13 +44971,69 @@ char *idx2PtrUTF8(const char *utf8, int64_t index) {
i--;
}
}
- return((char *)utf8);
+ return(utf8);
+}
+
+/**
+ * index to pointer UTF8 encoded string - read write utf8 string (char*)
+ *
+ * Converts character index to pointer in utf8
+ *
+ * \param
+ * utf8 UTF8 encoded string
+ * \param
+ * index character index in utf8, positive or negative. -1 is the last character in the string
+ * \return
+ * pointer to character at index
+ * NULL when index is outside the string
+ */
+local char *idx2PtrRWUTF8(char *utf8, int64_t index) {
+
+ if (!utf8 || !*utf8 || !index) {
+ return(utf8);
+ }
+
+ int64_t len = (int64_t)strlen(utf8);
+
+ if (index > 0) {
+ if (index > len) {
+ // index is outside the string
+ return(NULL);
+ }
+
+ // go forward
+ char *end = utf8 + len;;
+ int64_t i = 0;;
+ while (i != index) {
+ nxCodeUTF8(utf8);
+ if (utf8 > end) {
+ return(NULL);
+ }
+ i++;
+ }
+ }
+ else {
+ if (index < -len) {
+ // index is outside the string
+ return(NULL);
+ }
+
+ // go from the end
+ char *start = utf8;;
+ utf8 += len;;
+ int64_t i = 0;;
+ while (i != index) {
+ utf8 = bPrevRWUTF8Tiny(start, utf8);;
+ i--;
+ }
+ }
+ return(utf8);
}
-char *bLIdx2PtrUTF8(const char *utf8, size_t utf8Size, int64_t index) {
+const char *bLIdx2PtrUTF8(const char *utf8, size_t utf8Size, int64_t index) {
if (!utf8 || !*utf8 || !utf8Size || !index) {
- return((char *)utf8);
+ return(utf8);
}
if (index > 0) {
@@ -45051,7 +45043,7 @@ char *bLIdx2PtrUTF8(const char *utf8, size_t utf8Size, int64_t index) {
}
// go forward
- char *end = (char *)utf8 + utf8Size;;
+ const char *end = utf8 + utf8Size;;
int64_t i = 0;;
while (i != index) {
nxCodeUTF8(utf8);
@@ -45075,7 +45067,7 @@ char *bLIdx2PtrUTF8(const char *utf8, size_t utf8Size, int64_t index) {
}
// go from the end
- char *start = (char *)utf8;;
+ const char *start = utf8;;
utf8 += len;;
int64_t i = 0;;
while (i != index) {
@@ -45083,7 +45075,7 @@ char *bLIdx2PtrUTF8(const char *utf8, size_t utf8Size, int64_t index) {
i--;
}
}
- return((char *)utf8);
+ return(utf8);
}
/**
@@ -45249,7 +45241,7 @@ int64_t bLPtr2IdxUTF8(const char *utf8, size_t utf8Size, const char *pos) {
if (pos > utf8) {
// there is at least one code point
// find next code point, works even when utf8 points inside a code point
- char *end = (char *)(utf8+utf8Size-1);;
+ const char *end = utf8+utf8Size-1;;
while ((utf8 < end) && *utf8) {
if ((*utf8++ & 0xC0) != 0x80) {
break;
@@ -45296,7 +45288,7 @@ int64_t bLPtr2NegIdxUTF8(const char *utf8, size_t utf8Size, const char *pos) {
int64_t r = 0;
- char *end = (char *)(utf8+utf8Size-1);
+ const char *end = utf8+utf8Size-1;
while ((end > pos) && (end > utf8)) {
// find previous code point
@@ -45654,7 +45646,7 @@ char *strLCpyUTF8(char *dst, size_t dstSize, const char *src) {
if (dstSize) {
r[dstSize-1] = 0;
}
- bMakeValidUTF8(r);
+ pErrorNULL(bMakeValidUTF8(r));
return(r);
}
@@ -45729,7 +45721,7 @@ char *strLCatUTF8(char *dst, size_t dstSize, const char *src) {
if (dL+sL > dstLen) {
// truncate
char *r = strncat(dst, src, dstLen - dL);
- bMakeValidUTF8(r);
+ pErrorNULL(bMakeValidUTF8(r));
return(r);
}
else {
@@ -45786,7 +45778,7 @@ char *strLNCatUTF8(char *dst, size_t dstSize, const char *src, size_t srcLen) {
if (dL+sL > dstLen) {
// truncate
char *r = strncat(dst, src, dstLen - dL);
- bMakeValidUTF8(r);
+ pErrorNULL(bMakeValidUTF8(r));
return(r);
}
else {
@@ -46050,7 +46042,7 @@ bool eqIUTF8(const char *string1, const char *string2, int64_t index) {
return(false);
}
- char *i = idx2PtrUTF8(string1, index);
+ const char *i = idx2PtrUTF8(string1, index);
return(eqIS(string1, string2, (int64_t)(i-string1)));
}
@@ -46060,7 +46052,7 @@ bool eqICharUTF8(const char *string1, char c, int64_t index) {
return(false);
}
- char *i = idx2PtrUTF8(string1, index);
+ const char *i = idx2PtrUTF8(string1, index);
return(eqICharS(string1, c, (int64_t)(i-string1)));
}
@@ -46096,7 +46088,7 @@ bool icEqCharUTF8(char c, const char *string2) {
return(false);
}
- charToS(s, tolower(c));
+ charToS(s, (char)tolower(c));
char *s2 = casefoldUTF8(string2);
bool r = (strcmp(s,s2) == 0);
free(s2);
@@ -46110,7 +46102,7 @@ bool icEqUTF8Char(const char *string1, char c) {
return(false);
}
- charToS(s, tolower(c));
+ charToS(s, (char)tolower(c));
char *s1 = casefoldUTF8(string1);
bool r = (strcmp(s1,s) == 0);
free(s1);
@@ -46266,6 +46258,8 @@ internal localeType getLocaleType(void) {
return(LOCALE_TURKIC);
}
break;
+ default:;
+ // return default value
}
return(LOCALE_NORMAL);
@@ -46381,11 +46375,11 @@ size_t bRune2CodeUTF8(char *dst, rune c) {
first = firstBytesUTF8[len-1];
if (dst) {
- rangeDownTo(i, len, 1) {
- dst[i] = (c & 0x3f) | 0x80;
+ rangeDownTo(i, (ssize_t)len, 1) {
+ dst[i] = (char)((c & 0x3f) | 0x80);
c >>= 6;
}
- dst[0] = c | first;
+ dst[0] = (char)(c | first);
}
return(len);
@@ -46526,9 +46520,9 @@ internal size_t runeFullyDecompose(rune ch, rune *result, size_t resultLen) {
return(1);
}
-internal int output_marks(const char **p_inout, char *dst, bool remove_dot) {
+internal size_t output_marks(const char **p_inout, char *dst, bool remove_dot) {
const char *p = NULL;
- int len = 0;;
+ size_t len = 0;;
p = *p_inout;
@@ -46551,9 +46545,9 @@ internal int output_marks(const char **p_inout, char *dst, bool remove_dot) {
return(len);
}
-internal int output_special_case(char *dst, int offset, int type, int which) {
+internal size_t output_special_case(char *dst, int offset, int type, int which) {
const char *p = NULL;
- int len;
+ size_t len;
p = special_case_table + offset;
@@ -46874,6 +46868,8 @@ internal size_t _lowerUTF8(char *dst, const char *utf8, localeType lcl) {
case 0x0128:
len += bRune2CodeUTF8(dst ? dst + len : NULL, 0x0303);
break;
+ default:;
+ // do nothing
}
}
else if (lcl == LOCALE_LITHUANIAN && (c == 'I' || c == 'J' || c == 0x012e) && has_more_above (utf8)) {
@@ -47041,7 +47037,7 @@ char *casefoldUTF8(const char *utf8) {
forever {
int half = (start + end) / 2;
if (ch == casefold_table[half].ch) {
- iAppendS(&r, casefold_table[half].data);
+ pErrorNULL(iAppendS(&r, casefold_table[half].data));
goto next;
}
else if (half == start) {
@@ -47057,8 +47053,8 @@ char *casefoldUTF8(const char *utf8) {
}
char code[8] = {0, 0, 0, 0, 0, 0, 0, 0};
- bRune2CodeUTF8(code, tolowerUTF8(ch));
- iAppendS(&r, code);
+ pError0(bRune2CodeUTF8(code, tolowerUTF8(ch)));
+ pErrorNULL(iAppendS(&r, code));
next:
nxCodeUTF8(utf8);
@@ -47302,7 +47298,7 @@ rune getUTF8(const char *string, int64_t index) {
return(0);
}
- len = lenUTF8(string);
+ len = (int64_t)lenUTF8(string);
if (index >= len) {
return(0);
}
@@ -47313,7 +47309,7 @@ rune getUTF8(const char *string, int64_t index) {
index = len + index;
}
- char *c = idx2PtrUTF8(string, index);
+ const char *c = idx2PtrUTF8(string, index);
return(code2RuneUTF8(c));
}
@@ -47333,7 +47329,7 @@ char *setUTF8(char *string, int64_t index, rune c) {
return(NULL);
}
- len = lenUTF8(string);
+ len = (int64_t)lenUTF8(string);
if (index >= len) {
return(NULL);
}
@@ -47344,8 +47340,8 @@ char *setUTF8(char *string, int64_t index, rune c) {
index = len + index;
}
- char *p = idx2PtrUTF8(string, index);
- bRune2CodeUTF8(p, c);
+ char *p = idx2PtrRWUTF8(string, index);
+ pError0(bRune2CodeUTF8(p, c));
// TODO check code point length and shift string end when necessary
return(string);
}
@@ -47378,7 +47374,7 @@ char *sliceUTF8(const char *string, int64_t start, int64_t end) {
return(NULL);
}
- len = lenUTF8(string);
+ len = (int64_t)lenUTF8(string);
if (start > len) {
return(NULL);
@@ -47410,9 +47406,9 @@ char *sliceUTF8(const char *string, int64_t start, int64_t end) {
// copy range to a new string
const char *startp = idx2PtrUTF8(string, start);
const char *endp = idx2PtrUTF8(string, end);
- int64_t n;
- n = endp - startp;
- s = MALLOC(n+1);
+ size_t n;
+ n = (size_t)(endp - startp);
+ s = MALLOC((n+1));
if (!s) {
return(NULL);//LCOV_EXCL_LINE
}
@@ -47449,7 +47445,7 @@ char *iSliceUTF8(char **string, int64_t start, int64_t end) {
return(NULL);
}
- len = lenUTF8(*string);
+ len = (int64_t)lenUTF8(*string);
if (start > len) {
free(*string);
@@ -47485,10 +47481,10 @@ char *iSliceUTF8(char **string, int64_t start, int64_t end) {
else {
// start < end < len
// copy range to a new string
- char *startp = idx2PtrUTF8(*string, start);
- char *endp = idx2PtrUTF8(*string, end);
- int64_t n;
- n = endp - startp;
+ const char *startp = idx2PtrUTF8(*string, start);
+ const char *endp = idx2PtrUTF8(*string, end);
+ size_t n;
+ n = (size_t)(endp - startp);
s = MALLOC(n+1);
if (!s) {
return(NULL);
@@ -47527,7 +47523,7 @@ char *bSliceUTF8(char *string, int64_t start, int64_t end) {
return(NULL);
}
- len = lenUTF8(string);
+ len = (int64_t)lenUTF8(string);
if (start > len) {
bEmptyS(string);
@@ -47560,11 +47556,11 @@ char *bSliceUTF8(char *string, int64_t start, int64_t end) {
else {
// start < end < len
// copy range to a new string
- char *startp = idx2PtrUTF8(string, start);
- char *endp = idx2PtrUTF8(string, end);
- int64_t n;
- n = endp - startp;
- strncpy(string, string+(size_t)(startp-string), n);
+ const char *startp = idx2PtrUTF8(string, start);
+ const char *endp = idx2PtrUTF8(string, end);
+ size_t n;
+ n = (size_t)(endp - startp);
+ memmove(string, string+(size_t)(startp-string), n);
string[n] = 0;
}
@@ -47598,9 +47594,9 @@ char *bLSliceUTF8(char *string, size_t stringSize, int64_t start, int64_t end) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if ((size_t)len+1 > stringSize) {
- len = stringSize - 1;
+ len = (int64_t)(stringSize - 1);
}
if (start > len) {
@@ -47628,8 +47624,8 @@ char *bLSliceUTF8(char *string, size_t stringSize, int64_t start, int64_t end) {
return(NULL);
}
- char *startp = bLIdx2PtrUTF8(string, stringSize, start);
- char *endp = bLIdx2PtrUTF8(string, stringSize, end);
+ const char *startp = bLIdx2PtrUTF8(string, stringSize, start);
+ const char *endp = bLIdx2PtrUTF8(string, stringSize, end);
size_t starto = (size_t)(startp-string);
size_t endo = (size_t)(endp-string);
@@ -47641,7 +47637,7 @@ char *bLSliceUTF8(char *string, size_t stringSize, int64_t start, int64_t end) {
return(NULL);
}
if (endo > stringSize) {
- end = stringSize;
+ end = (int64_t)stringSize;
}
if (start == 0) {
starto = 0;
@@ -47657,9 +47653,9 @@ char *bLSliceUTF8(char *string, size_t stringSize, int64_t start, int64_t end) {
else {
// start < end < stringSize
// copy range to a new string
- int64_t n;
- n = endp - startp;
- strncpy(string, string+starto, n);
+ size_t n;
+ n = (size_t)(endp - startp);
+ memmove(string, string+starto, n);
string[n] = 0;
}
@@ -47696,7 +47692,7 @@ char *insertUTF8(const char *string, int64_t index, const char *toInsert) {
return(strdup(toInsert));
}
- len = lenUTF8(string);
+ len = (int64_t)lenUTF8(string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -47730,10 +47726,10 @@ char *insertUTF8(const char *string, int64_t index, const char *toInsert) {
return(catS(toInsert, string));
}
- size_t offset = (size_t)(idx2PtrUTF8(string, index) - string);
- char *s1 = sliceS(string, 0, offset);
- char *s2 = sliceS(string, offset, 0);
- r = catS(s1, toInsert, s2);
+ int64_t offset = idx2PtrUTF8(string, index) - string;
+ char *s1 = sliceS(string, 0, offset);
+ char *s2 = sliceS(string, offset, 0);
+ r = catS(s1, toInsert, s2);
freeManyS(s1,s2);
return(r);
@@ -47774,7 +47770,7 @@ char *insertNFreeUTF8(const char *string, int64_t index, char *toInsert) {
return(r);
}
- len = lenUTF8(string);
+ len = (int64_t)lenUTF8(string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -47811,10 +47807,10 @@ char *insertNFreeUTF8(const char *string, int64_t index, char *toInsert) {
return(r);
}
- size_t offset = (size_t)(idx2PtrUTF8(string, index) - string);
- char *s1 = sliceS(string, 0, offset);
- char *s2 = sliceS(string, offset, 0);
- r = catS(s1, toInsert, s2);
+ int64_t offset = idx2PtrUTF8(string, index) - string;
+ char *s1 = sliceS(string, 0, offset);
+ char *s2 = sliceS(string, offset, 0);
+ r = catS(s1, toInsert, s2);
freeManyS(s1,s2, toInsert);
return(r);
@@ -47855,7 +47851,7 @@ char *iInsertUTF8(char **string, int64_t index, const char *toInsert) {
return(r);
}
- len = lenUTF8(*string);
+ len = (int64_t)lenUTF8(*string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -47889,10 +47885,10 @@ char *iInsertUTF8(char **string, int64_t index, const char *toInsert) {
r = catS(toInsert, *string);
}
else {
- size_t offset = (size_t)(idx2PtrUTF8(*string, index) - *string);
- char *s1 = sliceS(*string, 0, offset);
- char *s2 = sliceS(*string, offset, 0);
- r = catS(s1, toInsert, s2);
+ int64_t offset = idx2PtrUTF8(*string, index) - *string;
+ char *s1 = sliceS(*string, 0, offset);
+ char *s2 = sliceS(*string, offset, 0);
+ r = catS(s1, toInsert, s2);
freeManyS(s1,s2);
}
@@ -47937,7 +47933,7 @@ char *iInsertNFreeUTF8(char **string, int64_t index, char *toInsert) {
return(r);
}
- len = lenUTF8(*string);
+ len = (int64_t)lenUTF8(*string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -47972,10 +47968,10 @@ char *iInsertNFreeUTF8(char **string, int64_t index, char *toInsert) {
r = catS(toInsert, *string);
}
else {
- size_t offset = (size_t)(idx2PtrUTF8(*string, index) - *string);
- char *s1 = sliceS(*string, 0, offset);
- char *s2 = sliceS(*string, offset, 0);
- r = catS(s1, toInsert, s2);
+ int64_t offset = idx2PtrUTF8(*string, index) - *string;
+ char *s1 = sliceS(*string, 0, offset);
+ char *s2 = sliceS(*string, offset, 0);
+ r = catS(s1, toInsert, s2);
freeManyS(s1,s2);
}
free(toInsert);
@@ -48011,7 +48007,7 @@ char *bInsertUTF8(char *string, int64_t index, const char *toInsert) {
return(NULL);
}
- len = lenUTF8(string);
+ len = (int64_t)lenUTF8(string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -48042,17 +48038,17 @@ char *bInsertUTF8(char *string, int64_t index, const char *toInsert) {
if (index == 0) {
// insert at beginning
- char *s = alloca(len+1);;
+ char *s = alloca((size_t)(len+1));
strcpy(s, string);
- bCatS(string, toInsert, s);
+ pErrorNULL(bCatS(string, toInsert, s));
}
else {
- size_t offset = (size_t)(idx2PtrUTF8(string, index) - string);
- char *s1 = alloca(offset+1);;
- strLCpy(s1, offset+1, string);
- char *s2 = alloca(len-offset+1);;
+ int64_t offset = idx2PtrUTF8(string, index) - string;
+ char *s1 = alloca((size_t)(offset+1));
+ pErrorNULL(strLCpy(s1, (size_t)(offset+1), string));
+ char *s2 = alloca((size_t)(len-offset+1));
strcpy(s2, string+offset);
- bCatS(string, s1, toInsert, s2);
+ pErrorNULL(bCatS(string, s1, toInsert, s2));
}
return(string);
}
@@ -48088,7 +48084,7 @@ char *bLInsertUTF8(char *string, size_t stringSize, int64_t index, const char *t
return(string);
}
- len = bLLenUTF8(string, stringSize);
+ len = (int64_t)bLLenUTF8(string, stringSize);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -48119,17 +48115,17 @@ char *bLInsertUTF8(char *string, size_t stringSize, int64_t index, const char *t
if (index == 0) {
// insert at beginning
- char *s = alloca(len+1);;
+ char *s = alloca((size_t)(len+1));;
strcpy(s, string);
- bLCatS(string, stringSize, toInsert, s);
+ pErrorNULL(bLCatS(string, stringSize, toInsert, s));
}
else {
- size_t offset = (size_t)(bLIdx2PtrUTF8(string, stringSize, index) - string);
- char *s1 = alloca(offset+1);;
- strLCpy(s1, offset+1, string);
- char *s2 = alloca(len-offset+1);;
+ int64_t offset = bLIdx2PtrUTF8(string, stringSize, index) - string;
+ char *s1 = alloca((size_t)(offset+1));
+ pErrorNULL(strLCpy(s1, (size_t)(offset+1), string));
+ char *s2 = alloca((size_t)(len-offset+1));
strcpy(s2, string+offset);
- bLCatS(string, stringSize, s1, toInsert, s2);
+ pErrorNULL(bLCatS(string, stringSize, s1, toInsert, s2));
}
return(string);
}
@@ -48161,7 +48157,7 @@ char *delUTF8(const char *string, int64_t start, int64_t end) {
return(NULL);
}
- len = lenUTF8(string);
+ len = (int64_t)lenUTF8(string);
if (start >= len) {
start = len;
@@ -48191,18 +48187,18 @@ char *delUTF8(const char *string, int64_t start, int64_t end) {
// start < end < len
// copy range to a new string
- len = strlen(string);
+ len = (int64_t)strlen(string);
const char *startp = idx2PtrUTF8(string, start);
const char *endp = idx2PtrUTF8(string, end);
size_t starto = (size_t)(startp-string);
int64_t n;
n = endp - startp;
- s = MALLOC(len-n+1);
+ s = MALLOC((size_t)(len-n+1));
if (!s) {
return(NULL);//LCOV_EXCL_LINE
}
strncpy(s, string, starto);
- strncpy(s+starto, string+starto+n, len-n-starto);
+ strncpy(s+starto, string+starto+n, (size_t)(len-n)-starto);
s[len-n] = 0;
return(s);
@@ -48236,7 +48232,7 @@ char *iDelUTF8(char **string, int64_t start, int64_t end) {
return(NULL);
}
- len = lenUTF8(*string);
+ len = (int64_t)lenUTF8(*string);
if (start >= len) {
start = len;
@@ -48266,18 +48262,18 @@ char *iDelUTF8(char **string, int64_t start, int64_t end) {
// start < end < len
// copy range to a new string
- len = strlen(*string);
- char *startp = idx2PtrUTF8(*string, start);
- char *endp = idx2PtrUTF8(*string, end);
- size_t starto = (size_t)(startp-*string);
+ len = (int64_t)strlen(*string);
+ const char *startp = idx2PtrUTF8(*string, start);
+ const char *endp = idx2PtrUTF8(*string, end);
+ size_t starto = (size_t)(startp-*string);
int64_t n;
n = endp - startp;
- s = MALLOC(len-n+1);
+ s = MALLOC((size_t)(len-n+1));
if (!s) {
return(NULL);
}
strncpy(s, *string, starto);
- strncpy(s+starto, (*string)+starto+n, len-n-starto);
+ strncpy(s+starto, (*string)+starto+n, (size_t)(len-n)-starto);
s[len-n] = 0;
free(*string);
@@ -48312,7 +48308,7 @@ char *bDelUTF8(char *string, int64_t start, int64_t end) {
return(NULL);
}
- len = lenUTF8(string);
+ len = (int64_t)lenUTF8(string);
if (start >= len) {
start = len;
@@ -48342,13 +48338,13 @@ char *bDelUTF8(char *string, int64_t start, int64_t end) {
// start < end < len
// copy range to a new string
- len = strlen(string);
+ len = (int64_t)strlen(string);
const char *startp = idx2PtrUTF8(string, start);
const char *endp = idx2PtrUTF8(string, end);
size_t starto = (size_t)(startp-string);
int64_t n;
n = endp - startp;
- strncpy(string+starto, string+starto+n, len-n-starto);
+ memmove(string+starto, string+starto+n, (size_t)(len-n)-starto);
string[len-n] = 0;
return(string);
@@ -48383,9 +48379,9 @@ char *bLDelUTF8(char *string, size_t stringSize, int64_t start, int64_t end) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if ((size_t)len+1 > stringSize) {
- len = stringSize - 1;
+ len = (int64_t)(stringSize - 1);
}
// compute string length without NUL
@@ -48411,8 +48407,8 @@ char *bLDelUTF8(char *string, size_t stringSize, int64_t start, int64_t end) {
return(NULL);
}
- char *startp = bLIdx2PtrUTF8(string, stringSize, start);
- char *endp = bLIdx2PtrUTF8(string, stringSize, end);
+ const char *startp = bLIdx2PtrUTF8(string, stringSize, start);
+ const char *endp = bLIdx2PtrUTF8(string, stringSize, end);
size_t starto = (size_t)(startp-string);
@@ -48434,7 +48430,7 @@ char *bLDelUTF8(char *string, size_t stringSize, int64_t start, int64_t end) {
// copy range to a new string
int64_t n;
n = endp - startp;
- strncpy(string+starto, string+starto+n, len-n-starto);
+ memmove(string+starto, string+starto+n, (size_t)(len-n)-starto);
string[len-n] = 0;
return(string);
@@ -48611,8 +48607,8 @@ internal int icListSortUTF8Cmp(const void * a, const void * b) {
if (a && !b) {
return(1);
}
- char *A = casefoldUTF8(*(char **)a);
- char *B = casefoldUTF8(*(char **)b);
+ char *A = casefoldUTF8(*(char *const*)a);
+ char *B = casefoldUTF8(*(char *const*)b);
int r = strcmp(A,B);
free(A);
free(B);
@@ -48761,7 +48757,7 @@ ssize_t icListIndexOfUTF8(char **list, const char *string) {
}
}
if (found) {
- return(i);
+ return((ssize_t)i);
}
else {
return(-1);
@@ -48792,7 +48788,7 @@ ssize_t icListBinarySearchUTF8(char **list, const char *string) {
char *s = casefoldUTF8(string);
- last = listLengthS(list) - 1;
+ last = (ssize_t)(listLengthS(list) - 1);
while (first <= last) {
middle = (first+last)/2;
char *m = casefoldUTF8(list[middle]);
@@ -48840,7 +48836,7 @@ char **icListUniqUTF8(char **list) {
listEmptyS(r);
return(r);
}
- listPushS(&r, list[0]);
+ pErrorNULL(listPushS(&r, list[0]));
// one element list
if (len == 1) {
return(r);
@@ -48848,7 +48844,7 @@ char **icListUniqUTF8(char **list) {
// push element to new list if it is not already in new list
forEachCharP(list, e) {
if (icListIndexOfUTF8(r, *e) == -1) {
- listPushS(&r, *e);
+ pErrorNULL(listPushS(&r, *e));
}
}
return(r);
@@ -48882,13 +48878,13 @@ char **iicListUniqUTF8(char ***list) {
}
else if (len < 2) {
// one element list
- iListPushS(&r, (*list)[0]);
+ pErrorNULL(iListPushS(&r, (*list)[0]));
}
else {
// push element to new list if it is not already in new list
forEachCharP(*list, e) {
if (icListIndexOfUTF8(r, *e) == -1) {
- iListPushS(&r, *e);
+ pErrorNULL(iListPushS(&r, *e));
}
else {
free(*e);
@@ -49133,7 +49129,7 @@ char **listCreateSF(const char *paramType, ...) {
va_start(pl, paramType);
paramType = va_arg(pl, char *);
while (paramType) {
- listPushS(&l, paramType);
+ pErrorNULL(listPushS(&l, paramType));
paramType = va_arg(pl, char *);
}
va_end(pl);
@@ -49171,7 +49167,44 @@ char **listFromArrayS(char **array, size_t size) {
for (size_t i = 0 ; i < size ; i++) {
if (array[i]) {
// remove NULL strings
- listPushS(&r, array[i]);
+ pErrorNULL(listPushS(&r, array[i]));
+ }
+ }
+ return(r);
+}
+
+/**
+ * list From Const Array String
+ *
+ * copy array of 'size' strings to a new list
+ * NULL strings are not copied to the list
+ *
+ * \param
+ * array of strings
+ * \param
+ * size - number of strings in the array
+ * \return
+ * list
+ * empty list when size is 0
+ * NULL when array is NULL
+ */
+char **listFromCArrayS(const char **array, size_t size) {
+ char **r = NULL;
+
+ // sanity checks
+ if (!array) {
+ return(NULL);
+ }
+ if (!size) {
+ listEmptyS(r);
+ return(r);
+ }
+
+ // copy array content
+ for (size_t i = 0 ; i < size ; i++) {
+ if (array[i]) {
+ // remove NULL strings
+ pErrorNULL(listPushS(&r, array[i]));
}
}
return(r);
@@ -49294,7 +49327,7 @@ char **iListPushS(char ***list, char *s) {
*/
char *listPopS(char ***list) {
char *s = NULL;
- uint64_t len;
+ size_t len;
// sanity checks
if (!list) {
@@ -49348,7 +49381,7 @@ char **listPrependS(char ***list, const char *s) {
}
else {
// realloc list and copy s to first element
- uint64_t len;
+ size_t len;
len = listLengthS(*list);
char **tmp = REALLOC(*list, (len+2) * sizeof(char *));
if (!tmp) {
@@ -49407,7 +49440,7 @@ char **iListPrependS(char ***list, char *s) {
}
else {
// realloc list and copy s to first element
- uint64_t len;
+ size_t len;
len = listLengthS(*list);
char **tmp = REALLOC(*list, (len+2) * sizeof(char *));
if (!tmp) {
@@ -49438,7 +49471,7 @@ char **iListPrependS(char ***list, char *s) {
*/
char *listDequeueS(char ***list) {
char *s = NULL;
- uint64_t len;
+ size_t len;
// sanity checks
if (!list) {
@@ -49524,6 +49557,29 @@ size_t listLengthS(char **list) {
}
/**
+ * const list Length String
+ * return number of elements until the first NULL element
+ *
+ * \param
+ * list
+ * \return
+ * number of element until first NULL element
+ * 0 when list is NULL
+ */
+size_t listLengthCS(const char **list) {
+ size_t r = 0;;
+
+ // sanity checks
+ if (!list) {
+ return(0);
+ }
+ forEachCCharP(list, i) {
+ r++;
+ }
+ return(r);
+}
+
+/**
* list String Length String
*
* \param
@@ -49541,7 +49597,7 @@ ssize_t listStrLengthS(char **list) {
}
forEachS(list, i) {
- r += strlen(i);
+ r += (ssize_t)strlen(i);
}
return(r);
@@ -49568,7 +49624,7 @@ ssize_t listIntIndexS(char **list, int64_t index) {
return(-1);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (index >= len) {
return(-1);
}
@@ -49605,7 +49661,7 @@ char **listAddrS(char **list, int64_t index) {
return(NULL);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (index >= len) {
return(NULL);
}
@@ -49613,10 +49669,10 @@ char **listAddrS(char **list, int64_t index) {
return(NULL);
}
if (index < 0) {
- r = len + index;
+ r = (size_t)(len + index);
}
else {
- r = index;
+ r = (size_t)(index);
}
return((list+r));
}
@@ -49642,7 +49698,7 @@ char *listGetS(char **list, int64_t index) {
return(NULL);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (index >= len) {
return(NULL);
}
@@ -49676,7 +49732,76 @@ char *iListGetS(char **list, int64_t index) {
return(NULL);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
+ if (index >= len) {
+ return(NULL);
+ }
+ if (index < -len) {
+ return(NULL);
+ }
+ if (index < 0) {
+ index = len + index;
+ }
+
+ return(list[index]);
+}
+
+/**
+ * const list Get String
+ * duplicate string at given index
+ * index can be negative
+ *
+ * \param
+ * list
+ * \param
+ * index: index in list, must be inside the list
+ * \return
+ * duplicated string (you must free the pointer)
+ * NULL when list is NULL or index is not set correctly
+ */
+char *listGetCS(const char **list, int64_t index) {
+ int64_t len;
+
+ // sanity checks
+ if (!list) {
+ return(NULL);
+ }
+
+ len = (int64_t)listLengthCS(list);
+ if (index >= len) {
+ return(NULL);
+ }
+ if (index < -len) {
+ return(NULL);
+ }
+ if (index < 0) {
+ index = len + index;
+ }
+
+ return(strdup(list[index]));
+}
+
+/**
+ * const list Get String
+ * index can be negative
+ *
+ * \param
+ * list
+ * \param
+ * index: index in list, must be inside the list
+ * \return
+ * string
+ * NULL when list is NULL or index is not set correctly
+ */
+const char *iListGetCS(const char **list, int64_t index) {
+ int64_t len;
+
+ // sanity checks
+ if (!list) {
+ return(NULL);
+ }
+
+ len = (int64_t)listLengthCS(list);
if (index >= len) {
return(NULL);
}
@@ -49716,7 +49841,7 @@ char **listSetS(char **list, int64_t index, const char *s) {
return(NULL);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (index >= len) {
return(NULL);
}
@@ -49764,7 +49889,7 @@ char **iListSetS(char **list, int64_t index, char *s) {
return(NULL);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (index >= len) {
return(NULL);
}
@@ -49800,7 +49925,7 @@ char **listSwapS(char **list, int64_t index1, int64_t index2) {
return(NULL);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (index1 >= len) {
return(NULL);
}
@@ -49850,7 +49975,7 @@ char **iListSwapS(char **list, int64_t index1, int64_t index2) {
return(NULL);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (index1 >= len) {
return(NULL);
}
@@ -49881,6 +50006,7 @@ char **iListSwapS(char **list, int64_t index1, int64_t index2) {
/**
* split string with delim string
+ * when updating this function, also update splitS (identical to split)
* return list
*
* \param
@@ -49905,7 +50031,7 @@ char **split(const char *string, const char* delim) {
if (!*delim || !*string) {
// empty delimiter empty string, return string in a list
- listPushS(&r, string);
+ pErrorNULL(listPushS(&r, string));
return(r);
}
@@ -49915,7 +50041,7 @@ char **split(const char *string, const char* delim) {
line = workingString;
while (strlen(workingString) != 0) {
token = tokS(line, delim, &workingString);
- listPushS(&r, token);
+ pErrorNULL(listPushS(&r, token));
// mac os sets workingString to NULL at the end
if (!workingString) {
break; //LCOV_EXCL_LINE
@@ -49931,7 +50057,55 @@ char **split(const char *string, const char* delim) {
size_t len = strlen(string);
size_t lenD = strlen(delim);
if (strEq(string+(len-lenD), delim)) {
- listPushS(&r, "");
+ pErrorNULL(listPushS(&r, ""));
+ }
+
+ return(r);
+}
+
+// splitS is identical to split
+// to make the interface uniform
+char **splitS(const char *string, const char* delim) {
+ char *startString = NULL;
+ char *workingString = NULL;
+ char *line = NULL;
+ char *token = NULL;
+ char **r = NULL;
+
+ // sanity checks
+ if (!string || !delim) {
+ return(NULL);
+ }
+
+ if (!*delim || !*string) {
+ // empty delimiter empty string, return string in a list
+ pErrorNULL(listPushS(&r, string));
+ return(r);
+ }
+
+ // split using strtok_r
+ startString = strdup(string);
+ workingString = startString;
+ line = workingString;
+ while (strlen(workingString) != 0) {
+ token = tokS(line, delim, &workingString);
+ pErrorNULL(listPushS(&r, token));
+ // mac os sets workingString to NULL at the end
+ if (!workingString) {
+ break; //LCOV_EXCL_LINE
+ }
+ // first parameter should be NULL in next strtok_r calls
+ line = NULL;
+ }
+ free(startString);
+
+ // check if delim is at the end of string
+ // if yes, add an empty string in the result
+ // ["one",""] = split "one/" "/"
+ size_t len = strlen(string);
+ size_t lenD = strlen(delim);
+ if (strEq(string+(len-lenD), delim)) {
+ pErrorNULL(listPushS(&r, ""));
}
return(r);
@@ -49945,6 +50119,7 @@ char **splitChar(const char *string, char delim) {
/**
* ignore case split string with delim string
+ * when updating this function, also update icSplitS (identical to icSplit)
* return list
*
* \param
@@ -49969,7 +50144,7 @@ char **icSplit(const char *string, const char* delim) {
if (!*delim || !*string) {
// empty delimiter empty string, return string in a list
- listPushS(&r, string);
+ pErrorNULL(listPushS(&r, string));
return(r);
}
@@ -49979,7 +50154,7 @@ char **icSplit(const char *string, const char* delim) {
line = workingString;
while (strlen(workingString) != 0) {
token = icTokS(line, delim, &workingString);
- listPushS(&r, token);
+ pErrorNULL(listPushS(&r, token));
// mac os sets workingString to NULL at the end
if (!workingString) {
break; //LCOV_EXCL_LINE
@@ -49995,7 +50170,55 @@ char **icSplit(const char *string, const char* delim) {
size_t len = strlen(string);
size_t lenD = strlen(delim);
if (icEqS(string+(len-lenD), delim)) {
- listPushS(&r, "");
+ pErrorNULL(listPushS(&r, ""));
+ }
+
+ return(r);
+}
+
+// icSplitS is identical to icSplit
+// to make the interface uniform
+char **icSplitS(const char *string, const char* delim) {
+ char *startString = NULL;
+ char *workingString = NULL;
+ char *line = NULL;
+ char *token = NULL;
+ char **r = NULL;
+
+ // sanity checks
+ if (!string || !delim) {
+ return(NULL);
+ }
+
+ if (!*delim || !*string) {
+ // empty delimiter empty string, return string in a list
+ pErrorNULL(listPushS(&r, string));
+ return(r);
+ }
+
+ // split using strtok_r
+ startString = strdup(string);
+ workingString = startString;
+ line = workingString;
+ while (strlen(workingString) != 0) {
+ token = icTokS(line, delim, &workingString);
+ pErrorNULL(listPushS(&r, token));
+ // mac os sets workingString to NULL at the end
+ if (!workingString) {
+ break; //LCOV_EXCL_LINE
+ }
+ // first parameter should be NULL in next strtok_r calls
+ line = NULL;
+ }
+ free(startString);
+
+ // check if delim is at the end of string
+ // if yes, add an empty string in the result
+ // ["one",""] = split "one/" "/"
+ size_t len = strlen(string);
+ size_t lenD = strlen(delim);
+ if (icEqS(string+(len-lenD), delim)) {
+ pErrorNULL(listPushS(&r, ""));
}
return(r);
@@ -50031,11 +50254,11 @@ ssize_t joinLength(char **list, const char* delim) {
bool isFirstElem = true;
forEachS(list, i) {
if (isFirstElem) {
- r += strlen(i);
+ r += (ssize_t)strlen(i);
isFirstElem = no;
}
else {
- r += strlen(i) + delimLen;
+ r += (ssize_t)(strlen(i) + delimLen);
}
}
@@ -50044,6 +50267,7 @@ ssize_t joinLength(char **list, const char* delim) {
/**
* join list, the elements are seperated with delim in the resulting string
+ * when updating this function, also update joinS (identical to join)
*
* \param
* list
@@ -50086,6 +50310,85 @@ char *join(char **list, const char* delim) {
return(r);
}
+// joinS is identical to join
+// to make the interface uniform
+char *joinS(char **list, const char* delim) {
+ char *r = NULL;
+
+ // sanity checks
+ if (!list || !delim) {
+ return(NULL);
+ }
+
+ forEachCharP(list, e) {
+ if (!r) {
+ r = strdup(*e);
+ }
+ else {
+ char *tmp;
+ tmp = REALLOC(r, strlen(r) + strlen(delim) + 1);
+ if (!tmp) {
+ free(r);
+ return(NULL);//LCOV_EXCL_LINE
+ }
+ r = tmp;
+ strcat(r, delim);
+ tmp = REALLOC(r, strlen(r) + strlen(*e) + 1);
+ if (!tmp) {
+ free(r);
+ return(NULL);//LCOV_EXCL_LINE
+ }
+ r = tmp;
+ strcat(r, *e);
+ }
+ }
+ return(r);
+}
+
+/**
+ * join list, the elements are seperated with delim in the resulting string
+ *
+ * \param
+ * list
+ * \param
+ * delim: string seperator
+ * \return
+ * joined string (you must free the pointer)
+ * NULL when list or delim are NULL
+ */
+char *joinCS(const char **list, const char* delim) {
+ char *r = NULL;
+
+ // sanity checks
+ if (!list || !delim) {
+ return(NULL);
+ }
+
+ forEachCCharP(list, e) {
+ if (!r) {
+ r = strdup(*e);
+ }
+ else {
+ char *tmp;
+ tmp = REALLOC(r, strlen(r) + strlen(delim) + 1);
+ if (!tmp) {
+ free(r);
+ return(NULL);//LCOV_EXCL_LINE
+ }
+ r = tmp;
+ strcat(r, delim);
+ tmp = REALLOC(r, strlen(r) + strlen(*e) + 1);
+ if (!tmp) {
+ free(r);
+ return(NULL);//LCOV_EXCL_LINE
+ }
+ r = tmp;
+ strcat(r, *e);
+ }
+ }
+ return(r);
+}
+
char *joinChar(char **list, char delim) {
charToS(s, delim);
@@ -50117,7 +50420,7 @@ char *bJoin(char *string, char **list, const char* delim) {
strcpy(string, *e);
}
else {
- bAppendManyS(string, delim, *e);
+ pErrorNULL(bAppendManyS(string, delim, *e));
}
}
return(string);
@@ -50156,10 +50459,10 @@ char *bLJoin(char *string, size_t stringSize, char **list, const char* delim) {
enumerateCharP(list, e, i) {
if (!i) {
- strLCpy(string, stringSize, *e);
+ pErrorNULL(strLCpy(string, stringSize, *e));
}
else {
- bLAppendManyS(string, stringSize, delim, *e);
+ pErrorNULL(bLAppendManyS(string, stringSize, delim, *e));
}
}
return(string);
@@ -50211,12 +50514,12 @@ char **extractS(const char *string, const char* delim1, const char* delim2) {
}
// remove first element
- iListSliceS(&tmp, 1, 0);
+ pErrorNULL(iListSliceS(&tmp, 1, 0));
forEachCharP(tmp, e) {
char **tmp2 = split(*e, delim2);
if (listLengthS(tmp2) > 1) {
- listPushS(&r, tmp2[0]);
+ pErrorNULL(listPushS(&r, tmp2[0]));
}
listFreeS(tmp2);
}
@@ -50284,12 +50587,12 @@ char **icExtractS(const char *string, const char* delim1, const char* delim2) {
}
// remove first element
- iListSliceS(&tmp, 1, 0);
+ pErrorNULL(iListSliceS(&tmp, 1, 0));
forEachCharP(tmp, e) {
char **tmp2 = icSplit(*e, delim2);
if (listLengthS(tmp2) > 1) {
- listPushS(&r, tmp2[0]);
+ pErrorNULL(listPushS(&r, tmp2[0]));
}
listFreeS(tmp2);
}
@@ -50352,6 +50655,40 @@ char **listDupS(char **list) {
}
/**
+ * const list Duplicate String
+ *
+ * \param
+ * list
+ * \return
+ * duplicated list (you must free the pointer with listFreeS)
+ * NULL when list is NULL
+ */
+char **listDupCS(const char **list) {
+ char **l = NULL;
+ size_t len;
+
+ // sanity checks
+ if (!list) {
+ return(NULL);
+ }
+
+ len = listLengthCS(list);
+ l = MALLOC((len+1) * sizeof(char *));
+ if (!l) {
+ return(NULL);//LCOV_EXCL_LINE
+ }
+
+ // last element is NULL
+ l[len] = NULL;
+
+ // copy each element
+ enumerateCCharP(list, e, i) {
+ l[i] = strdup(*e);
+ }
+ return(l);
+}
+
+/**
* list Duplicate String
*
* copy pointers to new list
@@ -50480,7 +50817,7 @@ char **listCatSF(char **paramType, ...) {
va_start(pl, paramType);
paramType = va_arg(pl, char **);
while (paramType) {
- listAppendS(&r, paramType);
+ pErrorNULL(listAppendS(&r, paramType));
paramType = va_arg(pl, char **);
}
va_end(pl);
@@ -50798,6 +51135,57 @@ char **listAddS(char **list1, char **list2) {
/**
+ * const list Add String
+ * add list1 and list2 in a new list
+ *
+ * \param
+ * list1
+ * \param
+ * list2
+ * \return
+ * new list with list1 and list2 (you must free the pointer with listFreeS)
+ * NULL when list1 and list2 are NULL
+ */
+char **listAddCS(char **list1, const char **list2) {
+ char **l = NULL;
+ char **r = NULL;
+ size_t len1;
+ size_t len2;
+
+ // sanity checks
+ if (!list1 && !list2) {
+ return(NULL);
+ }
+ if (!list1) {
+ // copy list2
+ return(listDupCS(list2));
+ }
+ if (!list2) {
+ // copy list1
+ return(listDupS(list1));
+ }
+ // duplicate list1
+ l = listDupS(list1);
+ len1 = listLengthS(list1);
+ len2 = listLengthCS(list2);
+ r = REALLOC(l, (len1+len2+1) * sizeof(char *));
+ if (!r) {
+ // free l when realloc fails
+ listFreeS(l);
+ return(NULL);//LCOV_EXCL_LINE
+ }
+ // push list2 to new list
+ enumerateCCharP(list2, e, i) {
+ r[len1+i] = strdup(*e);
+ }
+
+ r[len1+len2] = NULL;
+
+ return(r);
+}
+
+
+/**
* list Slice String
* return new list with elements from start and end in list
* negative indexes are allowed
@@ -50823,7 +51211,7 @@ char **listSliceS(char **list, int64_t start, int64_t end) {
return(NULL);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (start > len) {
return(NULL);
@@ -50856,7 +51244,7 @@ char **listSliceS(char **list, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = MALLOC((n+1) * sizeof(char *));
+ l = MALLOC((size_t)(n+1) * sizeof(char *));
if (!l) {
return(NULL);//LCOV_EXCL_LINE
}
@@ -50896,7 +51284,7 @@ char **iListCopyS(char **list, int64_t start, int64_t end) {
return(NULL);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (start > len) {
return(NULL);
@@ -50929,7 +51317,7 @@ char **iListCopyS(char **list, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = MALLOC((n+1) * sizeof(char *));
+ l = MALLOC((size_t)(n+1) * sizeof(char *));
if (!l) {
return(NULL);//LCOV_EXCL_LINE
}
@@ -50967,7 +51355,7 @@ char **iListSliceS(char ***list, int64_t start, int64_t end) {
return(NULL);
}
- len = listLengthS(*list);
+ len = (int64_t)listLengthS(*list);
if (start > len) {
listFreeS(*list);
@@ -51007,7 +51395,7 @@ char **iListSliceS(char ***list, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = MALLOC((n+1) * sizeof(char *));
+ l = MALLOC((size_t)(n+1) * sizeof(char *));
if (!l) {
return(NULL);
}
@@ -51061,7 +51449,7 @@ char **listCropS(char **list, int64_t start, int64_t end) {
return(NULL);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (start > len) {
return(NULL);
@@ -51094,7 +51482,7 @@ char **listCropS(char **list, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = MALLOC((n+1) * sizeof(char *));
+ l = MALLOC((size_t)(n+1) * sizeof(char *));
if (!l) {
return(NULL);
}
@@ -51143,7 +51531,7 @@ char **iListCropS(char ***list, int64_t start, int64_t end) {
return(NULL);
}
- len = listLengthS(*list);
+ len = (int64_t)listLengthS(*list);
if (start > len) {
return(NULL);
@@ -51176,7 +51564,7 @@ char **iListCropS(char ***list, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = MALLOC((n+1) * sizeof(char *));
+ l = MALLOC((size_t)(n+1) * sizeof(char *));
if (!l) {
return(NULL);
}
@@ -51223,7 +51611,7 @@ char *listCropElemS(char **list, int64_t index) {
return(NULL);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (len == 0) {
return(NULL);
@@ -51277,7 +51665,7 @@ char *iListCropElemS(char ***list, int64_t index) {
return(NULL);
}
- len = listLengthS(*list);
+ len = (int64_t)listLengthS(*list);
if (len == 0) {
return(NULL);
@@ -51332,7 +51720,7 @@ char **listInsertS(char **list, int64_t index, char **toInsert) {
}
return(listDupS(toInsert));
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -51407,8 +51795,8 @@ char **iListInsertS(char ***list, int64_t index, char **toInsert) {
if (index) {
return(NULL);
}
- len = listLengthS(toInsert);
- r = MALLOC((len+1) * sizeof(char *));
+ len = (int64_t)listLengthS(toInsert);
+ r = MALLOC((size_t)(len+1) * sizeof(char *));
if (!r) {
return(NULL);//LCOV_EXCL_LINE
}
@@ -51422,7 +51810,7 @@ char **iListInsertS(char ***list, int64_t index, char **toInsert) {
return(r);
}
- len = listLengthS(*list);
+ len = (int64_t)listLengthS(*list);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -51459,15 +51847,15 @@ char **iListInsertS(char ***list, int64_t index, char **toInsert) {
if (index == 0) {
// insert at beginning
- iListAppendS(&r, toInsert);
- iListAppendS(&r, *list);
+ pErrorNULL(iListAppendS(&r, toInsert));
+ pErrorNULL(iListAppendS(&r, *list));
}
else {
r = iListCopyS(*list, 0, index);;
char **l2 = iListCopyS(*list, index, 0);
- iListAppendS(&r, toInsert);
- iListAppendS(&r, l2);
+ pErrorNULL(iListAppendS(&r, toInsert));
+ pErrorNULL(iListAppendS(&r, l2));
free(l2);
}
@@ -51514,7 +51902,7 @@ char **iListInsertNFreeS(char ***list, int64_t index, char **toInsert) {
return(r);
}
- len = listLengthS(*list);
+ len = (int64_t)listLengthS(*list);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -51552,15 +51940,15 @@ char **iListInsertNFreeS(char ***list, int64_t index, char **toInsert) {
if (index == 0) {
// insert at beginning
- iListAppendS(&r, toInsert);
- iListAppendS(&r, *list);
+ pErrorNULL(iListAppendS(&r, toInsert));
+ pErrorNULL(iListAppendS(&r, *list));
}
else {
r = iListCopyS(*list, 0, index);;
char **l2 = iListCopyS(*list, index, 0);
- iListAppendS(&r, toInsert);
- iListAppendS(&r, l2);
+ pErrorNULL(iListAppendS(&r, toInsert));
+ pErrorNULL(iListAppendS(&r, l2));
free(l2);
}
free(toInsert);
@@ -51598,7 +51986,7 @@ char **listInjectS(char **list, int64_t index, char *toInject) {
if (index || !toInject) {
return(NULL);
}
- listPushS(&r, toInject);
+ pErrorNULL(listPushS(&r, toInject));
return(r);
}
@@ -51606,7 +51994,7 @@ char **listInjectS(char **list, int64_t index, char *toInject) {
return(NULL);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -51686,11 +52074,11 @@ char **iListInjectS(char ***list, int64_t index, char *toInject) {
if (index) {
return(NULL);
}
- iListPushS(list, toInject);
+ pErrorNULL(iListPushS(list, toInject));
return(*list);
}
- len = listLengthS(*list);
+ len = (int64_t)listLengthS(*list);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -51721,15 +52109,15 @@ char **iListInjectS(char ***list, int64_t index, char *toInject) {
if (index == 0) {
// Inject at beginning
- iListAppendS(&r, inject);
- iListAppendS(&r, *list);
+ pErrorNULL(iListAppendS(&r, inject));
+ pErrorNULL(iListAppendS(&r, *list));
}
else {
r = iListCopyS(*list, 0, index);;
char **l2 = iListCopyS(*list, index, 0);
- iListAppendS(&r, inject);
- iListAppendS(&r, l2);
+ pErrorNULL(iListAppendS(&r, inject));
+ pErrorNULL(iListAppendS(&r, l2));
free(l2);
}
@@ -51779,7 +52167,7 @@ char **listDelS(char **list, int64_t start, int64_t end) {
return(NULL);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (len == 0) {
return(NULL);
@@ -51814,7 +52202,7 @@ char **listDelS(char **list, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = MALLOC((len-n+1) * sizeof(char *));
+ l = MALLOC((size_t)(len-n+1) * sizeof(char *));
if (!l) {
return(NULL);//LCOV_EXCL_LINE
}
@@ -51856,7 +52244,7 @@ char **iListDelS(char ***list, int64_t start, int64_t end) {
return(NULL);
}
- len = listLengthS(*list);
+ len = (int64_t)listLengthS(*list);
if (len == 0) {
return(NULL);
@@ -51891,7 +52279,7 @@ char **iListDelS(char ***list, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = MALLOC((len-n+1) * sizeof(char *));
+ l = MALLOC((size_t)(len-n+1) * sizeof(char *));
if (!l) {
return(NULL);
}
@@ -51939,7 +52327,7 @@ char **iListRemoveS(char ***list, int64_t start, int64_t end) {
return(NULL);
}
- len = listLengthS(*list);
+ len = (int64_t)listLengthS(*list);
if (len == 0) {
return(NULL);
@@ -51974,7 +52362,7 @@ char **iListRemoveS(char ***list, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = MALLOC((len-n+1) * sizeof(char *));
+ l = MALLOC((size_t)(len-n+1) * sizeof(char *));
if (!l) {
return(NULL);
}
@@ -52014,7 +52402,7 @@ char **listDelElemS(char **list, int64_t index) {
return(NULL);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (len == 0) {
return(NULL);
@@ -52030,7 +52418,7 @@ char **listDelElemS(char **list, int64_t index) {
index = len + index;
}
- l = MALLOC((len-1+1) * sizeof(char *));
+ l = MALLOC((size_t)(len-1+1) * sizeof(char *));
if (!l) {
return(NULL);//LCOV_EXCL_LINE
}
@@ -52069,7 +52457,7 @@ char **iListDelElemS(char ***list, int64_t index) {
return(NULL);
}
- len = listLengthS(*list);
+ len = (int64_t)listLengthS(*list);
if (len == 0) {
return(NULL);
@@ -52085,7 +52473,7 @@ char **iListDelElemS(char ***list, int64_t index) {
index = len + index;
}
- l = MALLOC((len-1+1) * sizeof(char *));
+ l = MALLOC((size_t)(len-1+1) * sizeof(char *));
if (!l) {
return(NULL);
}
@@ -52129,7 +52517,7 @@ char **iListRemoveElemS(char ***list, int64_t index) {
return(NULL);
}
- len = listLengthS(*list);
+ len = (int64_t)listLengthS(*list);
if (len == 0) {
return(NULL);
@@ -52145,7 +52533,7 @@ char **iListRemoveElemS(char ***list, int64_t index) {
index = len + index;
}
- l = MALLOC((len-1+1) * sizeof(char *));
+ l = MALLOC((size_t)(len-1+1) * sizeof(char *));
if (!l) {
return(NULL);
}
@@ -52173,18 +52561,29 @@ char **iListRemoveElemS(char ***list, int64_t index) {
* list
* \return
* nothing
- * 0 success
- * -1 error
+ * 1 success
+ * 0 error
*/
int listPrintS(char **list) {
if (!list) {
- return(-1);
+ return(0);
}
forEachCharP(list, e) {
printf("%s\n", *e);
}
- return(0);
+ return(1);
+}
+
+int listPrintCS(const char **list) {
+
+ if (!list) {
+ return(0);
+ }
+ forEachCCharP(list, e) {
+ printf("%s\n", *e);
+ }
+ return(1);
}
/**
@@ -52208,7 +52607,7 @@ internal int listSortSCmp(const void * a, const void * b) {
if (a && !b) {
return(1);
}
- return(strcmp(*(char **)a,*(char **)b));
+ return(strcmp(*(char *const*)a,*(char *const*)b));
}
/**
@@ -52349,7 +52748,7 @@ internal int icListSortSCmp(const void * a, const void * b) {
if (a && !b) {
return(1);
}
- return(strcasecmp(*(char **)a,*(char **)b));
+ return(strcasecmp(*(char *const*)a,*(char *const*)b));
}
/**
@@ -52472,7 +52871,7 @@ char **readText(const char *filePath) {
if (pos != NULL)
*pos = '\0';
}
- listPushS(&list, line);
+ pErrorNULL(listPushS(&list, line));
read = getline(&line, &len, fp);
}
fclose(fp);
@@ -52514,7 +52913,7 @@ char **readStream(FILE *fp) {
if (pos != NULL)
*pos = '\0';
}
- iListPushS(&list, line);
+ pErrorNULL(iListPushS(&list, line));
line = NULL;
len = 0;
read = getline(&line, &len, (FILE *) fp);
@@ -52565,6 +52964,43 @@ bool writeText(const char *filePath, char **list) {
}
/**
+ * write const list to filePath
+ *
+ * \param
+ * filePath
+ * \param
+ * list
+ * \return
+ * true success
+ * false failed, filePath or list are NULL
+ */
+bool writeCText(const char *filePath, const char **list) {
+ FILE *fp = NULL;
+
+ // sanity checks
+ if (!filePath || isBlankS(filePath)) {
+ return(false);
+ }
+
+ fp = fopen(filePath, "w");
+ if (!fp) {
+ pFuncError
+ shEPrintfS("The path was: \"%s\"\n", filePath);
+ return(false);
+ }
+ if (!list) {
+ fclose(fp);
+ return(false);
+ }
+ forEachCCharP(list, e) {
+ // add new line
+ fprintf(fp, "%s\n", *e);
+ }
+ fclose(fp);
+ return(true);
+}
+
+/**
* write list to stream
*
* \param
@@ -52589,6 +53025,30 @@ bool writeStream(FILE *fp, char **list) {
}
/**
+ * write const list to stream
+ *
+ * \param
+ * fp: file stream
+ * \param
+ * list
+ * \return
+ * true success
+ * false failed, fp or list are NULL
+ */
+bool writeCStream(FILE *fp, const char **list) {
+
+ // sanity checks
+ if (!fp || !list) {
+ return(false);
+ }
+ forEachCCharP(list, e) {
+ // add new line
+ fprintf((FILE*)fp, "%s\n", *e);
+ }
+ return(true);
+}
+
+/**
* append list to filePath
*
* \param
@@ -52626,6 +53086,43 @@ bool appendText(const char *filePath, char **list) {
}
/**
+ * append const list to filePath
+ *
+ * \param
+ * filePath
+ * \param
+ * list
+ * \return
+ * true success
+ * false failed, filePath or list are NULL
+ */
+bool appendCText(const char *filePath, const char **list) {
+ FILE *fp = NULL;
+
+ // sanity checks
+ if (!filePath || isBlankS(filePath)) {
+ return(false);
+ }
+
+ fp = fopen(filePath, "a");
+ if (!fp) {
+ pFuncError
+ shEPrintfS("The path was: \"%s\"\n", filePath);
+ return(false);
+ }
+ if (!list) {
+ fclose(fp);
+ return(false);
+ }
+ forEachCCharP(list, e) {
+ // add new line
+ fprintf(fp, "%s\n", *e);
+ }
+ fclose(fp);
+ return(true);
+}
+
+/**
* execute command
* return stdout from cmd
*
@@ -52830,6 +53327,96 @@ bool listEqS(char **list1, char **list2) {
}
/**
+ * const(list2) list Equal String
+ * compare each element of list1 and list2
+ *
+ * \param
+ * 2 lists
+ * \return
+ * true the lists have identical elements
+ * false they differ
+ */
+bool listEqCS(char **list1, const char **list2) {
+
+ // sanity checks
+ if (!list1 || !list2) {
+ return(false);
+ }
+ if (listLengthS(list1) != listLengthCS(list2)) {
+ return(false);
+ }
+
+ // compare elements
+ enumerateCharP(list1, e, i) {
+ if (!strEq(*e, list2[i])) {
+ return(false);
+ }
+ }
+
+ return(true);
+}
+
+/**
+ * const(list1) list Equal String
+ * compare each element of list1 and list2
+ *
+ * \param
+ * 2 lists
+ * \return
+ * true the lists have identical elements
+ * false they differ
+ */
+bool listEqC1S(const char **list1, char **list2) {
+
+ // sanity checks
+ if (!list1 || !list2) {
+ return(false);
+ }
+ if (listLengthCS(list1) != listLengthS(list2)) {
+ return(false);
+ }
+
+ // compare elements
+ enumerateCCharP(list1, e, i) {
+ if (!strEq(*e, list2[i])) {
+ return(false);
+ }
+ }
+
+ return(true);
+}
+
+/**
+ * const(list1 and 2) list Equal String
+ * compare each element of list1 and list2
+ *
+ * \param
+ * 2 lists
+ * \return
+ * true the lists have identical elements
+ * false they differ
+ */
+bool listEqCCS(const char **list1, const char **list2) {
+
+ // sanity checks
+ if (!list1 || !list2) {
+ return(false);
+ }
+ if (listLengthCS(list1) != listLengthCS(list2)) {
+ return(false);
+ }
+
+ // compare elements
+ enumerateCCharP(list1, e, i) {
+ if (!strEq(*e, list2[i])) {
+ return(false);
+ }
+ }
+
+ return(true);
+}
+
+/**
* return true when list has string
*
* \param
@@ -52852,12 +53439,41 @@ bool listHasS(char **list, const char *string) {
return(true);
}
+/**
+ * return true when const list has string
+ *
+ * \param
+ * list
+ * \param
+ * string
+ * \return
+ * true when list has string
+ * false when the string is not found
+ * false when list or string are NULL
+ */
+bool listHasCS(const char **list, const char *string) {
+
+ if (!list || !string) {
+ return(false);
+ }
+ if (listIndexOfCS(list, string) == -1) {
+ return(false);
+ }
+ return(true);
+}
+
bool listHasCharS(char **list, char c) {
charToS(s, c);
return(listHasS(list, s));
}
+bool listHasCharCS(const char **list, char c) {
+
+ charToS(s, c);
+ return(listHasCS(list, s));
+}
+
/**
* return index of string in list
*
@@ -52885,7 +53501,41 @@ ssize_t listIndexOfS(char **list, const char *string) {
}
}
if (found) {
- return(i);
+ return((ssize_t)i);
+ }
+ else {
+ return(-1);
+}
+ }
+
+/**
+ * return index of string in const list
+ *
+ * \param
+ * list
+ * \param
+ * string
+ * \return
+ * index
+ * -1 when the string is not found
+ * -1 when list or string are NULL
+ */
+ssize_t listIndexOfCS(const char **list, const char *string) {
+ bool found = false;;
+
+ // sanity checks
+ if (!list || !string) {
+ return(-1);
+ }
+ // search string in elements
+ enumerateCCharP(list, e, i) {
+ if (strEq(*e, string)) {
+ found = true;
+ break;
+ }
+ }
+ if (found) {
+ return((ssize_t)i);
}
else {
return(-1);
@@ -52898,6 +53548,12 @@ ssize_t listIndexOfCharS(char **list, char c) {
return(listIndexOfS(list, s));
}
+ssize_t listIndexOfCharCS(const char **list, char c) {
+
+ charToS(s, c);
+ return(listIndexOfCS(list, s));
+}
+
/**
* list binary search string
*
@@ -52919,7 +53575,7 @@ ssize_t listBinarySearchS(char **list, const char *string) {
return(-1);
}
- last = listLengthS(list) - 1;
+ last = (ssize_t)(listLengthS(list) - 1);
while (first <= last) {
middle = (first+last)/2;
if (strcmp(list[middle], string) < 0) {
@@ -52967,7 +53623,7 @@ char **listUniqS(char **list) {
listEmptyS(r);
return(r);
}
- listPushS(&r, list[0]);
+ pErrorNULL(listPushS(&r, list[0]));
// one element list
if (len == 1) {
return(r);
@@ -52975,7 +53631,7 @@ char **listUniqS(char **list) {
// push element to new list if it is not already in new list
forEachCharP(list, e) {
if (listIndexOfS(r, *e) == -1) {
- listPushS(&r, *e);
+ pErrorNULL(listPushS(&r, *e));
}
}
return(r);
@@ -53008,13 +53664,13 @@ char **iListUniqS(char ***list) {
}
else if (len == 1) {
// one element list
- iListPushS(&r, (*list)[0]);
+ pErrorNULL(iListPushS(&r, (*list)[0]));
}
else {
// push element to new list if it is not already in new list
forEachCharP(*list, e) {
if (listIndexOfS(r, *e) == -1) {
- iListPushS(&r, *e);
+ pErrorNULL(iListPushS(&r, *e));
}
else {
free(*e);
@@ -53058,6 +53714,96 @@ bool icListEqS(char **list1, char **list2) {
}
/**
+ * ignore case const(list2) list Equal String
+ * compare each element of list1 and list2
+ *
+ * \param
+ * 2 lists
+ * \return
+ * true the lists have identical elements
+ * false they differ
+ */
+bool icListEqCS(char **list1, const char **list2) {
+
+ // sanity checks
+ if (!list1 || !list2) {
+ return(false);
+ }
+ if (listLengthS(list1) != listLengthCS(list2)) {
+ return(false);
+ }
+
+ // compare elements
+ enumerateCharP(list1, e, i) {
+ if (!icEqS(*e, list2[i])) {
+ return(false);
+ }
+ }
+
+ return(true);
+}
+
+/**
+ * ignore case const(list1) list Equal String
+ * compare each element of list1 and list2
+ *
+ * \param
+ * 2 lists
+ * \return
+ * true the lists have identical elements
+ * false they differ
+ */
+bool icListEqC1S(const char **list1, char **list2) {
+
+ // sanity checks
+ if (!list1 || !list2) {
+ return(false);
+ }
+ if (listLengthCS(list1) != listLengthS(list2)) {
+ return(false);
+ }
+
+ // compare elements
+ enumerateCCharP(list1, e, i) {
+ if (!icEqS(*e, list2[i])) {
+ return(false);
+ }
+ }
+
+ return(true);
+}
+
+/**
+ * ignore case const(list1 and 2) list Equal String
+ * compare each element of list1 and list2
+ *
+ * \param
+ * 2 lists
+ * \return
+ * true the lists have identical elements
+ * false they differ
+ */
+bool icListEqCCS(const char **list1, const char **list2) {
+
+ // sanity checks
+ if (!list1 || !list2) {
+ return(false);
+ }
+ if (listLengthCS(list1) != listLengthCS(list2)) {
+ return(false);
+ }
+
+ // compare elements
+ enumerateCCharP(list1, e, i) {
+ if (!icEqS(*e, list2[i])) {
+ return(false);
+ }
+ }
+
+ return(true);
+}
+
+/**
* ignore case and return true when list has string
*
* \param
@@ -53087,6 +53833,35 @@ bool icListHasCharS(char **list, char c) {
}
/**
+ * ignore case and return true when const list has string
+ *
+ * \param
+ * list
+ * \param
+ * string
+ * \return
+ * true when list has string
+ * false when the string is not found
+ * false when list or string are NULL
+ */
+bool icListHasCS(const char **list, const char *string) {
+
+ if (!list || !string) {
+ return(false);
+ }
+ if (icListIndexOfCS(list, string) == -1) {
+ return(false);
+ }
+ return(true);
+}
+
+bool icListHasCharCS(const char **list, char c) {
+
+ charToS(s, c);
+ return(icListHasCS(list, s));
+}
+
+/**
* ignore case and return index of string in list
*
* \param
@@ -53113,7 +53888,41 @@ ssize_t icListIndexOfS(char **list, const char *string) {
}
}
if (found) {
- return(i);
+ return((ssize_t)i);
+ }
+ else {
+ return(-1);
+}
+ }
+
+/**
+ * ignore case and return index of string in const list
+ *
+ * \param
+ * list
+ * \param
+ * string
+ * \return
+ * index
+ * -1 when the string is not found
+ * -1 when list or string are NULL
+ */
+ssize_t icListIndexOfCS(const char **list, const char *string) {
+ bool found = false;;
+
+ // sanity checks
+ if (!list || !string) {
+ return(-1);
+ }
+ // search string in elements
+ enumerateCCharP(list, e, i) {
+ if (icEqS(*e, string)) {
+ found = true;
+ break;
+ }
+ }
+ if (found) {
+ return((ssize_t)i);
}
else {
return(-1);
@@ -53126,6 +53935,12 @@ ssize_t icListIndexOfCharS(char **list, char c) {
return(icListIndexOfS(list, s));
}
+ssize_t icListIndexOfCharCS(const char **list, char c) {
+
+ charToS(s, c);
+ return(icListIndexOfCS(list, s));
+}
+
/**
* ignore case list binary search string
*
@@ -53147,7 +53962,7 @@ ssize_t icListBinarySearchS(char **list, const char *string) {
return(-1);
}
- last = listLengthS(list) - 1;
+ last = (ssize_t)listLengthS(list) - 1;
while (first <= last) {
middle = (first+last)/2;
if (strcasecmp(list[middle], string) < 0) {
@@ -53195,7 +54010,7 @@ char **icListUniqS(char **list) {
listEmptyS(r);
return(r);
}
- listPushS(&r, list[0]);
+ pErrorNULL(listPushS(&r, list[0]));
// one element list
if (listLengthS(list) == 1) {
return(r);
@@ -53203,7 +54018,7 @@ char **icListUniqS(char **list) {
// push element to new list if it is not already in new list
forEachCharP(list, e) {
if (icListIndexOfS(r, *e) == -1) {
- listPushS(&r, *e);
+ pErrorNULL(listPushS(&r, *e));
}
}
return(r);
@@ -53236,13 +54051,13 @@ char **iicListUniqS(char ***list) {
}
else if (len == 1) {
// one element list
- iListPushS(&r, (*list)[0]);
+ pErrorNULL(iListPushS(&r, (*list)[0]));
}
else {
// push element to new list if it is not already in new list
forEachCharP(*list, e) {
if (icListIndexOfS(r, *e) == -1) {
- iListPushS(&r, *e);
+ pErrorNULL(iListPushS(&r, *e));
}
else {
free(*e);
@@ -53277,7 +54092,7 @@ char **listCompactS(char **list) {
forEachCharP(list, e) {
char *trim = trimS(*e);
if (*trim != 0) {
- listPushS(&r, *e);
+ pErrorNULL(listPushS(&r, *e));
}
free(trim);
}
@@ -53311,7 +54126,7 @@ char **iListCompactS(char ***list) {
forEachCharP(*list, e) {
char *trim = trimS(*e);
if (*trim != 0) {
- iListPushS(&r, *e);
+ pErrorNULL(iListPushS(&r, *e));
}
else {
free(*e);
@@ -53328,7 +54143,7 @@ char **iListCompactS(char ***list) {
*list = r;
}
else {
- iListEmptySF(list);
+ pErrorNULL(iListEmptySF(list));
}
return(*list);
}
@@ -53416,7 +54231,7 @@ char **btrace(void) {
char **symbols = NULL;;
forEachCharP(elf, s) {
// keep only one space between columns
- iUniqS(s, ' ');
+ pErrorNULL(iUniqS(s, ' '));
// s = " 530: 000000000000b7e5 65 FUNC GLOBAL DEFAULT 14 zeroS"
size_t len = strlen(*s);
// spaces is the column number
@@ -53447,7 +54262,7 @@ char **btrace(void) {
if (_ and startsWithS(_, "FUNC")) {
// this symbol is a function
// store function name and function address as a uint64_t
- iListPushS(&symbols, funcName);
+ pErrorNULL(iListPushS(&symbols, funcName));
dArrayAppend(&addresses, parseHex(addr));
}
}
@@ -53484,7 +54299,7 @@ char **btrace(void) {
free(bts);
return(NULL);
}
- size_t funcNameLen = (offset-1) - funcName;
+ size_t funcNameLen = (size_t)((offset-1) - funcName);
// search function in all funtions from the elf file
int symbolIndex = 0;;
@@ -53494,7 +54309,7 @@ char **btrace(void) {
}
if (!strncmp(funcName, *l, funcNameLen)) {
// found function
- symbolIndex = j;
+ symbolIndex = (int)j;
break;
}
}
@@ -53511,7 +54326,7 @@ char **btrace(void) {
continue;
}
- iListPushS(&r, formatS("%s: %s", symbols[symbolIndex], cres[0]));
+ pErrorNULL(iListPushS(&r, formatS("%s: %s", symbols[symbolIndex], cres[0])));
listFreeS(cres);
}
@@ -53618,7 +54433,7 @@ void **listCreateF(void *paramType, ...) {
va_start(pl, paramType);
paramType = va_arg(pl, void *);
while (paramType) {
- listPush(&l, paramType);
+ pErrorNULL(listPush(&l, paramType));
paramType = va_arg(pl, void *);
}
va_end(pl);
@@ -53656,7 +54471,7 @@ void **listFromArray(void **array, size_t size) {
for (size_t i = 0 ; i < size ; i++) {
if (array[i]) {
// remove NULL elements
- listPush(&r, array[i]);
+ pErrorNULL(listPush(&r, array[i]));
}
}
return(r);
@@ -53726,7 +54541,7 @@ void **listPush(void ***list, void *s) {
*/
void *listPop(void ***list) {
void *s = NULL;
- uint64_t len;
+ size_t len;
// sanity checks
if (!list) {
@@ -53783,7 +54598,7 @@ void **listPrepend(void ***list, void *s) {
}
else {
// realloc list and copy s to last element
- uint64_t len;
+ size_t len;
len = listLength(*list);
void **tmp = REALLOC(*list, (len+2) * sizeof(void *));
if (!tmp) {
@@ -53814,7 +54629,7 @@ void **listPrepend(void ***list, void *s) {
*/
void *listDequeue(void ***list) {
void *s = NULL;
- uint64_t len;
+ size_t len;
// sanity checks
if (!list) {
@@ -53922,7 +54737,7 @@ void *listGet(void **list, int64_t index) {
return(NULL);
}
- len = listLength(list);
+ len = (int64_t)listLength(list);
if (index >= len) {
return(NULL);
}
@@ -53966,7 +54781,7 @@ void **listSet(void **list, int64_t index, void *s) {
return(NULL);
}
- len = listLength(list);
+ len = (int64_t)listLength(list);
if (index >= len) {
return(NULL);
}
@@ -54103,7 +54918,7 @@ void **listCatF(void **paramType, ...) {
va_start(pl, paramType);
paramType = va_arg(pl, void **);
while (paramType) {
- listAppend(&r, paramType);
+ pErrorNULL(listAppend(&r, paramType));
paramType = va_arg(pl, void **);
}
va_end(pl);
@@ -54271,7 +55086,7 @@ void **listSlice(void **list, int64_t start, int64_t end) {
return(NULL);
}
- len = listLength(list);
+ len = (int64_t)listLength(list);
if (start > len) {
return(NULL);
@@ -54304,7 +55119,7 @@ void **listSlice(void **list, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = MALLOC((n+1) * sizeof(void *));
+ l = MALLOC((size_t)(n+1) * sizeof(void *));
if (!l) {
return(NULL);//LCOV_EXCL_LINE
}
@@ -54342,7 +55157,7 @@ void **iListSlice(void ***list, int64_t start, int64_t end) {
return(NULL);
}
- len = listLength(*list);
+ len = (int64_t)listLength(*list);
if (start > len) {
free(*list);
@@ -54380,7 +55195,7 @@ void **iListSlice(void ***list, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = MALLOC((n+1) * sizeof(void *));
+ l = MALLOC((size_t)(n+1) * sizeof(void *));
if (!l) {
return(NULL);
}
@@ -54430,7 +55245,7 @@ void **listInsert(void **list, int64_t index, void **toInsert) {
return(NULL);
}
- len = listLength(list);
+ len = (int64_t)listLength(list);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -54511,7 +55326,7 @@ void **iListInsert(void ***list, int64_t index, void **toInsert) {
return(r);
}
- len = listLength(*list);
+ len = (int64_t)listLength(*list);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -54542,15 +55357,15 @@ void **iListInsert(void ***list, int64_t index, void **toInsert) {
if (index == 0) {
// insert at beginning
- listAppend(&r, toInsert);
- listAppend(&r, *list);
+ pErrorNULL(listAppend(&r, toInsert));
+ pErrorNULL(listAppend(&r, *list));
}
else {
r = listSlice(*list, 0, index);
void **l2 = listSlice(*list, index, 0);
- listAppend(&r, toInsert);
- listAppend(&r, l2);
+ pErrorNULL(listAppend(&r, toInsert));
+ pErrorNULL(listAppend(&r, l2));
free(l2);
}
@@ -54585,7 +55400,7 @@ void **listDel(void **list, int64_t start, int64_t end) {
return(NULL);
}
- len = listLength(list);
+ len = (int64_t)listLength(list);
if (len == 0) {
return(NULL);
@@ -54620,7 +55435,7 @@ void **listDel(void **list, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = MALLOC((len-n+1) * sizeof(void *));
+ l = MALLOC((size_t)(len-n+1) * sizeof(void *));
if (!l) {
return(NULL);//LCOV_EXCL_LINE
}
@@ -54662,7 +55477,7 @@ void **iListDel(void ***list, int64_t start, int64_t end) {
return(NULL);
}
- len = listLength(*list);
+ len = (int64_t)listLength(*list);
if (len == 0) {
return(NULL);
@@ -54697,7 +55512,7 @@ void **iListDel(void ***list, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = MALLOC((len-n+1) * sizeof(void *));
+ l = MALLOC((size_t)(len-n+1) * sizeof(void *));
if (!l) {
return(NULL);
}
@@ -55322,8 +56137,8 @@ uint64_t getMonotonicTime(void) {
int nanoSleepF(uint64_t time) {
struct timespec ts;
- ts.tv_sec = time / 1000000000;
- ts.tv_nsec = time % 1000000000;
+ ts.tv_sec = (time_t)(time / 1000000000);
+ ts.tv_nsec = (time_t)(time % 1000000000);
int r = nanosleep(&ts, NULL);;
if (r == -1) {
pFuncError
diff --git a/release/libsheepy.h b/release/libsheepy.h
@@ -98,7 +98,7 @@
// version accoring to the version package: Release.Major.minor.patch
// https://noulin.net/version/file/README.md.html
-#define LIBSHEEPY_VERSION "2.2.5.5"
+#define LIBSHEEPY_VERSION "2.2.6"
#ifndef SH_PREFIX
#define SH_PREFIX(NAME) NAME
@@ -802,8 +802,8 @@ void cleanUpFileFree(FILE **val);
#define BGWHT "\x1B[47m"
// bug in cg_c.py
-#define sheepyRGBFP len = fprintf(stream, "%*s", (info->left ? -info->width : info->width), b)
-#define sheepyBOOLFP len = fprintf(stream, "%*s", (info->left ? -info->width : info->width), boolS(value))
+#define sheepyRGBFP len = fprintf(stream, "%*s", (int)(info->left ? -info->width : info->width), b)
+#define sheepyBOOLFP len = fprintf(stream, "%*s", (int)(info->left ? -info->width : info->width), boolS(value))
/**
* time a function in nanoseconds
@@ -970,14 +970,24 @@ uint64_t shStopwatch(uint8_t op);
// add a log file, maximum 15 files
FILE *SH_PREFIX(setLogFile)(char *filename);
+#ifdef __GNUC__
+/** force function callers to check return value
+ * The warning is disabled with -Wno-unused-result (default in sheepy config ~/.sheepy/config.yml
+ * Enable this warning to make all errors caught as early as possible and handled correctly.
+ */
+#define MUST_CHECK __attribute__ ((warn_unused_result))
+#else
+#define MUST_CHECK
+#endif
+
// current log symbols
-int getLogSymbols(void);
+int getLogSymbols(void) MUST_CHECK;
// set log symbols, LOG_VERBOSE for words, LOG_UTF8 for emojis, LOG_VOID for no symbols, LOG_INVALID_MODE (reset log symbols) for default log mode symbols, anything else (LOG_CONCISE,...) for symbols (!*+->~)
void setLogSymbols(int mode);
// current max log level
-int getMaxLogLevel(void);
+int getMaxLogLevel(void) MUST_CHECK;
// set max log level, logs above logMaxLevel are skipped
void setMaxLogLevel(int logLevel);
@@ -986,25 +996,25 @@ void setMaxLogLevel(int logLevel);
void closeLogFiles(void);
// get current log mode (LOG_VERBOSE, LOG_CONCISE, ...)
-int getLogMode(void);
+int getLogMode(void) MUST_CHECK;
// set log mode LOG_VERBOSE, LOG_CONCISE, ...
void setLogMode(int mode);
// get current log long/short path value, default is TRUE (short paths)
-bool getLogShortPath(void);
+bool getLogShortPath(void) MUST_CHECK;
// set log long/short file path value for VERBOSE mode
void setLogShortPath(bool shortPath);
// get stdout state, when TRUE (default) all logs are printed to stdout
-bool getLogStdout(void);
+bool getLogStdout(void) MUST_CHECK;
// enable/disable printing logs to stdout
void setLogStdout(bool state);
// log to a file named progName.log
-bool openProgLogFile(void);
+bool openProgLogFile(void) MUST_CHECK;
/**
* print logging levels
@@ -1548,16 +1558,16 @@ void initLibsheepyF(const char *progPath, initLibsheepyObjectP initF);
void finalizeLibsheepyCharAtExit(void);
// get current stack limit - returns 0 when error
-int64_t getStackLimit(void);
+int64_t getStackLimit(void) MUST_CHECK;
// set stack limit (-1 for unlimited) - returns 0 when error
-int setStackLimit(int64_t stackSize);
+int setStackLimit(int64_t stackSize) MUST_CHECK;
// get program name
-const char *getProgName(void);
+const char *getProgName(void) MUST_CHECK;
// set program name
-bool setProgName(const char *name);
+bool setProgName(const char *name) MUST_CHECK;
// set default program name
void setDefaultProgName(void);
@@ -1566,180 +1576,187 @@ void setDefaultProgName(void);
void freeProgName(void);
// get program path as given in the shell
-const char *getProgPath(void);
+const char *getProgPath(void) MUST_CHECK;
// get real program path, allocates path string internally
-const char *getRealProgPath(void);
+const char *getRealProgPath(void) MUST_CHECK;
// free real program path
void freeRealProgPath(void);
// run system command and free command buffer
#define systemNFree(command) systemNFreeF(command, __LINE__, __func__, __FILE__)
-int systemNFreeF(char *command, int line, const char *thisFunc, const char *thisFileName);
+int systemNFreeF(char *command, int line, const char *thisFunc, const char *thisFileName) MUST_CHECK;
// get modification time for path
-time_t getModificationTime(const char *path);
+time_t getModificationTime(const char *path) MUST_CHECK;
// set modification time for path
-int setModificationTime(const char *path, time_t mtime);
+int setModificationTime(const char *path, time_t mtime) MUST_CHECK;
// true when path is readable
-bool isReadable(const char *path);
+bool isReadable(const char *path) MUST_CHECK;
// true when path is writable
-bool isWritable(const char *path);
+bool isWritable(const char *path) MUST_CHECK;
// true when path is executable
-bool isExecutable(const char *path);
+bool isExecutable(const char *path) MUST_CHECK;
// compare modification times for path1 and path2
-bool equalModificationTimes(const char *path1, const char *path2);
+bool equalModificationTimes(const char *path1, const char *path2) MUST_CHECK;
// get current unix time
-time_t getCurrentUnixTime(void);
+time_t getCurrentUnixTime(void) MUST_CHECK;
// convert date string to unix time
-time_t strToUnixTime(const char *date, const char *format);
+time_t strToUnixTime(const char *date, const char *format) MUST_CHECK;
// convert unix time to string
-char *timeToS(const time_t t);
-char *bTimeToS(char *dst, const time_t t);
-char *bLTimeToS(char *dst, size_t dstSize, const time_t t);
+char *timeToS(const time_t t) MUST_CHECK;
+char *bTimeToS(char *dst, const time_t t) MUST_CHECK;
+char *bLTimeToS(char *dst, size_t dstSize, const time_t t) MUST_CHECK;
// convert unix time to Y-m-d H:M:S string
-char *timeToYMDS(const time_t t);
-char *bTimeToYMDS(char *dst, const time_t t);
-char *bLTimeToYMDS(char *dst, size_t dstSize, const time_t t);
+char *timeToYMDS(const time_t t) MUST_CHECK;
+char *bTimeToYMDS(char *dst, const time_t t) MUST_CHECK;
+char *bLTimeToYMDS(char *dst, size_t dstSize, const time_t t) MUST_CHECK;
// get current date in ctime format
-char *getCurrentDate(void);
-char *bGetCurrentDate(char *dst);
-char *bLGetCurrentDate(char *dst, size_t dstSize);
+char *getCurrentDate(void) MUST_CHECK;
+char *bGetCurrentDate(char *dst) MUST_CHECK;
+char *bLGetCurrentDate(char *dst, size_t dstSize) MUST_CHECK;
// get current date in Y-m-d H:M:S format
-char *getCurrentDateYMD(void);
-char *bGetCurrentDateYMD(char *dst);
-char *bLGetCurrentDateYMD(char *dst, size_t dstSize);
+char *getCurrentDateYMD(void) MUST_CHECK;
+char *bGetCurrentDateYMD(char *dst) MUST_CHECK;
+char *bLGetCurrentDateYMD(char *dst, size_t dstSize) MUST_CHECK;
// dirname
-char *shDirname(const char *path);
-char *bDirname(char *path);
-char *bLDirname(char *path, size_t pathSize);
+char *shDirname(const char *path) MUST_CHECK;
+char *bDirname(char *path) MUST_CHECK;
+char *bLDirname(char *path, size_t pathSize) MUST_CHECK;
// expand home ~/
-char *expandHome(const char *path);
-char *iExpandHome(char **path);
-char *bExpandHome(char *path);
-char *bLExpandHome(char *path, size_t pathSize);
+char *expandHome(const char *path) MUST_CHECK;
+char *iExpandHome(char **path) MUST_CHECK;
+char *bExpandHome(char *path) MUST_CHECK;
+char *bLExpandHome(char *path, size_t pathSize) MUST_CHECK;
// normalize path
-char *normalizePath(const char *path);
-char *iNormalizePath(char **path);
-char *bNormalizePath(char *path);
-char *bLNormalizePath(char *path, size_t pathSize);
+char *normalizePath(const char *path) MUST_CHECK;
+char *iNormalizePath(char **path) MUST_CHECK;
+char *bNormalizePath(char *path) MUST_CHECK;
+char *bLNormalizePath(char *path, size_t pathSize) MUST_CHECK;
// relative path
-char *relPath(const char *path, const char *start);
-char *iRelPath(char **path, const char *start);
-char *bRelPath(char *dest, const char *path, const char *start);
-char *bLRelPath(char *dest, size_t destSize, char *path, const char *start);
+char *relPath(const char *path, const char *start) MUST_CHECK;
+char *iRelPath(char **path, const char *start) MUST_CHECK;
+char *bRelPath(char *dest, const char *path, const char *start) MUST_CHECK;
+char *bLRelPath(char *dest, size_t destSize, char *path, const char *start) MUST_CHECK;
// get home path
-char *getHomePath(void);
-char *bGetHomePath(char *path);
-char *bLGetHomePath(char *path, size_t pathSize);
-const char *getCHomePath(void);
+char *getHomePath(void) MUST_CHECK;
+char *bGetHomePath(char *path) MUST_CHECK;
+char *bLGetHomePath(char *path, size_t pathSize) MUST_CHECK;
+const char *getCHomePath(void) MUST_CHECK;
// get current working directory
-char *getCwd(void);
-char *bLGetCwd(char *path, size_t pathSize);
+char *getCwd(void) MUST_CHECK;
+char *bLGetCwd(char *path, size_t pathSize) MUST_CHECK;
// change directory
-int chDir(const char *path);
+int chDir(const char *path) MUST_CHECK;
// true when path is directory
-bool isDir(const char *path);
+bool isDir(const char *path) MUST_CHECK;
// read link to a new string
-char *shReadlink(const char *path);
+char *shReadlink(const char *path) MUST_CHECK;
// read link chain to the end to a new string
-char *endlink(const char *path);
+char *endlink(const char *path) MUST_CHECK;
// true when path is symbolic link
-bool isLink(const char *path);
+bool isLink(const char *path) MUST_CHECK;
// file and dir exists
-bool fileExists(const char *filePath);
+bool fileExists(const char *filePath) MUST_CHECK;
#define isPath fileExists
// chmod "721"
-bool fileChmod(const char *filePath, mode_t mode);
+bool fileChmod(const char *filePath, mode_t mode) MUST_CHECK;
// file size
-ssize_t fileSize(const char *filePath);
-ssize_t fileSizeFP(FILE *fp);
+ssize_t fileSize(const char *filePath) MUST_CHECK;
+ssize_t fileSizeFP(FILE *fp) MUST_CHECK;
// read file
-void *readFileToS(const char *filePath);
-void *bReadFileToS(const char *filePath, void *dst);
-void *bLReadFileToS(const char *filePath, void *dst, size_t dstSize);
-ssize_t readFile(const char *filePath, void **buffer);
-ssize_t bReadFile(const char *filePath, void *buffer);
-ssize_t bLReadFile(const char *filePath, void *buffer, size_t dstSize);
-void *readStreamToS(FILE *fp);
-void *bReadStreamToS(FILE *fp, void *dst);
-void *bLReadStreamToS(FILE *fp, void *dst, size_t dstSize);
+void *readFileToS(const char *filePath) MUST_CHECK;
+void *bReadFileToS(const char *filePath, void *dst) MUST_CHECK;
+void *bLReadFileToS(const char *filePath, void *dst, size_t dstSize) MUST_CHECK;
+ssize_t readFile(const char *filePath, void **buffer) MUST_CHECK;
+ssize_t bReadFile(const char *filePath, void *buffer) MUST_CHECK;
+ssize_t bLReadFile(const char *filePath, void *buffer, size_t dstSize) MUST_CHECK;
+void *readStreamToS(FILE *fp) MUST_CHECK;
+void *bReadStreamToS(FILE *fp, void *dst) MUST_CHECK;
+void *bLReadStreamToS(FILE *fp, void *dst, size_t dstSize) MUST_CHECK;
+// defines without '...ToS'
+#define readFileS readFileToS
+#define bReadFileS bReadFileToS
+#define bLReadFileS bLReadFileToS
+#define readStreamS readStreamToS
+#define bReadStreamS bReadStreamToS
+#define bLReadStreamS bLReadStreamToS
// write file
-int writeFileS(const char *filePath, const char *string);
-int writeFile(const char *filePath, void *buffer, size_t len);
-int writeStreamS(FILE *fp, const char *string);
-int writeLStream(FILE *fp, void *buffer, size_t len);
+int writeFileS(const char *filePath, const char *string) MUST_CHECK;
+int writeFile(const char *filePath, void *buffer, size_t len) MUST_CHECK;
+int writeStreamS(FILE *fp, const char *string) MUST_CHECK;
+int writeLStream(FILE *fp, void *buffer, size_t len) MUST_CHECK;
// append string to file
-bool appendFileS(const char *filePath, const char *string);
-bool appendFile(const char *filePath, void *buffer, size_t len);
+bool appendFileS(const char *filePath, const char *string) MUST_CHECK;
+bool appendFile(const char *filePath, void *buffer, size_t len) MUST_CHECK;
// walkDir lists files only
-char **walkDir(const char* dirPath);
+char **walkDir(const char* dirPath) MUST_CHECK;
// walkDirDir lists directories
-char **walkDirDir(const char* dirPath);
+char **walkDirDir(const char* dirPath) MUST_CHECK;
// readDir lists files in a directory
-char **readDir(const char *dirPath);
+char **readDir(const char *dirPath) MUST_CHECK;
// readDirDir lists directories in a directory
-char **readDirDir(const char *dirPath);
+char **readDirDir(const char *dirPath) MUST_CHECK;
// walkDirAll lists files and directories
-char **walkDirAll(const char* dirPath);
+char **walkDirAll(const char* dirPath) MUST_CHECK;
// readDirAll lists files and directories in a directory
-char **readDirAll(const char *dirPath);
+char **readDirAll(const char *dirPath) MUST_CHECK;
// get umask
-mode_t getumask(void);
+mode_t getUmask(void) MUST_CHECK;
// get current permissions for creating directories
-mode_t getCurrentPermissions(void);
+mode_t getCurrentPermissions(void) MUST_CHECK;
// recursive mkdir
-int mkdirParents(const char* path);
+int mkdirParents(const char* path) MUST_CHECK;
// delete files and directories
-int rmAll(const char* path);
+int rmAll(const char* path) MUST_CHECK;
// copy files recursively
-int copy(const char* src, const char* dst);
+int copy(const char* src, const char* dst) MUST_CHECK;
// rename file
-int shRename(const char* src, const char* dst);
+int shRename(const char* src, const char* dst) MUST_CHECK;
// move files recursively
-int shMove(const char* src, const char* dst);
+int shMove(const char* src, const char* dst) MUST_CHECK;
// use /dev/urandom as a source of random numbers
void setSoftwareRandom(void);
@@ -1748,43 +1765,43 @@ void setSoftwareRandom(void);
void setHardwareRandom(void);
// open /dev/urandom in libsheepy
-int randomUrandomOpen(void);
+int randomUrandomOpen(void) MUST_CHECK;
// close /dev/urandom in libsheepy
void randomUrandomClose(void);
// return random 64 bit unsigned integer
-uint64_t randomWord(void);
+uint64_t randomWord(void) MUST_CHECK;
// return random 64 bit unsigned integer from the cpu
-uint64_t randomWordFromHW(void);
+uint64_t randomWordFromHW(void) MUST_CHECK;
// return a random value between 0 and range 0<=value<range
-uint64_t randomChoice(uint64_t range);
+uint64_t randomChoice(uint64_t range) MUST_CHECK;
// generate random string
-char *randomS(uint64_t length);
-char *bRandomS(char *dst, size_t length);
+char *randomS(uint64_t length) MUST_CHECK;
+char *bRandomS(char *dst, size_t length) MUST_CHECK;
// generate random alpha numerical string
-char *randomAlphaNumS(uint64_t length);
-char *bRandomAlphaNumS(char *dst, size_t dstSize);
+char *randomAlphaNumS(uint64_t length) MUST_CHECK;
+char *bRandomAlphaNumS(char *dst, size_t dstSize) MUST_CHECK;
// read user input (one line) as a string
-char *readS(void);
-char *bLReadS(char *dst, size_t dstSize);
+char *readS(void) MUST_CHECK;
+char *bLReadS(char *dst, size_t dstSize) MUST_CHECK;
// read hidden password as a string - like getpass
-char *readPasswordS(void);
+char *readPasswordS(void) MUST_CHECK;
// write zero to all bytes in string with memset, for clearing password buffers
-bool zeroS(char *string);
+bool zeroS(char *string) MUST_CHECK;
// write zero to all bytes in buffer with memset
-bool zeroBuf(void *buf, size_t len);
+bool zeroBuf(void *buf, size_t len) MUST_CHECK;
// allocate and copy buffer
-void *memdup(const void *buf, size_t size);
+void *memdup(const void *buf, size_t size) MUST_CHECK;
// wait until press the enter key
void readEnter(void);
@@ -1792,7 +1809,7 @@ void readEnter(void);
// TODO writeLine - copy cg_c code
// readLine
-char *readLine(FILE *fp);
+char *readLine(FILE *fp) MUST_CHECK;
// convert char to string by declaring string dst with c in it
#define charToS(dst, c) \
@@ -1803,7 +1820,7 @@ void freeManySF(char *paramType, ...);
#define freeManyS(...) freeManySF("", __VA_ARGS__, NULL)
// duplicate string
-char *dupS(const char *string);
+char *dupS(const char *string) MUST_CHECK;
// print like printf, the formating can be NULL
void shPrintfS(const char *fmt, ...);
@@ -1818,218 +1835,218 @@ void logNFree(char *s);
void loghex(const void *buf, size_t len);
// create a string with bytes in buf converted to hex strings: 0xff,
-char *toHexS(const void *buf, size_t len);
+char *toHexS(const void *buf, size_t len) MUST_CHECK;
// create a string with bytes in buf converted to hex strings separated by separator: 0xffSEP
-char *toHexSepS(const void *buf, size_t len, const char *separator);
+char *toHexSepS(const void *buf, size_t len, const char *separator) MUST_CHECK;
// create a string with bytes in buf converted to hex strings separated by separator and with head string in front of earch byte: HEADffSEP
-char *toHexHeadSepS(const void *buf, size_t len, const char *head, const char *separator);
+char *toHexHeadSepS(const void *buf, size_t len, const char *head, const char *separator) MUST_CHECK;
// print new line
#define put puts("");
// copy src to dst
-char *strCpy(char *dst, const char *src);
+char *strCpy(char *restrict dst, const char *restrict src) MUST_CHECK;
// copy string to buffer given string length: strNCpy(buffer, string, lenS(string));
// null safe version of strncpy
-char *strNCpy(char *dst, const char *src, size_t srcSize);
-char *strLCpy(char *dst, size_t dstSize, const char *src);
+char *strNCpy(char *restrict dst, const char *restrict src, size_t srcSize) MUST_CHECK;
+char *strLCpy(char *restrict dst, size_t dstSize, const char *restrict src) MUST_CHECK;
// concatenate src to dst
-char *strCat(char *dst, const char *src);
-char *strNCat(char *dst, const char *src, size_t srcLen);
-char *strLCat(char *dst, size_t dstSize, const char *src);
-char *strLNCat(char *dst, size_t dstSize, const char *src, size_t srcLen);
+char *strCat(char *restrict dst, const char *restrict src) MUST_CHECK;
+char *strNCat(char *restrict dst, const char *restrict src, size_t srcLen) MUST_CHECK;
+char *strLCat(char *restrict dst, size_t dstSize, const char *restrict src) MUST_CHECK;
+char *strLNCat(char *restrict dst, size_t dstSize, const char *restrict src, size_t srcLen) MUST_CHECK;
// cat: f("qwd ", str," werr ", str2)
-char *catSF(const char *paramType, ...);
+char *catSF(const char *paramType, ...) MUST_CHECK;
#define catS(...) catSF("", __VA_ARGS__, NULL)
// cat and copy result to dst buffer
-char *iCatSF(char *dst, const char *paramType, ...);
+char *iCatSF(char *dst, const char *paramType, ...) MUST_CHECK;
#define iCatS(dst, ...) iCatSF(dst, "", __VA_ARGS__, NULL)
#define bCatS iCatS
-char *bLCatSF(char *dst, size_t dstSize, const char *paramType, ...);
+char *bLCatSF(char *dst, size_t dstSize, const char *paramType, ...) MUST_CHECK;
#define bLCatS(dst, dstSize, ...) bLCatSF(dst, dstSize, "", __VA_ARGS__, NULL)
// allocate and format string using asprintf
-char *formatS(const char *fmt, ...);
+char *formatS(const char *fmt, ...) MUST_CHECK;
/** format and store in string: bFormatS(string, "Value %d", i); */
-char *bFormatS(char *string, const char *fmt, ...);
+char *bFormatS(char *string, const char *fmt, ...) MUST_CHECK;
/** format and store in string: bLFormatS(string, sizeof(string), "Value %d", i); */
-char *bLFormatS(char *string, size_t stringSize, const char *fmt, ...);
+char *bLFormatS(char *string, size_t stringSize, const char *fmt, ...) MUST_CHECK;
// append strings
-char *appendS(const char *string1, const char *string2);
-char *appendCharS(const char *string1, char c);
-char *appendSChar(char c, const char *string2);
-char *iAppendS(char **string1, const char *string2);
-char *iAppendCharS(char **string1, char c);
-char *iAppendNFreeS(char **string1, char *string2);
-char *iAppendManySF(char **string, const char *paramType, ...);
+char *appendS(const char *string1, const char *string2) MUST_CHECK;
+char *appendCharS(const char *string1, char c) MUST_CHECK;
+char *appendSChar(char c, const char *string2) MUST_CHECK;
+char *iAppendS(char **string1, const char *string2) MUST_CHECK;
+char *iAppendCharS(char **string1, char c) MUST_CHECK;
+char *iAppendNFreeS(char **string1, char *string2) MUST_CHECK;
+char *iAppendManySF(char **string, const char *paramType, ...) MUST_CHECK;
#define iAppendManyS(s, s1, ...) iAppendManySF(s, s1, __VA_ARGS__, NULL)
-char *bAppendManySF(char *string, const char *paramType, ...);
+char *bAppendManySF(char *string, const char *paramType, ...) MUST_CHECK;
#define bAppendManyS(s, s1, ...) bAppendManySF(s, s1, __VA_ARGS__, NULL)
-char *bLAppendManySF(char *string, size_t stringSize, const char *paramType, ...);
+char *bLAppendManySF(char *string, size_t stringSize, const char *paramType, ...) MUST_CHECK;
#define bLAppendManyS(s, sSize, s1, ...) bLAppendManySF(s, sSize, s1, __VA_ARGS__, NULL)
// prepend string
-char *prependS(const char *string1, const char *string2);
-char *prependCharS(const char *string1, char c);
-char *prependSChar(char c, const char *string2);
-char *iPrependS(char **string1, const char *string2);
-char *iPrependCharS(char **string1, char c);
-char *iPrependNFreeS(char **string1, char *string2);
-char *bPrependS(char *string1, const char *string2);
-char *bLPrependS(char *string1, size_t string1Size, const char *string2);
+char *prependS(const char *string1, const char *string2) MUST_CHECK;
+char *prependCharS(const char *string1, char c) MUST_CHECK;
+char *prependSChar(char c, const char *string2) MUST_CHECK;
+char *iPrependS(char **string1, const char *string2) MUST_CHECK;
+char *iPrependCharS(char **string1, char c) MUST_CHECK;
+char *iPrependNFreeS(char **string1, char *string2) MUST_CHECK;
+char *bPrependS(char *string1, const char *string2) MUST_CHECK;
+char *bLPrependS(char *string1, size_t string1Size, const char *string2) MUST_CHECK;
// string replace
-char *replaceS(const char *s, const char *olds, const char *news, size_t max);
-char *replaceCharSS(const char *s, char olds, const char *news, size_t max);
-char *replaceSCharS(const char *s, const char *olds, char news, size_t max);
-char *replaceCharCharS(const char *s, char olds, char news, size_t max);
+char *replaceS(const char *s, const char *olds, const char *news, size_t max) MUST_CHECK;
+char *replaceCharSS(const char *s, char olds, const char *news, size_t max) MUST_CHECK;
+char *replaceSCharS(const char *s, const char *olds, char news, size_t max) MUST_CHECK;
+char *replaceCharCharS(const char *s, char olds, char news, size_t max) MUST_CHECK;
#define replaceS_max(s,olds,news) replaceS(s,olds,news, 0)
#define replaceSMax replaceS_max
-char* iReplaceS(char **s, const char *olds, const char *news, size_t max);
-char* iReplaceCharSS(char **s, char olds, const char *news, size_t max);
-char* iReplaceSCharS(char **s, const char *olds, char news, size_t max);
-char* iReplaceCharCharS(char **s, char olds, char news, size_t max);
+char* iReplaceS(char **s, const char *olds, const char *news, size_t max) MUST_CHECK;
+char* iReplaceCharSS(char **s, char olds, const char *news, size_t max) MUST_CHECK;
+char* iReplaceSCharS(char **s, const char *olds, char news, size_t max) MUST_CHECK;
+char* iReplaceCharCharS(char **s, char olds, char news, size_t max) MUST_CHECK;
#define iReplaceS_max(s,olds,news) iReplaceS(s,olds,news, 0)
#define iReplaceSMax iReplaceS_max
-char* bReplaceS(char *s, const char *olds, const char *news, size_t max);
+char* bReplaceS(char *s, const char *olds, const char *news, size_t max) MUST_CHECK;
#define bReplaceS_max(s,olds,news) bReplaceS(s,olds,news, 0)
#define bReplaceSMax bReplaceS_max
-char* bLReplaceS(char *s, size_t sSize, const char *olds, const char *news, size_t max);
+char* bLReplaceS(char *s, size_t sSize, const char *olds, const char *news, size_t max) MUST_CHECK;
#define bLReplaceS_max(s,sSize,olds,news) bLReplaceS(s,sSize,olds,news, 0)
#define bLReplaceSMax bLReplaceS_max
// string replace many olds with news (s, olds1, news1, olds2, news2,...)
-char *replaceManySF(const char *paramType, ...);
+char *replaceManySF(const char *paramType, ...) MUST_CHECK;
#define replaceManyS(s, ...) replaceManySF(s, __VA_ARGS__, NULL)
-char *iReplaceManySF(char **string, char *paramType, ...);
+char *iReplaceManySF(char **string, char *paramType, ...) MUST_CHECK;
#define iReplaceManyS(s, olds, ...) iReplaceManySF(s, olds, __VA_ARGS__, NULL)
-char *bReplaceManySF(char *s, char *paramType, ...);
+char *bReplaceManySF(char *s, char *paramType, ...) MUST_CHECK;
#define bReplaceManyS(s, olds, ...) bReplaceManySF(s, olds, __VA_ARGS__, NULL)
-char *bLReplaceManySF(char *s, size_t sSize, char *paramType, ...);
+char *bLReplaceManySF(char *s, size_t sSize, char *paramType, ...) MUST_CHECK;
#define bLReplaceManyS(s, sSize, olds, ...) bLReplaceManySF(s, sSize, olds, __VA_ARGS__, NULL)
// ignore case string replace
-char *icReplaceS(const char *s, const char *olds, const char *news, size_t max);
-char *icReplaceCharSS(const char *s, char olds, const char *news, size_t max);
-char *icReplaceSCharS(const char *s, const char *olds, char news, size_t max);
-char *icReplaceCharCharS(const char *s, char olds, char news, size_t max);
+char *icReplaceS(const char *s, const char *olds, const char *news, size_t max) MUST_CHECK;
+char *icReplaceCharSS(const char *s, char olds, const char *news, size_t max) MUST_CHECK;
+char *icReplaceSCharS(const char *s, const char *olds, char news, size_t max) MUST_CHECK;
+char *icReplaceCharCharS(const char *s, char olds, char news, size_t max) MUST_CHECK;
#define icReplaceS_max(s,olds,news) icReplaceS(s,olds,news, 0)
#define icReplaceSMax icReplaceS_max
-char* iicReplaceS(char **s, const char *olds, const char *news, size_t max);
-char* iicReplaceCharSS(char **s, char olds, const char *news, size_t max);
-char* iicReplaceSCharS(char **s, const char *olds, char news, size_t max);
-char* iicReplaceCharCharS(char **s, char olds, char news, size_t max);
+char* iicReplaceS(char **s, const char *olds, const char *news, size_t max) MUST_CHECK;
+char* iicReplaceCharSS(char **s, char olds, const char *news, size_t max) MUST_CHECK;
+char* iicReplaceSCharS(char **s, const char *olds, char news, size_t max) MUST_CHECK;
+char* iicReplaceCharCharS(char **s, char olds, char news, size_t max) MUST_CHECK;
#define iicReplaceS_max(s,olds,news) iicReplaceS(s,olds,news, 0)
#define iicReplaceSMax iicReplaceS_max
-char* bicReplaceS(char *s, const char *olds, const char *news, size_t max);
+char* bicReplaceS(char *s, const char *olds, const char *news, size_t max) MUST_CHECK;
#define bicReplaceS_max(s,olds,news) bicReplaceS(s,olds,news, 0)
#define bicReplaceSMax bicReplaceS_max
-char* bLicReplaceS(char *s, size_t sSize, const char *olds, const char *news, size_t max);
+char* bLicReplaceS(char *s, size_t sSize, const char *olds, const char *news, size_t max) MUST_CHECK;
#define bLicReplaceS_max(s,sSize,olds,news) bLicReplaceS(s,sSize,olds,news, 0)
#define bLicReplaceSMax bLicReplaceS_max
// string replace many olds with news (s, olds1, news1, olds2, news2,...)
-char *icReplaceManySF(const char *paramType, ...);
+char *icReplaceManySF(const char *paramType, ...) MUST_CHECK;
#define icReplaceManyS(s, ...) icReplaceManySF(s, __VA_ARGS__, NULL)
-char *iicReplaceManySF(char **string, char *paramType, ...);
+char *iicReplaceManySF(char **string, char *paramType, ...) MUST_CHECK;
#define iicReplaceManyS(s, olds, ...) iicReplaceManySF(s, olds, __VA_ARGS__, NULL)
-char *bicReplaceManySF(char *s, char *paramType, ...);
+char *bicReplaceManySF(char *s, char *paramType, ...) MUST_CHECK;
#define bicReplaceManyS(s, olds, ...) bicReplaceManySF(s, olds, __VA_ARGS__, NULL)
-char *bLicReplaceManySF(char *s, size_t sSize, char *paramType, ...);
+char *bLicReplaceManySF(char *s, size_t sSize, char *paramType, ...) MUST_CHECK;
#define bLicReplaceManyS(s, sSize, olds, ...) bLicReplaceManySF(s, sSize, olds, __VA_ARGS__, NULL)
// string equal (compare content)
-bool eqS(const char *string1, const char *string2);
+bool eqS(const char *string1, const char *string2) MUST_CHECK;
#define strEq eqS
-bool eqCharS(char c, const char *string2);
-bool eqSChar(const char *string1, char c);
+bool eqCharS(char c, const char *string2) MUST_CHECK;
+bool eqSChar(const char *string1, char c) MUST_CHECK;
// string equal at index (compare content)
-bool eqIS(const char *string1, const char *string2, int64_t index);
+bool eqIS(const char *string1, const char *string2, int64_t index) MUST_CHECK;
#define strIEq eqIS
-bool eqICharS(const char *string1, char c, int64_t index);
+bool eqICharS(const char *string1, char c, int64_t index) MUST_CHECK;
// look for string2 at string1 start
-bool startsWithS(const char *string1, const char *string2);
-bool startsWithCharS(const char *string1, char c);
+bool startsWithS(const char *string1, const char *string2) MUST_CHECK;
+bool startsWithCharS(const char *string1, char c) MUST_CHECK;
// look for string2 at string1 end
-bool endsWithS(const char *string1, const char *string2);
-bool endsWithCharS(const char *string1, char c);
+bool endsWithS(const char *string1, const char *string2) MUST_CHECK;
+bool endsWithCharS(const char *string1, char c) MUST_CHECK;
// count number of (non-overlapping) occurrences of a substring
-ssize_t countS(const char *s, const char *needle);
-ssize_t countCharS(const char *s, char c);
+ssize_t countS(const char *s, const char *needle) MUST_CHECK;
+ssize_t countCharS(const char *s, char c) MUST_CHECK;
// ignore case string equal (compare content)
-bool icEqS(const char *string1, const char *string2);
-bool icEqCharS(char c, const char *string2);
-bool icEqSChar(const char *string1, char c);
+bool icEqS(const char *string1, const char *string2) MUST_CHECK;
+bool icEqCharS(char c, const char *string2) MUST_CHECK;
+bool icEqSChar(const char *string1, char c) MUST_CHECK;
// ignore case string equal at index (compare content)
-bool icEqIS(const char *string1, const char *string2, int64_t index);
-bool icEqICharS(const char *string1, char c, int64_t index);
+bool icEqIS(const char *string1, const char *string2, int64_t index) MUST_CHECK;
+bool icEqICharS(const char *string1, char c, int64_t index) MUST_CHECK;
// ignore case and look for string2 at string1 start
-bool icStartsWithS(const char *string1, const char *string2);
-bool icStartsWithCharS(const char *string1, char c);
+bool icStartsWithS(const char *string1, const char *string2) MUST_CHECK;
+bool icStartsWithCharS(const char *string1, char c) MUST_CHECK;
// ignore case look for string2 at string1 end
-bool icEndsWithS(const char *string1, const char *string2);
-bool icEndsWithCharS(const char *string1, char c);
+bool icEndsWithS(const char *string1, const char *string2) MUST_CHECK;
+bool icEndsWithCharS(const char *string1, char c) MUST_CHECK;
// ignore case and count number of (non-overlapping) occurrences of a substring
-ssize_t icCountS(const char *s, const char *needle);
-ssize_t icCountCharS(const char *s, char c);
+ssize_t icCountS(const char *s, const char *needle) MUST_CHECK;
+ssize_t icCountCharS(const char *s, char c) MUST_CHECK;
// has terminal control char (for example colors)
-bool hasCtrlChar(const char *string);
+bool hasCtrlChar(const char *string) MUST_CHECK;
// remove terminal control char from string
-char *stripCtrlS(const char *string);
-char *iStripCtrlS(char **string);
-char *bStripCtrlS(char *string);
+char *stripCtrlS(const char *string) MUST_CHECK;
+char *iStripCtrlS(char **string) MUST_CHECK;
+char *bStripCtrlS(char *string) MUST_CHECK;
// true when string is a number (integer or float)
-bool isNumber(const char *string);
+bool isNumber(const char *string) MUST_CHECK;
// true when string is an integer
-bool isInt(const char *string);
+bool isInt(const char *string) MUST_CHECK;
// parseInt
-int64_t parseInt(const char *string);
-int64_t parseIntChar(char c);
-int64_t parseI64(const char *string);
-int64_t parseI64Char(char c);
+int64_t parseInt(const char *string) MUST_CHECK;
+int64_t parseIntChar(char c) MUST_CHECK;
+int64_t parseI64(const char *string) MUST_CHECK;
+int64_t parseI64Char(char c) MUST_CHECK;
// parseDouble
-double parseDouble(const char *string);
-double parseDoubleChar(char c);
+double parseDouble(const char *string) MUST_CHECK;
+double parseDoubleChar(char c) MUST_CHECK;
// parse hexadecimal string: 0xff
-uint64_t parseHex(const char *string);
+uint64_t parseHex(const char *string) MUST_CHECK;
// TODO parseHexChar
// convert int to string
-char *intToS(int64_t n);
-char *bIntToS(char *s, int64_t n);
+char *intToS(int64_t n) MUST_CHECK;
+char *bIntToS(char *s, int64_t n) MUST_CHECK;
// convert double to string
-char *doubleToS(double n);
-char *bDoubleToS(char *s, double n);
+char *doubleToS(double n) MUST_CHECK;
+char *bDoubleToS(char *s, double n) MUST_CHECK;
// length
-size_t lenS(const char *string);
+size_t lenS(const char *string) MUST_CHECK;
// string buffer size: strlen+1
-size_t sizeS(const char *string);
+size_t sizeS(const char *string) MUST_CHECK;
/**
* upper case and store the result in c and return the result
@@ -2037,9 +2054,9 @@ size_t sizeS(const char *string);
#define toUpper(c) ((c) = toupper(c), c)
// duplicate and upper case
-char *upperS(const char *string);
-char *iUpperS(char **string);
-char *bUpperS(char *string);
+char *upperS(const char *string) MUST_CHECK;
+char *iUpperS(char **string) MUST_CHECK;
+char *bUpperS(char *string) MUST_CHECK;
/**
* lower case and store the result in c and return the result
@@ -2047,172 +2064,172 @@ char *bUpperS(char *string);
#define toLower(c) ((c) = tolower(c), c)
// duplicate and lower case
-char *lowerS(const char *string);
-char *iLowerS(char **string);
-char *bLowerS(char *string);
+char *lowerS(const char *string) MUST_CHECK;
+char *iLowerS(char **string) MUST_CHECK;
+char *bLowerS(char *string) MUST_CHECK;
// duplicate and trim
-char *trimS(const char *string);
-char *iTrimS(char **string);
-char *bTrimS(char *string);
-char *lTrimS(const char *string);
-char *iLTrimS(char **string);
-char *bLTrimS(char *string);
-char *rTrimS(const char *string);
-char *iRTrimS(char **string);
-char *bRTrimS(char *string);
+char *trimS(const char *string) MUST_CHECK;
+char *iTrimS(char **string) MUST_CHECK;
+char *bTrimS(char *string) MUST_CHECK;
+char *lTrimS(const char *string) MUST_CHECK;
+char *iLTrimS(char **string) MUST_CHECK;
+char *bLTrimS(char *string) MUST_CHECK;
+char *rTrimS(const char *string) MUST_CHECK;
+char *iRTrimS(char **string) MUST_CHECK;
+char *bRTrimS(char *string) MUST_CHECK;
// remove successive repetitions of char c
-char *uniqS(const char *string, char c);
-char *iUniqS(char **string, char c);
-char *bUniqS(char *string, char c);
+char *uniqS(const char *string, char c) MUST_CHECK;
+char *iUniqS(char **string, char c) MUST_CHECK;
+char *bUniqS(char *string, char c) MUST_CHECK;
#define uniqSlash(s) uniqS(s, '/')
#define iUniqSlash(s) iUniqS(&(s), '/')
#define bUniqSlash(s) bUniqS(s, '/')
// ignore case and remove successive repetitions of char c
-char *icUniqS(const char *string, char c);
-char *iicUniqS(char **string, char c);
-char *bicUniqS(char *string, char c);
+char *icUniqS(const char *string, char c) MUST_CHECK;
+char *iicUniqS(char **string, char c) MUST_CHECK;
+char *bicUniqS(char *string, char c) MUST_CHECK;
// repeat string count times
-char *repeatS(const char *string, size_t count);
-char *iRepeatS(char **string, size_t count);
-char *bRepeatS(char *dest, const char *string, size_t count);
-char *bLRepeatS(char *dest, size_t destSize, const char *string, size_t count);
-char *repeatCharS(char c, size_t count);
-char *bRepeatCharS(char *dest, char c, size_t count);
-char *bLRepeatCharS(char *dest, size_t destSize, char c, size_t count);
+char *repeatS(const char *string, size_t count) MUST_CHECK;
+char *iRepeatS(char **string, size_t count) MUST_CHECK;
+char *bRepeatS(char *dest, const char *string, size_t count) MUST_CHECK;
+char *bLRepeatS(char *dest, size_t destSize, const char *string, size_t count) MUST_CHECK;
+char *repeatCharS(char c, size_t count) MUST_CHECK;
+char *bRepeatCharS(char *dest, char c, size_t count) MUST_CHECK;
+char *bLRepeatCharS(char *dest, size_t destSize, char c, size_t count) MUST_CHECK;
// length of string repeated count times
-ssize_t repeatLenS(const char *string, size_t count);
+ssize_t repeatLenS(const char *string, size_t count) MUST_CHECK;
// ellipsisStart string
-char *ellipsisStartS(const char *string, size_t targetLength, const char *ellipsisString);
-char *iEllipsisStartS(char **string, size_t targetLength, const char *ellipsisString);
-char *bEllipsisStartS(char *dest, const char *string, size_t targetLength, const char *ellipsisString);
-char *bLEllipsisStartS(char *dest, size_t destSize, const char *string, size_t targetLength, const char *ellipsisString);
-char *ellipsisStartCharS(const char *string, size_t targetLength, char ellipsisChar);
-char *iEllipsisStartCharS(char **string, size_t targetLength, char ellipsisChar);
-char *bEllipsisStartCharS(char *dest, const char *string, size_t targetLength, char ellipsisChar);
-char *bLEllipsisStartCharS(char *dest, size_t destSize, const char *string, size_t targetLength, char ellipsisChar);
+char *ellipsisStartS(const char *string, size_t targetLength, const char *ellipsisString) MUST_CHECK;
+char *iEllipsisStartS(char **string, size_t targetLength, const char *ellipsisString) MUST_CHECK;
+char *bEllipsisStartS(char *dest, const char *string, size_t targetLength, const char *ellipsisString) MUST_CHECK;
+char *bLEllipsisStartS(char *dest, size_t destSize, const char *string, size_t targetLength, const char *ellipsisString) MUST_CHECK;
+char *ellipsisStartCharS(const char *string, size_t targetLength, char ellipsisChar) MUST_CHECK;
+char *iEllipsisStartCharS(char **string, size_t targetLength, char ellipsisChar) MUST_CHECK;
+char *bEllipsisStartCharS(char *dest, const char *string, size_t targetLength, char ellipsisChar) MUST_CHECK;
+char *bLEllipsisStartCharS(char *dest, size_t destSize, const char *string, size_t targetLength, char ellipsisChar) MUST_CHECK;
// length of string after ellipsis
-ssize_t ellipsisLenS(const char *string, size_t targetLength, const char *ellipsisString);
+ssize_t ellipsisLenS(const char *string, size_t targetLength, const char *ellipsisString) MUST_CHECK;
// ellipsisEnd string
-char *ellipsisEndS(const char *string, size_t targetLength, const char *ellipsisString);
-char *iEllipsisEndS(char **string, size_t targetLength, const char *ellipsisString);
-char *bEllipsisEndS(char *dest, const char *string, size_t targetLength, const char *ellipsisString);
-char *bLEllipsisEndS(char *dest, size_t destSize, const char *string, size_t targetLength, const char *ellipsisString);
-char *ellipsisEndCharS(const char *string, size_t targetLength, char ellipsisChar);
-char *iEllipsisEndCharS(char **string, size_t targetLength, char ellipsisChar);
-char *bEllipsisEndCharS(char *dest, const char *string, size_t targetLength, char ellipsisChar);
-char *bLEllipsisEndCharS(char *dest, size_t destSize, const char *string, size_t targetLength, char ellipsisChar);
+char *ellipsisEndS(const char *string, size_t targetLength, const char *ellipsisString) MUST_CHECK;
+char *iEllipsisEndS(char **string, size_t targetLength, const char *ellipsisString) MUST_CHECK;
+char *bEllipsisEndS(char *dest, const char *string, size_t targetLength, const char *ellipsisString) MUST_CHECK;
+char *bLEllipsisEndS(char *dest, size_t destSize, const char *string, size_t targetLength, const char *ellipsisString) MUST_CHECK;
+char *ellipsisEndCharS(const char *string, size_t targetLength, char ellipsisChar) MUST_CHECK;
+char *iEllipsisEndCharS(char **string, size_t targetLength, char ellipsisChar) MUST_CHECK;
+char *bEllipsisEndCharS(char *dest, const char *string, size_t targetLength, char ellipsisChar) MUST_CHECK;
+char *bLEllipsisEndCharS(char *dest, size_t destSize, const char *string, size_t targetLength, char ellipsisChar) MUST_CHECK;
// padStart string
-char *padStartS(const char *string, size_t targetLength, const char *padString);
-char *iPadStartS(char **string, size_t targetLength, const char *padString);
-char *bPadStartS(char *dest, const char *string, size_t targetLength, const char *padString);
-char *bLPadStartS(char *dest, size_t destSize, const char *string, size_t targetLength, const char *padString);
-char *padStartCharS(const char *string, size_t targetLength, char padChar);
-char *iPadStartCharS(char **string, size_t targetLength, char padChar);
-char *bPadStartCharS(char *dest, const char *string, size_t targetLength, char padChar);
-char *bLPadStartCharS(char *dest, size_t destSize, const char *string, size_t targetLength, char padChar);
+char *padStartS(const char *string, size_t targetLength, const char *padString) MUST_CHECK;
+char *iPadStartS(char **string, size_t targetLength, const char *padString) MUST_CHECK;
+char *bPadStartS(char *dest, const char *string, size_t targetLength, const char *padString) MUST_CHECK;
+char *bLPadStartS(char *dest, size_t destSize, const char *string, size_t targetLength, const char *padString) MUST_CHECK;
+char *padStartCharS(const char *string, size_t targetLength, char padChar) MUST_CHECK;
+char *iPadStartCharS(char **string, size_t targetLength, char padChar) MUST_CHECK;
+char *bPadStartCharS(char *dest, const char *string, size_t targetLength, char padChar) MUST_CHECK;
+char *bLPadStartCharS(char *dest, size_t destSize, const char *string, size_t targetLength, char padChar) MUST_CHECK;
// length of string after padStart
-ssize_t padStartLenS(const char *string, size_t targetLength, const char *padString);
+ssize_t padStartLenS(const char *string, size_t targetLength, const char *padString) MUST_CHECK;
// padEnd string
-char *padEndS(const char *string, size_t targetLength, const char *padString);
-char *iPadEndS(char **string, size_t targetLength, const char *padString);
-char *bPadEndS(char *dest, const char *string, size_t targetLength, const char *padString);
-char *bLPadEndS(char *dest, size_t destSize, const char *string, size_t targetLength, const char *padString);
-char *padEndCharS(const char *string, size_t targetLength, char padChar);
-char *iPadEndCharS(char **string, size_t targetLength, char padChar);
-char *bPadEndCharS(char *dest, const char *string, size_t targetLength, char padChar);
-char *bLPadEndCharS(char *dest, size_t destSize, const char *string, size_t targetLength, char padChar);
+char *padEndS(const char *string, size_t targetLength, const char *padString) MUST_CHECK;
+char *iPadEndS(char **string, size_t targetLength, const char *padString) MUST_CHECK;
+char *bPadEndS(char *dest, const char *string, size_t targetLength, const char *padString) MUST_CHECK;
+char *bLPadEndS(char *dest, size_t destSize, const char *string, size_t targetLength, const char *padString) MUST_CHECK;
+char *padEndCharS(const char *string, size_t targetLength, char padChar) MUST_CHECK;
+char *iPadEndCharS(char **string, size_t targetLength, char padChar) MUST_CHECK;
+char *bPadEndCharS(char *dest, const char *string, size_t targetLength, char padChar) MUST_CHECK;
+char *bLPadEndCharS(char *dest, size_t destSize, const char *string, size_t targetLength, char padChar) MUST_CHECK;
// length of string after padEnd
-ssize_t padEndLenS(const char *string, size_t targetLength, const char *padString);
+ssize_t padEndLenS(const char *string, size_t targetLength, const char *padString) MUST_CHECK;
// get char at python index
-char getS(const char *string, int64_t index);
+char getS(const char *string, int64_t index) MUST_CHECK;
// set char at python index
-char *setS(char *string, int64_t index, char c);
+char *setS(char *string, int64_t index, char c) MUST_CHECK;
// swap characters in a string
-char *swapS(char *string, int64_t index1, int64_t index2);
-char *iSwapS(char **string, int64_t index1, int64_t index2);
-char *bSwapS(char *string, int64_t index1, int64_t index2);
-char *bLSwapS(char *string, size_t size, int64_t index1, int64_t index2);
+char *swapS(char *string, int64_t index1, int64_t index2) MUST_CHECK;
+char *iSwapS(char **string, int64_t index1, int64_t index2) MUST_CHECK;
+char *bSwapS(char *string, int64_t index1, int64_t index2) MUST_CHECK;
+char *bLSwapS(char *string, size_t size, int64_t index1, int64_t index2) MUST_CHECK;
// slice string
// function to slice parts of a string [1:10] - python style indexes 0..len-1 -1..-len+1
-char *sliceS(const char *string, int64_t start, int64_t end);
-char *iSliceS(char **string, int64_t start, int64_t end);
-char *bSliceS(char *string, int64_t start, int64_t end);
-char *bLSliceS(char *string, size_t stringSize, int64_t start, int64_t end);
+char *sliceS(const char *string, int64_t start, int64_t end) MUST_CHECK;
+char *iSliceS(char **string, int64_t start, int64_t end) MUST_CHECK;
+char *bSliceS(char *string, int64_t start, int64_t end) MUST_CHECK;
+char *bLSliceS(char *string, size_t stringSize, int64_t start, int64_t end) MUST_CHECK;
// crop string (slice+del)
-char *cropS(char *string, int64_t start, int64_t end);
-char *iCropS(char **string, int64_t start, int64_t end);
-char cropElemS(char *string, int64_t index);
-char iCropElemS(char **string, int64_t index);
+char *cropS(char *string, int64_t start, int64_t end) MUST_CHECK;
+char *iCropS(char **string, int64_t start, int64_t end) MUST_CHECK;
+char cropElemS(char *string, int64_t index) MUST_CHECK;
+char iCropElemS(char **string, int64_t index) MUST_CHECK;
// insert string in string
-char *insertS(const char *string, int64_t index, const char *toInsert);
-char *insertNFreeS(const char *string, int64_t index, char *toInsert);
-char *iInsertS(char **string, int64_t index, const char *toInsert);
-char *iInsertNFreeS(char **string, int64_t index, char *toInsert);
-char *bInsertS(char *string, int64_t index, const char *toInsert);
-char *bLInsertS(char *string, size_t stringSize, int64_t index, const char *toInsert);
+char *insertS(const char *string, int64_t index, const char *toInsert) MUST_CHECK;
+char *insertNFreeS(const char *string, int64_t index, char *toInsert) MUST_CHECK;
+char *iInsertS(char **string, int64_t index, const char *toInsert) MUST_CHECK;
+char *iInsertNFreeS(char **string, int64_t index, char *toInsert) MUST_CHECK;
+char *bInsertS(char *string, int64_t index, const char *toInsert) MUST_CHECK;
+char *bLInsertS(char *string, size_t stringSize, int64_t index, const char *toInsert) MUST_CHECK;
// inject a char in string
-char *injectS(const char *string, int64_t index, char toInject);
-char *iInjectS(char **string, int64_t index, char toInject);
-char *bInjectS(char *string, int64_t index, char toInject);
-char *bLInjectS(char *string, size_t stringSize, int64_t index, char toInject);
+char *injectS(const char *string, int64_t index, char toInject) MUST_CHECK;
+char *iInjectS(char **string, int64_t index, char toInject) MUST_CHECK;
+char *bInjectS(char *string, int64_t index, char toInject) MUST_CHECK;
+char *bLInjectS(char *string, size_t stringSize, int64_t index, char toInject) MUST_CHECK;
// del string
// function to delete parts of a string [1:10] - python style indexes 0..len-1 -1..-len+1
-char *delS(const char *string, int64_t start, int64_t end);
-char *iDelS(char **string, int64_t start, int64_t end);
-char *bDelS(char *string, int64_t start, int64_t end);
-char *bLDelS(char *string, size_t stringSize, int64_t start, int64_t end);
+char *delS(const char *string, int64_t start, int64_t end) MUST_CHECK;
+char *iDelS(char **string, int64_t start, int64_t end) MUST_CHECK;
+char *bDelS(char *string, int64_t start, int64_t end) MUST_CHECK;
+char *bLDelS(char *string, size_t stringSize, int64_t start, int64_t end) MUST_CHECK;
// del a character in string
-char *delElemS(const char *string, int64_t index);
-char *iDelElemS(char **string, int64_t index);
-char *bDelElemS(char *string, int64_t index);
-char *bLDelElemS(char *string, size_t stringSize, int64_t index);
+char *delElemS(const char *string, int64_t index) MUST_CHECK;
+char *iDelElemS(char **string, int64_t index) MUST_CHECK;
+char *bDelElemS(char *string, int64_t index) MUST_CHECK;
+char *bLDelElemS(char *string, size_t stringSize, int64_t index) MUST_CHECK;
// find substring
-char *findS(const char *string, const char *needle);
-char *findCharS(const char *string, char c);
-ssize_t indexOfS(const char *string, const char *needle);
-ssize_t indexOfCharS(const char *string, char c);
+char *findS(const char *string, const char *needle) MUST_CHECK;
+char *findCharS(const char *string, char c) MUST_CHECK;
+ssize_t indexOfS(const char *string, const char *needle) MUST_CHECK;
+ssize_t indexOfCharS(const char *string, char c) MUST_CHECK;
// true when needle is found
-bool hasS(const char *string, const char *needle);
-bool hasCharS(const char *string, char c);
+bool hasS(const char *string, const char *needle) MUST_CHECK;
+bool hasCharS(const char *string, char c) MUST_CHECK;
// ignore case find substring
-char *icFindS(const char *string, const char *needle);
-char *icFindCharS(const char *string, char c);
-ssize_t icIndexOfS(const char *string, const char *needle);
-ssize_t icIndexOfCharS(const char *string, char c);
+char *icFindS(const char *string, const char *needle) MUST_CHECK;
+char *icFindCharS(const char *string, char c) MUST_CHECK;
+ssize_t icIndexOfS(const char *string, const char *needle) MUST_CHECK;
+ssize_t icIndexOfCharS(const char *string, char c) MUST_CHECK;
// ignore case, true when needle is found
-bool icHasS(const char *string, const char *needle);
-bool icHasCharS(const char *string, char c);
+bool icHasS(const char *string, const char *needle) MUST_CHECK;
+bool icHasCharS(const char *string, char c) MUST_CHECK;
// parse s string with delim - work like strtok_r from stdlib
-char *tokS(const char *s, const char *delim, char **saveptr);
+char *tokS(char *s, const char *delim, char **saveptr) MUST_CHECK;
// ignore case and parse s string with delim - work like strtok_r from stdlib
-char *icTokS(const char *s, const char *delim, char **saveptr);
+char *icTokS(char *s, const char *delim, char **saveptr) MUST_CHECK;
//
// UTF8 string functions
@@ -2222,15 +2239,15 @@ char *icTokS(const char *s, const char *delim, char **saveptr);
typedef int rune;
// character length of UTF-8 encoded string
-size_t lenUTF8(const char *s);
-size_t bLLenUTF8(const char *s, size_t maxSize);
+size_t lenUTF8(const char *s) MUST_CHECK;
+size_t bLLenUTF8(const char *s, size_t maxSize) MUST_CHECK;
// is string valid UTF-8 encoded string
-bool isUTF8(const char * string);
-bool bLIsUTF8(const char * string, size_t stringSize);
+bool isUTF8(const char * string) MUST_CHECK;
+bool bLIsUTF8(const char * string, size_t stringSize) MUST_CHECK;
// is string a valid UTF-8 code point
-bool isCodeUTF8(const char *code);
+bool isCodeUTF8(const char *code) MUST_CHECK;
extern const uint8_t codeSzUTF8[256];
@@ -2238,212 +2255,212 @@ extern const uint8_t codeSzUTF8[256];
#define codeSizeUTF8(utf8) codeSzUTF8[*(const uint8_t *)(utf8)]
/** move pointer to next UTF-8 code point, no checks are done, the utf8 pointer parameter is unchanged */
-#define nextCodeUTF8(utf8) (char *)((utf8) + codeSizeUTF8(utf8))
+#define nextCodeUTF8(utf8) ((utf8) + codeSizeUTF8(utf8))
/** change the utf8 pointer parameter to next UTF-8 code point, like char *s; s++; */
#define nxtCodeUTF8(utf8) EVA(utf8, nextCodeUTF8(utf8))
#define nxCodeUTF8(utf8) (utf8 = nextCodeUTF8(utf8))
// next code point, works only when utf8 points to a valid code point
-char *nextUTF8(const char *utf8);
-char *bLNextUTF8(const char *string, size_t utf8Size, const char *utf8);
+const char *nextUTF8(const char *utf8) MUST_CHECK;
+const char *bLNextUTF8(const char *string, size_t utf8Size, const char *utf8) MUST_CHECK;
// find next code point even when utf8 points inside a code point
-char *findNextUTF8(const char *string, size_t utf8Size, const char *utf8);
+const char *findNextUTF8(const char *string, size_t utf8Size, const char *utf8) MUST_CHECK;
// previous code point, undefined behavior when utf8 points to the start of the string
-char *prevUTF8(const char *utf8);
+const char *prevUTF8(const char *utf8) MUST_CHECK;
// previous code point
-char *bPrevUTF8(const char *string, const char *utf8);
+const char *bPrevUTF8(const char *string, const char *utf8) MUST_CHECK;
// character index to pointer
-char *idx2PtrUTF8(const char *utf8, int64_t index);
-char *bLIdx2PtrUTF8(const char *utf8, size_t utf8Size, int64_t index);
+const char *idx2PtrUTF8(const char *utf8, int64_t index) MUST_CHECK;
+const char *bLIdx2PtrUTF8(const char *utf8, size_t utf8Size, int64_t index) MUST_CHECK;
// pointer to character index
-int64_t ptr2IdxUTF8(const char *utf8, const char *pos);
-int64_t bPtr2IdxUTF8(const char *start, const char *utf8, const char *pos);
-int64_t bLPtr2IdxUTF8(const char *utf8, size_t utf8Size, const char *pos);
-int64_t bLPtr2NegIdxUTF8(const char *utf8, size_t utf8Size, const char *pos);
+int64_t ptr2IdxUTF8(const char *utf8, const char *pos) MUST_CHECK;
+int64_t bPtr2IdxUTF8(const char *start, const char *utf8, const char *pos) MUST_CHECK;
+int64_t bLPtr2IdxUTF8(const char *utf8, size_t utf8Size, const char *pos) MUST_CHECK;
+int64_t bLPtr2NegIdxUTF8(const char *utf8, size_t utf8Size, const char *pos) MUST_CHECK;
// make new valid UTF-8 encoded string
-char *makeValidUTF8(const char *utf8);
+char *makeValidUTF8(const char *utf8) MUST_CHECK;
// make utf8 a valid UTF-8 encoded string
-char *bMakeValidUTF8(char *utf8);
-char *nMakeValidUTF8(const char *utf8, size_t utf8Len);
-char *bNMakeValidUTF8(char *dst, const char *utf8, size_t utf8Len);
-char *bLMakeValidUTF8(char *dst, size_t dstSize, const char *utf8);
-char *bLNMakeValidUTF8(char *dst, size_t dstSize, const char *utf8, size_t utf8Len);
+char *bMakeValidUTF8(char *utf8) MUST_CHECK;
+char *nMakeValidUTF8(const char *utf8, size_t utf8Len) MUST_CHECK;
+char *bNMakeValidUTF8(char *dst, const char *utf8, size_t utf8Len) MUST_CHECK;
+char *bLMakeValidUTF8(char *dst, size_t dstSize, const char *utf8) MUST_CHECK;
+char *bLNMakeValidUTF8(char *dst, size_t dstSize, const char *utf8, size_t utf8Len) MUST_CHECK;
// strncpy where srcLen is number of characters
-char *strNCpyUTF8(char *dst, const char *src, size_t srcLen);
+char *strNCpyUTF8(char *dst, const char *src, size_t srcLen) MUST_CHECK;
// strLCpy for UTF-8 encoded strings
-char *strLCpyUTF8(char *dst, size_t dstSize, const char *src);
+char *strLCpyUTF8(char *dst, size_t dstSize, const char *src) MUST_CHECK;
// strncat where srcLen is number of characters
-char *strNCatUTF8(char *dst, const char *src, size_t srcLen);
+char *strNCatUTF8(char *dst, const char *src, size_t srcLen) MUST_CHECK;
// strLCat for UTF-8 encoded strings
-char *strLCatUTF8(char *dst, size_t dstSize, const char *src);
+char *strLCatUTF8(char *dst, size_t dstSize, const char *src) MUST_CHECK;
// strLNCat for UTF-8 encoded strings
-char *strLNCatUTF8(char *dst, size_t dstSize, const char *src, size_t srcLen);
+char *strLNCatUTF8(char *dst, size_t dstSize, const char *src, size_t srcLen) MUST_CHECK;
// TODO
-char* icReplaceUTF8(const char *s, const char *olds, const char *news, size_t max);
+char* icReplaceUTF8(const char *s, const char *olds, const char *news, size_t max) MUST_CHECK;
// TODO
-char *icReplaceCharSUTF8(const char *s, char olds, const char *news, size_t max);
+char *icReplaceCharSUTF8(const char *s, char olds, const char *news, size_t max) MUST_CHECK;
// TODO
-char *icReplaceSCharUTF8(const char *s, const char *olds, char news, size_t max);
+char *icReplaceSCharUTF8(const char *s, const char *olds, char news, size_t max) MUST_CHECK;
// TODO
-char* iicReplaceUTF8(char **s, const char *olds, const char *news, size_t max);
+char* iicReplaceUTF8(char **s, const char *olds, const char *news, size_t max) MUST_CHECK;
// TODO
-char *iicReplaceCharSUTF8(char **s, char olds, const char *news, size_t max);
+char *iicReplaceCharSUTF8(char **s, char olds, const char *news, size_t max) MUST_CHECK;
// TODO
-char *iicReplaceSCharUTF8(char **s, const char *olds, char news, size_t max);
+char *iicReplaceSCharUTF8(char **s, const char *olds, char news, size_t max) MUST_CHECK;
// TODO
-char* bicReplaceUTF8(char *s, const char *olds, const char *news, size_t max);
+char* bicReplaceUTF8(char *s, const char *olds, const char *news, size_t max) MUST_CHECK;
// TODO
-char* bLicReplaceUTF8(char *s, size_t sSize, const char *olds, const char *news, size_t max);
+char* bLicReplaceUTF8(char *s, size_t sSize, const char *olds, const char *news, size_t max) MUST_CHECK;
// TODO
-char *icReplaceManyUTF8F(const char *paramType, ...);
+char *icReplaceManyUTF8F(const char *paramType, ...) MUST_CHECK;
// TODO
-char *iicReplaceManyUTF8F(char **s, char *paramType, ...);
+char *iicReplaceManyUTF8F(char **s, char *paramType, ...) MUST_CHECK;
// TODO
-char *bicReplaceManyUTF8F(char *s, char *paramType, ...);
+char *bicReplaceManyUTF8F(char *s, char *paramType, ...) MUST_CHECK;
// TODO
-char *bLicReplaceManyUTF8F(char *s, size_t sSize, char *paramType, ...);
+char *bLicReplaceManyUTF8F(char *s, size_t sSize, char *paramType, ...) MUST_CHECK;
// UTF8 encoded string Index Equal
-bool eqIUTF8(const char *string1, const char *string2, int64_t index);
+bool eqIUTF8(const char *string1, const char *string2, int64_t index) MUST_CHECK;
// UTF8 encoded string Index Equal
-bool eqICharUTF8(const char *string1, char c, int64_t index);
+bool eqICharUTF8(const char *string1, char c, int64_t index) MUST_CHECK;
// ignore case UTF8 encoded string Equal
-bool icEqUTF8(const char *string1, const char *string2);
-bool icEqCharUTF8(char c, const char *string2);
-bool icEqUTF8Char(const char *string1, char c);
+bool icEqUTF8(const char *string1, const char *string2) MUST_CHECK;
+bool icEqCharUTF8(char c, const char *string2) MUST_CHECK;
+bool icEqUTF8Char(const char *string1, char c) MUST_CHECK;
// TODO
-bool icEqIUTF8(const char *string1, const char *string2, int64_t index);
+bool icEqIUTF8(const char *string1, const char *string2, int64_t index) MUST_CHECK;
// TODO
-bool icEqICharUTF8(const char *string1, char c, int64_t index);
+bool icEqICharUTF8(const char *string1, char c, int64_t index) MUST_CHECK;
// starts with for UTF-8 encoded string
-bool icStartsWithUTF8(const char *string1, const char *string2);
+bool icStartsWithUTF8(const char *string1, const char *string2) MUST_CHECK;
// ends with for UTF-8 encoded string
-bool icEndsWithUTF8(const char *string1, const char *string2);
+bool icEndsWithUTF8(const char *string1, const char *string2) MUST_CHECK;
// ignore case count UTF8 encoded String
-ssize_t icCountUTF8(const char *s, const char *needle);
+ssize_t icCountUTF8(const char *s, const char *needle) MUST_CHECK;
// UTF-8 code point to rune
-rune code2RuneUTF8(const char *code);
-rune code2RuneLUTF8(const char *code, uint8_t *n);
+rune code2RuneUTF8(const char *code) MUST_CHECK;
+rune code2RuneLUTF8(const char *code, uint8_t *n) MUST_CHECK;
// rune to UTF-8 code point
-size_t bRune2CodeUTF8(char *dst, rune c);
+size_t bRune2CodeUTF8(char *dst, rune c) MUST_CHECK;
// rune length as UTF-8 code point
-uint8_t runeLenUTF8(rune r);
+uint8_t runeLenUTF8(rune r) MUST_CHECK;
// rune toupper UTF8
-rune toupperUTF8(rune c);
+rune toupperUTF8(rune c) MUST_CHECK;
// upper case UTF-8 encoded string
-char *upperUTF8(const char *string);
-char *iUpperUTF8(char **string);
+char *upperUTF8(const char *string) MUST_CHECK;
+char *iUpperUTF8(char **string) MUST_CHECK;
// TODO
-char *bUpperUTF8(char *string);
+char *bUpperUTF8(char *string) MUST_CHECK;
// rune tolower UTF8
-rune tolowerUTF8(rune c);
+rune tolowerUTF8(rune c) MUST_CHECK;
// lower case UTF-8 String
-char *lowerUTF8(const char *string);
-char *iLowerUTF8(char **string);
+char *lowerUTF8(const char *string) MUST_CHECK;
+char *iLowerUTF8(char **string) MUST_CHECK;
// TODO
-char *bLowerUTF8(char *string);
+char *bLowerUTF8(char *string) MUST_CHECK;
// transform UTF-8 string to make it comparable regardless of case
-char *casefoldUTF8(const char *utf8);
+char *casefoldUTF8(const char *utf8) MUST_CHECK;
// uniquify code point in UTF-8 String
-char *uniqUTF8(const char *string, const char *code);
-char *iUniqUTF8(char **string, const char *code);
-char *bUniqUTF8(char *string, const char *code);
+char *uniqUTF8(const char *string, const char *code) MUST_CHECK;
+char *iUniqUTF8(char **string, const char *code) MUST_CHECK;
+char *bUniqUTF8(char *string, const char *code) MUST_CHECK;
// TODO
-char *icUniqUTF8(const char *string, const char *code);
+char *icUniqUTF8(const char *string, const char *code) MUST_CHECK;
// TODO
-char *iicUniqUTF8(char **string, const char *code);
+char *iicUniqUTF8(char **string, const char *code) MUST_CHECK;
// TODO
-char *bicUniqUTF8(char *string, char c);
+char *bicUniqUTF8(char *string, char c) MUST_CHECK;
// get rune in UTF8 encoded string
-rune getUTF8(const char *string, int64_t index);
+rune getUTF8(const char *string, int64_t index) MUST_CHECK;
// TODO
-char *setUTF8(char *string, int64_t index, rune c);
+char *setUTF8(char *string, int64_t index, rune c) MUST_CHECK;
// slice UTF8 encoded String
-char *sliceUTF8(const char *string, int64_t start, int64_t end);
-char *iSliceUTF8(char **string, int64_t start, int64_t end);
-char *bSliceUTF8(char *string, int64_t start, int64_t end);
-char *bLSliceUTF8(char *string, size_t stringSize, int64_t start, int64_t end);
+char *sliceUTF8(const char *string, int64_t start, int64_t end) MUST_CHECK;
+char *iSliceUTF8(char **string, int64_t start, int64_t end) MUST_CHECK;
+char *bSliceUTF8(char *string, int64_t start, int64_t end) MUST_CHECK;
+char *bLSliceUTF8(char *string, size_t stringSize, int64_t start, int64_t end) MUST_CHECK;
// insert string in UTF8 encoded string at index
-char *insertUTF8(const char *string, int64_t index, const char *toInsert);
-char *insertNFreeUTF8(const char *string, int64_t index, char *toInsert);
-char *iInsertUTF8(char **string, int64_t index, const char *toInsert);
-char *iInsertNFreeUTF8(char **string, int64_t index, char *toInsert);
-char *bInsertUTF8(char *string, int64_t index, const char *toInsert);
-char *bLInsertUTF8(char *string, size_t stringSize, int64_t index, const char *toInsert);
+char *insertUTF8(const char *string, int64_t index, const char *toInsert) MUST_CHECK;
+char *insertNFreeUTF8(const char *string, int64_t index, char *toInsert) MUST_CHECK;
+char *iInsertUTF8(char **string, int64_t index, const char *toInsert) MUST_CHECK;
+char *iInsertNFreeUTF8(char **string, int64_t index, char *toInsert) MUST_CHECK;
+char *bInsertUTF8(char *string, int64_t index, const char *toInsert) MUST_CHECK;
+char *bLInsertUTF8(char *string, size_t stringSize, int64_t index, const char *toInsert) MUST_CHECK;
// delete UTF8 encoded string
-char *delUTF8(const char *string, int64_t start, int64_t end);
-char *iDelUTF8(char **string, int64_t start, int64_t end);
-char *bDelUTF8(char *string, int64_t start, int64_t end);
-char *bLDelUTF8(char *string, size_t stringSize, int64_t start, int64_t end);
+char *delUTF8(const char *string, int64_t start, int64_t end) MUST_CHECK;
+char *iDelUTF8(char **string, int64_t start, int64_t end) MUST_CHECK;
+char *bDelUTF8(char *string, int64_t start, int64_t end) MUST_CHECK;
+char *bLDelUTF8(char *string, size_t stringSize, int64_t start, int64_t end) MUST_CHECK;
// indexOf UTF8 encoded String
-ssize_t indexOfUTF8(const char *string, const char *needle);
+ssize_t indexOfUTF8(const char *string, const char *needle) MUST_CHECK;
// TODO
-ssize_t icIndexOfUTF8(const char *string, const char *needle);
+ssize_t icIndexOfUTF8(const char *string, const char *needle) MUST_CHECK;
// ignore case has UTF8 encoded String
-bool icHasUTF8(const char *string, const char *needle);
+bool icHasUTF8(const char *string, const char *needle) MUST_CHECK;
// TODO
-char *icTokUTF8(const char *s, const char *delim, char **saveptr);
+char *icTokUTF8(const char *s, const char *delim, char **saveptr) MUST_CHECK;
// TODO
-char **icExtractUTF8(const char *string, const char* delim1, const char* delim2);
-char **icExtractCharSUTF8(const char *string, char delim1, const char* delim2);
-char **icExtractSCharUTF8(const char *string, const char* delim1, char delim2);
+char **icExtractUTF8(const char *string, const char* delim1, const char* delim2) MUST_CHECK;
+char **icExtractCharSUTF8(const char *string, char delim1, const char* delim2) MUST_CHECK;
+char **icExtractSCharUTF8(const char *string, const char* delim1, char delim2) MUST_CHECK;
// ignore case list Sort UTF8 encoded String
-char **icListSortUTF8(char **list);
-char **iicListSortUTF8(char ***list);
+char **icListSortUTF8(char **list) MUST_CHECK;
+char **iicListSortUTF8(char ***list) MUST_CHECK;
// ignore case list Equal UTF8 encoded String
-bool icListEqUTF8(char **list1, char **list2);
+bool icListEqUTF8(char **list1, char **list2) MUST_CHECK;
// ignore case and return true when list has UTF8 encoded string
-bool icListHasUTF8(char **list, const char *string);
+bool icListHasUTF8(char **list, const char *string) MUST_CHECK;
// ignore case and return index of UTF8 encoded string in list
-ssize_t icListIndexOfUTF8(char **list, const char *string);
+ssize_t icListIndexOfUTF8(char **list, const char *string) MUST_CHECK;
// ignore case list binary search UTF8 encoded string
-ssize_t icListBinarySearchUTF8(char **list, const char *string);
+ssize_t icListBinarySearchUTF8(char **list, const char *string) MUST_CHECK;
// ignore case and uniquify UTF8 encoded elements of list
-char **icListUniqUTF8(char **list);
-char **iicListUniqUTF8(char ***list);
+char **icListUniqUTF8(char **list) MUST_CHECK;
+char **iicListUniqUTF8(char ***list) MUST_CHECK;
//
// End UTF8 string functions
@@ -2453,35 +2470,41 @@ char **iicListUniqUTF8(char ***list);
// create empty string
#define emptyS(string) \
string = strdup("");
-char *emptySF(void);
-char *iEmptySF(char **string);
+char *emptySF(void) MUST_CHECK;
+char *iEmptySF(char **string) MUST_CHECK;
// string buffer empty - set 0 at index 0
#define bEmptyS(string) \
(string)[0] = 0
// is empty string
-bool isEmptyS(const char *string);
+bool isEmptyS(const char *string) MUST_CHECK;
/**
* orS - if string is empty, the value is alternative
*/
#define orS(string, alternative) \
- !isEmptyS(string) ? string : alternative
+ !isEmptyS(string) ? (string) : (alternative)
// true when string is empty or white spaces
-bool isBlankS(const char *string);
+bool isBlankS(const char *string) MUST_CHECK;
/**
* blankS - if string is blank(white spaces) or empty, the value is alternative
*/
#define orBlankS(string, alternative) \
- !isBlankS(string) ? string : alternative
+ !isBlankS(string) ? (string) : (alternative)
/**
* nS - null String - replace null string with "" string (empty string)
*/
#define nS(string) \
- string ? string : ""
+ (string) ? (string) : ""
+
+/**
+ * nAS - null Alternative String - replace null string with alternative string
+ */
+#define nAS(string, alternative) \
+ (string) ? (string) : (alternative)
// convert python index (int, positive and negative) to always positive index (uint), this function is more generic than listIntIndexS
@@ -2494,40 +2517,41 @@ ssize_t intIndex(int64_t index, int64_t length);
if (list) list[0] = NULL; \
} while(0);
-char **listEmptySF(void);
-char **iListEmptySF(char ***list);
+char **listEmptySF(void) MUST_CHECK;
+char **iListEmptySF(char ***list) MUST_CHECK;
// false when there are elements in the list
-bool listIsEmptyS(char **list);
+bool listIsEmptyS(char **list) MUST_CHECK;
// false when there are non blank elements in the list
-bool listIsBlankS(char **list);
+bool listIsBlankS(char **list) MUST_CHECK;
// String Lists
// createList(...)
-char **listCreateSF(const char *paramType, ...);
+char **listCreateSF(const char *paramType, ...) MUST_CHECK;
#define listCreateS(...) listCreateSF("", __VA_ARGS__, NULL)
// copy array to new list
-char **listFromArrayS(char **array, size_t size);
+char **listFromArrayS(char **array, size_t size) MUST_CHECK;
+char **listFromCArrayS(const char **array, size_t size) MUST_CHECK;
// push and pop (append) str
// modifies the list
-char **listPushS(char ***list, const char *s);
-char **listPushCharS(char ***list, char c);
-char **iListPushS(char ***list, char *s);
+char **listPushS(char ***list, const char *s) MUST_CHECK;
+char **listPushCharS(char ***list, char c) MUST_CHECK;
+char **iListPushS(char ***list, char *s) MUST_CHECK;
// copy last string and free it in the list
-char *listPopS(char ***list);
+char *listPopS(char ***list) MUST_CHECK;
// prepend and dequeue (append) str
// modifies the list
-char **listPrependS(char ***list, const char *s);
-char **listPrependCharS(char ***list, char c);
-char **iListPrependS(char ***list, char *s);
+char **listPrependS(char ***list, const char *s) MUST_CHECK;
+char **listPrependCharS(char ***list, char c) MUST_CHECK;
+char **iListPrependS(char ***list, char *s) MUST_CHECK;
// copy fist string and free it in the list
-char *listDequeueS(char ***list);
+char *listDequeueS(char ***list) MUST_CHECK;
// freeList
void listFreeS(char **list);
@@ -2537,120 +2561,130 @@ void listFreeManySF(char **paramType, ...);
#define listFreeManyS(...) listFreeManySF(NULL, __VA_ARGS__, NULL)
// length
-size_t listLengthS(char **list);
+size_t listLengthS(char **list) MUST_CHECK;
+size_t listLengthCS(const char **list) MUST_CHECK;
// list length as a single string
-ssize_t listStrLengthS(char **list);
+ssize_t listStrLengthS(char **list) MUST_CHECK;
// convert python index (int) to always positive index (uint)
-ssize_t listIntIndexS(char **list, int64_t index);
+ssize_t listIntIndexS(char **list, int64_t index) MUST_CHECK;
// pointer to the char* at python index
-char **listAddrS(char **list, int64_t index);
+char **listAddrS(char **list, int64_t index) MUST_CHECK;
// list get - get a string at python index
-char *listGetS(char **list, int64_t index);
-char *iListGetS(char **list, int64_t index);
+char *listGetS(char **list, int64_t index) MUST_CHECK;
+char *iListGetS(char **list, int64_t index) MUST_CHECK;
+char *listGetCS(const char **list, int64_t index) MUST_CHECK;
+const char *iListGetCS(const char **list, int64_t index) MUST_CHECK;
// list set - replace a string at python index
-char **listSetS(char **list, int64_t index, const char *s);
-char **listSetCharS(char **list, int64_t index, char c);
-char **iListSetS(char **list, int64_t index, char *s);
+char **listSetS(char **list, int64_t index, const char *s) MUST_CHECK;
+char **listSetCharS(char **list, int64_t index, char c) MUST_CHECK;
+char **iListSetS(char **list, int64_t index, char *s) MUST_CHECK;
// swap elements in a list
-char **listSwapS(char **list, int64_t index1, int64_t index2);
-char **iListSwapS(char **list, int64_t index1, int64_t index2);
+char **listSwapS(char **list, int64_t index1, int64_t index2) MUST_CHECK;
+char **iListSwapS(char **list, int64_t index1, int64_t index2) MUST_CHECK;
// split
-char **split(const char *string, const char* delim);
-char **splitChar(const char *string, char delim);
+char **split(const char *string, const char* delim) MUST_CHECK;
+char **splitS(const char *string, const char* delim) MUST_CHECK;
+char **splitChar(const char *string, char delim) MUST_CHECK;
// ignore case split
-char **icSplit(const char *string, const char* delim);
-char **icSplitChar(const char *string, char delim);
+char **icSplit(const char *string, const char* delim) MUST_CHECK;
+char **icSplitS(const char *string, const char* delim) MUST_CHECK;
+char **icSplitChar(const char *string, char delim) MUST_CHECK;
// list length after joined with delimiter
-ssize_t joinLength(char **list, const char* delim);
+ssize_t joinLength(char **list, const char* delim) MUST_CHECK;
// join
-char *join(char **list, const char* delim);
-char *joinChar(char **list, char delim);
-char *bJoin(char *string, char **list, const char* delim);
-char *bJoinChar(char *string, char **list, char delim);
-char *bLJoin(char *string, size_t stringSize, char **list, const char* delim);
-char *bLJoinChar(char *string, size_t stringSize, char **list, char delim);
+char *join(char **list, const char* delim) MUST_CHECK;
+char *joinS(char **list, const char* delim) MUST_CHECK;
+char *joinCS(const char **list, const char* delim) MUST_CHECK;
+char *joinChar(char **list, char delim) MUST_CHECK;
+char *bJoin(char *string, char **list, const char* delim) MUST_CHECK;
+char *bJoinChar(char *string, char **list, char delim) MUST_CHECK;
+char *bLJoin(char *string, size_t stringSize, char **list, const char* delim) MUST_CHECK;
+char *bLJoinChar(char *string, size_t stringSize, char **list, char delim) MUST_CHECK;
// extract string
-char **extractS(const char *string, const char* delim1, const char* delim2);
-char **extractCharSS(const char *string, char delim1, const char* delim2);
-char **extractSCharS(const char *string, const char* delim1, char delim2);
-char **extractCharCharS(const char *string, char delim1, char delim2);
+char **extractS(const char *string, const char* delim1, const char* delim2) MUST_CHECK;
+char **extractCharSS(const char *string, char delim1, const char* delim2) MUST_CHECK;
+char **extractSCharS(const char *string, const char* delim1, char delim2) MUST_CHECK;
+char **extractCharCharS(const char *string, char delim1, char delim2) MUST_CHECK;
// ignore case extract string
-char **icExtractS(const char *string, const char* delim1, const char* delim2);
-char **icExtractCharSS(const char *string, char delim1, const char* delim2);
-char **icExtractSCharS(const char *string, const char* delim1, char delim2);
-char **icExtractCharCharS(const char *string, char delim1, char delim2);
+char **icExtractS(const char *string, const char* delim1, const char* delim2) MUST_CHECK;
+char **icExtractCharSS(const char *string, char delim1, const char* delim2) MUST_CHECK;
+char **icExtractSCharS(const char *string, const char* delim1, char delim2) MUST_CHECK;
+char **icExtractCharCharS(const char *string, char delim1, char delim2) MUST_CHECK;
// duplicate list
-char **listDupS(char **list);
-char **iListDupS(char **list);
+char **listDupS(char **list) MUST_CHECK;
+char **listDupCS(const char **list) MUST_CHECK;
+char **iListDupS(char **list) MUST_CHECK;
// duplicate and reverse list
-char **listReverseS(char **list);
-char **iListReverseS(char ***list);
+char **listReverseS(char **list) MUST_CHECK;
+char **iListReverseS(char ***list) MUST_CHECK;
// listCatS: f(l1, l2, l3)
-char **listCatSF(char **paramType, ...);
+char **listCatSF(char **paramType, ...) MUST_CHECK;
#define listCatS(...) listCatSF(NULL, __VA_ARGS__, NULL)
// append lists
-char **listAppendS(char ***list1, char **list2);
-char **iListAppendS(char ***list1, char **list2);
-char **iListAppendNSmashS(char ***list1, char **list2);
+char **listAppendS(char ***list1, char **list2) MUST_CHECK;
+char **iListAppendS(char ***list1, char **list2) MUST_CHECK;
+char **iListAppendNSmashS(char ***list1, char **list2) MUST_CHECK;
// prepend list at the start and shift existing elements
-char **listShiftS(char ***list1, char **list2);
-char **iListShiftS(char ***list1, char **list2);
-char **iListShiftNSmashS(char ***list1, char **list2);
+char **listShiftS(char ***list1, char **list2) MUST_CHECK;
+char **iListShiftS(char ***list1, char **list2) MUST_CHECK;
+char **iListShiftNSmashS(char ***list1, char **list2) MUST_CHECK;
// add lists
char **listAddS(char **list1, char **list2);
+char **listAddCS(char **list1, const char **list2);
// slice - python style indexes 0..len-1 -1..-len+1
-char **listSliceS(char **list, int64_t start, int64_t end);
-char **iListCopyS(char **list, int64_t start, int64_t end);
-char **iListSliceS(char ***list, int64_t start, int64_t end);
+char **listSliceS(char **list, int64_t start, int64_t end) MUST_CHECK;
+char **iListCopyS(char **list, int64_t start, int64_t end) MUST_CHECK;
+char **iListSliceS(char ***list, int64_t start, int64_t end) MUST_CHECK;
// crop list (slice+del)
-char **listCropS(char **list, int64_t start, int64_t end);
-char **iListCropS(char ***list, int64_t start, int64_t end);
-char *listCropElemS(char **list, int64_t index);
-char *iListCropElemS(char ***list, int64_t index);
+char **listCropS(char **list, int64_t start, int64_t end) MUST_CHECK;
+char **iListCropS(char ***list, int64_t start, int64_t end) MUST_CHECK;
+char *listCropElemS(char **list, int64_t index) MUST_CHECK;
+char *iListCropElemS(char ***list, int64_t index) MUST_CHECK;
// insert list in list
-char **listInsertS(char **list, int64_t index, char **toInsert);
-char **iListInsertS(char ***list, int64_t index, char **toInsert);
-char **iListInsertNFreeS(char ***list, int64_t index, char **toInsert);
+char **listInsertS(char **list, int64_t index, char **toInsert) MUST_CHECK;
+char **iListInsertS(char ***list, int64_t index, char **toInsert) MUST_CHECK;
+char **iListInsertNFreeS(char ***list, int64_t index, char **toInsert) MUST_CHECK;
// inject string in list
-char **listInjectS(char **list, int64_t index, char *toInject);
-char **listInjectCharS(char **list, int64_t index, char toInject);
-char **iListInjectS(char ***list, int64_t index, char *toInject);
-char **iListInjectCharS(char ***list, int64_t index, char toInject);
+char **listInjectS(char **list, int64_t index, char *toInject) MUST_CHECK;
+char **listInjectCharS(char **list, int64_t index, char toInject) MUST_CHECK;
+char **iListInjectS(char ***list, int64_t index, char *toInject) MUST_CHECK;
+char **iListInjectCharS(char ***list, int64_t index, char toInject) MUST_CHECK;
// del - python style indexes 0..len-1 -1..-len+1
-char **listDelS(char **list, int64_t start, int64_t end);
-char **iListDelS(char ***list, int64_t start, int64_t end);
+char **listDelS(char **list, int64_t start, int64_t end) MUST_CHECK;
+char **iListDelS(char ***list, int64_t start, int64_t end) MUST_CHECK;
char **iListRemoveS(char ***list, int64_t start, int64_t end);
// del element in list
-char **listDelElemS(char **list, int64_t index);
-char **iListDelElemS(char ***list, int64_t index);
-char **iListRemoveElemS(char ***list, int64_t index);
+char **listDelElemS(char **list, int64_t index) MUST_CHECK;
+char **iListDelElemS(char ***list, int64_t index) MUST_CHECK;
+char **iListRemoveElemS(char ***list, int64_t index) MUST_CHECK;
// print list
-int listPrintS(char **list);
+int listPrintS(char **list) MUST_CHECK;
+int listPrintCS(const char **list) MUST_CHECK;
/**
* forever loop
@@ -2789,7 +2823,7 @@ int listPrintS(char **list);
*/
#define rangeFromStep(index, from, maxCount, step) \
;size_t UNIQVAR(maxCnt) = (size_t)(maxCount); \
- for (size_t index = from ; index < UNIQVAR(maxCnt) ; index+=step)
+ for (size_t index = from ; index < UNIQVAR(maxCnt) ; index+=(size_t)step)
/**
@@ -2868,11 +2902,17 @@ int listPrintS(char **list);
/**
* forEach - loop macro on list indexes
* to access the element in the loop, use *element
- */
+ */
#define forEachCharP(list, element) \
for (char **element=list ; *element != NULL ; element++)
/**
+ * forEach for const char** lists
+ */
+#define forEachCCharP(list, element) \
+ for (const char **element=list ; *element != NULL ; element++)
+
+/**
* forEach - loop macro on list indexes
* to access the element in the loop, use element
* ;size_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement
@@ -2883,6 +2923,13 @@ int listPrintS(char **list);
for (char *element = (list)[0]; (list)[UNIQVAR(libsheepyInternalIndex)]!= NULL ; UNIQVAR(libsheepyInternalIndex)++, element = (list)[UNIQVAR(libsheepyInternalIndex)])
/**
+ * forEach for const char** lists
+ */
+#define forEachCS(list, element) \
+ ;size_t UNIQVAR(libsheepyInternalIndex) = 0; \
+ for (const char *element = (list)[0]; (list)[UNIQVAR(libsheepyInternalIndex)]!= NULL ; UNIQVAR(libsheepyInternalIndex)++, element = (list)[UNIQVAR(libsheepyInternalIndex)])
+
+/**
* forEach - loop macro on list indexes
*/
#define forEachType(type, list, element) \
@@ -2891,7 +2938,7 @@ int listPrintS(char **list);
/**
* enumerateCharP list
* to access the element in the loop, use *element
- * ;size_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement
+ * ;size_t needed to avoid: error: a label can only be part of a statement and a declaration is not a statement
* on older compilers
*/
#define enumerateCharP(list, element, index) \
@@ -2899,9 +2946,19 @@ int listPrintS(char **list);
for (char **element=list; *element != NULL ; element++, index++)
/**
- * enumerateCharP list
+ * enumerateCCharP const list
+ * to access the element in the loop, use *element
+ * ;size_t needed to avoid: error: a label can only be part of a statement and a declaration is not a statement
+ * on older compilers
+ */
+#define enumerateCCharP(list, element, index) \
+ ;size_t index = 0; \
+ for (const char **element=list; *element != NULL ; element++, index++)
+
+/**
+ * enumerateS list
* to acess the element in the loop, use element
- * ;size_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement
+ * ;size_t needed to avoid: error: a label can only be part of a statement and a declaration is not a statement
* on older compilers
*/
#define enumerateS(list, element, index) \
@@ -2909,8 +2966,18 @@ int listPrintS(char **list);
for (char *element=(list)[0]; element != NULL ; index++, element = (list)[index])
/**
- * enumerateCharP list
- * ;size_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement
+ * enumerateCS const list
+ * to acess the element in the loop, use element
+ * ;size_t needed to avoid: error: a label can only be part of a statement and a declaration is not a statement
+ * on older compilers
+ */
+#define enumerateCS(list, element, index) \
+ ;size_t index = 0; \
+ for (const char *element=(list)[0]; element != NULL ; index++, element = (list)[index])
+
+/**
+ * enumerateType list
+ * ;size_t needed to avoid: error: a label can only be part of a statement and a declaration is not a statement
* on older compilers
*/
#define enumerateType(type, list, element, index) \
@@ -2945,42 +3012,45 @@ int listPrintS(char **list);
typedef int (*shCmpt)(const void * a, const void * b);
// duplicate and sort
-char **listSortS(char **list);
-char **iListSortS(char ***list);
-char **listSortFS(char **list, shCmpt compareFunction);
-char **iListSortFS(char ***list, shCmpt compareFunction);
+char **listSortS(char **list) MUST_CHECK;
+char **iListSortS(char ***list) MUST_CHECK;
+char **listSortFS(char **list, shCmpt compareFunction) MUST_CHECK;
+char **iListSortFS(char ***list, shCmpt compareFunction) MUST_CHECK;
// ignore case, duplicate and sort
-char **icListSortS(char **list);
-char **iicListSortS(char ***list);
+char **icListSortS(char **list) MUST_CHECK;
+char **iicListSortS(char ***list) MUST_CHECK;
// open text file and return lines in list
-char **readText(const char *filePath);
+char **readText(const char *filePath) MUST_CHECK;
// read opened text file and return lines in list
// the file is left open
-char **readStream(FILE *fp);
+char **readStream(FILE *fp) MUST_CHECK;
// write text file
-bool writeText(const char *filePath, char **list);
+bool writeText(const char *filePath, char **list) MUST_CHECK;
+bool writeCText(const char *filePath, const char **list) MUST_CHECK;
// write buffer
-bool writeStream(FILE *fp, char **list);
+bool writeStream(FILE *fp, char **list) MUST_CHECK;
+bool writeCStream(FILE *fp, const char **list) MUST_CHECK;
// append text to file
-bool appendText(const char *filePath, char **list);
+bool appendText(const char *filePath, char **list) MUST_CHECK;
+bool appendCText(const char *filePath, const char **list) MUST_CHECK;
// execOut
-char **execOut(const char *cmd);
+char **execOut(const char *cmd) MUST_CHECK;
// convenience define
#define execOutf systemOutf
#define execf systemf
// system command with formatting
-char **systemOutf(const char *fmt, ...);
+char **systemOutf(const char *fmt, ...) MUST_CHECK;
// convenience define
#define systemOut execOut
-int systemf(const char *fmt, ...);
+int systemf(const char *fmt, ...) MUST_CHECK;
// system commands and log
#define logSystem(cmd) do{\
@@ -3006,11 +3076,11 @@ int systemf(const char *fmt, ...);
// run command and return exit code from command (not system return value like system, systemf and systemNFree)
#define command(cmd) commandF(cmd, __LINE__, __func__, __FILE__)
-int commandF(const char *cmd, int line, const char *thisFunc, const char *thisFileName);
+int commandF(const char *cmd, int line, const char *thisFunc, const char *thisFileName) MUST_CHECK;
#define commandf(...) commandfF(__LINE__, __func__, __FILE__, __VA_ARGS__)
-int commandfF(int line, const char *thisFunc, const char *thisFileName, const char *fmt, ...);
+int commandfF(int line, const char *thisFunc, const char *thisFileName, const char *fmt, ...) MUST_CHECK;
#define commandNFree(cmd) commandNFreeF(cmd, __LINE__, __func__, __FILE__)
-int commandNFreeF(char *cmd, int line, const char *thisFunc, const char *thisFileName);
+int commandNFreeF(char *cmd, int line, const char *thisFunc, const char *thisFileName) MUST_CHECK;
#define commandOut execOut
#define commandOutf systemOutf
@@ -3036,50 +3106,64 @@ int commandNFreeF(char *cmd, int line, const char *thisFunc, const char *thisFil
#define logCommandOutf logExecOutf
// compare lists
-bool listEqS(char **list1, char **list2);
+bool listEqS(char **list1, char **list2) MUST_CHECK;
+bool listEqCS(char **list1, const char **list2) MUST_CHECK;
+bool listEqC1S(const char **list1, char **list2) MUST_CHECK;
+bool listEqCCS(const char **list1, const char **list2) MUST_CHECK;
// has
-bool listHasS(char **list, const char *string);
-bool listHasCharS(char **list, char c);
+bool listHasS(char **list, const char *string) MUST_CHECK;
+bool listHasCS(const char **list, const char *string) MUST_CHECK;
+bool listHasCharS(char **list, char c) MUST_CHECK;
+bool listHasCharCS(const char **list, char c) MUST_CHECK;
// indexOf
-ssize_t listIndexOfS(char **list, const char *string);
-ssize_t listIndexOfCharS(char **list, char c);
+ssize_t listIndexOfS(char **list, const char *string) MUST_CHECK;
+ssize_t listIndexOfCS(const char **list, const char *string) MUST_CHECK;
+ssize_t listIndexOfCharS(char **list, char c) MUST_CHECK;
+ssize_t listIndexOfCharCS(const char **list, char c) MUST_CHECK;
// list binary search string
-ssize_t listBinarySearchS(char **list, const char *string);
-ssize_t listBinarySearchCharS(char **list, char c);
+ssize_t listBinarySearchS(char **list, const char *string) MUST_CHECK;
+ssize_t listBinarySearchCharS(char **list, char c) MUST_CHECK;
// duplicate and uniquify
-char **listUniqS(char **list);
-char **iListUniqS(char ***list);
+char **listUniqS(char **list) MUST_CHECK;
+char **iListUniqS(char ***list) MUST_CHECK;
// ignore case and compare lists
-bool icListEqS(char **list1, char **list2);
+bool icListEqS(char **list1, char **list2) MUST_CHECK;
+bool icListEqCS(char **list1, const char **list2) MUST_CHECK;
+bool icListEqC1S(const char **list1, char **list2) MUST_CHECK;
+bool icListEqCCS(const char **list1, const char **list2) MUST_CHECK;
// ignore case has
-bool icListHasS(char **list, const char *string);
-bool icListHasCharS(char **list, char c);
+bool icListHasS(char **list, const char *string) MUST_CHECK;
+bool icListHasCharS(char **list, char c) MUST_CHECK;
+bool icListHasCS(const char **list, const char *string) MUST_CHECK;
+bool icListHasCharCS(const char **list, char c) MUST_CHECK;
// ignore case indexOf
-ssize_t icListIndexOfS(char **list, const char *string);
-ssize_t icListIndexOfCharS(char **list, char c);
+ssize_t icListIndexOfS(char **list, const char *string) MUST_CHECK;
+ssize_t icListIndexOfCS(const char **list, const char *string) MUST_CHECK;
+ssize_t icListIndexOfCharS(char **list, char c) MUST_CHECK;
+ssize_t icListIndexOfCharCS(const char **list, char c) MUST_CHECK;
// ignore case list binary search string
-ssize_t icListBinarySearchS(char **list, const char *string);
-ssize_t icListBinarySearchCharS(char **list, char c);
+ssize_t icListBinarySearchS(char **list, const char *string) MUST_CHECK;
+ssize_t icListBinarySearchCharS(char **list, char c) MUST_CHECK;
// ignore case, duplicate and uniquify
-char **icListUniqS(char **list);
-char **iicListUniqS(char ***list);
+char **icListUniqS(char **list) MUST_CHECK;
+char **iicListUniqS(char ***list) MUST_CHECK;
// duplicate and compact
-char **listCompactS(char **list);
-char **iListCompactS(char ***list);
+char **listCompactS(char **list) MUST_CHECK;
+char **iListCompactS(char ***list) MUST_CHECK;
void btraceEnable(void);
void btraceDisable(void);
-bool btraceConfig(void);
+bool btraceConfig(void) MUST_CHECK;
// get backtrace
char **btrace(void);
@@ -3109,32 +3193,32 @@ extern bool btraceCfg;
if (list) list[0] = NULL; \
} while(0);
-void **listEmptyF(void);
-void **iListEmptyF(void ***list);
+void **listEmptyF(void) MUST_CHECK;
+void **iListEmptyF(void ***list) MUST_CHECK;
// false when there are elements in the list
-bool listIsEmpty(void **list);
+bool listIsEmpty(void **list) MUST_CHECK;
// createList(...)
-void **listCreateF(void *paramType, ...);
+void **listCreateF(void *paramType, ...) MUST_CHECK;
#define listCreate(...) listCreateF(NULL, __VA_ARGS__, NULL)
// copy array to new list
-void **listFromArray(void **array, size_t size);
+void **listFromArray(void **array, size_t size) MUST_CHECK;
// push and pop (append) element
// modifies the list
-void **listPush(void ***list, void *s);
+void **listPush(void ***list, void *s) MUST_CHECK;
// return last element and remove it from the list
-void *listPop(void ***list);
+void *listPop(void ***list) MUST_CHECK;
// prepend and dequeue (append) element
// modifies the list
-void **listPrepend(void ***list, void *s);
+void **listPrepend(void ***list, void *s) MUST_CHECK;
// return fist element and remove it from the list
-void *listDequeue(void ***list);
+void *listDequeue(void ***list) MUST_CHECK;
// freeList
void listFree(void **list);
@@ -3144,42 +3228,42 @@ void listFreeManyF(void **paramType, ...);
#define listFreeMany(...) listFreeManyF(NULL, __VA_ARGS__, NULL)
// length
-size_t listLength(void **list);
+size_t listLength(void **list) MUST_CHECK;
// list get - get an element at python index
-void *listGet(void **list, int64_t index);
+void *listGet(void **list, int64_t index) MUST_CHECK;
// list set - replace a string at python index
-void **listSet(void **list, int64_t index, void *s);
+void **listSet(void **list, int64_t index, void *s) MUST_CHECK;
// duplicate list
-void **listDup(void **list);
+void **listDup(void **list) MUST_CHECK;
// duplicate and reverse list
-void **listReverse(void **list);
-void **iListReverse(void ***list);
+void **listReverse(void **list) MUST_CHECK;
+void **iListReverse(void ***list) MUST_CHECK;
// listCatS: f(l1, l2, l3)
-void **listCatF(void **paramType, ...);
+void **listCatF(void **paramType, ...) MUST_CHECK;
#define listCat(...) listCatF(NULL, __VA_ARGS__, NULL)
// append lists
-void **listAppend(void ***list1, void **list2);
+void **listAppend(void ***list1, void **list2) MUST_CHECK;
// add lists
-void **listAdd(void **list1, void **list2);
+void **listAdd(void **list1, void **list2) MUST_CHECK;
// slice - python style indexes 0..len-1 -1..-len+1
-void **listSlice(void **list, int64_t start, int64_t end);
-void **iListSlice(void ***list, int64_t start, int64_t end);
+void **listSlice(void **list, int64_t start, int64_t end) MUST_CHECK;
+void **iListSlice(void ***list, int64_t start, int64_t end) MUST_CHECK;
// insert list in list
-void **listInsert(void **list, int64_t index, void **toInsert);
-void **iListInsert(void ***list, int64_t index, void **toInsert);
+void **listInsert(void **list, int64_t index, void **toInsert) MUST_CHECK;
+void **iListInsert(void ***list, int64_t index, void **toInsert) MUST_CHECK;
// del - python style indexes 0..len-1 -1..-len+1
-void **listDel(void **list, int64_t start, int64_t end);
-void **iListDel(void ***list, int64_t start, int64_t end);
+void **listDel(void **list, int64_t start, int64_t end) MUST_CHECK;
+void **iListDel(void ***list, int64_t start, int64_t end) MUST_CHECK;
//NOT NEEDED same as iListDel - void **iListRemove(void ***list, int64_t start, int64_t end);
// duplicate and sort
@@ -6913,7 +6997,7 @@ bool fiberPrepend(void *ctx, int thisSlot, fiberFT func);
#define dArrayAlloc(a) do{\
if ((a)->last == dArrayMaxCount(a)) {\
(a)->maxCount++;\
- (a)->buffers = realloc((a)->buffers, (a)->maxCount * sizeof(void*));\
+ (a)->buffers = realloc((a)->buffers, (size_t)(a)->maxCount * sizeof(void*));\
(a)->buffers[(a)->maxCount-1] = malloc(dArraySz * sizeof((a)->element));\
}\
}while(0)
@@ -7904,10 +7988,10 @@ bool fiberPrepend(void *ctx, int thisSlot, fiberFT func);
*/
// get monotonic time in ns
-uint64_t getMonotonicTime(void);
+uint64_t getMonotonicTime(void) MUST_CHECK;
// sleep nanoseconds
-int nanoSleepF(uint64_t time);
+int nanoSleepF(uint64_t time) MUST_CHECK;
#define nanoSleep(time) pError0(nanoSleepF(time))
/** sleep nanoseconds */
@@ -7989,9 +8073,6 @@ int nanoSleepF(uint64_t time);
/** function returning a pointer to a newly allocated buffer */
#define AMALLOC __attribute__ ((malloc))
-/** force function callers to check return value */
-#define MUST_CHECK __attribute__ ((warn_unused_result))
-
/** mark a function as used */
#define USED __attribute__ ((used))
diff --git a/release/libsheepyObject.h b/release/libsheepyObject.h
@@ -7429,6 +7429,9 @@ void finishManyOF(void *paramType, ...);
#define mirrorO(self) (self)->f->mirror(self)
#define mirrorG mirrorO
+#define fromCArrayO(self, array, size) (self)->f->fromCArray(self, array, size)
+#define fromCArrayG fromCArrayO
+
#define fromArrayNFreeO(self, array, size) (self)->f->fromArrayNFree(self, array, size)
#define fromArrayNFreeG fromArrayNFreeO
@@ -7438,6 +7441,9 @@ void finishManyOF(void *paramType, ...);
#define pushArraycO(self, array) (self)->f->pushArrayc(self, array)
#define pushArraycG pushArraycO
+#define pushCArraycO(self, array) (self)->f->pushCArrayc(self, array)
+#define pushCArraycG pushCArraycO
+
#define pushNFreeArraycO(self, array) (self)->f->pushNFreeArrayc(self, array)
#define pushNFreeArraycG pushNFreeArraycO
@@ -7477,6 +7483,9 @@ void finishManyOF(void *paramType, ...);
#define prependArraycO(self, array) (self)->f->prependArrayc(self, array)
#define prependArraycG prependArraycO
+#define prependCArraycO(self, array) (self)->f->prependCArrayc(self, array)
+#define prependCArraycG prependCArraycO
+
#define prependSmallBoolO(self, value) (self)->f->prependSmallBool(self, value)
#define prependSmallBoolG prependSmallBoolO
@@ -7492,7 +7501,7 @@ void finishManyOF(void *paramType, ...);
#define prependSmallContainerO(self, container) (self)->f->prependSmallContainer(self, container)
#define prependSmallContainerG prependSmallContainerO
-#define prependNFreeUndefinedO(self, undefined) (self)->f->prependNFreeUndefined(self, undefined)
+#define prependNFreeUndefinedO(self, u) (self)->f->prependNFreeUndefined(self, u)
#define prependNFreeUndefinedG prependNFreeUndefinedO
#define prependNFreeSO(self, string) (self)->f->prependNFreeS(self, string)
@@ -7582,6 +7591,9 @@ void finishManyOF(void *paramType, ...);
#define appendArrayO(self, array) (self)->f->appendArray(self, array)
#define appendArrayG appendArrayO
+#define appendCArrayO(self, array) (self)->f->appendCArray(self, array)
+#define appendCArrayG appendCArrayO
+
#define appendNSmashArrayO(self, array) (self)->f->appendNSmashArray(self, array)
#define appendNSmashArrayG appendNSmashArrayO
@@ -7663,6 +7675,9 @@ void finishManyOF(void *paramType, ...);
#define injectArraycO(self, index, toInject) (self)->f->injectArrayc(self, index, toInject)
#define injectArraycG injectArraycO
+#define injectCArraycO(self, index, toInject) (self)->f->injectCArrayc(self, index, toInject)
+#define injectCArraycG injectCArraycO
+
#define injectSmallBoolO(self, index, toInject) (self)->f->injectSmallBool(self, index, toInject)
#define injectSmallBoolG injectSmallBoolO
@@ -7678,7 +7693,7 @@ void finishManyOF(void *paramType, ...);
#define injectSmallContainerO(self, index, toInject) (self)->f->injectSmallContainer(self, index, toInject)
#define injectSmallContainerG injectSmallContainerO
-#define injectNFreeUndefinedO(self, index, undefined) (self)->f->injectNFreeUndefined(self, index, undefined)
+#define injectNFreeUndefinedO(self, index, u) (self)->f->injectNFreeUndefined(self, index, u)
#define injectNFreeUndefinedG injectNFreeUndefinedO
#define injectNFreeSO(self, index, toInject) (self)->f->injectNFreeS(self, index, toInject)
@@ -7723,6 +7738,9 @@ void finishManyOF(void *paramType, ...);
#define equalArrayO(self, p2) (self)->f->equalArray(self, p2)
#define equalArrayG equalArrayO
+#define equalCArrayO(self, p2) (self)->f->equalCArray(self, p2)
+#define equalCArrayG equalCArrayO
+
#define equalBaseO(self, p2) (self)->f->equalBase(self, p2)
#define equalBaseG equalBaseO
@@ -7738,6 +7756,9 @@ void finishManyOF(void *paramType, ...);
#define setAtArraycO(self, index, array) (self)->f->setAtArrayc(self, index, array)
#define setAtArraycG setAtArraycO
+#define setAtCArraycO(self, index, array) (self)->f->setAtCArrayc(self, index, array)
+#define setAtCArraycG setAtCArraycO
+
#define setAtSmallBytesO(self, index, value) (self)->f->setAtSmallBytes(self, index, value)
#define setAtSmallBytesG setAtSmallBytesO
@@ -7753,7 +7774,7 @@ void finishManyOF(void *paramType, ...);
#define setPAtNFreeSmallJsonO(self, index, json) (self)->f->setPAtNFreeSmallJson(self, index, json)
#define setPAtNFreeSmallJsonG setPAtNFreeSmallJsonO
-#define hasUndefinedO(self, undefined) (self)->f->hasUndefined(self, undefined)
+#define hasUndefinedO(self, u) (self)->f->hasUndefined(self, u)
#define hasUndefinedG hasUndefinedO
#define hasBoolO(self, value) (self)->f->hasBool(self, value)
@@ -7780,6 +7801,9 @@ void finishManyOF(void *paramType, ...);
#define hasArraycO(self, array) (self)->f->hasArrayc(self, array)
#define hasArraycG hasArraycO
+#define hasCArraycO(self, array) (self)->f->hasCArrayc(self, array)
+#define hasCArraycG hasCArraycO
+
#define hasSmallBoolO(self, value) (self)->f->hasSmallBool(self, value)
#define hasSmallBoolG hasSmallBoolO
@@ -7795,7 +7819,7 @@ void finishManyOF(void *paramType, ...);
#define hasSmallContainerO(self, container) (self)->f->hasSmallContainer(self, container)
#define hasSmallContainerG hasSmallContainerO
-#define indexOfUndefinedO(self, undefined) (self)->f->indexOfUndefined(self, undefined)
+#define indexOfUndefinedO(self, u) (self)->f->indexOfUndefined(self, u)
#define indexOfUndefinedG indexOfUndefinedO
#define indexOfBoolO(self, value) (self)->f->indexOfBool(self, value)
@@ -7822,6 +7846,9 @@ void finishManyOF(void *paramType, ...);
#define indexOfArraycO(self, array) (self)->f->indexOfArrayc(self, array)
#define indexOfArraycG indexOfArraycO
+#define indexOfCArraycO(self, array) (self)->f->indexOfCArrayc(self, array)
+#define indexOfCArraycG indexOfCArraycO
+
#define indexOfSmallBoolO(self, value) (self)->f->indexOfSmallBool(self, value)
#define indexOfSmallBoolG indexOfSmallBoolO
@@ -7834,7 +7861,7 @@ void finishManyOF(void *paramType, ...);
#define indexOfSmallIntO(self, value) (self)->f->indexOfSmallInt(self, value)
#define indexOfSmallIntG indexOfSmallIntO
-#define binarySearchUndefinedO(self, undefined) (self)->f->binarySearchUndefined(self, undefined)
+#define binarySearchUndefinedO(self, u) (self)->f->binarySearchUndefined(self, u)
#define binarySearchUndefinedG binarySearchUndefinedO
#define binarySearchBoolO(self, value) (self)->f->binarySearchBool(self, value)
@@ -7861,6 +7888,9 @@ void finishManyOF(void *paramType, ...);
#define binarySearchArraycO(self, array) (self)->f->binarySearchArrayc(self, array)
#define binarySearchArraycG binarySearchArraycO
+#define binarySearchCArraycO(self, array) (self)->f->binarySearchCArrayc(self, array)
+#define binarySearchCArraycG binarySearchCArraycO
+
#define binarySearchSmallBoolO(self, value) (self)->f->binarySearchSmallBool(self, value)
#define binarySearchSmallBoolG binarySearchSmallBoolO
@@ -7891,6 +7921,9 @@ void finishManyOF(void *paramType, ...);
#define icHasArraycO(self, array) (self)->f->icHasArrayc(self, array)
#define icHasArraycG icHasArraycO
+#define icHasCArraycO(self, array) (self)->f->icHasCArrayc(self, array)
+#define icHasCArraycG icHasCArraycO
+
#define icIndexOfSO(self, string) (self)->f->icIndexOfS(self, string)
#define icIndexOfSG icIndexOfSO
@@ -7906,6 +7939,9 @@ void finishManyOF(void *paramType, ...);
#define icIndexOfArraycO(self, array) (self)->f->icIndexOfArrayc(self, array)
#define icIndexOfArraycG icIndexOfArraycO
+#define icIndexOfCArraycO(self, array) (self)->f->icIndexOfCArrayc(self, array)
+#define icIndexOfCArraycG icIndexOfCArraycO
+
#define icBinarySearchSO(self, string) (self)->f->icBinarySearchS(self, string)
#define icBinarySearchSG icBinarySearchSO
@@ -7921,6 +7957,9 @@ void finishManyOF(void *paramType, ...);
#define icBinarySearchArraycO(self, array) (self)->f->icBinarySearchArrayc(self, array)
#define icBinarySearchArraycG icBinarySearchArraycO
+#define icBinarySearchCArraycO(self, array) (self)->f->icBinarySearchCArrayc(self, array)
+#define icBinarySearchCArraycG icBinarySearchCArraycO
+
#define icBinarySearchSmallStringO(self, string) (self)->f->icBinarySearchSmallString(self, string)
#define icBinarySearchSmallStringG icBinarySearchSmallStringO
@@ -7981,25 +8020,25 @@ void finishManyOF(void *paramType, ...);
#define zipArrayO(self, array1, array2) (self)->f->zipArray(self, array1, array2)
#define zipArrayG zipArrayO
-#define zipCArrayO(self, a1, array2) (self)->f->zipCArray(self, a1, array2)
+#define zipCArrayO(self, array1, array2) (self)->f->zipCArray(self, array1, array2)
#define zipCArrayG zipCArrayO
#define zipCharO(self, array1, array2) (self)->f->zipChar(self, array1, array2)
#define zipCharG zipCharO
-#define zipCCharO(self, array1, a2) (self)->f->zipCChar(self, array1, a2)
+#define zipCCharO(self, array1, array2) (self)->f->zipCChar(self, array1, array2)
#define zipCCharG zipCCharO
#define zipArrayCharO(self, array1, array2) (self)->f->zipArrayChar(self, array1, array2)
#define zipArrayCharG zipArrayCharO
-#define zipCArrayCharO(self, a1, array2) (self)->f->zipCArrayChar(self, a1, array2)
+#define zipCArrayCharO(self, array1, array2) (self)->f->zipCArrayChar(self, array1, array2)
#define zipCArrayCharG zipCArrayCharO
-#define zipArrayCCharO(self, array1, a2) (self)->f->zipArrayCChar(self, array1, a2)
+#define zipArrayCCharO(self, array1, array2) (self)->f->zipArrayCChar(self, array1, array2)
#define zipArrayCCharG zipArrayCCharO
-#define zipCArrayCCharO(self, a1, a2) (self)->f->zipCArrayCChar(self, a1, a2)
+#define zipCArrayCCharO(self, array1, array2) (self)->f->zipCArrayCChar(self, array1, array2)
#define zipCArrayCCharG zipCArrayCCharO
#define readTextSmallStringO(self, filePath) (self)->f->readTextSmallString(self, filePath)
@@ -8176,6 +8215,9 @@ void finishManyOF(void *paramType, ...);
#define setArraycO(self, key, array) (self)->f->setArrayc(self, key, array)
#define setArraycG setArraycO
+#define setCArraycO(self, key, array) (self)->f->setCArrayc(self, key, array)
+#define setCArraycG setCArraycO
+
#define setSmallBytesO(self, key, value) (self)->f->setSmallBytes(self, key, value)
#define setSmallBytesG setSmallBytesO
@@ -8209,6 +8251,9 @@ void finishManyOF(void *paramType, ...);
#define setArraycKCharO(self, key, array) (self)->f->setArraycKChar(self, key, array)
#define setArraycKCharG setArraycKCharO
+#define setCArraycKCharO(self, key, array) (self)->f->setCArraycKChar(self, key, array)
+#define setCArraycKCharG setCArraycKCharO
+
#define setSmallBoolKCharO(self, key, value) (self)->f->setSmallBoolKChar(self, key, value)
#define setSmallBoolKCharG setSmallBoolKCharO
@@ -8239,7 +8284,7 @@ void finishManyOF(void *paramType, ...);
#define setNFreeKCharO(self, key, value) (self)->f->setNFreeKChar(self, key, value)
#define setNFreeKCharG setNFreeKCharO
-#define setNFreeUndefinedKCharO(self, key, undefined) (self)->f->setNFreeUndefinedKChar(self, key, undefined)
+#define setNFreeUndefinedKCharO(self, key, u) (self)->f->setNFreeUndefinedKChar(self, key, u)
#define setNFreeUndefinedKCharG setNFreeUndefinedKCharO
#define setNFreeSKCharO(self, key, string) (self)->f->setNFreeSKChar(self, key, string)
@@ -8452,7 +8497,7 @@ void finishManyOF(void *paramType, ...);
#define hasKCharO(self, key) (self)->f->hasKChar(self, key)
#define hasKCharG hasKCharO
-#define keyByUndefinedO(self, undefined) (self)->f->keyByUndefined(self, undefined)
+#define keyByUndefinedO(self, u) (self)->f->keyByUndefined(self, u)
#define keyByUndefinedG keyByUndefinedO
#define keyByBoolO(self, value) (self)->f->keyByBool(self, value)
@@ -8479,6 +8524,9 @@ void finishManyOF(void *paramType, ...);
#define keyByArraycO(self, array) (self)->f->keyByArrayc(self, array)
#define keyByArraycG keyByArraycO
+#define keyByCArraycO(self, array) (self)->f->keyByCArrayc(self, array)
+#define keyByCArraycG keyByCArraycO
+
#define keyBySmallBoolO(self, value) (self)->f->keyBySmallBool(self, value)
#define keyBySmallBoolG keyBySmallBoolO
@@ -8512,6 +8560,9 @@ void finishManyOF(void *paramType, ...);
#define icKeyByArraycO(self, array) (self)->f->icKeyByArrayc(self, array)
#define icKeyByArraycG icKeyByArraycO
+#define icKeyByCArraycO(self, array) (self)->f->icKeyByCArrayc(self, array)
+#define icKeyByCArraycG icKeyByCArraycO
+
#define icKeyBySmallStringO(self, string) (self)->f->icKeyBySmallString(self, string)
#define icKeyBySmallStringG icKeyBySmallStringO
@@ -8539,12 +8590,27 @@ void finishManyOF(void *paramType, ...);
#define zipSmallJsonVArrayO(self, keys, values) (self)->f->zipSmallJsonVArray(self, keys, values)
#define zipSmallJsonVArrayG zipSmallJsonVArrayO
+#define zipSmallJsonVCArrayO(self, keys, values) (self)->f->zipSmallJsonVCArray(self, keys, values)
+#define zipSmallJsonVCArrayG zipSmallJsonVCArrayO
+
#define zipArrayArrayO(self, keys, values) (self)->f->zipArrayArray(self, keys, values)
#define zipArrayArrayG zipArrayArrayO
+#define zipCArrayArrayO(self, keys, values) (self)->f->zipCArrayArray(self, keys, values)
+#define zipCArrayArrayG zipCArrayArrayO
+
+#define zipArrayCArrayO(self, keys, values) (self)->f->zipArrayCArray(self, keys, values)
+#define zipArrayCArrayG zipArrayCArrayO
+
+#define zipCArrayCArrayO(self, keys, values) (self)->f->zipCArrayCArray(self, keys, values)
+#define zipCArrayCArrayG zipCArrayCArrayO
+
#define zipVArrayO(self, keys, values) (self)->f->zipVArray(self, keys, values)
#define zipVArrayG zipVArrayO
+#define zipVCArrayO(self, keys, values) (self)->f->zipVCArray(self, keys, values)
+#define zipVCArrayG zipVCArrayO
+
#define toArrayO(self) (self)->f->toArray(self)
#define toArrayG toArrayO
@@ -8608,6 +8674,9 @@ void finishManyOF(void *paramType, ...);
#define setTopArraycO(self, value) (self)->f->setTopArrayc(self, value)
#define setTopArraycG setTopArraycO
+#define setTopCArraycO(self, value) (self)->f->setTopCArrayc(self, value)
+#define setTopCArraycG setTopCArraycO
+
#define setTopSmallBoolO(self, value) (self)->f->setTopSmallBool(self, value)
#define setTopSmallBoolG setTopSmallBoolO
@@ -10407,7 +10476,7 @@ char *listGetCG(const char **list, int retType UNUSED, int64_t index);
* call iListGetS for getG
*/
char *iListGetG(char **list, int retType UNUSED, int64_t index);
-char *iListGetCG(const char **list, int retType UNUSED, int64_t index);
+const char *iListGetCG(const char **list, int retType UNUSED, int64_t index);
/**
* call listPopS for popG
@@ -10458,7 +10527,7 @@ bool equalChaDoubleG(char c, double value);
bool equalChaInt64G(char c, int64_t value);
bool equalChaInt32G(char c, int32_t value);
bool equalChaUint32G(char c, uint32_t value);
-bool equalChaUint64G(char c, uint32_t value);
+bool equalChaUint64G(char c, uint64_t value);
bool equalChaSmallBytesG(char c, smallBytest* value);
bool equalChaSmallDoubleG(char c, smallDoublet* value);
bool equalChaSmallIntG(char c, smallIntt* value);
diff --git a/release/libsheepySmall.c b/release/libsheepySmall.c
@@ -66,11 +66,11 @@ char* sUndefinedToStringTiny(sUndefinedt* obj UNUSED);
char* sBytesToStringTiny(sBytest* obj);
char* sTypesTiny(smallt* obj);
sBytest* sTypesToBytesTiny(smallt *obj);
-char** sDictTypeStrings(sDictt* obj);
-char ** sTypesToStrings(sBytest *types);
+const char** sDictTypeStrings(sDictt* obj);
+const char ** sTypesToStrings(sBytest *types);
sBytest* sDictTypes(sDictt* obj);
sBytest* sDictTypesTiny(sDictt* obj);
-char** sArrayTypeStrings(sArrayt* obj);
+const char** sArrayTypeStrings(sArrayt* obj);
sBytest* sArrayTypes(sArrayt* obj);
sBytest* sArrayTypesTiny(sArrayt* obj);
smallt* sDictGet(sDictt *dict, const char *key);
@@ -199,6 +199,8 @@ size_t sSizeTiny(smallt *obj) {
r = sizeof(sBytest) + sizeof(char) * (((sBytest* )obj)->count - 1);
}
break;
+ default:;
+ // return 0
}
return(r);
}
@@ -535,6 +537,8 @@ smallt* sDuplicateTiny(smallt *obj) {
}
r = (smallt *) B;
break;
+ default:
+ logME(libsheepyErrorMask, "Unsupported object type.");
}
return(r);
}
@@ -625,6 +629,8 @@ char* sToStringTiny(smallt *obj) {
case BYTES:
r = sBytesToStringTiny((sBytest* )obj);
break;
+ default:
+ logME(libsheepyErrorMask, "Unsupported object type.");
}
return(r);
}
@@ -703,32 +709,32 @@ char* sDictToStringTiny(sDictt* obj) {
forEachSDict(obj, e) {
if (e->key) {
hasAtLeastOneElement = yes;
- iAppendS(&r, "\"");
- iAppendS(&r, e->key);
- iAppendS(&r, "\"");
+ pErrorNULL(iAppendS(&r, "\""));
+ pErrorNULL(iAppendS(&r, e->key));
+ pErrorNULL(iAppendS(&r, "\""));
if (isSType(e->data, STRING) || isSType(e->data, CONTAINER)) {
// add quotes for strings
- iAppendS(&r, ":\"");
+ pErrorNULL(iAppendS(&r, ":\""));
s = sToStringTiny(e->data);
- iAppendS(&r, s);
+ pErrorNULL(iAppendS(&r, s));
free(s);
- iAppendS(&r, "\",");
+ pErrorNULL(iAppendS(&r, "\","));
}
else {
- iAppendS(&r, ":");
+ pErrorNULL(iAppendS(&r, ":"));
s = sToStringTiny(e->data);
- iAppendS(&r, s);
+ pErrorNULL(iAppendS(&r, s));
free(s);
- iAppendS(&r, ",");
+ pErrorNULL(iAppendS(&r, ","));
}
}
}
if (hasAtLeastOneElement) {
- setS(r, -1, '}');
+ pErrorNULL(setS(r, -1, '}'));
}
else {
- iAppendS(&r, "}");
+ pErrorNULL(iAppendS(&r, "}"));
}
return(r);
}
@@ -816,24 +822,24 @@ char* sArrayToStringTiny(sArrayt* obj) {
cnt++;
if (isSType(o, STRING) || isSType(o, CONTAINER)) {
// add quotes for strings
- iAppendS(&r, "\"");
+ pErrorNULL(iAppendS(&r, "\""));
s = sToStringTiny(o);
- iAppendS(&r, s);
+ pErrorNULL(iAppendS(&r, s));
free(s);
- iAppendS(&r, "\"");
+ pErrorNULL(iAppendS(&r, "\""));
}
else {
s = sToStringTiny(o);
- iAppendS(&r, s);
+ pErrorNULL(iAppendS(&r, s));
free(s);
}
- iAppendS(&r, ",");
+ pErrorNULL(iAppendS(&r, ","));
}
if (!cnt && emptySlot) {
- iAppendS(&r, "]");
+ pErrorNULL(iAppendS(&r, "]"));
}
else {
- setS(r, -1, ']');
+ pErrorNULL(setS(r, -1, ']'));
}
return(r);
}
@@ -870,8 +876,8 @@ char* sBytesToStringTiny(sBytest* obj) {
}
char *r = toHexSepS(&(obj->data), obj->count, ",");
- iPrependS(&r, "[");
- iAppendS(&r, "]");
+ pErrorNULL(iPrependS(&r, "["));
+ pErrorNULL(iAppendS(&r, "]"));
return(r);
}
@@ -936,6 +942,7 @@ sBytest* sTypesToBytesTiny(smallt *obj) {
case ARRAY:
r = sArrayTypesTiny((sArrayt *) obj);;
break;
+ default:;
}
return(r);
}
@@ -950,7 +957,7 @@ sBytest* sTypesToBytesTiny(smallt *obj) {
* \return
* list of strings representing the types
*/
-char** sDictTypeStrings(sDictt* obj) {
+const char** sDictTypeStrings(sDictt* obj) {
sBytest *types = sDictTypes(obj);
@@ -966,8 +973,8 @@ char** sDictTypeStrings(sDictt* obj) {
* list of strings representing the object types, use free to free the list (not listFreeS)
* NULL error, types is not freed
*/
-char ** sTypesToStrings(sBytest *types) {
- char **r = NULL;
+const char ** sTypesToStrings(sBytest *types) {
+ const char **r = NULL;
if (!types) {
return(NULL);
@@ -982,7 +989,7 @@ char ** sTypesToStrings(sBytest *types) {
free(r);
return(NULL);
}
- r[i] = (char *)SMALL_TYPE_NAMES[(size_t) b];
+ r[i] = SMALL_TYPE_NAMES[(size_t) b];
}
free(types);
@@ -1037,7 +1044,7 @@ sBytest* sDictTypesTiny(sDictt* obj) {
* \return
* list of strings representing the types
*/
-char** sArrayTypeStrings(sArrayt* obj) {
+const char** sArrayTypeStrings(sArrayt* obj) {
sBytest *types = sArrayTypes(obj);
@@ -1817,7 +1824,7 @@ sBytest *sSerialTiny(smallt *obj) {
break;
case STRING:
sBytesPush(&r, obj->type);
- sBytesPushBuffer(&r, &((sStringt *)&(obj->type))->data, sizeof(sStringt) + strlen(&(((sStringt *)&(obj->type))->data)) -1);
+ sBytesPushBuffer(&r, &((sStringt *)&(obj->type))->data, (uint32_t)sizeof(sStringt) + (uint32_t)strlen(&(((sStringt *)&(obj->type))->data)) -1);
break;
case ARRAY:
sArraySerialElementsTiny(&r, (sArrayt *)&(obj->type));
@@ -1828,6 +1835,8 @@ sBytest *sSerialTiny(smallt *obj) {
sBytesPushBuffer(&r, &(B->count), sizeof(uint32_t));
sBytesPushBuffer(&r, &(B->data), B->count);
break;
+ default:
+ logME(libsheepyErrorMask, "Unsupported object type.");
}
return(r);
}
@@ -1852,7 +1861,7 @@ void sDictSerialElementsTiny(sBytest **r, sDictt *dict) {
forEachSDict(dict, e) {
if (e->key) {
- sBytesPushBuffer(r, e->key, strlen(e->key) + 1);
+ sBytesPushBuffer(r, e->key, (uint32_t)strlen(e->key) + 1);
sBytesPush(r, e->data->type);
switch(e->data->type) {
@@ -1876,7 +1885,7 @@ void sDictSerialElementsTiny(sBytest **r, sDictt *dict) {
sBytesPushBuffer(r, &((sIntt *)(e->data))->value, sizeof(int64_t));
break;
case STRING:
- sBytesPushBuffer(r, &((sStringt *)(e->data))->data, sizeof(sStringt) + strlen(&(((sStringt *)(e->data))->data)) -1);
+ sBytesPushBuffer(r, &((sStringt *)(e->data))->data, (uint32_t)sizeof(sStringt) + (uint32_t)strlen(&(((sStringt *)(e->data))->data)) -1);
break;
case ARRAY:
// decrease to overwrite the e->type since sDictSerialElementsTiny stores the type
@@ -1889,6 +1898,8 @@ void sDictSerialElementsTiny(sBytest **r, sDictt *dict) {
sBytesPushBuffer(r, &(B->count), sizeof(uint32_t));
sBytesPushBuffer(r, &(B->data), B->count);
break;
+ default:
+ logME(libsheepyErrorMask, "Unsupported object type.");
}
}
}
@@ -1942,7 +1953,7 @@ void sArraySerialElementsTiny(sBytest **r, sArrayt *array) {
sBytesPushBuffer(r, &((sIntt *)e)->value, sizeof(int64_t));
break;
case STRING:
- sBytesPushBuffer(r, &((sStringt *)e)->data, sizeof(sStringt) + strlen(&(((sStringt *)e)->data)) -1);
+ sBytesPushBuffer(r, &((sStringt *)e)->data, (uint32_t)sizeof(sStringt) + (uint32_t)strlen(&(((sStringt *)e)->data)) -1);
break;
case ARRAY:
// decrease to overwrite the e->type since sDictSerialElementsTiny stores the type
@@ -1955,6 +1966,8 @@ void sArraySerialElementsTiny(sBytest **r, sArrayt *array) {
sBytesPushBuffer(r, &(B->count), sizeof(uint32_t));
sBytesPushBuffer(r, &(B->data), B->count);
break;
+ default:
+ logME(libsheepyErrorMask, "Unsupported object type.");
}
}
}
@@ -2041,6 +2054,8 @@ smallt* sDeserialTiny(sBytest *obj) {
sBytesPushBuffer(&B, s, *count);
r = (smallt *)B;
break;
+ default:
+ logME(libsheepyErrorMask, "Unsupported object type.");
}
return(r);
@@ -2141,6 +2156,8 @@ void sDictDeserialElementsTiny(sDictt **dict, char **data) {
sBytesPushBuffer(&B, s, *count);
sDictPushTiny(dict, key, (smallt *) B);
break;
+ default:
+ logME(libsheepyErrorMask, "Unsupported object type.");
}
}
}
@@ -2237,6 +2254,8 @@ void sArrayDeserialElementsTiny(sArrayt **array, char **data) {
sBytesPushBuffer(&B, s, *count);
sArrayPushTiny(array, (smallt *) B);
break;
+ default:
+ logME(libsheepyErrorMask, "Unsupported object type.");
}
}
}
diff --git a/release/libsheepySmall.h b/release/libsheepySmall.h
@@ -209,51 +209,51 @@ bool isSTypeF(smallt *obj, char sType);
size_t sSizeTiny(smallt *obj);
-sBoolt* allocSBool(bool value);
-sContainert* allocSContainer(void *data);
-sDictt* allocSDict(void);
-sDoublet* allocSDouble(double value);
-sIntt* allocSInt(int64_t value);
-sStringt* allocSStringTiny(const char* data);
-sArrayt* allocSArray(void);
-sUndefinedt* allocSUndefined(void);
-sBytest* allocSBytes(void);
+sBoolt* allocSBool(bool value) MUST_CHECK;
+sContainert* allocSContainer(void *data) MUST_CHECK;
+sDictt* allocSDict(void) MUST_CHECK;
+sDoublet* allocSDouble(double value) MUST_CHECK;
+sIntt* allocSInt(int64_t value) MUST_CHECK;
+sStringt* allocSStringTiny(const char* data) MUST_CHECK;
+sArrayt* allocSArray(void) MUST_CHECK;
+sUndefinedt* allocSUndefined(void) MUST_CHECK;
+sBytest* allocSBytes(void) MUST_CHECK;
void sFree(smallt *obj);
void sFreeTiny(smallt *obj);
void sDictFreeTiny(sDictt *dict);
void sArrayFreeTiny(sArrayt *array);
-smallt* sDuplicate(smallt *o);
-smallt* sDuplicateTiny(smallt *obj);
-sDictt* sDictDuplicateTiny(sDictt *dict);
-sArrayt* sArrayDuplicateTiny(sArrayt *obj);
-
-char* sToStringTiny(smallt *obj);
-char* sToString(smallt *obj);
-char* sBoolToStringTiny(sBoolt* obj);
-char* sContainerToStringTiny(sContainert* obj);
-char* sDictToStringTiny(sDictt* obj);
-char* sDoubleToStringTiny(sDoublet* obj);
-char* sIntToStringTiny(sIntt* obj);
-char* sStringToStringTiny(sStringt* obj);
-char* sArrayToStringTiny(sArrayt* obj);
-char* sUndefinedToStringTiny(sUndefinedt* obj);
-char* sBytesToStringTiny(sBytest* obj);
-
-char* sTypesTiny(smallt* obj);
-sBytest* sTypesToBytesTiny(smallt *obj);
-char** sDictTypeStrings(sDictt* obj);
-sBytest* sDictTypes(sDictt* obj);
-sBytest* sDictTypesTiny(sDictt* obj);
-char** sArrayTypeStrings(sArrayt* obj);
-sBytest* sArrayTypes(sArrayt* obj);
-sBytest* sArrayTypesTiny(sArrayt* obj);
+smallt* sDuplicate(smallt *o) MUST_CHECK;
+smallt* sDuplicateTiny(smallt *obj) MUST_CHECK;
+sDictt* sDictDuplicateTiny(sDictt *dict) MUST_CHECK;
+sArrayt* sArrayDuplicateTiny(sArrayt *obj) MUST_CHECK;
+
+char* sToStringTiny(smallt *obj) MUST_CHECK;
+char* sToString(smallt *obj) MUST_CHECK;
+char* sBoolToStringTiny(sBoolt* obj) MUST_CHECK;
+char* sContainerToStringTiny(sContainert* obj) MUST_CHECK;
+char* sDictToStringTiny(sDictt* obj) MUST_CHECK;
+char* sDoubleToStringTiny(sDoublet* obj) MUST_CHECK;
+char* sIntToStringTiny(sIntt* obj) MUST_CHECK;
+char* sStringToStringTiny(sStringt* obj) MUST_CHECK;
+char* sArrayToStringTiny(sArrayt* obj) MUST_CHECK;
+char* sUndefinedToStringTiny(sUndefinedt* obj) MUST_CHECK;
+char* sBytesToStringTiny(sBytest* obj) MUST_CHECK;
+
+char* sTypesTiny(smallt* obj) MUST_CHECK;
+sBytest* sTypesToBytesTiny(smallt *obj) MUST_CHECK;
+const char** sDictTypeStrings(sDictt* obj) MUST_CHECK;
+sBytest* sDictTypes(sDictt* obj) MUST_CHECK;
+sBytest* sDictTypesTiny(sDictt* obj) MUST_CHECK;
+const char** sArrayTypeStrings(sArrayt* obj) MUST_CHECK;
+sBytest* sArrayTypes(sArrayt* obj) MUST_CHECK;
+sBytest* sArrayTypesTiny(sArrayt* obj) MUST_CHECK;
// forEach - loop macro on elements
#define forEachSDict(dict, element) \
sDictElemt *element = &((dict)->elements); \
- for (size_t libsheepyInternalIndex = 0; libsheepyInternalIndex < (dict)->count ; libsheepyInternalIndex++, element = libsheepyInternalIndex < (dict)->count ? &((dict)->elements) + libsheepyInternalIndex : NULL)
+ for (size_t UNIQVAR(libsheepyInternalIndex) = 0; UNIQVAR(libsheepyInternalIndex) < (dict)->count ; UNIQVAR(libsheepyInternalIndex)++, element = UNIQVAR(libsheepyInternalIndex) < (dict)->count ? &((dict)->elements) + UNIQVAR(libsheepyInternalIndex) : NULL)
#define enumerateSDict(dict, element, index) \
sDictElemt *element = &((dict)->elements); \
@@ -261,7 +261,7 @@ sBytest* sArrayTypesTiny(sArrayt* obj);
#define forEachSArray(array, element) \
smallt *element = ((smallt **) &((array)->data))[0]; \
- for (size_t libsheepyInternalIndex = 0; libsheepyInternalIndex < (array)->count ; libsheepyInternalIndex++, element = libsheepyInternalIndex < (array)->count ? ((smallt **) &((array)->data))[libsheepyInternalIndex] : NULL)
+ for (size_t UNIQVAR(libsheepyInternalIndex) = 0; UNIQVAR(libsheepyInternalIndex) < (array)->count ; UNIQVAR(libsheepyInternalIndex)++, element = UNIQVAR(libsheepyInternalIndex) < (array)->count ? ((smallt **) &((array)->data))[UNIQVAR(libsheepyInternalIndex)] : NULL)
#define enumerateSArray(array, element, index) \
smallt *element = ((smallt **) &((array)->data))[0]; \
@@ -269,45 +269,45 @@ sBytest* sArrayTypesTiny(sArrayt* obj);
// TODO forEachSBytes
-smallt* sDictGet(sDictt *dict, const char *key);
-smallt** sDictGetP(sDictt *dict, const char *key);
-smallt* sDictGetTiny(sDictt *dict, const char *key);
-smallt* sDictElemGet(sDictElemt *dictElement);
+smallt* sDictGet(sDictt *dict, const char *key) MUST_CHECK;
+smallt** sDictGetP(sDictt *dict, const char *key) MUST_CHECK;
+smallt* sDictGetTiny(sDictt *dict, const char *key) MUST_CHECK;
+smallt* sDictElemGet(sDictElemt *dictElement) MUST_CHECK;
void sDictSetP(sDictt **dict, const char *key, smallt *data);
void sDictSetTiny(sDictt **dict, const char *key, smallt *data);
void sDictPushTiny(sDictt **dict, const char *key, smallt *data);
void sDictDelTiny(sDictt *dict, const char *key);
-char* sStringGetTiny(sStringt *string);
+char* sStringGetTiny(sStringt *string) MUST_CHECK;
void sStringSetTiny(sStringt **string, const char *news);
void sArrayPushTiny(sArrayt **array, smallt* data);
void sArrayPrependTiny(sArrayt **array, smallt* data);
-smallt* sArrayPopTiny(sArrayt *array);
-smallt* sArrayDequeueTiny(sArrayt *array);
-smallt** sArrayGetP(sArrayt *array, uint32_t index);
-smallt* sArrayGetTiny(sArrayt *array, uint32_t index);
+smallt* sArrayPopTiny(sArrayt *array) MUST_CHECK;
+smallt* sArrayDequeueTiny(sArrayt *array) MUST_CHECK;
+smallt** sArrayGetP(sArrayt *array, uint32_t index) MUST_CHECK;
+smallt* sArrayGetTiny(sArrayt *array, uint32_t index) MUST_CHECK;
void sArraySetShortTiny(sArrayt *array, uint32_t index, smallt *value);
void sArraySetP(sArrayt *array, uint32_t index, smallt *value);
void sArraySetTiny(sArrayt *array, uint32_t index, smallt *value);
-int sArrayReverseTiny(sArrayt *array);
+int sArrayReverseTiny(sArrayt *array) MUST_CHECK;
void sArrayDelTiny(sArrayt *array, uint32_t index);
void sArrayDelRangeTiny(sArrayt *array, uint32_t start, uint32_t end);
// get void* from sBytes
-void* sBytesGet(sBytest *bytes);
-void* sBytesGetTiny(sBytest *bytes);
+void* sBytesGet(sBytest *bytes) MUST_CHECK;
+void* sBytesGetTiny(sBytest *bytes) MUST_CHECK;
void sBytesPush(sBytest **bytes, char data);
// function to copy data from void* to sBytes
void sBytesPushBuffer(sBytest **bytes, void* data, uint32_t size);
void sBytesPushBufferTiny(sBytest **bytes, void* data, uint32_t size);
// serialyzer/deserialyzer
-sBytest *sSerial(smallt *obj);
-sBytest *sSerialTiny(smallt *obj);
+sBytest *sSerial(smallt *obj) MUST_CHECK;
+sBytest *sSerialTiny(smallt *obj) MUST_CHECK;
void sDictSerialElementsTiny(sBytest **r, sDictt *dict);
void sArraySerialElementsTiny(sBytest **r, sArrayt *array);
-smallt* sDeserial(sBytest *obj);
-smallt* sDeserialTiny(sBytest *obj);
+smallt* sDeserial(sBytest *obj) MUST_CHECK;
+smallt* sDeserialTiny(sBytest *obj) MUST_CHECK;
void sDictDeserialElementsTiny(sDictt **dict, char **data);
void sArrayDeserialElementsTiny(sArrayt **array, char **data);
diff --git a/src/CuTest/CuTest.h b/src/CuTest/CuTest.h
@@ -118,7 +118,7 @@ void CuAssertIntNotEquals_LineMsg(CuTest* tc, const char* file, int line, const
/* CuSuite */
-#define MAX_TEST_CASES 1024
+#define MAX_TEST_CASES 16384
#define SUITE_ADD_TEST(SUITE,TEST) CuSuiteAdd(SUITE, CuTestNew(#TEST, TEST))
diff --git a/src/json/laxjson.c b/src/json/laxjson.c
@@ -10,6 +10,8 @@
#include <stdlib.h>
#include <assert.h>
+#include "../../release/libsheepy.h"
+
#define WHITESPACE \
' ': \
case '\t': \
@@ -114,7 +116,7 @@
case '}': \
case '/'
-static const int HEX_MULT[] = {4096, 256, 16, 1};
+static const unsigned int HEX_MULT[] = {4096, 256, 16, 1};
/* static const char *STATE_NAMES[] = { */
/* "LaxJsonStateValue", */
@@ -146,7 +148,7 @@ static enum LaxJsonError push_state(struct LaxJsonContext *context, enum LaxJson
if (context->state_stack_size > context->max_state_stack_size)
return LaxJsonErrorExceededMaxStack;
new_ptr = realloc(context->state_stack,
- context->state_stack_size * sizeof(enum LaxJsonState));
+ (size_t)context->state_stack_size * sizeof(enum LaxJsonState));
if (!new_ptr)
return LaxJsonErrorNoMem;
context->state_stack = new_ptr;
@@ -163,7 +165,7 @@ struct LaxJsonContext *lax_json_create(void) {
return NULL;
context->value_buffer_size = 1024;
- context->value_buffer = malloc(context->value_buffer_size);
+ context->value_buffer = malloc((size_t)context->value_buffer_size);
if (!context->value_buffer) {
lax_json_destroy(context);
@@ -171,7 +173,7 @@ struct LaxJsonContext *lax_json_create(void) {
}
context->state_stack_size = 1024;
- context->state_stack = malloc(context->state_stack_size * sizeof(enum LaxJsonState));
+ context->state_stack = malloc((size_t)context->state_stack_size * sizeof(enum LaxJsonState));
if (!context->state_stack) {
lax_json_destroy(context);
return NULL;
@@ -204,7 +206,7 @@ static enum LaxJsonError buffer_char(struct LaxJsonContext *context, char c) {
context->value_buffer_size += 16384;
if (context->value_buffer_size > context->max_value_buffer_size)
return LaxJsonErrorExceededMaxValueSize;
- new_ptr = realloc(context->value_buffer, context->value_buffer_size);
+ new_ptr = realloc(context->value_buffer, (size_t)context->value_buffer_size);
if (!new_ptr)
return LaxJsonErrorNoMem;
context->value_buffer = new_ptr;
@@ -223,7 +225,7 @@ enum LaxJsonError lax_json_feed(struct LaxJsonContext *context, int size, const
if (err) return err;
enum LaxJsonError err = LaxJsonErrorNone;
- int x;
+ unsigned int x;
const char *end;
char c;
unsigned char byte;
@@ -365,6 +367,8 @@ enum LaxJsonError lax_json_feed(struct LaxJsonContext *context, int size, const
context->unicode_digit_index = 0;
context->unicode_point = 0;
break;
+ default:;
+ // do nothing
}
break;
case LaxJsonStateUnicodeEscape:
@@ -435,53 +439,53 @@ enum LaxJsonError lax_json_feed(struct LaxJsonContext *context, int size, const
context->state = LaxJsonStateString;
} else if (context->unicode_point <= 0x07ff) {
/* 2 bytes */
- byte = (0xc0 | (context->unicode_point >> 6));
+ byte = (unsigned char)(0xc0 | (context->unicode_point >> 6));
BUFFER_CHAR(*(char *)(&byte));
- byte = (0x80 | (context->unicode_point & 0x3f));
+ byte = (unsigned char)(0x80 | (context->unicode_point & 0x3f));
BUFFER_CHAR(*(char *)(&byte));
} else if (context->unicode_point <= 0xffff) {
/* 3 bytes */
- byte = (0xe0 | (context->unicode_point >> 12));
+ byte = (unsigned char)(0xe0 | (context->unicode_point >> 12));
BUFFER_CHAR(*(char *)(&byte));
- byte = (0x80 | ((context->unicode_point >> 6) & 0x3f));
+ byte = (unsigned char)(0x80 | ((context->unicode_point >> 6) & 0x3f));
BUFFER_CHAR(*(char *)(&byte));
- byte = (0x80 | (context->unicode_point & 0x3f));
+ byte = (unsigned char)(0x80 | (context->unicode_point & 0x3f));
BUFFER_CHAR(*(char *)(&byte));
} else if (context->unicode_point <= 0x1fffff) {
/* 4 bytes */
- byte = (0xf0 | (context->unicode_point >> 18));
+ byte = (unsigned char)(0xf0 | (context->unicode_point >> 18));
BUFFER_CHAR(*(char *)(&byte));
- byte = (0x80 | ((context->unicode_point >> 12) & 0x3f));
+ byte = (unsigned char)(0x80 | ((context->unicode_point >> 12) & 0x3f));
BUFFER_CHAR(*(char *)(&byte));
- byte = (0x80 | ((context->unicode_point >> 6) & 0x3f));
+ byte = (unsigned char)(0x80 | ((context->unicode_point >> 6) & 0x3f));
BUFFER_CHAR(*(char *)(&byte));
- byte = (0x80 | (context->unicode_point & 0x3f));
+ byte = (unsigned char)(0x80 | (context->unicode_point & 0x3f));
BUFFER_CHAR(*(char *)(&byte));
} else if (context->unicode_point <= 0x3ffffff) {
/* 5 bytes */
- byte = (0xf8 | (context->unicode_point >> 24));
+ byte = (unsigned char)(0xf8 | (context->unicode_point >> 24));
BUFFER_CHAR(*(char *)(&byte));
- byte = (0x80 | (context->unicode_point >> 18));
+ byte = (unsigned char)(0x80 | (context->unicode_point >> 18));
BUFFER_CHAR(*(char *)(&byte));
- byte = (0x80 | ((context->unicode_point >> 12) & 0x3f));
+ byte = (unsigned char)(0x80 | ((context->unicode_point >> 12) & 0x3f));
BUFFER_CHAR(*(char *)(&byte));
- byte = (0x80 | ((context->unicode_point >> 6) & 0x3f));
+ byte = (unsigned char)(0x80 | ((context->unicode_point >> 6) & 0x3f));
BUFFER_CHAR(*(char *)(&byte));
- byte = (0x80 | (context->unicode_point & 0x3f));
+ byte = (unsigned char)(0x80 | (context->unicode_point & 0x3f));
BUFFER_CHAR(*(char *)(&byte));
} else if (context->unicode_point <= 0x7fffffff) {
/* 6 bytes */
- byte = (0xfc | (context->unicode_point >> 30));
+ byte = (unsigned char)(0xfc | (context->unicode_point >> 30));
BUFFER_CHAR(*(char *)(&byte));
- byte = (0x80 | ((context->unicode_point >> 24) & 0x3f));
+ byte = (unsigned char)(0x80 | ((context->unicode_point >> 24) & 0x3f));
BUFFER_CHAR(*(char *)(&byte));
- byte = (0x80 | ((context->unicode_point >> 18) & 0x3f));
+ byte = (unsigned char)(0x80 | ((context->unicode_point >> 18) & 0x3f));
BUFFER_CHAR(*(char *)(&byte));
- byte = (0x80 | ((context->unicode_point >> 12) & 0x3f));
+ byte = (unsigned char)(0x80 | ((context->unicode_point >> 12) & 0x3f));
BUFFER_CHAR(*(char *)(&byte));
- byte = (0x80 | ((context->unicode_point >> 6) & 0x3f));
+ byte = (unsigned char)(0x80 | ((context->unicode_point >> 6) & 0x3f));
BUFFER_CHAR(*(char *)(&byte));
- byte = (0x80 | (context->unicode_point & 0x3f));
+ byte = (unsigned char)(0x80 | (context->unicode_point & 0x3f));
BUFFER_CHAR(*(char *)(&byte));
} else {
return LaxJsonErrorInvalidUnicodePoint;
@@ -707,6 +711,9 @@ enum LaxJsonError lax_json_feed(struct LaxJsonContext *context, int size, const
else
context->state = LaxJsonStateCommentMultiLine;
break;
+ default:;
+ // not reachable
+ logC("Check this function!");
}
}
if (context->state != LaxJsonStateEnd) {
@@ -751,6 +758,8 @@ const char *lax_json_str_err(enum LaxJsonError err) {
case LaxJsonErrorExpectedColon: return "expected colon";
case LaxJsonErrorUnexpectedEof: return "unexpected end of file";
case LaxJsonErrorAborted: return "aborted";
+ default:;
+ // return invalid error code
}
return "invalid error code";
}
diff --git a/src/json/libsheepyCSmallArray.c b/src/json/libsheepyCSmallArray.c
@@ -66,6 +66,7 @@ internal sArrayt* getsoSmallArray(smallArrayt *self);
internal void setsoSmallArray(smallArrayt *self, sArrayt *so);
internal smallArrayt* mirrorSmallArray(smallArrayt *self);
internal smallArrayt* fromArraySmallArray(smallArrayt *self, char **array, size_t size);
+internal smallArrayt* fromCArraySmallArray(smallArrayt *self, const char **array, size_t size);
internal smallArrayt* fromArrayNFreeSmallArray(smallArrayt *self, char **array, size_t size);
internal smallArrayt* pushSmallArray(smallArrayt *self, baset *value);
internal smallArrayt* pushUndefinedSmallArray(smallArrayt *self);
@@ -77,6 +78,7 @@ internal smallArrayt* pushCharSmallArray(smallArrayt *self, char c);
internal smallArrayt* pushDictSmallArray(smallArrayt *self, smallDictt *dict);
internal smallArrayt* pushArraySmallArray(smallArrayt *self, smallArrayt *array);
internal smallArrayt* pushArraycSmallArray(smallArrayt *self, char **array);
+internal smallArrayt* pushCArraycSmallArray(smallArrayt *self, const char **array);
internal smallArrayt* pushSmallBoolSmallArray(smallArrayt *self, smallBoolt *value);
internal smallArrayt* pushSmallBytesSmallArray(smallArrayt *self, smallBytest *value);
internal smallArrayt* pushSmallDoubleSmallArray(smallArrayt *self, smallDoublet *value);
@@ -85,7 +87,7 @@ internal smallArrayt* pushSmallJsonSmallArray(smallArrayt *self, smallJsont *val
internal smallArrayt* pushSmallStringSmallArray(smallArrayt *self, smallStringt *string);
internal smallArrayt* pushSmallContainerSmallArray(smallArrayt *self, smallContainert *container);
internal smallArrayt* pushNFreeSmallArray(smallArrayt *self, baset *value);
-internal smallArrayt* pushNFreeUndefinedSmallArray(smallArrayt *self, undefinedt *undefined);
+internal smallArrayt* pushNFreeUndefinedSmallArray(smallArrayt *self, undefinedt *u);
internal smallArrayt* pushNFreeSSmallArray(smallArrayt *self, char *string);
internal smallArrayt* pushNFreeDictSmallArray(smallArrayt *self, smallDictt *dict);
internal smallArrayt* pushNFreeArraySmallArray(smallArrayt *self, smallArrayt *array);
@@ -131,6 +133,7 @@ internal smallArrayt* prependCharSmallArray(smallArrayt *self, char c);
internal smallArrayt* prependDictSmallArray(smallArrayt *self, smallDictt *dict);
internal smallArrayt* prependArraySmallArray(smallArrayt *self, smallArrayt *array);
internal smallArrayt* prependArraycSmallArray(smallArrayt *self, char **array);
+internal smallArrayt* prependCArraycSmallArray(smallArrayt *self, const char **array);
internal smallArrayt* prependSmallBoolSmallArray(smallArrayt *self, smallBoolt *value);
internal smallArrayt* prependSmallBytesSmallArray(smallArrayt *self, smallBytest *value);
internal smallArrayt* prependSmallDoubleSmallArray(smallArrayt *self, smallDoublet *value);
@@ -139,7 +142,7 @@ internal smallArrayt* prependSmallJsonSmallArray(smallArrayt *self, smallJsont *
internal smallArrayt* prependSmallStringSmallArray(smallArrayt *self, smallStringt *string);
internal smallArrayt* prependSmallContainerSmallArray(smallArrayt *self, smallContainert *container);
internal smallArrayt* prependNFreeSmallArray(smallArrayt *self, baset *value);
-internal smallArrayt* prependNFreeUndefinedSmallArray(smallArrayt *self, undefinedt *undefined);
+internal smallArrayt* prependNFreeUndefinedSmallArray(smallArrayt *self, undefinedt *u);
internal smallArrayt* prependNFreeSSmallArray(smallArrayt *self, char *string);
internal smallArrayt* prependNFreeDictSmallArray(smallArrayt *self, smallDictt *dict);
internal smallArrayt* prependNFreeArraySmallArray(smallArrayt *self, smallArrayt *array);
@@ -178,6 +181,7 @@ internal smallArrayt* appendSmallJsonSmallArray(smallArrayt *self, smallJsont *j
internal smallArrayt* appendNSmashSmallArray(smallArrayt *self, smallArrayt *array);
internal smallArrayt* appendNSmashSmallJsonSmallArray(smallArrayt *self, smallJsont *json);
internal smallArrayt* appendArraySmallArray(smallArrayt *self, char **array);
+internal smallArrayt* appendCArraySmallArray(smallArrayt *self, const char **array);
internal smallArrayt* appendNSmashArraySmallArray(smallArrayt *self, char **array);
internal smallArrayt* shiftSmallArray(smallArrayt *self, smallArrayt *array);
internal smallArrayt* shiftSmallJsonSmallArray(smallArrayt *self, smallJsont *json);
@@ -220,6 +224,7 @@ internal smallArrayt* injectCharSmallArray(smallArrayt *self, int64_t index, cha
internal smallArrayt* injectDictSmallArray(smallArrayt *self, int64_t index, smallDictt *toInject);
internal smallArrayt* injectArraySmallArray(smallArrayt *self, int64_t index, smallArrayt *toInject);
internal smallArrayt* injectArraycSmallArray(smallArrayt *self, int64_t index, char **toInject);
+internal smallArrayt* injectCArraycSmallArray(smallArrayt *self, int64_t index, const char **toInject);
internal smallArrayt* injectSmallBoolSmallArray(smallArrayt *self, int64_t index, smallBoolt *toInject);
internal smallArrayt* injectSmallBytesSmallArray(smallArrayt *self, int64_t index, smallBytest *toInject);
internal smallArrayt* injectSmallDoubleSmallArray(smallArrayt *self, int64_t index, smallDoublet *toInject);
@@ -228,7 +233,7 @@ internal smallArrayt* injectSmallJsonSmallArray(smallArrayt *self, int64_t index
internal smallArrayt* injectSmallStringSmallArray(smallArrayt *self, int64_t index, smallStringt *toInject);
internal smallArrayt* injectSmallContainerSmallArray(smallArrayt *self, int64_t index, smallContainert *toInject);
internal smallArrayt* injectNFreeSmallArray(smallArrayt *self, int64_t index, baset *toInject);
-internal smallArrayt* injectNFreeUndefinedSmallArray(smallArrayt *self, int64_t index, undefinedt *undefined);
+internal smallArrayt* injectNFreeUndefinedSmallArray(smallArrayt *self, int64_t index, undefinedt *u);
internal smallArrayt* injectNFreeSSmallArray(smallArrayt *self, int64_t index, char *toInject);
internal smallArrayt* injectNFreeDictSmallArray(smallArrayt *self, int64_t index, smallDictt *toInject);
internal smallArrayt* injectNFreeArraySmallArray(smallArrayt *self, int64_t index, smallArrayt *toInject);
@@ -261,10 +266,12 @@ internal smallArrayt* sortFSmallArray(smallArrayt *self, shCmpt compareFunction)
internal bool equalSmallArray(smallArrayt *self, smallArrayt *array);
internal bool equalSmallArraySmallJson(smallArrayt *self, smallJsont *array);
internal bool equalSmallArrayArray(smallArrayt* self, char ** p2);
+internal bool equalSmallArrayCArray(smallArrayt* self, const char ** p2);
internal bool equalSmallArrayBase(smallArrayt* self, baset* p2);
internal bool icEqualSmallArray(smallArrayt *self, smallArrayt *array);
internal bool icEqualSmallArraySmallJson(smallArrayt *self, smallJsont *array);
bool icEqualSmallArrayArray(smallArrayt* self, char ** p2);
+bool icEqualSmallArrayCArray(smallArrayt* self, const char ** p2);
bool icEqualSmallArrayBase(smallArrayt* self, baset* p2);
internal size_t lenSmallArray(smallArrayt *self);
internal smallArrayt* trimSmallArray(smallArrayt *self);
@@ -322,6 +329,7 @@ internal smallArrayt* setAtCharSmallArray(smallArrayt *self, int64_t index, char
internal smallArrayt* setAtDictSmallArray(smallArrayt *self, int64_t index, smallDictt *dict);
internal smallArrayt* setAtArraySmallArray(smallArrayt *self, int64_t index, smallArrayt *array);
internal smallArrayt* setAtArraycSmallArray(smallArrayt *self, int64_t index, char **array);
+internal smallArrayt* setAtCArraycSmallArray(smallArrayt *self, int64_t index, const char **array);
internal smallArrayt* setAtSmallBoolSmallArray(smallArrayt *self, int64_t index, smallBoolt *value);
internal smallArrayt* setAtSmallBytesSmallArray(smallArrayt *self, int64_t index, smallBytest *value);
internal smallArrayt* setAtSmallDoubleSmallArray(smallArrayt *self, int64_t index, smallDoublet *value);
@@ -330,7 +338,7 @@ internal smallArrayt* setAtSmallJsonSmallArray(smallArrayt *self, int64_t index,
internal smallArrayt* setAtSmallStringSmallArray(smallArrayt *self, int64_t index, smallStringt *string);
internal smallArrayt* setAtSmallContainerSmallArray(smallArrayt *self, int64_t index, smallContainert *container);
internal smallArrayt* setAtNFreeSmallArray(smallArrayt *self, int64_t index, baset *value);
-internal smallArrayt* setAtNFreeUndefinedSmallArray(smallArrayt *self, int64_t index, undefinedt *undefined);
+internal smallArrayt* setAtNFreeUndefinedSmallArray(smallArrayt *self, int64_t index, undefinedt *u);
internal smallArrayt* setAtNFreeSSmallArray(smallArrayt *self, int64_t index, char *string);
internal smallArrayt* setAtNFreeDictSmallArray(smallArrayt *self, int64_t index, smallDictt *dict);
internal smallArrayt* setAtNFreeArraySmallArray(smallArrayt *self, int64_t index, smallArrayt *array);
@@ -352,7 +360,7 @@ internal smallArrayt* setPAtNFreeSmallJsonSmallArray(smallArrayt *self, int64_t
internal smallArrayt* setPAtNFreeSmallStringSmallArray(smallArrayt *self, int64_t index, smallStringt *string);
internal double getNumSmallArray(smallArrayt *self, int64_t index);
internal bool hasSmallArray(smallArrayt *self, baset *value);
-internal bool hasUndefinedSmallArray(smallArrayt *self, undefinedt *undefined);
+internal bool hasUndefinedSmallArray(smallArrayt *self, undefinedt *u);
internal bool hasBoolSmallArray(smallArrayt *self, bool value);
internal bool hasDoubleSmallArray(smallArrayt *self, double value);
internal bool hasIntSmallArray(smallArrayt *self, int64_t value);
@@ -361,6 +369,7 @@ internal bool hasCharSmallArray(smallArrayt *self, char c);
internal bool hasDictSmallArray(smallArrayt *self, smallDictt *dict);
internal bool hasArraySmallArray(smallArrayt *self, smallArrayt *array);
internal bool hasArraycSmallArray(smallArrayt *self, char **array);
+internal bool hasCArraycSmallArray(smallArrayt *self, const char **array);
internal bool hasSmallBoolSmallArray(smallArrayt *self, smallBoolt *value);
internal bool hasSmallBytesSmallArray(smallArrayt *self, smallBytest *value);
internal bool hasSmallDoubleSmallArray(smallArrayt *self, smallDoublet *value);
@@ -369,7 +378,7 @@ internal bool hasSmallJsonSmallArray(smallArrayt *self, smallJsont *string);
internal bool hasSmallStringSmallArray(smallArrayt *self, smallStringt *string);
internal bool hasSmallContainerSmallArray(smallArrayt *self, smallContainert *container);
internal ssize_t indexOfSmallArray(smallArrayt *self, baset *value);
-internal ssize_t indexOfUndefinedSmallArray(smallArrayt *self, undefinedt *undefined);
+internal ssize_t indexOfUndefinedSmallArray(smallArrayt *self, undefinedt *u);
internal ssize_t indexOfBoolSmallArray(smallArrayt *self, bool value);
internal ssize_t indexOfDoubleSmallArray(smallArrayt *self, double value);
internal ssize_t indexOfIntSmallArray(smallArrayt *self, int64_t value);
@@ -378,6 +387,7 @@ internal ssize_t indexOfCharSmallArray(smallArrayt *self, char c);
internal ssize_t indexOfDictSmallArray(smallArrayt *self, smallDictt *dict);
internal ssize_t indexOfArraySmallArray(smallArrayt *self, smallArrayt *array);
internal ssize_t indexOfArraycSmallArray(smallArrayt *self, char **array);
+internal ssize_t indexOfCArraycSmallArray(smallArrayt *self, const char **array);
internal ssize_t indexOfSmallBoolSmallArray(smallArrayt *self, smallBoolt *value);
internal ssize_t indexOfSmallBytesSmallArray(smallArrayt *self, smallBytest *value);
internal ssize_t indexOfSmallDoubleSmallArray(smallArrayt *self, smallDoublet *value);
@@ -386,7 +396,7 @@ internal ssize_t indexOfSmallJsonSmallArray(smallArrayt *self, smallJsont *strin
internal ssize_t indexOfSmallStringSmallArray(smallArrayt *self, smallStringt *string);
internal ssize_t indexOfSmallContainerSmallArray(smallArrayt *self UNUSED, smallContainert *container UNUSED);
internal ssize_t binarySearchSmallArray(smallArrayt *self, baset *value);
-internal ssize_t binarySearchUndefinedSmallArray(smallArrayt *self UNUSED, undefinedt *undefined UNUSED);
+internal ssize_t binarySearchUndefinedSmallArray(smallArrayt *self UNUSED, undefinedt *u UNUSED);
internal ssize_t binarySearchBoolSmallArray(smallArrayt *self, bool value);
internal ssize_t binarySearchDoubleSmallArray(smallArrayt *self, double value);
internal ssize_t binarySearchIntSmallArray(smallArrayt *self, int64_t value);
@@ -395,6 +405,7 @@ internal ssize_t binarySearchCharSmallArray(smallArrayt *self, char c);
internal ssize_t binarySearchDictSmallArray(smallArrayt *self, smallDictt *dict);
internal ssize_t binarySearchArraySmallArray(smallArrayt *self, smallArrayt *array);
internal ssize_t binarySearchArraycSmallArray(smallArrayt *self, char **array);
+internal ssize_t binarySearchCArraycSmallArray(smallArrayt *self, const char **array);
internal ssize_t binarySearchSmallBoolSmallArray(smallArrayt *self, smallBoolt *value);
internal ssize_t binarySearchSmallBytesSmallArray(smallArrayt *self, smallBytest *value);
internal ssize_t binarySearchSmallDoubleSmallArray(smallArrayt *self, smallDoublet *value);
@@ -409,6 +420,7 @@ internal bool icHasCharSmallArray(smallArrayt *self, char c);
internal bool icHasDictSmallArray(smallArrayt *self, smallDictt *dict);
internal bool icHasArraySmallArray(smallArrayt *self, smallArrayt *array);
internal bool icHasArraycSmallArray(smallArrayt *self, char **array);
+internal bool icHasCArraycSmallArray(smallArrayt *self, const char **array);
internal bool icHasSmallJsonSmallArray(smallArrayt *self, smallJsont *string);
internal bool icHasSmallStringSmallArray(smallArrayt *self, smallStringt *string);
internal ssize_t icIndexOfSmallArray(smallArrayt *self, baset *value);
@@ -417,6 +429,7 @@ internal ssize_t icIndexOfCharSmallArray(smallArrayt *self, char c);
internal ssize_t icIndexOfDictSmallArray(smallArrayt *self, smallDictt *dict);
internal ssize_t icIndexOfArraySmallArray(smallArrayt *self, smallArrayt *array);
internal ssize_t icIndexOfArraycSmallArray(smallArrayt *self, char **array);
+internal ssize_t icIndexOfCArraycSmallArray(smallArrayt *self, const char **array);
internal ssize_t icIndexOfSmallJsonSmallArray(smallArrayt *self, smallJsont *string);
internal ssize_t icIndexOfSmallStringSmallArray(smallArrayt *self, smallStringt *string);
internal ssize_t icBinarySearchSmallArray(smallArrayt *self, baset *value);
@@ -425,6 +438,7 @@ internal ssize_t icBinarySearchCharSmallArray(smallArrayt *self, char c);
internal ssize_t icBinarySearchDictSmallArray(smallArrayt *self, smallDictt *dict);
internal ssize_t icBinarySearchArraySmallArray(smallArrayt *self, smallArrayt *array);
internal ssize_t icBinarySearchArraycSmallArray(smallArrayt *self, char **array);
+internal ssize_t icBinarySearchCArraycSmallArray(smallArrayt *self, const char **array);
internal ssize_t icBinarySearchSmallJsonSmallArray(smallArrayt *self, smallJsont *string);
internal ssize_t icBinarySearchSmallStringSmallArray(smallArrayt *self, smallStringt *string);
internal smallArrayt* icUniqSmallArray(smallArrayt *self);
@@ -457,15 +471,15 @@ internal smallArrayt* zipSmallJsonSmallJsonSmallArray(smallArrayt *self, smallJ
internal smallArrayt* zipSmallJsonCharSmallArray(smallArrayt *self, smallJsont *array1, char **array2);
internal smallArrayt* zipSmallJsonCCharSmallArray(smallArrayt *self, smallJsont *array1, const char **array2);
internal smallArrayt* zipArraySmallArray(smallArrayt *self, char** array1, smallArrayt *array2);
-internal smallArrayt* zipCArraySmallArray(smallArrayt *self, const char** a1, smallArrayt *array2);
+internal smallArrayt* zipCArraySmallArray(smallArrayt *self, const char** array1, smallArrayt *array2);
internal smallArrayt* zipArraySmallJsonSmallArray(smallArrayt *self, char** array1, smallJsont *array2);
internal smallArrayt* zipCArraySmallJsonSmallArray(smallArrayt *self, const char** array1, smallJsont *array2);
internal smallArrayt* zipCharSmallArray(smallArrayt *self, smallArrayt *array1, char** array2);
-internal smallArrayt* zipCCharSmallArray(smallArrayt *self, smallArrayt *array1, const char** a2);
+internal smallArrayt* zipCCharSmallArray(smallArrayt *self, smallArrayt *array1, const char** array2);
internal smallArrayt* zipArrayCharSmallArray(smallArrayt *self, char** array1, char** array2);
-internal smallArrayt* zipCArrayCharSmallArray(smallArrayt *self, const char** a1, char** array2);
-internal smallArrayt* zipArrayCCharSmallArray(smallArrayt *self, char** array1, const char** a2);
-internal smallArrayt* zipCArrayCCharSmallArray(smallArrayt *self, const char** a1, const char** a2);
+internal smallArrayt* zipCArrayCharSmallArray(smallArrayt *self, const char** array1, char** array2);
+internal smallArrayt* zipArrayCCharSmallArray(smallArrayt *self, char** array1, const char** array2);
+internal smallArrayt* zipCArrayCCharSmallArray(smallArrayt *self, const char** array1, const char** array2);
internal void logSmallArray(smallArrayt *self);
internal smallArrayt* readTextSmallArray(smallArrayt *self, const char *filePath);
internal smallArrayt* readTextSmallJsonSmallArray(smallArrayt *self, smallJsont *filePath);
@@ -480,7 +494,7 @@ internal bool appendTextSmallStringSmallArray(smallArrayt *self, smallStringt *f
internal const char* typeStringSmallArray(smallArrayt *self, int64_t index);
internal smallStringt* typeSmallStringSmallArray(smallArrayt *self, int64_t index);
internal char typeSmallArray(smallArrayt *self, int64_t index);
-internal char** typeStringsSmallArray(smallArrayt *self);
+internal const char** typeStringsSmallArray(smallArrayt *self);
internal smallArrayt* typeSmallStringsSmallArray(smallArrayt *self);
internal smallBytest* typesSmallArray(smallArrayt *self);
internal bool isETypeSmallArray(smallArrayt *self, int64_t index, const char *type);
@@ -993,6 +1007,7 @@ void registerMethodsSmallArray(smallArrayFunctionst *f) {
f->getAtNDupSmallContainer = getAtNDupSmallContainerSmallArray;
f->set = setAtSmallArray;
f->fromArray = fromArraySmallArray;
+ f->fromCArray = fromCArraySmallArray;
f->fromArrayNFree = fromArrayNFreeSmallArray;
f->push = pushSmallArray;
f->pushUndefined = pushUndefinedSmallArray;
@@ -1004,6 +1019,7 @@ void registerMethodsSmallArray(smallArrayFunctionst *f) {
f->pushDict = pushDictSmallArray;
f->pushArray = pushArraySmallArray;
f->pushArrayc = pushArraycSmallArray;
+ f->pushCArrayc = pushCArraycSmallArray;
f->pushSmallBool = pushSmallBoolSmallArray;
f->pushSmallBytes = pushSmallBytesSmallArray;
f->pushSmallDouble = pushSmallDoubleSmallArray;
@@ -1058,6 +1074,7 @@ void registerMethodsSmallArray(smallArrayFunctionst *f) {
f->prependDict = prependDictSmallArray;
f->prependArray = prependArraySmallArray;
f->prependArrayc = prependArraycSmallArray;
+ f->prependCArrayc = prependCArraycSmallArray;
f->prependSmallBool = prependSmallBoolSmallArray;
f->prependSmallBytes = prependSmallBytesSmallArray;
f->prependSmallDouble = prependSmallDoubleSmallArray;
@@ -1105,6 +1122,7 @@ void registerMethodsSmallArray(smallArrayFunctionst *f) {
f->appendNSmash = appendNSmashSmallArray;
f->appendNSmashSmallJson = appendNSmashSmallJsonSmallArray;
f->appendArray = appendArraySmallArray;
+ f->appendCArray = appendCArraySmallArray;
f->appendNSmashArray = appendNSmashArraySmallArray;
f->shift = shiftSmallArray; {
f->shiftSmallJson = shiftSmallJsonSmallArray; {
@@ -1147,6 +1165,7 @@ void registerMethodsSmallArray(smallArrayFunctionst *f) {
f->injectDict = injectDictSmallArray;
f->injectArray = injectArraySmallArray;
f->injectArrayc = injectArraycSmallArray;
+ f->injectCArrayc = injectCArraycSmallArray;
f->injectSmallBool = injectSmallBoolSmallArray;
f->injectSmallBytes = injectSmallBytesSmallArray;
f->injectSmallDouble = injectSmallDoubleSmallArray;
@@ -1177,10 +1196,12 @@ void registerMethodsSmallArray(smallArrayFunctionst *f) {
f->equal = equalSmallArray;
f->equalSmallJson = equalSmallArraySmallJson;
f->equalArray = equalSmallArrayArray;
+ f->equalCArray = equalSmallArrayCArray;
f->equalBase = equalSmallArrayBase;
f->icEqual = icEqualSmallArray;
f->icEqualSmallJson = icEqualSmallArraySmallJson;
f->icEqualArray = icEqualSmallArrayArray;
+ f->icEqualCArray = icEqualSmallArrayCArray;
f->icEqualBase = icEqualSmallArrayBase;
f->len = lenSmallArray;
f->trim = trimSmallArray;
@@ -1196,6 +1217,7 @@ void registerMethodsSmallArray(smallArrayFunctionst *f) {
f->setAtDict = setAtDictSmallArray;
f->setAtArray = setAtArraySmallArray;
f->setAtArrayc = setAtArraycSmallArray;
+ f->setAtCArrayc = setAtCArraycSmallArray;
f->setAtSmallBool = setAtSmallBoolSmallArray;
f->setAtSmallBytes = setAtSmallBytesSmallArray;
f->setAtSmallDouble = setAtSmallDoubleSmallArray;
@@ -1235,6 +1257,7 @@ void registerMethodsSmallArray(smallArrayFunctionst *f) {
f->hasDict = hasDictSmallArray;
f->hasArray = hasArraySmallArray;
f->hasArrayc = hasArraycSmallArray;
+ f->hasCArrayc = hasCArraycSmallArray;
f->hasSmallBool = hasSmallBoolSmallArray;
f->hasSmallBytes = hasSmallBytesSmallArray;
f->hasSmallDouble = hasSmallDoubleSmallArray;
@@ -1252,6 +1275,7 @@ void registerMethodsSmallArray(smallArrayFunctionst *f) {
f->indexOfDict = indexOfDictSmallArray;
f->indexOfArray = indexOfArraySmallArray;
f->indexOfArrayc = indexOfArraycSmallArray;
+ f->indexOfCArrayc = indexOfCArraycSmallArray;
f->indexOfSmallBool = indexOfSmallBoolSmallArray;
f->indexOfSmallBytes = indexOfSmallBytesSmallArray;
f->indexOfSmallDouble = indexOfSmallDoubleSmallArray;
@@ -1269,6 +1293,7 @@ void registerMethodsSmallArray(smallArrayFunctionst *f) {
f->binarySearchDict = binarySearchDictSmallArray;
f->binarySearchArray = binarySearchArraySmallArray;
f->binarySearchArrayc = binarySearchArraycSmallArray;
+ f->binarySearchCArrayc = binarySearchCArraycSmallArray;
f->binarySearchSmallBool = binarySearchSmallBoolSmallArray;
f->binarySearchSmallBytes = binarySearchSmallBytesSmallArray;
f->binarySearchSmallDouble = binarySearchSmallDoubleSmallArray;
@@ -1283,6 +1308,7 @@ void registerMethodsSmallArray(smallArrayFunctionst *f) {
f->icHasDict = icHasDictSmallArray;
f->icHasArray = icHasArraySmallArray;
f->icHasArrayc = icHasArraycSmallArray;
+ f->icHasCArrayc = icHasCArraycSmallArray;
f->icHasSmallJson = icHasSmallJsonSmallArray;
f->icHasSmallString = icHasSmallStringSmallArray;
f->icIndexOf = icIndexOfSmallArray;
@@ -1291,6 +1317,7 @@ void registerMethodsSmallArray(smallArrayFunctionst *f) {
f->icIndexOfDict = icIndexOfDictSmallArray;
f->icIndexOfArray = icIndexOfArraySmallArray;
f->icIndexOfArrayc = icIndexOfArraycSmallArray;
+ f->icIndexOfCArrayc = icIndexOfCArraycSmallArray;
f->icIndexOfSmallJson = icIndexOfSmallJsonSmallArray;
f->icIndexOfSmallString = icIndexOfSmallStringSmallArray;
f->icBinarySearch = icBinarySearchSmallArray;
@@ -1299,6 +1326,7 @@ void registerMethodsSmallArray(smallArrayFunctionst *f) {
f->icBinarySearchDict = icBinarySearchDictSmallArray;
f->icBinarySearchArray = icBinarySearchArraySmallArray;
f->icBinarySearchArrayc = icBinarySearchArraycSmallArray;
+ f->icBinarySearchCArrayc = icBinarySearchCArraycSmallArray;
f->icBinarySearchSmallJson = icBinarySearchSmallJsonSmallArray;
f->icBinarySearchSmallString = icBinarySearchSmallStringSmallArray;
f->icUniq = icUniqSmallArray;
@@ -1423,8 +1451,11 @@ smallArrayt* allocArraySmallArray(char **array) {
}
smallArrayt* allocCArraySmallArray(const char **array) {
+ smallArrayt *r = NULL;
- return(allocArraySmallArray((char**)array));
+ isError(r, allocSmallArray()) return(NULL);
+ fromCArraySmallArray(r, array, 0);
+ return(r);
}
void cleanUpSmallArrayTerminateG(smallArrayt **val) {
@@ -1465,10 +1496,10 @@ smallArrayt* createSAF(const char *paramType, ...) {
// push arguments to a list
va_start(pl, paramType);
- paramType = va_arg(pl, char *);
+ paramType = va_arg(pl, const char *);
while (paramType) {
- pushSSmallArray(r, (char *)paramType);
- paramType = va_arg(pl, char *);
+ pushSSmallArray(r, paramType);
+ paramType = va_arg(pl, const char *);
}
va_end(pl);
return(r);
@@ -1529,7 +1560,7 @@ internal smallArrayt* duplicateSmallArray(smallArrayt *self) {
dup->iterIndex = self->iterIndex;
dup->iterStep = self->iterStep;
if (dup->iterIndex != -1) {
- dup->iterElement = toBaset(sArrayGetTiny(dup->a, dup->iterIndex));
+ dup->iterElement = toBaset(sArrayGetTiny(dup->a, (uint32_t)dup->iterIndex));
}
}
return(dup);
@@ -1634,7 +1665,7 @@ internal smallArrayt* mirrorSmallArray(smallArrayt *self) {
mirror->iterIndex = self->iterIndex;
mirror->iterStep = self->iterStep;
if (mirror->iterIndex != -1) {
- mirror->iterElement = toBaset(sArrayGetTiny(mirror->a, mirror->iterIndex));
+ mirror->iterElement = toBaset(sArrayGetTiny(mirror->a, (uint32_t)mirror->iterIndex));
}
return(mirror);
}
@@ -1679,6 +1710,44 @@ internal smallArrayt* fromArraySmallArray(smallArrayt *self, char **array, size_
return(self);
}
+internal smallArrayt* fromCArraySmallArray(smallArrayt *self, const char **array, size_t size) {
+
+ // sanity checks
+ if (!array) {
+ return(NULL);
+ }
+
+ freeSmallArray(self);
+
+ if (!size) {
+ forEachCCharP(array, e) {
+ sStringt *s = allocSStringTiny(*e);
+ if (!s) {
+ return(NULL);
+ }
+ sArrayPushTiny(&(self->a), (smallt *) s);
+ }
+ return(self);
+ }
+
+ // copy array content
+ for (size_t i = 0 ; i < size ; i++) {
+ if (array[i]) {
+ // remove NULL strings
+ sStringt *s = allocSStringTiny(array[i]);
+ if (!s) {
+ return(NULL);
+ }
+ sArrayPushTiny(&(self->a), (smallt *) s);
+ }
+ else {
+ sArrayPushTiny(&(self->a), NULL);
+ }
+ }
+
+ return(self);
+}
+
internal smallArrayt* fromArrayNFreeSmallArray(smallArrayt *self, char **array, size_t size) {
smallArrayt *r = fromArraySmallArray(self, array, size);
@@ -1831,6 +1900,29 @@ internal smallArrayt* pushArraycSmallArray(smallArrayt *self, char **array) {
return(self);
}
+internal smallArrayt* pushCArraycSmallArray(smallArrayt *self, const char **array) {
+
+ // sanity checks
+ if (!array) {
+ return(NULL);
+ }
+
+ sArrayt *a = allocSArray();
+ if (!a) {
+ return(NULL);
+ }
+
+ forEachCCharP(array, e) {
+ sStringt *s = allocSStringTiny(*e);
+ if (!s) {
+ return(NULL);
+ }
+ sArrayPushTiny(&a, (smallt *) s);
+ }
+ sArrayPushTiny(&(self->a), (smallt *) a);
+ return(self);
+}
+
internal smallArrayt* pushSmallBoolSmallArray(smallArrayt *self, smallBoolt *value) {
if (checkObjectTypes && value && !isOSmallBool(value)) {
@@ -1973,11 +2065,11 @@ internal smallArrayt* pushNFreeSmallArray(smallArrayt *self, baset *value) {
return(self);
}
-internal smallArrayt* pushNFreeUndefinedSmallArray(smallArrayt *self, undefinedt *undefined) {
+internal smallArrayt* pushNFreeUndefinedSmallArray(smallArrayt *self, undefinedt *u) {
smallArrayt *r = pushUndefinedSmallArray(self);;
if (r) {
- terminateO(undefined);
+ terminateO(u);
}
return(r);
}
@@ -2639,7 +2731,7 @@ internal double popNumSmallArray(smallArrayt *self) {
r = getValO((smallDoublet*)e);
}
elif (isOSmallInt(e)) {
- r = getValO((smallIntt*)e);
+ r = (double)getValO((smallIntt*)e);
}
terminateO(e);
return(r);
@@ -2779,6 +2871,28 @@ internal smallArrayt* prependArraycSmallArray(smallArrayt *self, char **array) {
return(self);
}
+internal smallArrayt* prependCArraycSmallArray(smallArrayt *self, const char **array) {
+
+ if (!array) {
+ return(NULL);
+ }
+
+ sArrayt *a = allocSArray();
+ if (!a) {
+ return(NULL);
+ }
+
+ forEachCCharP(array, e) {
+ sStringt *s = allocSStringTiny(*e);
+ if (!s) {
+ return(NULL);
+ }
+ sArrayPushTiny(&a, (smallt *) s);
+ }
+ sArrayPrependTiny(&(self->a), (smallt *) a);
+ return(self);
+}
+
internal smallArrayt* prependSmallBoolSmallArray(smallArrayt *self, smallBoolt *value) {
if (checkObjectTypes && value && !isOSmallBool(value)) {
@@ -2922,11 +3036,11 @@ internal smallArrayt* prependNFreeSmallArray(smallArrayt *self, baset *value) {
return(self);
}
-internal smallArrayt* prependNFreeUndefinedSmallArray(smallArrayt *self, undefinedt *undefined) {
+internal smallArrayt* prependNFreeUndefinedSmallArray(smallArrayt *self, undefinedt *u) {
smallArrayt *r = prependUndefinedSmallArray(self);;
if (r) {
- terminateO(undefined);
+ terminateO(u);
}
return(self);
}
@@ -3078,7 +3192,7 @@ internal undefinedt* dequeueUndefinedSmallArray(smallArrayt *self) {
size_t i;
for (i = 0 ; i < len ; i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
if (o) {
break;
}
@@ -3095,10 +3209,10 @@ internal undefinedt* dequeueUndefinedSmallArray(smallArrayt *self) {
// finish dequeuing
smallt **arr = &(self->a->data);
// shift list
- for (uint32_t j = i+1 ; j < self->a->count ; j++) {
+ for (uint32_t j = (uint32_t)i+1 ; j < self->a->count ; j++) {
arr[j-i-1] = arr[j];
}
- self->a->count -= i+1;;
+ self->a->count -= (uint32_t)i+1;
free(o);
return(allocUndefined());
@@ -3199,7 +3313,7 @@ internal smallDictt* dequeueDictSmallArray(smallArrayt *self) {
size_t i;
for (i = 0 ; i < len ; i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
if (o) {
break;
}
@@ -3216,10 +3330,10 @@ internal smallDictt* dequeueDictSmallArray(smallArrayt *self) {
// finish dequeuing
smallt **arr = &(self->a->data);
// shift list
- for (uint32_t j = i+1 ; j < self->a->count ; j++) {
+ for (uint32_t j = (uint32_t)i+1 ; j < self->a->count ; j++) {
arr[j-i-1] = arr[j];
}
- self->a->count -= i+1;;
+ self->a->count -= (uint32_t)i+1;
return((smallDictt*) toBaset(o));
}
@@ -3235,7 +3349,7 @@ internal smallArrayt* dequeueArraySmallArray(smallArrayt *self) {
size_t i;
for (i = 0 ; i < len ; i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
if (o) {
break;
}
@@ -3252,10 +3366,10 @@ internal smallArrayt* dequeueArraySmallArray(smallArrayt *self) {
// finish dequeuing
smallt **arr = &(self->a->data);
// shift list
- for (uint32_t j = i+1 ; j < self->a->count ; j++) {
+ for (uint32_t j = (uint32_t)i+1 ; j < self->a->count ; j++) {
arr[j-i-1] = arr[j];
}
- self->a->count -= i+1;;
+ self->a->count -= (uint32_t)i+1;
return((smallArrayt*) toBaset(o));
}
@@ -3271,7 +3385,7 @@ internal smallBoolt* dequeueSmallBoolSmallArray(smallArrayt *self) {
size_t i;
for (i = 0 ; i < len ; i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
if (o) {
break;
}
@@ -3288,10 +3402,10 @@ internal smallBoolt* dequeueSmallBoolSmallArray(smallArrayt *self) {
// finish dequeuing
smallt **arr = &(self->a->data);
// shift list
- for (uint32_t j = i+1 ; j < self->a->count ; j++) {
+ for (uint32_t j = (uint32_t)i+1 ; j < self->a->count ; j++) {
arr[j-i-1] = arr[j];
}
- self->a->count -= i+1;;
+ self->a->count -= (uint32_t)i+1;
return((smallBoolt*) toBaset(o));
}
@@ -3307,7 +3421,7 @@ internal smallBytest* dequeueSmallBytesSmallArray(smallArrayt *self) {
size_t i;
for (i = 0 ; i < len ; i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
if (o) {
break;
}
@@ -3324,10 +3438,10 @@ internal smallBytest* dequeueSmallBytesSmallArray(smallArrayt *self) {
// finish dequeuing
smallt **arr = &(self->a->data);
// shift list
- for (uint32_t j = i+1 ; j < self->a->count ; j++) {
+ for (uint32_t j = (uint32_t)i+1 ; j < self->a->count ; j++) {
arr[j-i-1] = arr[j];
}
- self->a->count -= i+1;;
+ self->a->count -= (uint32_t)i+1;
return((smallBytest*) toBaset(o));
}
@@ -3343,7 +3457,7 @@ internal smallDoublet* dequeueSmallDoubleSmallArray(smallArrayt *self) {
size_t i;
for (i = 0 ; i < len ; i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
if (o) {
break;
}
@@ -3360,10 +3474,10 @@ internal smallDoublet* dequeueSmallDoubleSmallArray(smallArrayt *self) {
// finish dequeuing
smallt **arr = &(self->a->data);
// shift list
- for (uint32_t j = i+1 ; j < self->a->count ; j++) {
+ for (uint32_t j = (uint32_t)i+1 ; j < self->a->count ; j++) {
arr[j-i-1] = arr[j];
}
- self->a->count -= i+1;;
+ self->a->count -= (uint32_t)i+1;
return((smallDoublet*) toBaset(o));
}
@@ -3379,7 +3493,7 @@ internal smallIntt* dequeueSmallIntSmallArray(smallArrayt *self) {
size_t i;
for (i = 0 ; i < len ; i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
if (o) {
break;
}
@@ -3396,10 +3510,10 @@ internal smallIntt* dequeueSmallIntSmallArray(smallArrayt *self) {
// finish dequeuing
smallt **arr = &(self->a->data);
// shift list
- for (uint32_t j = i+1 ; j < self->a->count ; j++) {
+ for (uint32_t j = (uint32_t)i+1 ; j < self->a->count ; j++) {
arr[j-i-1] = arr[j];
}
- self->a->count -= i+1;;
+ self->a->count -= (uint32_t)i+1;
return((smallIntt*) toBaset(o));
}
@@ -3415,7 +3529,7 @@ internal smallJsont* dequeueSmallJsonSmallArray(smallArrayt *self) {
size_t i;
for (i = 0 ; i < len ; i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
if (o) {
break;
}
@@ -3432,10 +3546,10 @@ internal smallJsont* dequeueSmallJsonSmallArray(smallArrayt *self) {
// finish dequeuing
smallt **arr = &(self->a->data);
// shift list
- for (uint32_t j = i+1 ; j < self->a->count ; j++) {
+ for (uint32_t j = (uint32_t)i+1 ; j < self->a->count ; j++) {
arr[j-i-1] = arr[j];
}
- self->a->count -= i+1;;
+ self->a->count -= (uint32_t)i+1;
baset *e = toBaset(o);
@@ -3458,7 +3572,7 @@ internal smallStringt* dequeueSmallStringSmallArray(smallArrayt *self) {
size_t i;
for (i = 0 ; i < len ; i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
if (o) {
break;
}
@@ -3475,10 +3589,10 @@ internal smallStringt* dequeueSmallStringSmallArray(smallArrayt *self) {
// finish dequeuing
smallt **arr = &(self->a->data);
// shift list
- for (uint32_t j = i+1 ; j < self->a->count ; j++) {
+ for (uint32_t j = (uint32_t)i+1 ; j < self->a->count ; j++) {
arr[j-i-1] = arr[j];
}
- self->a->count -= i+1;;
+ self->a->count -= (uint32_t)i+1;
return((smallStringt*) toBaset(o));
}
@@ -3506,7 +3620,7 @@ internal smallContainert* dequeueSmallContainerSmallArray(smallArrayt *self) {
size_t i;
for (i = 0 ; i < len ; i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
if (o) {
break;
}
@@ -3527,10 +3641,10 @@ internal smallContainert* dequeueSmallContainerSmallArray(smallArrayt *self) {
// finish dequeuing
smallt **arr = &(self->a->data);
// shift list
- for (uint32_t j = i+1 ; j < self->a->count ; j++) {
+ for (uint32_t j = (uint32_t)i+1 ; j < self->a->count ; j++) {
arr[j-i-1] = arr[j];
}
- self->a->count -= i+1;;
+ self->a->count -= (uint32_t)i+1;
return((smallContainert*) toBaset(o));
}
@@ -3546,7 +3660,7 @@ internal double dequeueNumSmallArray(smallArrayt *self) {
size_t i;
for (i = 0 ; i < len ; i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
if (o) {
break;
}
@@ -3563,10 +3677,10 @@ internal double dequeueNumSmallArray(smallArrayt *self) {
// finish dequeuing
smallt **arr = &(self->a->data);
// shift list
- for (uint32_t j = i+1 ; j < self->a->count ; j++) {
+ for (uint32_t j = (uint32_t)i+1 ; j < self->a->count ; j++) {
arr[j-i-1] = arr[j];
}
- self->a->count -= i+1;;
+ self->a->count -= (uint32_t)i+1;
baset *e = toBaset(o);
@@ -3575,7 +3689,7 @@ internal double dequeueNumSmallArray(smallArrayt *self) {
r = getValO((smallDoublet*)e);
}
elif (isOSmallInt(e)) {
- r = getValO((smallIntt*)e);
+ r = (double)getValO((smallIntt*)e);
}
terminateO(e);
return(r);
@@ -3591,7 +3705,9 @@ internal smallArrayt* reverseSmallArray(smallArrayt *self) {
return(self);
}
- sArrayReverseTiny(self->a);
+ if (!sArrayReverseTiny(self->a)) {
+ return(NULL);
+ }
return(self);
}
@@ -3720,6 +3836,26 @@ internal smallArrayt* appendArraySmallArray(smallArrayt *self, char **array) {
return(self);
}
+internal smallArrayt* appendCArraySmallArray(smallArrayt *self, const char **array) {
+
+ if (!array) {
+ return(NULL);
+ }
+
+ if (!*array) {
+ return(self);
+ }
+
+ forEachCCharP(array, e) {
+ sStringt *s = allocSStringTiny(*e);
+ if (!s) {
+ return(NULL);
+ }
+ sArrayPushTiny(&(self->a), (smallt *) s);
+ }
+ return(self);
+}
+
internal smallArrayt* appendNSmashArraySmallArray(smallArrayt *self, char **array) {
if (!array) {
@@ -3811,20 +3947,20 @@ internal smallArrayt* sliceSmallArray(smallArrayt *self, int64_t start, int64_t
return(NULL);
}
if (end > (int64_t)len) {
- end = len;
+ end = (int64_t)len;
}
if (start <= -(int64_t)len) {
- start = -len;
+ start = -(int64_t)len;
}
if (end <= -(int64_t)len) {
emptySmallArray(self);
return(NULL);
}
if (start < 0) {
- start = len + start;
+ start = (int64_t)len + start;
}
if (end <= 0) {
- end = len + end;
+ end = (int64_t)len + end;
}
if (end < start) {
emptySmallArray(self);
@@ -3839,8 +3975,8 @@ internal smallArrayt* sliceSmallArray(smallArrayt *self, int64_t start, int64_t
else {
// start < end < len
- sArrayDelRangeTiny(self->a, end, len);
- sArrayDelRangeTiny(self->a, 0, start);
+ sArrayDelRangeTiny(self->a, (uint32_t)end, (uint32_t)len);
+ sArrayDelRangeTiny(self->a, 0, (uint32_t)start);
}
return(self);
@@ -3860,19 +3996,19 @@ internal smallArrayt* cropSmallArray(smallArrayt *self, int64_t start, int64_t e
return(NULL);
}
if (end > (int64_t)len) {
- end = len;
+ end = (int64_t)len;
}
if (start <= -(int64_t)len) {
- start = -len;
+ start = -(int64_t)len;
}
if (end <= -(int64_t)len) {
return(NULL);
}
if (start < 0) {
- start = len + start;
+ start = (int64_t)len + start;
}
if (end <= 0) {
- end = len + end;
+ end = (int64_t)len + end;
}
if (end < start) {
return(NULL);
@@ -3889,7 +4025,7 @@ internal smallArrayt* cropSmallArray(smallArrayt *self, int64_t start, int64_t e
n = end - start;
for (int64_t i=0;i < n;i++) {
- o = sArrayGetTiny(self->a, start+i);
+ o = sArrayGetTiny(self->a, (uint32_t)(start+i));
sArrayPushTiny(&(r->a), o);
}
@@ -3900,7 +4036,7 @@ internal smallArrayt* cropSmallArray(smallArrayt *self, int64_t start, int64_t e
arr[start+i] = arr[end + i];
}
- self->a->count -= end - start;
+ self->a->count -= (uint32_t)(end - start);
}
return(r);
@@ -3916,10 +4052,10 @@ internal baset* cropElemSmallArray(smallArrayt *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);;
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);;
if (!o) {
return(NULL);
}
@@ -3965,10 +4101,10 @@ internal undefinedt* cropElemUndefinedSmallArray(smallArrayt *self, int64_t inde
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);;
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);;
if (!o) {
return(NULL);
}
@@ -4001,11 +4137,11 @@ internal bool cropElemBoolSmallArray(smallArrayt *self, int64_t index) {
return(false);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
bool r = false;
- smallt *o = sArrayGetTiny(self->a, index);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(false);
}
@@ -4043,11 +4179,11 @@ internal double cropElemDoubleSmallArray(smallArrayt *self, int64_t index) {
return(0);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
double r = 0;
- smallt *o = sArrayGetTiny(self->a, index);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(0);
}
@@ -4085,11 +4221,11 @@ internal int64_t cropElemIntSmallArray(smallArrayt *self, int64_t index) {
return(0);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
int64_t r = 0;
- smallt *o = sArrayGetTiny(self->a, index);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(0);
}
@@ -4128,11 +4264,11 @@ internal int32_t cropElemInt32SmallArray(smallArrayt *self, int64_t index) {
return(0);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
int32_t r = 0;
- smallt *o = sArrayGetTiny(self->a, index);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(0);
}
@@ -4145,7 +4281,7 @@ internal int32_t cropElemInt32SmallArray(smallArrayt *self, int64_t index) {
finishO(e);
return(0);
}
- r = e->f->get(e);
+ r = (int32_t)e->f->get(e);
terminateO(e);
// copy pointers from range index+1, array->count to index
@@ -4170,11 +4306,11 @@ internal uint64_t cropElemUintSmallArray(smallArrayt *self, int64_t index) {
return(0);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
uint64_t r = 0;
- smallt *o = sArrayGetTiny(self->a, index);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(0);
}
@@ -4187,7 +4323,7 @@ internal uint64_t cropElemUintSmallArray(smallArrayt *self, int64_t index) {
finishO(e);
return(0);
}
- r = e->f->get(e);
+ r = (uint64_t)e->f->get(e);
terminateO(e);
// copy pointers from range index+1, array->count to index
@@ -4212,11 +4348,11 @@ internal uint32_t cropElemUint32SmallArray(smallArrayt *self, int64_t index) {
return(0);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
uint32_t r = 0;
- smallt *o = sArrayGetTiny(self->a, index);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(0);
}
@@ -4229,7 +4365,7 @@ internal uint32_t cropElemUint32SmallArray(smallArrayt *self, int64_t index) {
finishO(e);
return(0);
}
- r = e->f->get(e);
+ r = (uint32_t)e->f->get(e);
terminateO(e);
// copy pointers from range index+1, array->count to index
@@ -4254,11 +4390,11 @@ internal char* cropElemSSmallArray(smallArrayt *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
char *r = NULL;
- smallt *o = sArrayGetTiny(self->a, index);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -4296,10 +4432,10 @@ internal smallDictt* cropElemDictSmallArray(smallArrayt *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -4333,10 +4469,10 @@ internal smallArrayt* cropElemArraySmallArray(smallArrayt *self, int64_t index)
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -4370,10 +4506,10 @@ internal smallBoolt* cropElemSmallBoolSmallArray(smallArrayt *self, int64_t inde
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -4407,10 +4543,10 @@ internal smallBytest* cropElemSmallBytesSmallArray(smallArrayt *self, int64_t in
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -4444,10 +4580,10 @@ internal smallDoublet* cropElemSmallDoubleSmallArray(smallArrayt *self, int64_t
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -4481,10 +4617,10 @@ internal smallIntt* cropElemSmallIntSmallArray(smallArrayt *self, int64_t index)
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -4518,10 +4654,10 @@ internal smallJsont* cropElemSmallJsonSmallArray(smallArrayt *self, int64_t inde
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -4561,10 +4697,10 @@ internal smallStringt* cropElemSmallStringSmallArray(smallArrayt *self, int64_t
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -4598,11 +4734,11 @@ internal void* cropElemVoidSmallArray(smallArrayt *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
void *r = NULL;
- smallt *o = sArrayGetTiny(self->a, index);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -4640,10 +4776,10 @@ internal smallContainert* cropElemSmallContainerSmallArray(smallArrayt *self, in
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -4682,19 +4818,19 @@ internal smallArrayt* copySmallArray(smallArrayt *self, int64_t start, int64_t e
return(NULL);
}
if (end > (int64_t)len) {
- end = len;
+ end = (int64_t)len;
}
if (start <= -(int64_t)len) {
- start = -len;
+ start = -(int64_t)len;
}
if (end <= -(int64_t)len) {
return(NULL);
}
if (start < 0) {
- start = len + start;
+ start = (int64_t)len + start;
}
if (end <= 0) {
- end = len + end;
+ end = (int64_t)len + end;
}
if (end < start) {
return(NULL);
@@ -4715,7 +4851,7 @@ internal smallArrayt* copySmallArray(smallArrayt *self, int64_t start, int64_t e
n = end - start;
for (int64_t i=0;i < n;i++) {
- o = sArrayGetTiny(self->a, start+i);
+ o = sArrayGetTiny(self->a, (uint32_t)(start+i));
sArrayPushTiny(&(r->a), sDuplicate(o));
}
}
@@ -4760,7 +4896,7 @@ internal smallArrayt* insertSmallArray(smallArrayt *self, int64_t index, smallAr
return(NULL);
}
if (neg) {
- index = len + index;
+ index = (int64_t)len + index;
}
@@ -4777,26 +4913,26 @@ internal smallArrayt* insertSmallArray(smallArrayt *self, int64_t index, smallAr
if (index == 0) {
// insert at beginning
for (int64_t i=0;i < (int64_t)toInsert->f->len(toInsert);i++) {
- o = sArrayGetTiny(toInsert->a, i);
+ o = sArrayGetTiny(toInsert->a, (uint32_t)i);
sArrayPushTiny(&a, o);
}
for (int64_t i=0;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
else {
for (int64_t i=0;i < index;i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o);
}
for (int64_t i=0;i < (int64_t)toInsert->f->len(toInsert);i++) {
- o = sArrayGetTiny(toInsert->a, i);
+ o = sArrayGetTiny(toInsert->a, (uint32_t)i);
sArrayPushTiny(&a, o);
}
for (int64_t i=index;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -4883,7 +5019,7 @@ internal smallArrayt* injectSmallArray(smallArrayt *self, int64_t index, baset *
return(NULL);
}
if (neg) {
- index = len + index;
+ index = (int64_t)len + index;
}
@@ -4902,7 +5038,7 @@ internal smallArrayt* injectSmallArray(smallArrayt *self, int64_t index, baset *
// inject at beginning
sArrayPushTiny(&a, o);
for (int64_t i=0;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -4910,12 +5046,12 @@ internal smallArrayt* injectSmallArray(smallArrayt *self, int64_t index, baset *
smallt *o2;
for (int64_t i=0;i < index;i++) {
- o2 = sArrayGetTiny(self->a, i);
+ o2 = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o2);
}
sArrayPushTiny(&a, o);
for (int64_t i=index;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -4949,7 +5085,7 @@ internal smallArrayt* injectUndefinedSmallArray(smallArrayt *self, int64_t index
return(NULL);
}
if (neg) {
- index = len + index;
+ index = (int64_t)len + index;
}
@@ -4964,7 +5100,7 @@ internal smallArrayt* injectUndefinedSmallArray(smallArrayt *self, int64_t index
// inject at beginning
sArrayPushTiny(&a, o);
for (int64_t i=0;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -4972,12 +5108,12 @@ internal smallArrayt* injectUndefinedSmallArray(smallArrayt *self, int64_t index
smallt *o2;
for (int64_t i=0;i < index;i++) {
- o2 = sArrayGetTiny(self->a, i);
+ o2 = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o2);
}
sArrayPushTiny(&a, o);
for (int64_t i=index;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -5011,7 +5147,7 @@ internal smallArrayt* injectBoolSmallArray(smallArrayt *self, int64_t index, boo
return(NULL);
}
if (neg) {
- index = len + index;
+ index = (int64_t)len + index;
}
@@ -5027,7 +5163,7 @@ internal smallArrayt* injectBoolSmallArray(smallArrayt *self, int64_t index, boo
// inject at beginning
sArrayPushTiny(&a, o);
for (int64_t i=0;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -5035,12 +5171,12 @@ internal smallArrayt* injectBoolSmallArray(smallArrayt *self, int64_t index, boo
smallt *o2;
for (int64_t i=0;i < index;i++) {
- o2 = sArrayGetTiny(self->a, i);
+ o2 = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o2);
}
sArrayPushTiny(&a, o);
for (int64_t i=index;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -5074,7 +5210,7 @@ internal smallArrayt* injectDoubleSmallArray(smallArrayt *self, int64_t index, d
return(NULL);
}
if (neg) {
- index = len + index;
+ index = (int64_t)len + index;
}
@@ -5090,7 +5226,7 @@ internal smallArrayt* injectDoubleSmallArray(smallArrayt *self, int64_t index, d
// inject at beginning
sArrayPushTiny(&a, o);
for (int64_t i=0;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -5098,12 +5234,12 @@ internal smallArrayt* injectDoubleSmallArray(smallArrayt *self, int64_t index, d
smallt *o2;
for (int64_t i=0;i < index;i++) {
- o2 = sArrayGetTiny(self->a, i);
+ o2 = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o2);
}
sArrayPushTiny(&a, o);
for (int64_t i=index;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -5137,7 +5273,7 @@ internal smallArrayt* injectIntSmallArray(smallArrayt *self, int64_t index, int6
return(NULL);
}
if (neg) {
- index = len + index;
+ index = (int64_t)len + index;
}
@@ -5153,7 +5289,7 @@ internal smallArrayt* injectIntSmallArray(smallArrayt *self, int64_t index, int6
// inject at beginning
sArrayPushTiny(&a, o);
for (int64_t i=0;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -5161,12 +5297,12 @@ internal smallArrayt* injectIntSmallArray(smallArrayt *self, int64_t index, int6
smallt *o2;
for (int64_t i=0;i < index;i++) {
- o2 = sArrayGetTiny(self->a, i);
+ o2 = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o2);
}
sArrayPushTiny(&a, o);
for (int64_t i=index;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -5204,7 +5340,7 @@ internal smallArrayt* injectSSmallArray(smallArrayt *self, int64_t index, const
return(NULL);
}
if (neg) {
- index = len + index;
+ index = (int64_t)len + index;
}
@@ -5219,7 +5355,7 @@ internal smallArrayt* injectSSmallArray(smallArrayt *self, int64_t index, const
// inject at beginning
sArrayPushTiny(&a, o);
for (int64_t i=0;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -5227,12 +5363,12 @@ internal smallArrayt* injectSSmallArray(smallArrayt *self, int64_t index, const
smallt *o2;
for (int64_t i=0;i < index;i++) {
- o2 = sArrayGetTiny(self->a, i);
+ o2 = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o2);
}
sArrayPushTiny(&a, o);
for (int64_t i=index;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -5280,7 +5416,7 @@ internal smallArrayt* injectDictSmallArray(smallArrayt *self, int64_t index, sma
return(NULL);
}
if (neg) {
- index = len + index;
+ index = (int64_t)len + index;
}
@@ -5299,7 +5435,7 @@ internal smallArrayt* injectDictSmallArray(smallArrayt *self, int64_t index, sma
// inject at beginning
sArrayPushTiny(&a, o);
for (int64_t i=0;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -5307,12 +5443,12 @@ internal smallArrayt* injectDictSmallArray(smallArrayt *self, int64_t index, sma
smallt *o2;
for (int64_t i=0;i < index;i++) {
- o2 = sArrayGetTiny(self->a, i);
+ o2 = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o2);
}
sArrayPushTiny(&a, o);
for (int64_t i=index;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -5354,7 +5490,7 @@ internal smallArrayt* injectArraySmallArray(smallArrayt *self, int64_t index, sm
return(NULL);
}
if (neg) {
- index = len + index;
+ index = (int64_t)len + index;
}
@@ -5373,7 +5509,7 @@ internal smallArrayt* injectArraySmallArray(smallArrayt *self, int64_t index, sm
// inject at beginning
sArrayPushTiny(&a, o);
for (int64_t i=0;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -5381,12 +5517,12 @@ internal smallArrayt* injectArraySmallArray(smallArrayt *self, int64_t index, sm
smallt *o2;
for (int64_t i=0;i < index;i++) {
- o2 = sArrayGetTiny(self->a, i);
+ o2 = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o2);
}
sArrayPushTiny(&a, o);
for (int64_t i=index;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -5424,7 +5560,7 @@ internal smallArrayt* injectArraycSmallArray(smallArrayt *self, int64_t index, c
return(NULL);
}
if (neg) {
- index = len + index;
+ index = (int64_t)len + index;
}
@@ -5455,7 +5591,89 @@ internal smallArrayt* injectArraycSmallArray(smallArrayt *self, int64_t index, c
// inject at beginning
sArrayPushTiny(&a, o);
for (int64_t i=0;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
+ sArrayPushTiny(&a, o);
+ }
+ }
+ else {
+
+ smallt *o2;
+ for (int64_t i=0;i < index;i++) {
+ o2 = sArrayGetTiny(self->a, (uint32_t)i);
+ sArrayPushTiny(&a, o2);
+ }
+ sArrayPushTiny(&a, o);
+ for (int64_t i=index;i < (int64_t)len;i++) {
+ o = sArrayGetTiny(self->a, (uint32_t)i);
+ sArrayPushTiny(&a, o);
+ }
+ }
+
+ free(self->a);
+ self->a = a;
+ return(self);
+}
+
+internal smallArrayt* injectCArraycSmallArray(smallArrayt *self, int64_t index, const char **toInject) {
+ size_t len;
+
+ if (!toInject) {
+ return(NULL);
+ }
+
+ len = lenSmallArray(self);
+
+ if (!len && index == -1) {
+ // empty string, index -1 is equal to 0
+ index = 0;
+ }
+ bool neg = false;
+ if (index < 0) {
+ neg = true;
+ }
+
+ if (index > (int64_t)len) {
+ return(NULL);
+ }
+ if (neg) {
+ index++;
+ }
+ if (index < -(int64_t)len) {
+ return(NULL);
+ }
+ if (neg) {
+ index = (int64_t)len + index;
+ }
+
+
+ sArrayt *a = allocSArray();
+ if (!a) {
+ return(NULL);
+ }
+
+ smallt *o = NULL;
+ sArrayt *aa = allocSArray();
+
+ forEachCCharP(toInject, e) {
+ sStringt *s = allocSStringTiny(*e);
+ if (!s) {
+ if (a) {
+ sArrayFreeTiny(a);
+ }
+ if (aa) {
+ sArrayFreeTiny(aa);
+ }
+ return(NULL);
+ }
+ sArrayPushTiny(&aa, (smallt *) s);
+ }
+ o = (smallt *) aa;
+
+ if (index == 0) {
+ // inject at beginning
+ sArrayPushTiny(&a, o);
+ for (int64_t i=0;i < (int64_t)len;i++) {
+ o = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -5463,12 +5681,12 @@ internal smallArrayt* injectArraycSmallArray(smallArrayt *self, int64_t index, c
smallt *o2;
for (int64_t i=0;i < index;i++) {
- o2 = sArrayGetTiny(self->a, i);
+ o2 = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o2);
}
sArrayPushTiny(&a, o);
for (int64_t i=index;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -5632,7 +5850,7 @@ internal smallArrayt* injectNFreeSmallArray(smallArrayt *self, int64_t index, ba
return(NULL);
}
if (neg) {
- index = len + index;
+ index = (int64_t)len + index;
}
@@ -5655,7 +5873,7 @@ internal smallArrayt* injectNFreeSmallArray(smallArrayt *self, int64_t index, ba
// inject at beginning
sArrayPushTiny(&a, o);
for (int64_t i=0;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -5663,12 +5881,12 @@ internal smallArrayt* injectNFreeSmallArray(smallArrayt *self, int64_t index, ba
smallt *o2;
for (int64_t i=0;i < index;i++) {
- o2 = sArrayGetTiny(self->a, i);
+ o2 = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o2);
}
sArrayPushTiny(&a, o);
for (int64_t i=index;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -5679,11 +5897,11 @@ internal smallArrayt* injectNFreeSmallArray(smallArrayt *self, int64_t index, ba
return(self);
}
-internal smallArrayt* injectNFreeUndefinedSmallArray(smallArrayt *self, int64_t index, undefinedt *undefined) {
+internal smallArrayt* injectNFreeUndefinedSmallArray(smallArrayt *self, int64_t index, undefinedt *u) {
smallArrayt *r = injectUndefinedSmallArray(self, index);
if (r) {
- terminateO(undefined);
+ terminateO(u);
}
return(r);
}
@@ -5798,22 +6016,22 @@ internal smallArrayt* delSmallArray(smallArrayt *self, int64_t start, int64_t en
}
if (start >= (int64_t)len) {
- start = len;
+ start = (int64_t)len;
}
if (end > (int64_t)len) {
- end = len;
+ end = (int64_t)len;
}
if (start <= -(int64_t)len) {
- start = -len;
+ start = -(int64_t)len;
}
if (end <= -(int64_t)len) {
- end = -len;
+ end = -(int64_t)len;
}
if (start < 0) {
- start = len + start;
+ start = (int64_t)len + start;
}
if (end <= 0) {
- end = len + end;
+ end = (int64_t)len + end;
}
if (end < start) {
return(NULL);
@@ -5824,7 +6042,7 @@ internal smallArrayt* delSmallArray(smallArrayt *self, int64_t start, int64_t en
}
// start < end < len
- sArrayDelRangeTiny(self->a, start, end);
+ sArrayDelRangeTiny(self->a, (uint32_t)start, (uint32_t)end);
return(self);
}
@@ -5841,10 +6059,10 @@ internal smallArrayt* delElemSmallArray(smallArrayt *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = len + index;
+ index = (int64_t)len + index;
}
- sArrayDelTiny(self->a, index);
+ sArrayDelTiny(self->a, (uint32_t)index);
return(self);
}
@@ -5859,22 +6077,22 @@ internal smallArrayt* removeSmallArray(smallArrayt *self, int64_t start, int64_t
}
if (start >= (int64_t)len) {
- start = len;
+ start = (int64_t)len;
}
if (end > (int64_t)len) {
- end = len;
+ end = (int64_t)len;
}
if (start <= -(int64_t)len) {
- start = -len;
+ start = -(int64_t)len;
}
if (end <= -(int64_t)len) {
- end = -len;
+ end = -(int64_t)len;
}
if (start < 0) {
- start = len + start;
+ start = (int64_t)len + start;
}
if (end <= 0) {
- end = len + end;
+ end = (int64_t)len + end;
}
if (end < start) {
return(NULL);
@@ -5885,7 +6103,7 @@ internal smallArrayt* removeSmallArray(smallArrayt *self, int64_t start, int64_t
}
// start < end < len
- for (uint32_t i = start ; i < end ; i++) {
+ for (uint32_t i = (uint32_t)start ; i < end ; i++) {
sArraySetShortTiny(self->a, i, NULL);
}
@@ -5904,18 +6122,18 @@ internal smallArrayt* removeElemSmallArray(smallArrayt *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = len + index;
+ index = (int64_t)len + index;
}
- sArraySetShortTiny(self->a, index, NULL);
+ sArraySetShortTiny(self->a, (uint32_t)index, NULL);
return(self);
}
internal int sortSCmp(const void * a, const void * b) {
// sanity checks
- smallt *A = (*((smallt **)a));
- smallt *B = (*((smallt **)b));
+ smallt *A = (*((smallt *const*)a));
+ smallt *B = (*((smallt *const*)b));
if (!A && !B) {
return(0);
}
@@ -6024,8 +6242,8 @@ internal smallArrayt* sortSmallArray(smallArrayt *self) {
internal int sortFCmp(void *func, const void *a, const void *b) {
shCmpt cmp;
- smallt *A = (*((smallt **)a));
- smallt *B = (*((smallt **)b));
+ smallt *A = (*((smallt *const*)a));
+ smallt *B = (*((smallt *const*)b));
baset *aO = toBaset(A);;
baset *bO = toBaset(B);;
@@ -6045,8 +6263,8 @@ internal int sortFCmp(void *func, const void *a, const void *b) {
internal int sortFCmp(const void *a, const void *b, void *func) {
shCmpt cmp;
- smallt *A = (*((smallt **)a));
- smallt *B = (*((smallt **)b));
+ smallt *A = (*((smallt *const*)a));
+ smallt *B = (*((smallt *const*)b));
baset *aO = toBaset(A);;
baset *bO = toBaset(B);;
@@ -6067,8 +6285,8 @@ internal int sortFCmp(const void *a, const void *b, void *func) {
internal int icSortSCmp(const void * a, const void * b) {
// sanity checks
- smallt *A = (*((smallt **)a));
- smallt *B = (*((smallt **)b));
+ smallt *A = (*((smallt *const*)a));
+ smallt *B = (*((smallt *const*)b));
if (!A && !B) {
return(0);
}
@@ -6237,28 +6455,28 @@ internal bool equalSmallArray(smallArrayt *self, smallArrayt *array) {
char *as = NULL;
enumerateSArray(self->a, e, i) {
if (not e) {
- if (not sArrayGetTiny(array->a, i)) {
+ if (not sArrayGetTiny(array->a, (uint32_t)i)) {
continue;
}
else {
return(false);
}
}
- if ((e->type != sArrayGetTiny(array->a, i)->type)) {
+ if ((e->type != sArrayGetTiny(array->a, (uint32_t)i)->type)) {
return(false);
}
else {
switch (e->type) {
// not needed always equal - case UNDEFINED:
case BOOL:
- if (((sBoolt*)e)->value != ((sBoolt*)sArrayGetTiny(array->a, i))->value) {
+ if (((sBoolt*)e)->value != ((sBoolt*)sArrayGetTiny(array->a, (uint32_t)i))->value) {
return(false);
}
break;
// TODO case CONTAINER:
case DICT:
es = sToString(e);
- as = sToString(sArrayGetTiny(array->a, i));
+ as = sToString(sArrayGetTiny(array->a, (uint32_t)i));
if (!strEq(es, as)) {
free(es);
free(as);
@@ -6268,23 +6486,23 @@ internal bool equalSmallArray(smallArrayt *self, smallArrayt *array) {
free(as);
break;
case DOUBLE:
- if (((sDoublet*)e)->value != ((sDoublet*)sArrayGetTiny(array->a, i))->value) {
+ if (((sDoublet*)e)->value != ((sDoublet*)sArrayGetTiny(array->a, (uint32_t)i))->value) {
return(false);
}
break;
case INT:
- if (((sIntt*)e)->value != ((sIntt*)sArrayGetTiny(array->a, i))->value) {
+ if (((sIntt*)e)->value != ((sIntt*)sArrayGetTiny(array->a, (uint32_t)i))->value) {
return(false);
}
break;
case STRING:
- if (!strEq(sStringGetTiny((sStringt*)e), sStringGetTiny((sStringt*)sArrayGetTiny(array->a, i)))) {
+ if (!strEq(sStringGetTiny((sStringt*)e), sStringGetTiny((sStringt*)sArrayGetTiny(array->a, (uint32_t)i)))) {
return(false);
}
break;
case ARRAY:
es = sToString(e);
- as = sToString(sArrayGetTiny(array->a, i));
+ as = sToString(sArrayGetTiny(array->a, (uint32_t)i));
if (!strEq(es, as)) {
free(es);
free(as);
@@ -6294,10 +6512,10 @@ internal bool equalSmallArray(smallArrayt *self, smallArrayt *array) {
free(as);
break;
case BYTES:
- if (((sBytest*)e)->count != ((sBytest*)sArrayGetTiny(array->a, i))->count) {
+ if (((sBytest*)e)->count != ((sBytest*)sArrayGetTiny(array->a, (uint32_t)i))->count) {
return(false);
}
- if (memcmp(&((sBytest*)e)->data, &((sBytest*)sArrayGetTiny(array->a, i))->data, ((sBytest*)e)->count)) {
+ if (memcmp(&((sBytest*)e)->data, &((sBytest*)sArrayGetTiny(array->a, (uint32_t)i))->data, ((sBytest*)e)->count)) {
return(false);
}
break;
@@ -6356,6 +6574,36 @@ internal bool equalSmallArrayArray(smallArrayt* self, char ** p2) {
return(true);
}
+internal bool equalSmallArrayCArray(smallArrayt* self, const char ** p2) {
+
+ // sanity checks
+ if (!lenSmallArray(self) && !listLengthCS(p2)) {
+ // both arrays are empty
+ return(true);
+ }
+ if (!lenSmallArray(self) || !listLengthCS(p2)) {
+ return(false);
+ }
+ if (lenSmallArray(self) != listLengthCS(p2)) {
+ return(false);
+ }
+
+ // compare elements
+ enumerateSArray(self->a, e, i) {
+ if (not e) {
+ return(false);
+ }
+ if (e->type != STRING) {
+ return(false);
+ }
+ if (!strEq(sStringGetTiny((sStringt*)e), p2[i])) {
+ return(false);
+ }
+ }
+
+ return(true);
+}
+
internal bool equalSmallArrayBase(smallArrayt* self, baset* p2) {
if (!lenSmallArray(self) || !p2) {
@@ -6399,28 +6647,28 @@ internal bool icEqualSmallArray(smallArrayt *self, smallArrayt *array) {
char *as = NULL;
enumerateSArray(self->a, e, i) {
if (not e) {
- if (not sArrayGetTiny(array->a, i)) {
+ if (not sArrayGetTiny(array->a, (uint32_t)i)) {
continue;
}
else {
return(false);
}
}
- if ((e->type != sArrayGetTiny(array->a, i)->type)) {
+ if ((e->type != sArrayGetTiny(array->a, (uint32_t)i)->type)) {
return(false);
}
else {
switch (e->type) {
// not needed always equal - case UNDEFINED:
case BOOL:
- if (((sBoolt*)e)->value != ((sBoolt*)sArrayGetTiny(array->a, i))->value) {
+ if (((sBoolt*)e)->value != ((sBoolt*)sArrayGetTiny(array->a, (uint32_t)i))->value) {
return(false);
}
break;
// TODO case CONTAINER:
case DICT:
es = sToString(e);
- as = sToString(sArrayGetTiny(array->a, i));
+ as = sToString(sArrayGetTiny(array->a, (uint32_t)i));
if (!icEqS(es, as)) {
free(es);
free(as);
@@ -6430,23 +6678,23 @@ internal bool icEqualSmallArray(smallArrayt *self, smallArrayt *array) {
free(as);
break;
case DOUBLE:
- if (((sDoublet*)e)->value != ((sDoublet*)sArrayGetTiny(array->a, i))->value) {
+ if (((sDoublet*)e)->value != ((sDoublet*)sArrayGetTiny(array->a, (uint32_t)i))->value) {
return(false);
}
break;
case INT:
- if (((sIntt*)e)->value != ((sIntt*)sArrayGetTiny(array->a, i))->value) {
+ if (((sIntt*)e)->value != ((sIntt*)sArrayGetTiny(array->a, (uint32_t)i))->value) {
return(false);
}
break;
case STRING:
- if (!icEqS(sStringGetTiny((sStringt*)e), sStringGetTiny((sStringt*)sArrayGetTiny(array->a, i)))) {
+ if (!icEqS(sStringGetTiny((sStringt*)e), sStringGetTiny((sStringt*)sArrayGetTiny(array->a, (uint32_t)i)))) {
return(false);
}
break;
case ARRAY:
es = sToString(e);
- as = sToString(sArrayGetTiny(array->a, i));
+ as = sToString(sArrayGetTiny(array->a, (uint32_t)i));
if (!icEqS(es, as)) {
free(es);
free(as);
@@ -6456,10 +6704,10 @@ internal bool icEqualSmallArray(smallArrayt *self, smallArrayt *array) {
free(as);
break;
case BYTES:
- if (((sBytest*)e)->count != ((sBytest*)sArrayGetTiny(array->a, i))->count) {
+ if (((sBytest*)e)->count != ((sBytest*)sArrayGetTiny(array->a, (uint32_t)i))->count) {
return(false);
}
- if (memcmp(&((sBytest*)e)->data, &((sBytest*)sArrayGetTiny(array->a, i))->data, ((sBytest*)e)->count)) {
+ if (memcmp(&((sBytest*)e)->data, &((sBytest*)sArrayGetTiny(array->a, (uint32_t)i))->data, ((sBytest*)e)->count)) {
return(false);
}
break;
@@ -6524,6 +6772,36 @@ bool icEqualSmallArrayArray(smallArrayt* self, char ** p2) {
return(true);
}
+bool icEqualSmallArrayCArray(smallArrayt* self, const char ** p2) {
+
+ // sanity checks
+ if (!lenSmallArray(self) && !listLengthCS(p2)) {
+ // both arrays are empty
+ return(true);
+ }
+ if (!lenSmallArray(self) || !listLengthCS(p2)) {
+ return(false);
+ }
+ if (lenSmallArray(self) != listLengthCS(p2)) {
+ return(false);
+ }
+
+ // compare elements
+ enumerateSArray(self->a, e, i) {
+ if (not e) {
+ return(false);
+ }
+ if (e->type != STRING) {
+ return(false);
+ }
+ if (!icEqS(sStringGetTiny((sStringt*)e), p2[i])) {
+ return(false);
+ }
+ }
+
+ return(true);
+}
+
bool icEqualSmallArrayBase(smallArrayt* self, baset* p2) {
if (!lenSmallArray(self) || !p2) {
@@ -6559,7 +6837,7 @@ internal smallArrayt* trimSmallArray(smallArrayt *self) {
}
for (size_t i = 0 ; i < lenSmallArray(self); i++) {
- o = sArrayGetTiny(self->a, i);
+ o = sArrayGetTiny(self->a, (uint32_t)i);
if (o) {
sArrayPushTiny(&a, o);
}
@@ -6579,10 +6857,10 @@ baset* getAtSmallArray(smallArrayt *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);;
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -6600,10 +6878,10 @@ internal undefinedt* getAtUndefinedSmallArray(smallArrayt *self, int64_t index)
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);;
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -6778,10 +7056,10 @@ internal smallDictt* getAtDictSmallArray(smallArrayt *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);;
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -6800,10 +7078,10 @@ internal smallArrayt* getAtArraySmallArray(smallArrayt *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);;
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -6822,10 +7100,10 @@ internal smallBoolt* getAtSmallBoolSmallArray(smallArrayt *self, int64_t index)
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);;
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -6844,10 +7122,10 @@ internal smallBytest* getAtSmallBytesSmallArray(smallArrayt *self, int64_t index
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);;
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -6866,10 +7144,10 @@ internal smallDoublet* getAtSmallDoubleSmallArray(smallArrayt *self, int64_t ind
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);;
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -6888,10 +7166,10 @@ internal smallIntt* getAtSmallIntSmallArray(smallArrayt *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);;
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -6910,10 +7188,10 @@ internal smallJsont* getAtSmallJsonSmallArray(smallArrayt *self, int64_t index)
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);;
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -6940,10 +7218,10 @@ internal smallStringt* getAtSmallStringSmallArray(smallArrayt *self, int64_t ind
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);;
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -6974,10 +7252,10 @@ internal smallContainert* getAtSmallContainerSmallArray(smallArrayt *self, int64
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);;
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -6999,10 +7277,10 @@ baset* getAtNDupSmallArray(smallArrayt *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -7027,10 +7305,10 @@ internal undefinedt* getAtNDupUndefinedSmallArray(smallArrayt *self, int64_t ind
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -7133,10 +7411,10 @@ internal smallDictt* getAtNDupDictSmallArray(smallArrayt *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -7155,10 +7433,10 @@ internal smallArrayt* getAtNDupArraySmallArray(smallArrayt *self, int64_t index)
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -7177,10 +7455,10 @@ internal smallBoolt* getAtNDupSmallBoolSmallArray(smallArrayt *self, int64_t ind
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -7199,10 +7477,10 @@ internal smallBytest* getAtNDupSmallBytesSmallArray(smallArrayt *self, int64_t i
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -7221,10 +7499,10 @@ internal smallDoublet* getAtNDupSmallDoubleSmallArray(smallArrayt *self, int64_t
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -7243,10 +7521,10 @@ internal smallIntt* getAtNDupSmallIntSmallArray(smallArrayt *self, int64_t index
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -7265,10 +7543,10 @@ internal smallJsont* getAtNDupSmallJsonSmallArray(smallArrayt *self, int64_t ind
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -7296,10 +7574,10 @@ internal smallStringt* getAtNDupSmallStringSmallArray(smallArrayt *self, int64_t
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -7330,10 +7608,10 @@ internal smallContainert* getAtNDupSmallContainerSmallArray(smallArrayt *self, i
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *o = sArrayGetTiny(self->a, index);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -7362,10 +7640,10 @@ internal smallArrayt* setAtSmallArray(smallArrayt *self, int64_t index, baset *v
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- sArraySetTiny(self->a, index, toSmallt(value));
+ sArraySetTiny(self->a, (uint32_t)index, toSmallt(value));
return(self);
}
@@ -7378,14 +7656,14 @@ internal smallArrayt* setAtUndefinedSmallArray(smallArrayt *self, int64_t index)
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
smallt *o = (smallt *) allocSUndefined();
if (!o) {
return(NULL);
}
- sArraySetTiny(self->a, index, o);
+ sArraySetTiny(self->a, (uint32_t)index, o);
return(self);
}
@@ -7398,14 +7676,14 @@ internal smallArrayt* setAtBoolSmallArray(smallArrayt *self, int64_t index, bool
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
smallt *o = (smallt *) allocSBool(value);
if (!o) {
return(NULL);
}
- sArraySetTiny(self->a, index, o);
+ sArraySetTiny(self->a, (uint32_t)index, o);
return(self);
}
@@ -7418,14 +7696,14 @@ internal smallArrayt* setAtDoubleSmallArray(smallArrayt *self, int64_t index, do
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
smallt *o = (smallt *) allocSDouble(value);
if (!o) {
return(NULL);
}
- sArraySetTiny(self->a, index, o);
+ sArraySetTiny(self->a, (uint32_t)index, o);
return(self);
}
@@ -7438,14 +7716,14 @@ internal smallArrayt* setAtIntSmallArray(smallArrayt *self, int64_t index, int64
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
smallt *o = (smallt *) allocSInt(value);
if (!o) {
return(NULL);
}
- sArraySetTiny(self->a, index, o);
+ sArraySetTiny(self->a, (uint32_t)index, o);
return(self);
}
@@ -7462,12 +7740,12 @@ internal smallArrayt* setAtSSmallArray(smallArrayt *self, int64_t index, const c
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
smallt *o;
isError(o, (smallt *) allocSStringTiny(string)) return(NULL);
- sArraySetTiny(self->a, index, o);
+ sArraySetTiny(self->a, (uint32_t)index, o);
return(self);
}
@@ -7494,14 +7772,14 @@ internal smallArrayt* setAtDictSmallArray(smallArrayt *self, int64_t index, smal
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
if (!dict->d) {
isError(dict->d, allocSDict()) return(NULL);
}
- sArraySetTiny(self->a, index, (smallt *)dict->d);
+ sArraySetTiny(self->a, (uint32_t)index, (smallt *)dict->d);
return(self);
}
@@ -7523,7 +7801,7 @@ internal smallArrayt* setAtArraySmallArray(smallArrayt *self, int64_t index, sma
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
if (!array->a) {
@@ -7531,7 +7809,7 @@ internal smallArrayt* setAtArraySmallArray(smallArrayt *self, int64_t index, sma
isError(array->a, allocSArray()) return(NULL);
}
- sArraySetTiny(self->a, index, (smallt *)array->a);
+ sArraySetTiny(self->a, (uint32_t)index, (smallt *)array->a);
return(self);
}
@@ -7548,7 +7826,7 @@ internal smallArrayt* setAtArraycSmallArray(smallArrayt *self, int64_t index, ch
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
sArrayt *a = allocSArray();
@@ -7567,7 +7845,43 @@ internal smallArrayt* setAtArraycSmallArray(smallArrayt *self, int64_t index, ch
sArrayPushTiny(&a, (smallt *) s);
}
- sArraySetTiny(self->a, index, (smallt *)a);
+ sArraySetTiny(self->a, (uint32_t)index, (smallt *)a);
+ return(self);
+}
+
+internal smallArrayt* setAtCArraycSmallArray(smallArrayt *self, int64_t index, const char **array) {
+
+ if (!array) {
+ return(NULL);
+ }
+
+ if (index >= (int64_t)lenSmallArray(self)) {
+ return(NULL);
+ }
+ if (index < -(int64_t)lenSmallArray(self)) {
+ return(NULL);
+ }
+ if (index < 0) {
+ index = (int64_t)lenSmallArray(self) + index;
+ }
+
+ sArrayt *a = allocSArray();
+ if (!a) {
+ return(NULL);
+ }
+
+ forEachCCharP(array, e) {
+ sStringt *s = allocSStringTiny(*e);
+ if (!s) {
+ if (a) {
+ sArrayFreeTiny(a);
+ }
+ return(NULL);
+ }
+ sArrayPushTiny(&a, (smallt *) s);
+ }
+
+ sArraySetTiny(self->a, (uint32_t)index, (smallt *)a);
return(self);
}
@@ -7588,13 +7902,13 @@ internal smallArrayt* setAtSmallBoolSmallArray(smallArrayt *self, int64_t index,
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
if (!value->value) {
isError(value->value, allocSBool(false)) return(NULL);
}
- sArraySetTiny(self->a, index, (smallt *) value->value);
+ sArraySetTiny(self->a, (uint32_t)index, (smallt *) value->value);
return(self);
}
@@ -7615,13 +7929,13 @@ internal smallArrayt* setAtSmallBytesSmallArray(smallArrayt *self, int64_t index
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
if (!value->B) {
isError(value->B, allocSBytes()) return(NULL);
}
- sArraySetTiny(self->a, index, (smallt*) value->B);
+ sArraySetTiny(self->a, (uint32_t)index, (smallt*) value->B);
return(self);
}
@@ -7642,13 +7956,13 @@ internal smallArrayt* setAtSmallDoubleSmallArray(smallArrayt *self, int64_t inde
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
if (!value->value) {
isError(value->value, allocSDouble(0)) return(NULL);
}
- sArraySetTiny(self->a, index, (smallt*) value->value);
+ sArraySetTiny(self->a, (uint32_t)index, (smallt*) value->value);
return(self);
}
@@ -7669,13 +7983,13 @@ internal smallArrayt* setAtSmallIntSmallArray(smallArrayt *self, int64_t index,
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
if (!value->value) {
isError(value->value, allocSInt(0)) return(NULL);
}
- sArraySetTiny(self->a, index, (smallt*) value->value);
+ sArraySetTiny(self->a, (uint32_t)index, (smallt*) value->value);
return(self);
}
@@ -7696,7 +8010,7 @@ internal smallArrayt* setAtSmallJsonSmallArray(smallArrayt *self, int64_t index,
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
smallt *o = getsoO(value);
@@ -7706,7 +8020,7 @@ internal smallArrayt* setAtSmallJsonSmallArray(smallArrayt *self, int64_t index,
setsoO(value, o);
}
- sArraySetTiny(self->a, index, o);
+ sArraySetTiny(self->a, (uint32_t)index, o);
return(self);
}
@@ -7727,13 +8041,13 @@ internal smallArrayt* setAtSmallStringSmallArray(smallArrayt *self, int64_t inde
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
if (!string->data) {
isError(string->data, allocSStringTiny("")) return(NULL);
}
- sArraySetTiny(self->a, index, (smallt *)string->data);
+ sArraySetTiny(self->a, (uint32_t)index, (smallt *)string->data);
return(self);
}
@@ -7754,13 +8068,13 @@ internal smallArrayt* setAtSmallContainerSmallArray(smallArrayt *self, int64_t i
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
if (!container->data) {
isError(container->data, allocSContainer(NULL)) return(NULL);
}
- sArraySetTiny(self->a, index, (smallt *) container->data);
+ sArraySetTiny(self->a, (uint32_t)index, (smallt *) container->data);
return(self);
}
@@ -7777,14 +8091,14 @@ internal smallArrayt* setAtNFreeSmallArray(smallArrayt *self, int64_t index, bas
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
smallt *o = toSmallt(value);
if (!o) {
return(NULL);
}
- sArraySetTiny(self->a, index, o);
+ sArraySetTiny(self->a, (uint32_t)index, o);
if (!(o->type == CONTAINER && (((sContainert*)o)->dataType == SH_DT_BASET))) {
finishO(value);
@@ -7792,11 +8106,11 @@ internal smallArrayt* setAtNFreeSmallArray(smallArrayt *self, int64_t index, bas
return(self);
}
-internal smallArrayt* setAtNFreeUndefinedSmallArray(smallArrayt *self, int64_t index, undefinedt *undefined) {
+internal smallArrayt* setAtNFreeUndefinedSmallArray(smallArrayt *self, int64_t index, undefinedt *u) {
smallArrayt *r = setAtUndefinedSmallArray(self, index);
if (r) {
- terminateO(undefined);
+ terminateO(u);
}
return(r);
}
@@ -7918,7 +8232,7 @@ internal smallArrayt* setPAtDictSmallArray(smallArrayt *self, int64_t index, sma
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
if (!dict->d) {
@@ -7926,7 +8240,7 @@ internal smallArrayt* setPAtDictSmallArray(smallArrayt *self, int64_t index, sma
return(NULL);
}
- sArraySetP(self->a, index, (smallt *)dict->d);
+ sArraySetP(self->a, (uint32_t)index, (smallt *)dict->d);
return(self);
}
@@ -7947,7 +8261,7 @@ internal smallArrayt* setPAtArraySmallArray(smallArrayt *self, int64_t index, sm
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
if (!array->a) {
@@ -7955,7 +8269,7 @@ internal smallArrayt* setPAtArraySmallArray(smallArrayt *self, int64_t index, sm
return(NULL);
}
- sArraySetP(self->a, index, (smallt *)array->a);
+ sArraySetP(self->a, (uint32_t)index, (smallt *)array->a);
return(self);
}
@@ -7976,7 +8290,7 @@ internal smallArrayt* setPAtSmallJsonSmallArray(smallArrayt *self, int64_t index
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
smallt *o;
@@ -7985,7 +8299,7 @@ internal smallArrayt* setPAtSmallJsonSmallArray(smallArrayt *self, int64_t index
// realloc error
return(NULL);
}
- sArraySetP(self->a, index, o);
+ sArraySetP(self->a, (uint32_t)index, o);
return(self);
}
@@ -8006,7 +8320,7 @@ internal smallArrayt* setPAtSmallStringSmallArray(smallArrayt *self, int64_t ind
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
if (!string->data) {
@@ -8015,7 +8329,7 @@ internal smallArrayt* setPAtSmallStringSmallArray(smallArrayt *self, int64_t ind
}
smallt *o = (smallt *) string->data;
- sArraySetP(self->a, index, o);
+ sArraySetP(self->a, (uint32_t)index, o);
return(self);
}
@@ -8036,7 +8350,7 @@ internal smallArrayt* setPAtNFreeDictSmallArray(smallArrayt *self, int64_t index
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
if (!dict->d) {
@@ -8044,7 +8358,7 @@ internal smallArrayt* setPAtNFreeDictSmallArray(smallArrayt *self, int64_t index
return(NULL);
}
- sArraySetP(self->a, index, (smallt *)dict->d);
+ sArraySetP(self->a, (uint32_t)index, (smallt *)dict->d);
finishO(dict);
return(self);
}
@@ -8067,7 +8381,7 @@ internal smallArrayt* setPAtNFreeArraySmallArray(smallArrayt *self, int64_t inde
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
if (!array->a) {
@@ -8075,7 +8389,7 @@ internal smallArrayt* setPAtNFreeArraySmallArray(smallArrayt *self, int64_t inde
return(NULL);
}
- sArraySetP(self->a, index, (smallt *)array->a);
+ sArraySetP(self->a, (uint32_t)index, (smallt *)array->a);
finishO(array);
return(self);
}
@@ -8097,7 +8411,7 @@ internal smallArrayt* setPAtNFreeSmallJsonSmallArray(smallArrayt *self, int64_t
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
smallt *o;
@@ -8107,7 +8421,7 @@ internal smallArrayt* setPAtNFreeSmallJsonSmallArray(smallArrayt *self, int64_t
return(NULL);
}
finishO(json);
- sArraySetP(self->a, index, o);
+ sArraySetP(self->a, (uint32_t)index, o);
return(self);
}
@@ -8128,7 +8442,7 @@ internal smallArrayt* setPAtNFreeSmallStringSmallArray(smallArrayt *self, int64_
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
if (!string->data) {
@@ -8138,7 +8452,7 @@ internal smallArrayt* setPAtNFreeSmallStringSmallArray(smallArrayt *self, int64_
smallt *o = (smallt *) string->data;
finishO(string);
- sArraySetP(self->a, index, o);
+ sArraySetP(self->a, (uint32_t)index, o);
return(self);
}
@@ -8151,10 +8465,10 @@ internal double getNumSmallArray(smallArrayt *self, int64_t index) {
return(0);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
- smallt *e = sArrayGetTiny(self->a, index);
+ smallt *e = sArrayGetTiny(self->a, (uint32_t)index);
if (!e) {
return(0);
}
@@ -8169,7 +8483,7 @@ internal double getNumSmallArray(smallArrayt *self, int64_t index) {
r = getValO((smallDoublet*)o);
}
elif (isOSmallInt(o)) {
- r = getValO((smallIntt*)o);
+ r = (double)getValO((smallIntt*)o);
}
finishO(o);
return(r);
@@ -8188,17 +8502,17 @@ internal bool hasSmallArray(smallArrayt *self, baset *value) {
return(true);
}
-internal bool hasUndefinedSmallArray(smallArrayt *self, undefinedt *undefined) {
+internal bool hasUndefinedSmallArray(smallArrayt *self, undefinedt *u) {
- if (!undefined) {
+ if (!u) {
return(false);
}
- if (checkObjectTypes && !isOUndefined(undefined)) {
+ if (checkObjectTypes && !isOUndefined(u)) {
return(false);
}
- if (indexOfUndefinedSmallArray(self, undefined) == -1) {
+ if (indexOfUndefinedSmallArray(self, u) == -1) {
return(false);
}
@@ -8298,6 +8612,19 @@ internal bool hasArraycSmallArray(smallArrayt *self, char **array) {
return(true);
}
+internal bool hasCArraycSmallArray(smallArrayt *self, const char **array) {
+
+ if (!array) {
+ return(false);
+ }
+
+ if (indexOfCArraycSmallArray(self, array) == -1) {
+ return(false);
+ }
+
+ return(true);
+}
+
internal bool hasSmallBoolSmallArray(smallArrayt *self, smallBoolt *value) {
if (!value) {
@@ -8436,7 +8763,7 @@ internal ssize_t indexOfSmallArray(smallArrayt *self, baset *value) {
if (strEq(es, s)) {
free(es);
free(s);
- return(i);
+ return((ssize_t)i);
}
free(es);
}
@@ -8444,14 +8771,14 @@ internal ssize_t indexOfSmallArray(smallArrayt *self, baset *value) {
return(-1);
}
-internal ssize_t indexOfUndefinedSmallArray(smallArrayt *self, undefinedt *undefined) {
+internal ssize_t indexOfUndefinedSmallArray(smallArrayt *self, undefinedt *u) {
// sanity checks
- if (!lenSmallArray(self) || !undefined) {
+ if (!lenSmallArray(self) || !u) {
return(-1);
}
- if (checkObjectTypes && !isOUndefined(undefined)) {
+ if (checkObjectTypes && !isOUndefined(u)) {
return(-1);
}
@@ -8461,7 +8788,7 @@ internal ssize_t indexOfUndefinedSmallArray(smallArrayt *self, undefinedt *undef
continue;
}
if (e->type == UNDEFINED) {
- return(i);
+ return((ssize_t)i);
}
}
return(-1);
@@ -8480,7 +8807,7 @@ internal ssize_t indexOfBoolSmallArray(smallArrayt *self, bool value) {
continue;
}
if (e->type == BOOL && ((sBoolt*)e)->value == value) {
- return(i);
+ return((ssize_t)i);
}
}
return(-1);
@@ -8499,7 +8826,7 @@ internal ssize_t indexOfDoubleSmallArray(smallArrayt *self, double value) {
continue;
}
if (e->type == DOUBLE && ((sDoublet*)e)->value == value) {
- return(i);
+ return((ssize_t)i);
}
}
return(-1);
@@ -8518,7 +8845,7 @@ internal ssize_t indexOfIntSmallArray(smallArrayt *self, int64_t value) {
continue;
}
if (e->type == INT && ((sIntt*)e)->value == value) {
- return(i);
+ return((ssize_t)i);
}
}
return(-1);
@@ -8539,7 +8866,7 @@ internal ssize_t indexOfSSmallArray(smallArrayt *self, const char *string) {
continue;
}
if (e->type == STRING && strEq(sStringGetTiny((sStringt*)e), string)) {
- return(i);
+ return((ssize_t)i);
}
}
return(-1);
@@ -8575,7 +8902,7 @@ internal ssize_t indexOfDictSmallArray(smallArrayt *self, smallDictt *dict) {
if (strEq(es, s)) {
free(es);
free(s);
- return(i);
+ return((ssize_t)i);
}
free(es);
}
@@ -8608,7 +8935,7 @@ internal ssize_t indexOfArraySmallArray(smallArrayt *self, smallArrayt *array) {
if (strEq(es, s)) {
free(es);
free(s);
- return(i);
+ return((ssize_t)i);
}
free(es);
}
@@ -8637,7 +8964,36 @@ internal ssize_t indexOfArraycSmallArray(smallArrayt *self, char **array) {
if (strEq(es, s)) {
free(es);
free(s);
- return(i);
+ return((ssize_t)i);
+ }
+ free(es);
+ }
+ }
+ free(s);
+ return(-1);
+}
+
+internal ssize_t indexOfCArraycSmallArray(smallArrayt *self, const char **array) {
+
+ // sanity checks
+ if (!lenSmallArray(self) || !array) {
+ return(-1);
+ }
+
+ // search object in elements
+ char *s = toStringListCSGF(array);
+ char *es = NULL;;
+
+ enumerateSArray(self->a, e, i) {
+ if (not e) {
+ continue;
+ }
+ if (e->type == ARRAY) {
+ es = sToString(e);
+ if (strEq(es, s)) {
+ free(es);
+ free(s);
+ return((ssize_t)i);
}
free(es);
}
@@ -8665,7 +9021,7 @@ internal ssize_t indexOfSmallBoolSmallArray(smallArrayt *self, smallBoolt *value
continue;
}
if (e->type == BOOL && ((sBoolt*)e)->value == b) {
- return(i);
+ return((ssize_t)i);
}
}
return(-1);
@@ -8691,7 +9047,7 @@ internal ssize_t indexOfSmallBytesSmallArray(smallArrayt *self, smallBytest *val
continue;
}
if (e->type == BYTES && ((sBytest*)e)->count == count && !memcmp(&(((sBytest*)e)->data), b, count)) {
- return(i);
+ return((ssize_t)i);
}
}
return(-1);
@@ -8716,7 +9072,7 @@ internal ssize_t indexOfSmallDoubleSmallArray(smallArrayt *self, smallDoublet *v
continue;
}
if (e->type == DOUBLE && ((sDoublet*)e)->value == v) {
- return(i);
+ return((ssize_t)i);
}
}
return(-1);
@@ -8741,7 +9097,7 @@ internal ssize_t indexOfSmallIntSmallArray(smallArrayt *self, smallIntt *value)
continue;
}
if (e->type == INT && ((sIntt*)e)->value == v) {
- return(i);
+ return((ssize_t)i);
}
}
return(-1);
@@ -8828,7 +9184,7 @@ internal ssize_t indexOfSmallStringSmallArray(smallArrayt *self, smallStringt *s
continue;
}
if (e->type == STRING && strEq(sStringGetTiny((sStringt*)e), s)) {
- return(i);
+ return((ssize_t)i);
}
}
return(-1);
@@ -8851,10 +9207,10 @@ internal ssize_t binarySearchSmallArray(smallArrayt *self, baset *value) {
char *m = NULL;
ssize_t r = -1;
- last = lenSmallArray(self) - 1;
+ last = (ssize_t)lenSmallArray(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- m = sToString(sArrayGetTiny(self->a, middle));
+ m = sToString(sArrayGetTiny(self->a, (uint32_t)middle));
if (!m) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -8878,7 +9234,7 @@ internal ssize_t binarySearchSmallArray(smallArrayt *self, baset *value) {
return(r);
}
-internal ssize_t binarySearchUndefinedSmallArray(smallArrayt *self UNUSED, undefinedt *undefined UNUSED) {
+internal ssize_t binarySearchUndefinedSmallArray(smallArrayt *self UNUSED, undefinedt *u UNUSED) {
// ssize_t first = 0, middle, last
// it doesn't make sense to search for undefined
@@ -8924,10 +9280,10 @@ internal ssize_t binarySearchBoolSmallArray(smallArrayt *self, bool value) {
sBoolt *m = NULL;
ssize_t r = -1;
- last = lenSmallArray(self) - 1;
+ last = (ssize_t)lenSmallArray(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- m = (sBoolt*)(sArrayGetTiny(self->a, middle));
+ m = (sBoolt*)(sArrayGetTiny(self->a, (uint32_t)middle));
if (!m) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -8959,10 +9315,10 @@ internal ssize_t binarySearchDoubleSmallArray(smallArrayt *self, double value) {
sDoublet *m = NULL;
ssize_t r = -1;
- last = lenSmallArray(self) - 1;
+ last = (ssize_t)lenSmallArray(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- m = (sDoublet*)(sArrayGetTiny(self->a, middle));
+ m = (sDoublet*)(sArrayGetTiny(self->a, (uint32_t)middle));
if (!m) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -8993,10 +9349,10 @@ internal ssize_t binarySearchIntSmallArray(smallArrayt *self, int64_t value) {
sIntt *m = NULL;
ssize_t r = -1;
- last = lenSmallArray(self) - 1;
+ last = (ssize_t)lenSmallArray(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- m = (sIntt*)(sArrayGetTiny(self->a, middle));
+ m = (sIntt*)(sArrayGetTiny(self->a, (uint32_t)middle));
if (!m) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -9026,10 +9382,10 @@ internal ssize_t binarySearchSSmallArray(smallArrayt *self, const char *string)
smallt *e = NULL;
- last = lenSmallArray(self) - 1;
+ last = (ssize_t)lenSmallArray(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- e = sArrayGetTiny(self->a, middle);
+ e = sArrayGetTiny(self->a, (uint32_t)middle);
if (!e) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -9071,10 +9427,10 @@ internal ssize_t binarySearchDictSmallArray(smallArrayt *self, smallDictt *dict)
char *m = NULL;
ssize_t r = -1;
- last = lenSmallArray(self) - 1;
+ last = (ssize_t)lenSmallArray(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- e = sArrayGetTiny(self->a, middle);
+ e = sArrayGetTiny(self->a, (uint32_t)middle);
if (!e) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -9122,10 +9478,10 @@ internal ssize_t binarySearchArraySmallArray(smallArrayt *self, smallArrayt *arr
char *m = NULL;
ssize_t r = -1;
- last = lenSmallArray(self) - 1;
+ last = (ssize_t)lenSmallArray(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- e = sArrayGetTiny(self->a, middle);
+ e = sArrayGetTiny(self->a, (uint32_t)middle);
if (!e) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -9169,10 +9525,57 @@ internal ssize_t binarySearchArraycSmallArray(smallArrayt *self, char **array) {
char *m = NULL;
ssize_t r = -1;
- last = lenSmallArray(self) - 1;
+ last = (ssize_t)lenSmallArray(self) - 1;
+ while (first <= last) {
+ middle = (first+last)/2;
+ e = sArrayGetTiny(self->a, (uint32_t)middle);
+ if (!e) {
+ // there are null element in the array
+ // the array needs to be trimmed or compacted
+ goto finish;
+ }
+ // cg_c bug, can't use comma operator, extra code
+ if (e->type == ARRAY) {
+ m = sToString(e);
+ }
+ // cg_c bug, can't use comma operator
+ /* if e->type < ARRAY || ((e->type = ARRAY) && strcmp((m=sToString(e),m), s) < 0) */
+ if (e->type < ARRAY || ((e->type == ARRAY) && strcmp(m, s) < 0)) {
+ first = middle + 1;
+ }
+ else if ((e->type == ARRAY) && strcmp(m, s) == 0) {
+ r = middle;
+ free(m);
+ goto finish;
+ }
+ else {
+ last = middle -1;
+ }
+ if (e->type == ARRAY) {
+ free(m);
+ }
+ }
+ finish:
+ free(s);
+ return(r);
+}
+
+internal ssize_t binarySearchCArraycSmallArray(smallArrayt *self, const char **array) {
+ ssize_t first = 0, middle, last;;
+
+ if (!lenSmallArray(self) || !array) {
+ return(-1);
+ }
+
+ char *s = toStringListCSGF(array);
+ smallt *e = NULL;
+ char *m = NULL;
+
+ ssize_t r = -1;
+ last = (ssize_t)lenSmallArray(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- e = sArrayGetTiny(self->a, middle);
+ e = sArrayGetTiny(self->a, (uint32_t)middle);
if (!e) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -9219,10 +9622,10 @@ internal ssize_t binarySearchSmallBoolSmallArray(smallArrayt *self, smallBoolt *
sBoolt *m = NULL;
ssize_t r = -1;
- last = lenSmallArray(self) - 1;
+ last = (ssize_t)lenSmallArray(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- m = (sBoolt*)(sArrayGetTiny(self->a, middle));
+ m = (sBoolt*)(sArrayGetTiny(self->a, (uint32_t)middle));
if (!m) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -9259,10 +9662,10 @@ internal ssize_t binarySearchSmallBytesSmallArray(smallArrayt *self, smallBytest
sBytest *m = NULL;
ssize_t r = -1;
- last = lenSmallArray(self) - 1;
+ last = (ssize_t)lenSmallArray(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- m = (sBytest*)(sArrayGetTiny(self->a, middle));
+ m = (sBytest*)(sArrayGetTiny(self->a, (uint32_t)middle));
if (!m) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -9298,10 +9701,10 @@ internal ssize_t binarySearchSmallDoubleSmallArray(smallArrayt *self, smallDoubl
sDoublet *m = NULL;
ssize_t r = -1;
- last = lenSmallArray(self) - 1;
+ last = (ssize_t)lenSmallArray(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- m = (sDoublet*)(sArrayGetTiny(self->a, middle));
+ m = (sDoublet*)(sArrayGetTiny(self->a, (uint32_t)middle));
if (!m) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -9337,10 +9740,10 @@ internal ssize_t binarySearchSmallIntSmallArray(smallArrayt *self, smallIntt *va
sIntt *m = NULL;
ssize_t r = -1;
- last = lenSmallArray(self) - 1;
+ last = (ssize_t)lenSmallArray(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- m = (sIntt*)(sArrayGetTiny(self->a, middle));
+ m = (sIntt*)(sArrayGetTiny(self->a, (uint32_t)middle));
if (!m) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -9433,10 +9836,10 @@ internal ssize_t binarySearchSmallStringSmallArray(smallArrayt *self, smallStrin
return(-1);
}
- last = lenSmallArray(self) - 1;
+ last = (ssize_t)lenSmallArray(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- e = sArrayGetTiny(self->a, middle);
+ e = sArrayGetTiny(self->a, (uint32_t)middle);
if (!e) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -9575,6 +9978,8 @@ internal smallArrayt* uniqSmallArray(smallArrayt *self) {
freeO(B);
}
break;
+ default:
+ logC("Unsupported object type!");
}
}
if (pushE) {
@@ -9663,6 +10068,19 @@ internal bool icHasArraycSmallArray(smallArrayt *self, char **array) {
return(true);
}
+internal bool icHasCArraycSmallArray(smallArrayt *self, const char **array) {
+
+ if (!array) {
+ return(false);
+ }
+
+ if (icIndexOfCArraycSmallArray(self, array) == -1) {
+ return(false);
+ }
+
+ return(true);
+}
+
internal bool icHasSmallJsonSmallArray(smallArrayt *self, smallJsont *string) {
if (!string) {
@@ -9708,7 +10126,7 @@ internal ssize_t icIndexOfSmallArray(smallArrayt *self, baset *value) {
if (icEqS(es, s)) {
free(es);
free(s);
- return(i);
+ return((ssize_t)i);
}
free(es);
}
@@ -9731,7 +10149,7 @@ internal ssize_t icIndexOfSSmallArray(smallArrayt *self, const char *string) {
continue;
}
if (e->type == STRING && icEqS(sStringGetTiny((sStringt*)e), string)) {
- return(i);
+ return((ssize_t)i);
}
}
return(-1);
@@ -9767,7 +10185,7 @@ internal ssize_t icIndexOfDictSmallArray(smallArrayt *self, smallDictt *dict) {
if (icEqS(es, s)) {
free(es);
free(s);
- return(i);
+ return((ssize_t)i);
}
free(es);
}
@@ -9800,7 +10218,7 @@ internal ssize_t icIndexOfArraySmallArray(smallArrayt *self, smallArrayt *array)
if (icEqS(es, s)) {
free(es);
free(s);
- return(i);
+ return((ssize_t)i);
}
free(es);
}
@@ -9829,7 +10247,36 @@ internal ssize_t icIndexOfArraycSmallArray(smallArrayt *self, char **array) {
if (icEqS(es, s)) {
free(es);
free(s);
- return(i);
+ return((ssize_t)i);
+ }
+ free(es);
+ }
+ }
+ free(s);
+ return(-1);
+}
+
+internal ssize_t icIndexOfCArraycSmallArray(smallArrayt *self, const char **array) {
+
+ // sanity checks
+ if (!lenSmallArray(self) || !array) {
+ return(-1);
+ }
+
+ // search object in elements
+ char *s = toStringListCSGF(array);
+ char *es = NULL;;
+
+ enumerateSArray(self->a, e, i) {
+ if (not e) {
+ continue;
+ }
+ if (e->type == ARRAY) {
+ es = sToString(e);
+ if (icEqS(es, s)) {
+ free(es);
+ free(s);
+ return((ssize_t)i);
}
free(es);
}
@@ -9918,7 +10365,7 @@ internal ssize_t icIndexOfSmallStringSmallArray(smallArrayt *self, smallStringt
continue;
}
if (e->type == STRING && icEqS(sStringGetTiny((sStringt*)e), s)) {
- return(i);
+ return((ssize_t)i);
}
}
return(-1);
@@ -9935,10 +10382,10 @@ internal ssize_t icBinarySearchSmallArray(smallArrayt *self, baset *value) {
char *m = NULL;
ssize_t r = -1;
- last = lenSmallArray(self) - 1;
+ last = (ssize_t)lenSmallArray(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- m = sToString(sArrayGetTiny(self->a, middle));
+ m = sToString(sArrayGetTiny(self->a, (uint32_t)middle));
if (!m) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -9971,10 +10418,10 @@ internal ssize_t icBinarySearchSSmallArray(smallArrayt *self, const char *string
smallt *e = NULL;
- last = lenSmallArray(self) - 1;
+ last = (ssize_t)lenSmallArray(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- e = sArrayGetTiny(self->a, middle);
+ e = sArrayGetTiny(self->a, (uint32_t)middle);
if (!e) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -10016,10 +10463,10 @@ internal ssize_t icBinarySearchDictSmallArray(smallArrayt *self, smallDictt *dic
char *m = NULL;
ssize_t r = -1;
- last = lenSmallArray(self) - 1;
+ last = (ssize_t)lenSmallArray(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- e = sArrayGetTiny(self->a, middle);
+ e = sArrayGetTiny(self->a, (uint32_t)middle);
if (!e) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -10067,10 +10514,10 @@ internal ssize_t icBinarySearchArraySmallArray(smallArrayt *self, smallArrayt *a
char *m = NULL;
ssize_t r = -1;
- last = lenSmallArray(self) - 1;
+ last = (ssize_t)lenSmallArray(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- e = sArrayGetTiny(self->a, middle);
+ e = sArrayGetTiny(self->a, (uint32_t)middle);
if (!e) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -10114,10 +10561,57 @@ internal ssize_t icBinarySearchArraycSmallArray(smallArrayt *self, char **array)
char *m = NULL;
ssize_t r = -1;
- last = lenSmallArray(self) - 1;
+ last = (ssize_t)lenSmallArray(self) - 1;
+ while (first <= last) {
+ middle = (first+last)/2;
+ e = sArrayGetTiny(self->a, (uint32_t)middle);
+ if (!e) {
+ // there are null element in the array
+ // the array needs to be trimmed or compacted
+ goto finish;
+ }
+ // cg_c bug, can't use comma operator, extra code
+ if (e->type == ARRAY) {
+ m = sToString(e);
+ }
+ // cg_c bug, can't use comma operator
+ /* if e->type < ARRAY || ((e->type = ARRAY) && strcmp((m=sToString(e),m), s) < 0) */
+ if (e->type < ARRAY || ((e->type == ARRAY) && strcasecmp(m, s) < 0)) {
+ first = middle + 1;
+ }
+ else if ((e->type == ARRAY) && strcasecmp(m, s) == 0) {
+ r = middle;
+ free(m);
+ goto finish;
+ }
+ else {
+ last = middle -1;
+ }
+ if (e->type == ARRAY) {
+ free(m);
+ }
+ }
+ finish:
+ free(s);
+ return(r);
+}
+
+internal ssize_t icBinarySearchCArraycSmallArray(smallArrayt *self, const char **array) {
+ ssize_t first = 0, middle, last;;
+
+ if (!lenSmallArray(self) || !array) {
+ return(-1);
+ }
+
+ char *s = toStringListCSGF(array);
+ smallt *e = NULL;
+ char *m = NULL;
+
+ ssize_t r = -1;
+ last = (ssize_t)lenSmallArray(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- e = sArrayGetTiny(self->a, middle);
+ e = sArrayGetTiny(self->a, (uint32_t)middle);
if (!e) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -10221,10 +10715,10 @@ internal ssize_t icBinarySearchSmallStringSmallArray(smallArrayt *self, smallStr
char *s = sStringGetTiny(string->data);
smallt *e = NULL;
- last = lenSmallArray(self) - 1;
+ last = (ssize_t)lenSmallArray(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- e = sArrayGetTiny(self->a, middle);
+ e = sArrayGetTiny(self->a, (uint32_t)middle);
if (!e) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -10357,6 +10851,8 @@ internal smallArrayt* icUniqSmallArray(smallArrayt *self) {
freeO(B);
}
break;
+ default:
+ logC("Unsupported object type!");
}
}
if (pushE) {
@@ -10441,6 +10937,8 @@ internal smallArrayt* compactSmallArray(smallArrayt *self) {
sFree(e);
}
break;
+ default:
+ logC("Unsupported object type!");
}
}
}
@@ -10468,7 +10966,7 @@ internal bool isEmptySmallArray(smallArrayt *self) {
}
for (size_t i=0; i < len; i++) {
- smallt *o = sArrayGetTiny(self->a, i);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)i);
if (o) {
return(false);
}
@@ -10515,6 +11013,8 @@ internal bool isBlankSmallArray(smallArrayt *self) {
return(false);
}
break;
+ default:
+ logC("Unsupported object type!");
}
}
}
@@ -10587,8 +11087,8 @@ internal baset* iterStartSmallArray(smallArrayt *self) {
// get first element
// find first non NULL element, deleted element can be at index 0
range(i, self->a->count)
- if (sArrayGetTiny(self->a, i)) {
- self->iterIndex = i;
+ if (sArrayGetTiny(self->a, (uint32_t)i)) {
+ self->iterIndex = (ssize_t)i;
break;
}
self->iterStep = 1;
@@ -10596,7 +11096,7 @@ internal baset* iterStartSmallArray(smallArrayt *self) {
// free already created base object
finishO(self->iterElement);
}
- smallt *o = sArrayGetTiny(self->a, self->iterIndex);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)self->iterIndex);
if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
self->iterElementDataType = SH_DT_BASET;
}
@@ -10619,7 +11119,7 @@ internal baset* iterStartLastSmallArray(smallArrayt *self) {
// get first element
// find first non NULL element, deleted element can be at index 0
rangeDown(i, self->a->count)
- if (sArrayGetTiny(self->a, i)) {
+ if (sArrayGetTiny(self->a, (uint32_t)i)) {
self->iterIndex = i;
break;
}
@@ -10628,7 +11128,7 @@ internal baset* iterStartLastSmallArray(smallArrayt *self) {
// free already created base object
finishO(self->iterElement);
}
- smallt *o = sArrayGetTiny(self->a, self->iterIndex);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)self->iterIndex);
if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
self->iterElementDataType = SH_DT_BASET;
}
@@ -10655,14 +11155,14 @@ internal baset* iterStartFromSmallArray(smallArrayt *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
// get first element
// find first non NULL element, deleted element can be at index 0
- rangeFrom(i, index, self->a->count)
- if (sArrayGetTiny(self->a, i)) {
- self->iterIndex = i;
+ rangeFrom(i, (size_t)index, self->a->count)
+ if (sArrayGetTiny(self->a, (uint32_t)i)) {
+ self->iterIndex = (ssize_t)i;
break;
}
if (self->iterIndex == -1) {
@@ -10674,7 +11174,7 @@ internal baset* iterStartFromSmallArray(smallArrayt *self, int64_t index) {
// free already created base object
finishO(self->iterElement);
}
- smallt *o = sArrayGetTiny(self->a, self->iterIndex);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)self->iterIndex);
if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
self->iterElementDataType = SH_DT_BASET;
}
@@ -10706,14 +11206,14 @@ internal baset* iterStartFromStepSmallArray(smallArrayt *self, int64_t index, in
return(NULL);
}
if (index < 0) {
- index = lenSmallArray(self) + index;
+ index = (int64_t)lenSmallArray(self) + index;
}
// get first element
// find first non NULL element, deleted element can be at index 0
- rangeFromStep(i, index, self->a->count, step)
- if (sArrayGetTiny(self->a, i)) {
- self->iterIndex = i;
+ rangeFromStep(i, (size_t)index, self->a->count, step)
+ if (sArrayGetTiny(self->a, (uint32_t)i)) {
+ self->iterIndex = (ssize_t)i;
break;
}
if (self->iterIndex == -1) {
@@ -10725,7 +11225,7 @@ internal baset* iterStartFromStepSmallArray(smallArrayt *self, int64_t index, in
// free already created base object
finishO(self->iterElement);
}
- smallt *o = sArrayGetTiny(self->a, self->iterIndex);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)self->iterIndex);
if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
self->iterElementDataType = SH_DT_BASET;
}
@@ -10758,7 +11258,7 @@ internal baset* iterNextSmallArray(smallArrayt *self) {
self->iterIndex = -1;
return(NULL);
}
- smallt *o = sArrayGetTiny(self->a, self->iterIndex);
+ smallt *o = sArrayGetTiny(self->a, (uint32_t)self->iterIndex);
if (!o) {
continue;
}
@@ -10806,7 +11306,7 @@ internal smallStringt* joinSmallArray(smallArrayt *self, const char* delim) {
r = allocSmallString(sStringGetTiny((sStringt*)e));
}
else {
- r->f->appendS(r, (char*)delim);
+ r->f->appendS(r, delim);
r->f->appendS(r, sStringGetTiny((sStringt*)e));
}
break;
@@ -10816,7 +11316,7 @@ internal smallStringt* joinSmallArray(smallArrayt *self, const char* delim) {
r = allocSmallString(s);
}
else {
- r->f->appendS(r, (char*)delim);
+ r->f->appendS(r, delim);
r->f->appendS(r, s);
}
free(s);
@@ -10877,8 +11377,8 @@ internal char* joinSSmallArray(smallArrayt *self, const char* delim) {
r = strdup(sStringGetTiny((sStringt*)e));
}
else {
- iAppendS(&r, delim);
- iAppendS(&r, sStringGetTiny((sStringt*)e));
+ pErrorNULL(iAppendS(&r, delim));
+ pErrorNULL(iAppendS(&r, sStringGetTiny((sStringt*)e)));
}
break;
default:
@@ -10891,8 +11391,8 @@ internal char* joinSSmallArray(smallArrayt *self, const char* delim) {
r = strdup(s);
}
else {
- iAppendS(&r, delim);
- iAppendS(&r, s);
+ pErrorNULL(iAppendS(&r, delim));
+ pErrorNULL(iAppendS(&r, s));
}
free(s);
}
@@ -10962,7 +11462,7 @@ internal smallArrayt* zipSmallArray(smallArrayt *self, smallArrayt *array1, smal
return(NULL);
}
pushNFreeO(a, E1);
- pushNFreeO(a, getO(array2, i));
+ pushNFreeO(a, getO(array2, (int64_t)i));
pushNFreeArraySmallArray(self, a);
count++;
if (count == len) {
@@ -11142,7 +11642,7 @@ internal smallArrayt* zipArraySmallArray(smallArrayt *self, char** array1, small
return(NULL);
}
a->f->pushNFreeS(a, E1);
- pushNFreeO(a, getO(array2, i));
+ pushNFreeO(a, getO(array2, (int64_t)i));
pushNFreeArraySmallArray(self, a);
count++;
if (count == len) {
@@ -11153,35 +11653,33 @@ internal smallArrayt* zipArraySmallArray(smallArrayt *self, char** array1, small
return(self);
}
-internal smallArrayt* zipCArraySmallArray(smallArrayt *self, const char** a1, smallArrayt *array2) {
+internal smallArrayt* zipCArraySmallArray(smallArrayt *self, const char** array1, smallArrayt *array2) {
size_t len;
size_t count;
- if (!a1 || !array2) {
+ if (!array1 || !array2) {
return(NULL);
}
- char** array1 = (char**)a1;
-
if (checkObjectTypes && !isOSmallArray(array2)) {
return(NULL);
}
- if (!listLengthS(array1) || !array2->f->len(array2)) {
+ if (!listLengthCS(array1) || !array2->f->len(array2)) {
return(self);
}
- len = MIN(listLengthS(array1), array2->f->len(array2));;
+ len = MIN(listLengthCS(array1), array2->f->len(array2));;
count = 0;
- enumerateS(array1, E1, i) {
+ enumerateCS(array1, E1, i) {
createAllocateSmallArray(a);
if (!a) {
return(NULL);
}
a->f->pushS(a, E1);
- pushNFreeO(a, getO(array2, i));
+ pushNFreeO(a, getO(array2, (int64_t)i));
pushNFreeArraySmallArray(self, a);
count++;
if (count == len) {
@@ -11278,25 +11776,23 @@ internal smallArrayt* zipCharSmallArray(smallArrayt *self, smallArrayt *array1,
return(self);
}
-internal smallArrayt* zipCCharSmallArray(smallArrayt *self, smallArrayt *array1, const char** a2) {
+internal smallArrayt* zipCCharSmallArray(smallArrayt *self, smallArrayt *array1, const char** array2) {
size_t len;
size_t count;
- if (!array1 || !a2) {
+ if (!array1 || !array2) {
return(NULL);
}
- char** array2 = (char**)a2;
-
if (checkObjectTypes && !isOSmallArray(array1)) {
return(NULL);
}
- if (!array1->f->len(array1) || !listLengthS(array2)) {
+ if (!array1->f->len(array1) || !listLengthCS(array2)) {
return(self);
}
- len = MIN(array1->f->len(array1), listLengthS(array2));;
+ len = MIN(array1->f->len(array1), listLengthCS(array2));;
count = 0;
@@ -11351,25 +11847,23 @@ internal smallArrayt* zipArrayCharSmallArray(smallArrayt *self, char** array1, c
return(self);
}
-internal smallArrayt* zipCArrayCharSmallArray(smallArrayt *self, const char** a1, char** array2) {
+internal smallArrayt* zipCArrayCharSmallArray(smallArrayt *self, const char** array1, char** array2) {
size_t len;
size_t count;
- if (!a1 || !array2) {
+ if (!array1 || !array2) {
return(NULL);
}
- char** array1 = (char**)a1;
-
- if (!listLengthS(array1) || !listLengthS(array2)) {
+ if (!listLengthCS(array1) || !listLengthS(array2)) {
return(self);
}
- len = MIN(listLengthS(array1), listLengthS(array2));;
+ len = MIN(listLengthCS(array1), listLengthS(array2));;
count = 0;
- enumerateS(array1, E1, i) {
+ enumerateCS(array1, E1, i) {
createAllocateSmallArray(a);
if (!a) {
return(NULL);
@@ -11386,21 +11880,19 @@ internal smallArrayt* zipCArrayCharSmallArray(smallArrayt *self, const char** a1
return(self);
}
-internal smallArrayt* zipArrayCCharSmallArray(smallArrayt *self, char** array1, const char** a2) {
+internal smallArrayt* zipArrayCCharSmallArray(smallArrayt *self, char** array1, const char** array2) {
size_t len;
size_t count;
- if (!array1 || !a2) {
+ if (!array1 || !array2) {
return(NULL);
}
- char** array2 = (char**)a2;
-
- if (!listLengthS(array1) || !listLengthS(array2)) {
+ if (!listLengthS(array1) || !listLengthCS(array2)) {
return(self);
}
- len = MIN(listLengthS(array1), listLengthS(array2));;
+ len = MIN(listLengthS(array1), listLengthCS(array2));;
count = 0;
@@ -11421,26 +11913,23 @@ internal smallArrayt* zipArrayCCharSmallArray(smallArrayt *self, char** array1,
return(self);
}
-internal smallArrayt* zipCArrayCCharSmallArray(smallArrayt *self, const char** a1, const char** a2) {
+internal smallArrayt* zipCArrayCCharSmallArray(smallArrayt *self, const char** array1, const char** array2) {
size_t len;
size_t count;
- if (!a1 || !a2) {
+ if (!array1 || !array2) {
return(NULL);
}
- char** array1 = (char**)a1;
- char** array2 = (char**)a2;
-
- if (!listLengthS(array1) || !listLengthS(array2)) {
+ if (!listLengthCS(array1) || !listLengthCS(array2)) {
return(self);
}
- len = MIN(listLengthS(array1), listLengthS(array2));;
+ len = MIN(listLengthCS(array1), listLengthCS(array2));;
count = 0;
- enumerateS(array1, E1, i) {
+ enumerateCS(array1, E1, i) {
createAllocateSmallArray(a);
if (!a) {
return(NULL);
@@ -11711,10 +12200,10 @@ internal char typeSmallArray(smallArrayt *self, int64_t index) {
return(0);
}
if (index < 0) {
- index = len + index;
+ index = (int64_t)len + index;
}
- smallt *r = sArrayGetTiny(self->a, index);
+ smallt *r = sArrayGetTiny(self->a, (uint32_t)index);
if (!r) {
return(0);
}
@@ -11722,14 +12211,14 @@ internal char typeSmallArray(smallArrayt *self, int64_t index) {
return(r->type);
}
-internal char** typeStringsSmallArray(smallArrayt *self) {
+internal const char** typeStringsSmallArray(smallArrayt *self) {
return(sArrayTypeStrings(self->a));
}
internal smallArrayt* typeSmallStringsSmallArray(smallArrayt *self) {
- char** r = sArrayTypeStrings(self->a);
+ const char** r = sArrayTypeStrings(self->a);
if (!r) {
return(NULL);
}
@@ -11737,7 +12226,7 @@ internal smallArrayt* typeSmallStringsSmallArray(smallArrayt *self) {
if (!a) {
return(NULL);
}
- fromArraySmallArray(a, r, 0);
+ fromCArraySmallArray(a, r, 0);
free(r);
return(a);
}
@@ -11832,7 +12321,7 @@ internal bool areAllETypeSmallArray(smallArrayt *self, const char *type) {
bool r = true;
range(i, len) {
- if (!eqS(SMALL_TYPE_NAMES[(size_t)typeSmallArray(self, i)], type)) {
+ if (!eqS(SMALL_TYPE_NAMES[(size_t)typeSmallArray(self, (int64_t)i)], type)) {
r = false;
break;
}
@@ -11911,7 +12400,7 @@ smallArrayt* fromArraySmallArrayG (smallArrayt *self, char **array, size_t s
smallArrayt* fromCArraySmallArrayG (smallArrayt *self, const char **array, size_t size) {
- return(self->f->fromArray(self, (char**)array, size));
+ return(self->f->fromCArray(self, array, size));
}
smallArrayt* setFromSmallArrayG(smallArrayt *self, char **array) {
@@ -11921,7 +12410,7 @@ smallArrayt* setFromSmallArrayG(smallArrayt *self, char **array) {
smallArrayt* setFromCSmallArrayG(smallArrayt *self, const char **array) {
- return(self->f->fromArray(self, (char**)array, 0));
+ return(self->f->fromCArray(self, array, 0));
}
smallArrayt* pushSmallArrayG (smallArrayt *self, baset *value) {
@@ -11976,7 +12465,7 @@ smallArrayt* pushArraycSmallArrayG (smallArrayt *self, char **array) {
smallArrayt* pushCArraycSmallArrayG (smallArrayt *self, const char **array) {
- return(self->f->pushArrayc(self,(char**)array));
+ return(self->f->pushCArrayc(self,array));
}
smallArrayt* pushVoidSmallArrayG (smallArrayt *self, void *value) {
@@ -12242,7 +12731,7 @@ smallArrayt* prependArraycSmallArrayG (smallArrayt *self, char **array) {
smallArrayt* prependCArraycSmallArrayG (smallArrayt *self, const char **array) {
- return(self->f->prependArrayc(self,(char**)array));
+ return(self->f->prependCArrayc(self,array));
}
smallArrayt* prependVoidSmallArrayG (smallArrayt *self, void *value) {
@@ -12731,7 +13220,7 @@ smallArrayt* setAtArraycSmallArrayG (smallArrayt *self, int64_t index, char **
smallArrayt* setAtCArraycSmallArrayG (smallArrayt *self, int64_t index, const char **array) {
- return(self->f->setAtArrayc(self,index,(char**)array));
+ return(self->f->setAtCArrayc(self,index,array));
}
smallArrayt* setAtVoidSmallArrayG (smallArrayt *self, int64_t index, void *value) {
@@ -12930,7 +13419,7 @@ smallArrayt* appendNSmashArraySmallArrayG (smallArrayt *self, char **array) {
smallArrayt* appendCArraySmallArrayG (smallArrayt *self, const char **array) {
- return(self->f->appendArray(self, (char**)array));
+ return(self->f->appendCArray(self, array));
}
smallArrayt* shiftSmallArrayG (smallArrayt *self, smallArrayt *array) {
@@ -13148,7 +13637,7 @@ smallArrayt* injectArraycSmallArrayG (smallArrayt *self, int64_t index, char *
smallArrayt* injectCArraycSmallArrayG (smallArrayt *self, int64_t index, const char **array) {
- return(self->f->injectArrayc(self,index,(char**)array));
+ return(self->f->injectCArrayc(self,index,array));
}
smallArrayt* injectVoidSmallArrayG (smallArrayt *self, int64_t index, void *value) {
@@ -13316,7 +13805,7 @@ bool equalSmallArrayArrayG(smallArrayt* self, char ** p2) {
bool equalSmallArrayCArrayG(smallArrayt* self, const char ** p2) {
- return(self->f->equalArray(self, (char**)p2));
+ return(self->f->equalCArray(self, p2));
}
bool equalSmallArrayBaseG(smallArrayt* self, baset* p2) {
@@ -13341,7 +13830,7 @@ bool icEqualSmallArrayArrayG(smallArrayt* self, char ** p2) {
bool icEqualSmallArrayCArrayG(smallArrayt* self, const char ** p2) {
- return(self->f->icEqualArray(self, (char**)p2));
+ return(self->f->icEqualCArray(self, p2));
}
bool icEqualSmallArrayBaseG(smallArrayt* self, baset* p2) {
@@ -13411,7 +13900,7 @@ bool hasArraycSmallArrayG (smallArrayt *self, char **array) {
bool hasCArraycSmallArrayG (smallArrayt *self, const char **array) {
- return(self->f->hasArrayc(self,(char**)array));
+ return(self->f->hasCArrayc(self,array));
}
bool hasSmallBoolSmallArrayG (smallArrayt *self, smallBoolt *value) {
@@ -13501,7 +13990,7 @@ ssize_t indexOfArraycSmallArrayG (smallArrayt *self, char **array) {
ssize_t indexOfCArraycSmallArrayG (smallArrayt *self, const char **array) {
- return(self->f->indexOfArrayc(self,(char**)array));
+ return(self->f->indexOfCArrayc(self,array));
}
ssize_t indexOfSmallBoolSmallArrayG (smallArrayt *self, smallBoolt *value) {
@@ -13591,7 +14080,7 @@ ssize_t binarySearchArraycSmallArrayG (smallArrayt *self, char **array) {
ssize_t binarySearchCArraycSmallArrayG (smallArrayt *self, const char **array) {
- return(self->f->binarySearchArrayc(self,(char**)array));
+ return(self->f->binarySearchCArrayc(self,array));
}
ssize_t binarySearchSmallBoolSmallArrayG (smallArrayt *self, smallBoolt *value) {
@@ -13666,7 +14155,7 @@ bool icHasArraycSmallArrayG (smallArrayt *self, char **array) {
bool icHasCArraycSmallArrayG (smallArrayt *self, const char **array) {
- return(self->f->icHasArrayc(self,(char**)array));
+ return(self->f->icHasCArrayc(self,array));
}
bool icHasSmallJsonSmallArrayG (smallArrayt *self, smallJsont *string) {
@@ -13711,7 +14200,7 @@ ssize_t icIndexOfArraycSmallArrayG (smallArrayt *self, char **array) {
ssize_t icIndexOfCArraycSmallArrayG (smallArrayt *self, const char **array) {
- return(self->f->icIndexOfArrayc(self,(char**)array));
+ return(self->f->icIndexOfCArrayc(self,array));
}
ssize_t icIndexOfSmallJsonSmallArrayG (smallArrayt *self, smallJsont *string) {
@@ -13756,7 +14245,7 @@ ssize_t icBinarySearchArraycSmallArrayG (smallArrayt *self, char **array) {
ssize_t icBinarySearchCArraycSmallArrayG (smallArrayt *self, const char **array) {
- return(self->f->icBinarySearchArrayc(self,(char**)array));
+ return(self->f->icBinarySearchCArrayc(self,array));
}
ssize_t icBinarySearchSmallJsonSmallArrayG (smallArrayt *self, smallJsont *string) {
diff --git a/src/json/libsheepyCSmallArray.h b/src/json/libsheepyCSmallArray.h
@@ -116,6 +116,7 @@ typedef smallArrayt* (*mirrorSmallArrayFt) (smallArrayt *self);
* NULL when array is NULL
*/
typedef smallArrayt* (*fromArraySmallArrayFt)(smallArrayt *self, char **array, size_t size);
+typedef smallArrayt* (*fromCArraySmallArrayFt)(smallArrayt *self, const char **array, size_t size);
typedef smallArrayt* (*fromArrayNFreeSmallArrayFt)(smallArrayt *self, char **array, size_t size);
/**
@@ -154,6 +155,7 @@ typedef smallArrayt* (*pushCharSmallArrayFt) (smallArrayt
typedef smallArrayt* (*pushDictSmallArrayFt) (smallArrayt *self, smallDictt *dict);
typedef smallArrayt* (*pushArraySmallArrayFt) (smallArrayt *self, smallArrayt *array);
typedef smallArrayt* (*pushArraycSmallArrayFt) (smallArrayt *self, char **array);
+typedef smallArrayt* (*pushCArraycSmallArrayFt) (smallArrayt *self, const char **array);
typedef smallArrayt* (*pushSmallBoolSmallArrayFt) (smallArrayt *self, smallBoolt *value);
typedef smallArrayt* (*pushSmallBytesSmallArrayFt) (smallArrayt *self, smallBytest *value);
typedef smallArrayt* (*pushSmallDoubleSmallArrayFt) (smallArrayt *self, smallDoublet *value);
@@ -293,6 +295,7 @@ typedef smallArrayt* (*prependCharSmallArrayFt) (smallAr
typedef smallArrayt* (*prependDictSmallArrayFt) (smallArrayt *self, smallDictt *dict);
typedef smallArrayt* (*prependArraySmallArrayFt) (smallArrayt *self, smallArrayt *array);
typedef smallArrayt* (*prependArraycSmallArrayFt) (smallArrayt *self, char **array);
+typedef smallArrayt* (*prependCArraycSmallArrayFt) (smallArrayt *self, const char **array);
typedef smallArrayt* (*prependSmallBoolSmallArrayFt) (smallArrayt *self, smallBoolt *value);
typedef smallArrayt* (*prependSmallBytesSmallArrayFt) (smallArrayt *self, smallBytest *value);
typedef smallArrayt* (*prependSmallDoubleSmallArrayFt) (smallArrayt *self, smallDoublet *value);
@@ -396,6 +399,7 @@ typedef smallArrayt* (*appendSmallJsonSmallArrayFt) (smallArrayt *
typedef smallArrayt* (*appendNSmashSmallArrayFt) (smallArrayt *self, smallArrayt *array);
typedef smallArrayt* (*appendNSmashSmallJsonSmallArrayFt)(smallArrayt *self, smallJsont *json);
typedef smallArrayt* (*appendArraySmallArrayFt) (smallArrayt *self, char **array);
+typedef smallArrayt* (*appendCArraySmallArrayFt) (smallArrayt *self, const char **array);
typedef smallArrayt* (*appendNSmashArraySmallArrayFt) (smallArrayt *self, char **array);
/**
@@ -565,6 +569,7 @@ typedef smallArrayt* (*injectCharSmallArrayFt) (smallArrayt *self, int64_t i
typedef smallArrayt* (*injectDictSmallArrayFt) (smallArrayt *self, int64_t index, smallDictt *toInject);
typedef smallArrayt* (*injectArraySmallArrayFt) (smallArrayt *self, int64_t index, smallArrayt *toInject);
typedef smallArrayt* (*injectArraycSmallArrayFt) (smallArrayt *self, int64_t index, char **toInject);
+typedef smallArrayt* (*injectCArraycSmallArrayFt) (smallArrayt *self, int64_t index, const char **toInject);
typedef smallArrayt* (*injectSmallBoolSmallArrayFt) (smallArrayt *self, int64_t index, smallBoolt *toInject);
typedef smallArrayt* (*injectSmallBytesSmallArrayFt) (smallArrayt *self, int64_t index, smallBytest *toInject);
typedef smallArrayt* (*injectSmallDoubleSmallArrayFt) (smallArrayt *self, int64_t index, smallDoublet *toInject);
@@ -711,6 +716,7 @@ typedef smallArrayt* (*icSortSmallArrayFt) (smallArrayt *self);
typedef bool (*equalSmallArrayFt) (smallArrayt *self, smallArrayt *array);
typedef bool (*equalSmallArraySmallJsonFt)(smallArrayt *self, smallJsont *array);
typedef bool (*equalSmallArrayArrayFt) (smallArrayt* self, char ** p2);
+typedef bool (*equalSmallArrayCArrayFt) (smallArrayt* self, const char ** p2);
typedef bool (*equalSmallArrayBaseFt) (smallArrayt* self, baset* p2);
/**
@@ -725,6 +731,7 @@ typedef bool (*equalSmallArrayBaseFt) (smallArrayt* self, baset* p2
typedef bool (*icEqualSmallArrayFt) (smallArrayt *self, smallArrayt *array);
typedef bool (*icEqualSmallArraySmallJsonFt)(smallArrayt *self, smallJsont *array);
typedef bool (*icEqualSmallArrayArrayFt) (smallArrayt* self, char ** p2);
+typedef bool (*icEqualSmallArrayCArrayFt) (smallArrayt* self, const char ** p2);
typedef bool (*icEqualSmallArrayBaseFt) (smallArrayt* self, baset* p2);
/**
@@ -846,6 +853,7 @@ typedef smallArrayt* (*setAtCharSmallArrayFt) (smallArrayt *self, in
typedef smallArrayt* (*setAtDictSmallArrayFt) (smallArrayt *self, int64_t index, smallDictt *dict);
typedef smallArrayt* (*setAtArraySmallArrayFt) (smallArrayt *self, int64_t index, smallArrayt *array);
typedef smallArrayt* (*setAtArraycSmallArrayFt) (smallArrayt *self, int64_t index, char **array);
+typedef smallArrayt* (*setAtCArraycSmallArrayFt) (smallArrayt *self, int64_t index, const char **array);
typedef smallArrayt* (*setAtSmallBoolSmallArrayFt) (smallArrayt *self, int64_t index, smallBoolt *value);
typedef smallArrayt* (*setAtSmallBytesSmallArrayFt) (smallArrayt *self, int64_t index, smallBytest *value);
typedef smallArrayt* (*setAtSmallDoubleSmallArrayFt) (smallArrayt *self, int64_t index, smallDoublet *value);
@@ -939,6 +947,7 @@ typedef bool (*hasCharSmallArrayFt) (smallArrayt *self, char c);
typedef bool (*hasDictSmallArrayFt) (smallArrayt *self, smallDictt *dict);
typedef bool (*hasArraySmallArrayFt) (smallArrayt *self, smallArrayt *array);
typedef bool (*hasArraycSmallArrayFt) (smallArrayt *self, char **array);
+typedef bool (*hasCArraycSmallArrayFt) (smallArrayt *self, const char **array);
typedef bool (*hasSmallBoolSmallArrayFt) (smallArrayt *self, smallBoolt *value);
typedef bool (*hasSmallBytesSmallArrayFt) (smallArrayt *self, smallBytest *value);
typedef bool (*hasSmallDoubleSmallArrayFt) (smallArrayt *self, smallDoublet *value);
@@ -967,6 +976,7 @@ typedef ssize_t (*indexOfCharSmallArrayFt) (smallArrayt *self, char c)
typedef ssize_t (*indexOfDictSmallArrayFt) (smallArrayt *self, smallDictt *dict);
typedef ssize_t (*indexOfArraySmallArrayFt) (smallArrayt *self, smallArrayt *array);
typedef ssize_t (*indexOfArraycSmallArrayFt) (smallArrayt *self, char **array);
+typedef ssize_t (*indexOfCArraycSmallArrayFt) (smallArrayt *self, const char **array);
typedef ssize_t (*indexOfSmallBoolSmallArrayFt) (smallArrayt *self, smallBoolt *value);
typedef ssize_t (*indexOfSmallBytesSmallArrayFt) (smallArrayt *self, smallBytest *value);
typedef ssize_t (*indexOfSmallDoubleSmallArrayFt) (smallArrayt *self, smallDoublet *value);
@@ -995,6 +1005,7 @@ typedef ssize_t (*binarySearchCharSmallArrayFt) (smallArrayt *self, ch
typedef ssize_t (*binarySearchDictSmallArrayFt) (smallArrayt *self, smallDictt *dict);
typedef ssize_t (*binarySearchArraySmallArrayFt) (smallArrayt *self, smallArrayt *array);
typedef ssize_t (*binarySearchArraycSmallArrayFt) (smallArrayt *self, char **array);
+typedef ssize_t (*binarySearchCArraycSmallArrayFt) (smallArrayt *self, const char **array);
typedef ssize_t (*binarySearchSmallBoolSmallArrayFt) (smallArrayt *self, smallBoolt *value);
typedef ssize_t (*binarySearchSmallBytesSmallArrayFt) (smallArrayt *self, smallBytest *value);
typedef ssize_t (*binarySearchSmallDoubleSmallArrayFt) (smallArrayt *self, smallDoublet *value);
@@ -1029,6 +1040,7 @@ typedef bool (*icHasCharSmallArrayFt) (smallArrayt *self, char c);
typedef bool (*icHasDictSmallArrayFt) (smallArrayt *self, smallDictt *dict);
typedef bool (*icHasArraySmallArrayFt) (smallArrayt *self, smallArrayt *array);
typedef bool (*icHasArraycSmallArrayFt) (smallArrayt *self, char **array);
+typedef bool (*icHasCArraycSmallArrayFt) (smallArrayt *self, const char **array);
typedef bool (*icHasSmallJsonSmallArrayFt) (smallArrayt *self, smallJsont *string);
typedef bool (*icHasSmallStringSmallArrayFt)(smallArrayt *self, smallStringt *string);
@@ -1048,6 +1060,7 @@ typedef ssize_t (*icIndexOfCharSmallArrayFt) (smallArrayt *self, cha
typedef ssize_t (*icIndexOfDictSmallArrayFt) (smallArrayt *self, smallDictt *dict);
typedef ssize_t (*icIndexOfArraySmallArrayFt) (smallArrayt *self, smallArrayt *array);
typedef ssize_t (*icIndexOfArraycSmallArrayFt) (smallArrayt *self, char **array);
+typedef ssize_t (*icIndexOfCArraycSmallArrayFt) (smallArrayt *self, const char **array);
typedef ssize_t (*icIndexOfSmallJsonSmallArrayFt) (smallArrayt *self, smallJsont *string);
typedef ssize_t (*icIndexOfSmallStringSmallArrayFt)(smallArrayt *self, smallStringt *string);
@@ -1067,6 +1080,7 @@ typedef ssize_t (*icBinarySearchCharSmallArrayFt) (smallArrayt *self
typedef ssize_t (*icBinarySearchDictSmallArrayFt) (smallArrayt *self, smallDictt *dict);
typedef ssize_t (*icBinarySearchArraySmallArrayFt) (smallArrayt *self, smallArrayt *array);
typedef ssize_t (*icBinarySearchArraycSmallArrayFt) (smallArrayt *self, char **array);
+typedef ssize_t (*icBinarySearchCArraycSmallArrayFt) (smallArrayt *self, const char **array);
typedef ssize_t (*icBinarySearchSmallJsonSmallArrayFt) (smallArrayt *self, smallJsont *string);
typedef ssize_t (*icBinarySearchSmallStringSmallArrayFt)(smallArrayt *self, smallStringt *string);
@@ -1344,7 +1358,7 @@ typedef char (*typeSmallArrayFt) (smallArrayt *self, int64_t index
* \return
* list of object type strings
*/
-typedef char** (*typeStringsSmallArrayFt)(smallArrayt *self);
+typedef const char** (*typeStringsSmallArrayFt)(smallArrayt *self);
typedef smallArrayt* (*typeSmallStringsSmallArrayFt)(smallArrayt *self);
/**
@@ -1411,6 +1425,7 @@ typedef bool (*areAllEBytesSmallArrayFt) (smallArrayt *self);
getAtNDupSmallArrayFt getNDup;\
setAtSmallArrayFt set;\
fromArraySmallArrayFt fromArray;\
+ fromCArraySmallArrayFt fromCArray;\
fromArrayNFreeSmallArrayFt fromArrayNFree;\
pushSmallArrayFt push;\
pushUndefinedSmallArrayFt pushUndefined;\
@@ -1422,6 +1437,7 @@ typedef bool (*areAllEBytesSmallArrayFt) (smallArrayt *self);
pushDictSmallArrayFt pushDict;\
pushArraySmallArrayFt pushArray;\
pushArraycSmallArrayFt pushArrayc;\
+ pushCArraycSmallArrayFt pushCArrayc;\
pushSmallBoolSmallArrayFt pushSmallBool;\
pushSmallBytesSmallArrayFt pushSmallBytes;\
pushSmallDoubleSmallArrayFt pushSmallDouble;\
@@ -1476,6 +1492,7 @@ typedef bool (*areAllEBytesSmallArrayFt) (smallArrayt *self);
prependDictSmallArrayFt prependDict;\
prependArraySmallArrayFt prependArray;\
prependArraycSmallArrayFt prependArrayc;\
+ prependCArraycSmallArrayFt prependCArrayc;\
prependSmallBoolSmallArrayFt prependSmallBool;\
prependSmallBytesSmallArrayFt prependSmallBytes;\
prependSmallDoubleSmallArrayFt prependSmallDouble;\
@@ -1523,6 +1540,7 @@ typedef bool (*areAllEBytesSmallArrayFt) (smallArrayt *self);
appendNSmashSmallArrayFt appendNSmash;\
appendNSmashSmallJsonSmallArrayFt appendNSmashSmallJson;\
appendArraySmallArrayFt appendArray;\
+ appendCArraySmallArrayFt appendCArray;\
appendNSmashArraySmallArrayFt appendNSmashArray;\
shiftSmallArrayFt shift;\
shiftSmallJsonSmallArrayFt shiftSmallJson;\
@@ -1565,6 +1583,7 @@ typedef bool (*areAllEBytesSmallArrayFt) (smallArrayt *self);
injectDictSmallArrayFt injectDict;\
injectArraySmallArrayFt injectArray;\
injectArraycSmallArrayFt injectArrayc;\
+ injectCArraycSmallArrayFt injectCArrayc;\
injectSmallBoolSmallArrayFt injectSmallBool;\
injectSmallBytesSmallArrayFt injectSmallBytes;\
injectSmallDoubleSmallArrayFt injectSmallDouble;\
@@ -1595,10 +1614,12 @@ typedef bool (*areAllEBytesSmallArrayFt) (smallArrayt *self);
equalSmallArrayFt equal;\
equalSmallArraySmallJsonFt equalSmallJson;\
equalSmallArrayArrayFt equalArray;\
+ equalSmallArrayCArrayFt equalCArray;\
equalSmallArrayBaseFt equalBase;\
icEqualSmallArrayFt icEqual;\
icEqualSmallArraySmallJsonFt icEqualSmallJson;\
icEqualSmallArrayArrayFt icEqualArray;\
+ icEqualSmallArrayCArrayFt icEqualCArray;\
icEqualSmallArrayBaseFt icEqualBase;\
lenSmallArrayFt len;\
trimSmallArrayFt trim;\
@@ -1656,6 +1677,7 @@ typedef bool (*areAllEBytesSmallArrayFt) (smallArrayt *self);
setAtDictSmallArrayFt setAtDict;\
setAtArraySmallArrayFt setAtArray;\
setAtArraycSmallArrayFt setAtArrayc;\
+ setAtCArraycSmallArrayFt setAtCArrayc;\
setAtSmallBoolSmallArrayFt setAtSmallBool;\
setAtSmallBytesSmallArrayFt setAtSmallBytes;\
setAtSmallDoubleSmallArrayFt setAtSmallDouble;\
@@ -1695,6 +1717,7 @@ typedef bool (*areAllEBytesSmallArrayFt) (smallArrayt *self);
hasDictSmallArrayFt hasDict;\
hasArraySmallArrayFt hasArray;\
hasArraycSmallArrayFt hasArrayc;\
+ hasCArraycSmallArrayFt hasCArrayc;\
hasSmallBoolSmallArrayFt hasSmallBool;\
hasSmallBytesSmallArrayFt hasSmallBytes;\
hasSmallDoubleSmallArrayFt hasSmallDouble;\
@@ -1712,6 +1735,7 @@ typedef bool (*areAllEBytesSmallArrayFt) (smallArrayt *self);
indexOfDictSmallArrayFt indexOfDict;\
indexOfArraySmallArrayFt indexOfArray;\
indexOfArraycSmallArrayFt indexOfArrayc;\
+ indexOfCArraycSmallArrayFt indexOfCArrayc;\
indexOfSmallBoolSmallArrayFt indexOfSmallBool;\
indexOfSmallBytesSmallArrayFt indexOfSmallBytes;\
indexOfSmallDoubleSmallArrayFt indexOfSmallDouble;\
@@ -1729,6 +1753,7 @@ typedef bool (*areAllEBytesSmallArrayFt) (smallArrayt *self);
binarySearchDictSmallArrayFt binarySearchDict;\
binarySearchArraySmallArrayFt binarySearchArray;\
binarySearchArraycSmallArrayFt binarySearchArrayc;\
+ binarySearchCArraycSmallArrayFt binarySearchCArrayc;\
binarySearchSmallBoolSmallArrayFt binarySearchSmallBool;\
binarySearchSmallBytesSmallArrayFt binarySearchSmallBytes;\
binarySearchSmallDoubleSmallArrayFt binarySearchSmallDouble;\
@@ -1743,6 +1768,7 @@ typedef bool (*areAllEBytesSmallArrayFt) (smallArrayt *self);
icHasDictSmallArrayFt icHasDict;\
icHasArraySmallArrayFt icHasArray;\
icHasArraycSmallArrayFt icHasArrayc;\
+ icHasCArraycSmallArrayFt icHasCArrayc;\
icHasSmallJsonSmallArrayFt icHasSmallJson;\
icHasSmallStringSmallArrayFt icHasSmallString;\
icIndexOfSmallArrayFt icIndexOf;\
@@ -1751,6 +1777,7 @@ typedef bool (*areAllEBytesSmallArrayFt) (smallArrayt *self);
icIndexOfDictSmallArrayFt icIndexOfDict;\
icIndexOfArraySmallArrayFt icIndexOfArray;\
icIndexOfArraycSmallArrayFt icIndexOfArrayc;\
+ icIndexOfCArraycSmallArrayFt icIndexOfCArrayc;\
icIndexOfSmallJsonSmallArrayFt icIndexOfSmallJson;\
icIndexOfSmallStringSmallArrayFt icIndexOfSmallString;\
icBinarySearchSmallArrayFt icBinarySearch;\
@@ -1759,6 +1786,7 @@ typedef bool (*areAllEBytesSmallArrayFt) (smallArrayt *self);
icBinarySearchDictSmallArrayFt icBinarySearchDict;\
icBinarySearchArraySmallArrayFt icBinarySearchArray;\
icBinarySearchArraycSmallArrayFt icBinarySearchArrayc;\
+ icBinarySearchCArraycSmallArrayFt icBinarySearchCArrayc;\
icBinarySearchSmallJsonSmallArrayFt icBinarySearchSmallJson;\
icBinarySearchSmallStringSmallArrayFt icBinarySearchSmallString;\
icUniqSmallArrayFt icUniq;\
@@ -2219,7 +2247,7 @@ smallArrayt* injectCharSmallArrayG(smallArrayt *self, int64_t index, char c);
smallArrayt* injectDictSmallArrayG (smallArrayt *self, int64_t index, smallDictt *dict);
smallArrayt* injectArraySmallArrayG (smallArrayt *self, int64_t index, smallArrayt *array);
smallArrayt* injectArraycSmallArrayG (smallArrayt *self, int64_t index, char **array);
-smallArrayt* injectCArraycSmallArrayG (smallArrayt *self, int64_t index, const char **array);
+smallArrayt* injectCArraycSmallArrayG (smallArrayt *self, int64_t index, const char **array);
smallArrayt* injectVoidSmallArrayG (smallArrayt *self, int64_t index, void *value);
smallArrayt* injectSmallBoolSmallArrayG (smallArrayt *self, int64_t index, smallBoolt *value);
smallArrayt* injectSmallBytesSmallArrayG (smallArrayt *self, int64_t index, smallBytest *value);
@@ -2393,7 +2421,7 @@ smallArrayt* typeSmallStringsSmallArrayG(smallArrayt *self);
*/
#define forEachSmallArray(array, element) \
size_t UNIQVAR(libsheepyInternalIndex) = 0; \
- for (baset *element = array->f->getAt(array, 0); UNIQVAR(libsheepyInternalIndex) < array->f->len(array) ; UNIQVAR(libsheepyInternalIndex)++, element = array->f->getAt(array, UNIQVAR(libsheepyInternalIndex))) \
+ for (baset *element = array->f->getAt(array, 0); UNIQVAR(libsheepyInternalIndex) < array->f->len(array) ; UNIQVAR(libsheepyInternalIndex)++, element = array->f->getAt(array, (int64_t)UNIQVAR(libsheepyInternalIndex))) \
if (element)
/**
@@ -2413,7 +2441,7 @@ smallArrayt* typeSmallStringsSmallArrayG(smallArrayt *self);
*/
#define enumerateSmallArray(array, element, index) \
size_t index = 0; \
- for (baset *element = array->f->getAt(array, 0); index < array->f->len(array) ; index++, element = array->f->getAt(array, index)) \
+ for (baset *element = array->f->getAt(array, 0); index < array->f->len(array) ; index++, element = array->f->getAt(array, (int64_t)index)) \
if (element)
/**
@@ -2424,7 +2452,7 @@ smallArrayt* typeSmallStringsSmallArrayG(smallArrayt *self);
*/
#define enumerateTypeSmallArray(type, array, element, index) \
size_t index = 0; \
- for (type element = getG(array, type, 0); index < array->f->len(array) ; index++, element = getG(array, type, index)) \
+ for (type element = getG(array, type, 0); index < array->f->len(array) ; index++, element = getG(array, type, (int64_t)index)) \
if (element)
// end class smallArray
diff --git a/src/json/libsheepyCSmallBytes.c b/src/json/libsheepyCSmallBytes.c
@@ -375,23 +375,24 @@ internal smallBytest* readFileSmallBytes(smallBytest *self, const char *filePath
}
len = fileSize(filePath);;
+ // TODO check that len is less than 4GB because sBytes can hold 4GB at most
if (len == -1) {
return(NULL);
}
freeSmallBytes(self);
- void *buffer = malloc(len);
+ void *buffer = malloc((size_t)len);
if (!buffer) {
return(NULL);
}
f = fopen(filePath, "r");
- readStatus = fread(buffer, 1, len , f);
+ readStatus = fread(buffer, 1, (size_t)len , f);
fclose(f);
// readStatus == len when ok
- pushBufferSmallBytes(self, buffer, readStatus);
+ pushBufferSmallBytes(self, buffer, (uint32_t)readStatus);
// pushBuffer copies the buffer, buffer is not used anymore, free it
free(buffer);
@@ -447,21 +448,22 @@ internal smallBytest* readStreamSmallBytes(smallBytest *self, FILE *fp) {
}
len = fileSizeFP(fp);
+ // TODO check that len is less than 4GB because sBytes can hold 4GB at most
if (len == -1) {
return(NULL);
}
freeSmallBytes(self);
- void *buffer = malloc(len);
+ void *buffer = malloc((size_t)len);
if (!buffer) {
return(NULL);
}
- readStatus = fread(buffer, 1, len , fp);
+ readStatus = fread(buffer, 1, (size_t)len , fp);
// readStatus == len when ok
- pushBufferSmallBytes(self, buffer, readStatus);
+ pushBufferSmallBytes(self, buffer, (uint32_t)readStatus);
// pushBuffer copies the buffer, buffer is not used anymore, free it
free(buffer);
@@ -705,7 +707,7 @@ internal bool equalSmallBytesInt32(smallBytest *self, int32_t value) {
return(false);
}
- int32_t val = parseInt(s);
+ int32_t val = (int32_t)parseInt(s);
return(val == value);;
}
@@ -734,7 +736,7 @@ internal bool equalSmallBytesUint32(smallBytest *self, uint32_t value) {
return(false);
}
- uint32_t val = parseInt(s);
+ uint32_t val = (uint32_t)parseInt(s);
return(val == value);;
}
@@ -763,7 +765,7 @@ internal bool equalSmallBytesUint64(smallBytest *self, uint64_t value) {
return(false);
}
- uint64_t val = parseInt(s);
+ uint64_t val = (uint64_t)parseInt(s);
return(val == value);;
}
diff --git a/src/json/libsheepyCSmallDict.c b/src/json/libsheepyCSmallDict.c
@@ -71,6 +71,7 @@ internal smallDictt* setCharSmallDict(smallDictt *self, const char *key, char c)
internal smallDictt* setDictSmallDict(smallDictt *self, const char *key, smallDictt *dict);
internal smallDictt* setArraySmallDict(smallDictt *self, const char *key, smallArrayt *array);
internal smallDictt* setArraycSmallDict(smallDictt *self, const char *key, char **array);
+internal smallDictt* setCArraycSmallDict(smallDictt *self, const char *key, const char **array);
internal smallDictt* setSmallBoolSmallDict(smallDictt *self, const char *key, smallBoolt *value);
internal smallDictt* setSmallBytesSmallDict(smallDictt *self, const char *key, smallBytest *value);
internal smallDictt* setSmallDoubleSmallDict(smallDictt *self, const char *key, smallDoublet *value);
@@ -88,6 +89,7 @@ internal smallDictt* setCharKCharSmallDict(smallDictt *self, char key, char c);
internal smallDictt* setDictKCharSmallDict(smallDictt *self, char key, smallDictt *dict);
internal smallDictt* setArrayKCharSmallDict(smallDictt *self, char key, smallArrayt *array);
internal smallDictt* setArraycKCharSmallDict(smallDictt *self, char key, char **array);
+internal smallDictt* setCArraycKCharSmallDict(smallDictt *self, char key, const char **array);
internal smallDictt* setSmallBoolKCharSmallDict(smallDictt *self, char key, smallBoolt *value);
internal smallDictt* setSmallBytesKCharSmallDict(smallDictt *self, char key, smallBytest *value);
internal smallDictt* setSmallDoubleKCharSmallDict(smallDictt *self, char key, smallDoublet *value);
@@ -96,7 +98,7 @@ internal smallDictt* setSmallJsonKCharSmallDict(smallDictt *self, char key, smal
internal smallDictt* setSmallStringKCharSmallDict(smallDictt *self, char key, smallStringt *string);
internal smallDictt* setSmallContainerKCharSmallDict(smallDictt *self, char key, smallContainert *container);
internal smallDictt* setNFreeSmallDict(smallDictt *self, const char *key, baset *value);
-internal smallDictt* setNFreeUndefinedSmallDict(smallDictt *self, const char *key, undefinedt *undefined);
+internal smallDictt* setNFreeUndefinedSmallDict(smallDictt *self, const char *key, undefinedt *u);
internal smallDictt* setNFreeSSmallDict(smallDictt *self, const char *key, char *string);
internal smallDictt* setNFreeDictSmallDict(smallDictt *self, const char *key, smallDictt *dict);
internal smallDictt* setNFreeArraySmallDict(smallDictt *self, const char *key, smallArrayt *array);
@@ -109,7 +111,7 @@ internal smallDictt* setNFreeSmallJsonSmallDict(smallDictt *self, const char *ke
internal smallDictt* setNFreeSmallStringSmallDict(smallDictt *self, const char *key, smallStringt *string);
internal smallDictt* setNFreeSmallContainerSmallDict(smallDictt *self, const char *key, smallContainert *container);
internal smallDictt* setNFreeKCharSmallDict(smallDictt *self, char key, baset *value);
-internal smallDictt* setNFreeUndefinedKCharSmallDict(smallDictt *self, char key, undefinedt *undefined);
+internal smallDictt* setNFreeUndefinedKCharSmallDict(smallDictt *self, char key, undefinedt *u);
internal smallDictt* setNFreeSKCharSmallDict(smallDictt *self, char key, char *string);
internal smallDictt* setNFreeDictKCharSmallDict(smallDictt *self, char key, smallDictt *dict);
internal smallDictt* setNFreeArrayKCharSmallDict(smallDictt *self, char key, smallArrayt *array);
@@ -226,25 +228,25 @@ internal smallStringt* getNDupSmallStringKCharSmallDict(smallDictt *self, char k
internal void* getNDupVoidKCharSmallDict(smallDictt *self, char key);
internal smallContainert* getNDupSmallContainerKCharSmallDict(smallDictt *self, char key);
internal double getNumSmallDict(smallDictt *self, const char *key);
-internal baset* cropElemSmallDict(smallDictt *self, char* key);
-internal undefinedt* cropElemUndefinedSmallDict(smallDictt *self, char* key);
-internal bool cropElemBoolSmallDict(smallDictt *self, char* key);
-internal double cropElemDoubleSmallDict(smallDictt *self, char* key);
-internal int64_t cropElemIntSmallDict(smallDictt *self, char* key);
-internal int32_t cropElemInt32SmallDict(smallDictt *self, char* key);
-internal uint64_t cropElemUintSmallDict(smallDictt *self, char* key);
-internal uint32_t cropElemUint32SmallDict(smallDictt *self, char* key);
-internal char* cropElemSSmallDict(smallDictt *self, char* key);
-internal smallDictt* cropElemDictSmallDict(smallDictt *self, char* key);
-internal smallArrayt* cropElemArraySmallDict(smallDictt *self, char* key);
-internal smallBoolt* cropElemSmallBoolSmallDict(smallDictt *self, char* key);
-internal smallBytest* cropElemSmallBytesSmallDict(smallDictt *self, char* key);
-internal smallDoublet* cropElemSmallDoubleSmallDict(smallDictt *self, char* key);
-internal smallIntt* cropElemSmallIntSmallDict(smallDictt *self, char* key);
-internal smallJsont* cropElemSmallJsonSmallDict(smallDictt *self, char* key);
-internal smallStringt* cropElemSmallStringSmallDict(smallDictt *self, char* key);
-internal void* cropElemVoidSmallDict(smallDictt *self, char* key);
-internal smallContainert* cropElemSmallContainerSmallDict(smallDictt *self, char* key);
+internal baset* cropElemSmallDict(smallDictt *self, const char* key);
+internal undefinedt* cropElemUndefinedSmallDict(smallDictt *self, const char* key);
+internal bool cropElemBoolSmallDict(smallDictt *self, const char* key);
+internal double cropElemDoubleSmallDict(smallDictt *self, const char* key);
+internal int64_t cropElemIntSmallDict(smallDictt *self, const char* key);
+internal int32_t cropElemInt32SmallDict(smallDictt *self, const char* key);
+internal uint64_t cropElemUintSmallDict(smallDictt *self, const char* key);
+internal uint32_t cropElemUint32SmallDict(smallDictt *self, const char* key);
+internal char* cropElemSSmallDict(smallDictt *self, const char* key);
+internal smallDictt* cropElemDictSmallDict(smallDictt *self, const char* key);
+internal smallArrayt* cropElemArraySmallDict(smallDictt *self, const char* key);
+internal smallBoolt* cropElemSmallBoolSmallDict(smallDictt *self, const char* key);
+internal smallBytest* cropElemSmallBytesSmallDict(smallDictt *self, const char* key);
+internal smallDoublet* cropElemSmallDoubleSmallDict(smallDictt *self, const char* key);
+internal smallIntt* cropElemSmallIntSmallDict(smallDictt *self, const char* key);
+internal smallJsont* cropElemSmallJsonSmallDict(smallDictt *self, const char* key);
+internal smallStringt* cropElemSmallStringSmallDict(smallDictt *self, const char* key);
+internal void* cropElemVoidSmallDict(smallDictt *self, const char* key);
+internal smallContainert* cropElemSmallContainerSmallDict(smallDictt *self, const char* key);
internal smallDictt* delSmallDict(smallDictt *self, const char *key);
internal smallDictt* delKCharSmallDict(smallDictt *self, char key);
internal smallDictt* removeSmallDict(smallDictt *self, const char *key);
@@ -252,7 +254,7 @@ internal smallDictt* removeKCharSmallDict(smallDictt *self, char key);
internal bool hasSmallDict(smallDictt *self, const char *key);
internal bool hasKCharSmallDict(smallDictt *self, char key);
internal char* keyBySmallDict(smallDictt *self, baset *value);
-internal char* keyByUndefinedSmallDict(smallDictt *self, undefinedt *undefined);
+internal char* keyByUndefinedSmallDict(smallDictt *self, undefinedt *u);
internal char* keyByBoolSmallDict(smallDictt *self, bool value);
internal char* keyByDoubleSmallDict(smallDictt *self, double value);
internal char* keyByIntSmallDict(smallDictt *self, int64_t value);
@@ -261,6 +263,7 @@ internal char* keyByCharSmallDict(smallDictt *self, char c);
internal char* keyByDictSmallDict(smallDictt *self, smallDictt *dict);
internal char* keyByArraySmallDict(smallDictt *self, smallArrayt *array);
internal char* keyByArraycSmallDict(smallDictt *self, char **array);
+internal char* keyByCArraycSmallDict(smallDictt *self, const char **array);
internal char* keyBySmallBoolSmallDict(smallDictt *self, smallBoolt *value);
internal char* keyBySmallBytesSmallDict(smallDictt *self, smallBytest *value);
internal char* keyBySmallDoubleSmallDict(smallDictt *self, smallDoublet *value);
@@ -274,6 +277,7 @@ internal char* icKeyByCharSmallDict(smallDictt *self, char c);
internal char* icKeyByDictSmallDict(smallDictt *self, smallDictt *dict);
internal char* icKeyByArraySmallDict(smallDictt *self, smallArrayt *array);
internal char* icKeyByArraycSmallDict(smallDictt *self, char **array);
+internal char* icKeyByCArraycSmallDict(smallDictt *self, const char **array);
internal char* icKeyBySmallJsonSmallDict(smallDictt *self, smallJsont *string);
internal char* icKeyBySmallStringSmallDict(smallDictt *self, smallStringt *string);
internal smallDictt* trimSmallDict(smallDictt *self);
@@ -307,10 +311,17 @@ internal smallDictt* zipSmallJsonSmallDict(smallDictt *self, smallArrayt *keys,
internal smallDictt* zipSmallJsonSmallArraySmallDict(smallDictt *self, smallJsont *keys, smallArrayt *values);
internal smallDictt* zipSmallJsonSmallJsonSmallDict(smallDictt *self, smallJsont *keys, smallJsont *values);
internal smallDictt* zipSmallJsonVArraySmallDict(smallDictt *self, smallJsont *keys, char** values);
+internal smallDictt* zipSmallJsonVCArraySmallDict(smallDictt *self, smallJsont *keys, const char** values);
internal smallDictt* zipArraySmallDict(smallDictt *self, char** keys, smallArrayt *values);
+internal smallDictt* zipCArraySmallDict(smallDictt *self, const char** keys, smallArrayt *values);
internal smallDictt* zipArraySmallJsonSmallDict(smallDictt *self, char** keys, smallJsont *values);
+internal smallDictt* zipCArraySmallJsonSmallDict(smallDictt *self, const char** keys, smallJsont *values);
internal smallDictt* zipArrayArraySmallDict(smallDictt *self, char** keys, char** values);
+internal smallDictt* zipCArrayArraySmallDict(smallDictt *self, const char** keys, char** values);
+internal smallDictt* zipArrayCArraySmallDict(smallDictt *self, char** keys, const char** values);
+internal smallDictt* zipCArrayCArraySmallDict(smallDictt *self, const char** keys, const char** values);
internal smallDictt* zipVArraySmallDict(smallDictt *self, smallArrayt *keys, char** values);
+internal smallDictt* zipVCArraySmallDict(smallDictt *self, smallArrayt *keys, const char** values);
internal smallDictt* fromArraySmallDict(smallDictt *self, smallArrayt *items);
internal smallArrayt* toArraySmallDict(smallDictt *self);
internal bool writeFileSmallDict(smallDictt *self, const char *filePath);
@@ -491,7 +502,7 @@ smallDictt* setNFreeSmallJsonSmallDictG(smallDictt *self, const char *key, small
smallDictt* setNFreeSmallStringSmallDictG (smallDictt *self, const char *key, smallStringt *string);
smallDictt* setNFreeSmallContainerSmallDictG(smallDictt *self, const char *key, smallContainert *container);
smallDictt* setNFreeKCharSmallDictG (smallDictt *self, char key, baset *value);
-smallDictt* setNFreeUndefinedKCharSmallDictG(smallDictt *self, char key, undefinedt *undefined);
+smallDictt* setNFreeUndefinedKCharSmallDictG(smallDictt *self, char key, undefinedt *u);
smallDictt* setNFreeSKCharSmallDictG (smallDictt *self, char key, char *string);
smallDictt* setNFreeDictKCharSmallDictG (smallDictt *self, char key, smallDictt *dict);
smallDictt* setNFreeArrayKCharSmallDictG (smallDictt *self, char key, smallArrayt *array);
@@ -560,7 +571,7 @@ smallDictt* removeElemKCharSmallDictG(smallDictt *self, char key);
bool hasSmallDictG (smallDictt *self, const char *key);
bool hasKCharSmallDictG (smallDictt *self, char key);
char* keyBySmallDictG(smallDictt *self, baset *value);
-char* keyByUndefinedSmallDictG(smallDictt *self, undefinedt *undefined);
+char* keyByUndefinedSmallDictG(smallDictt *self, undefinedt *u);
char* keyByBoolSmallDictG(smallDictt *self, bool value);
char* keyByDoubleSmallDictG(smallDictt *self, double value);
char* keyByIntSmallDictG(smallDictt *self, int64_t value);
@@ -664,6 +675,7 @@ void registerMethodsSmallDict(smallDictFunctionst *f) {
f->setDict = setDictSmallDict;
f->setArray = setArraySmallDict;
f->setArrayc = setArraycSmallDict;
+ f->setCArrayc = setCArraycSmallDict;
f->setSmallBool = setSmallBoolSmallDict;
f->setSmallBytes = setSmallBytesSmallDict;
f->setSmallDouble = setSmallDoubleSmallDict;
@@ -681,6 +693,7 @@ void registerMethodsSmallDict(smallDictFunctionst *f) {
f->setDictKChar = setDictKCharSmallDict;
f->setArrayKChar = setArrayKCharSmallDict;
f->setArraycKChar = setArraycKCharSmallDict;
+ f->setCArraycKChar = setCArraycKCharSmallDict;
f->setSmallBoolKChar = setSmallBoolKCharSmallDict;
f->setSmallBytesKChar = setSmallBytesKCharSmallDict;
f->setSmallDoubleKChar = setSmallDoubleKCharSmallDict;
@@ -854,6 +867,7 @@ void registerMethodsSmallDict(smallDictFunctionst *f) {
f->keyByDict = keyByDictSmallDict;
f->keyByArray = keyByArraySmallDict;
f->keyByArrayc = keyByArraycSmallDict;
+ f->keyByCArrayc = keyByCArraycSmallDict;
f->keyBySmallBool = keyBySmallBoolSmallDict;
f->keyBySmallBytes = keyBySmallBytesSmallDict;
f->keyBySmallDouble = keyBySmallDoubleSmallDict;
@@ -867,6 +881,7 @@ void registerMethodsSmallDict(smallDictFunctionst *f) {
f->icKeyByDict = icKeyByDictSmallDict;
f->icKeyByArray = icKeyByArraySmallDict;
f->icKeyByArrayc = icKeyByArraycSmallDict;
+ f->icKeyByCArrayc = icKeyByCArraycSmallDict;
f->icKeyBySmallJson = icKeyBySmallJsonSmallDict;
f->icKeyBySmallString = icKeyBySmallStringSmallDict;
f->trim = trimSmallDict;
@@ -900,10 +915,17 @@ void registerMethodsSmallDict(smallDictFunctionst *f) {
f->zipSmallJsonSmallArray = zipSmallJsonSmallArraySmallDict;
f->zipSmallJsonSmallJson = zipSmallJsonSmallJsonSmallDict;
f->zipSmallJsonVArray = zipSmallJsonVArraySmallDict;
+ f->zipSmallJsonVCArray = zipSmallJsonVCArraySmallDict;
f->zipArray = zipArraySmallDict;
+ f->zipCArray = zipCArraySmallDict;
f->zipArraySmallJson = zipArraySmallJsonSmallDict;
+ f->zipCArraySmallJson = zipCArraySmallJsonSmallDict;
f->zipArrayArray = zipArrayArraySmallDict;
+ f->zipCArrayArray = zipCArrayArraySmallDict;
+ f->zipArrayCArray = zipArrayCArraySmallDict;
+ f->zipCArrayCArray = zipCArrayCArraySmallDict;
f->zipVArray = zipVArraySmallDict;
+ f->zipVCArray = zipVCArraySmallDict;
f->fromArray = fromArraySmallDict;
f->toArray = toArraySmallDict;
f->writeFile = writeFileSmallDict;
@@ -1337,6 +1359,32 @@ internal smallDictt* setArraycSmallDict(smallDictt *self, const char *key, char
return(self);
}
+internal smallDictt* setCArraycSmallDict(smallDictt *self, const char *key, const char **array) {
+
+ if (!key || !array) {
+ return(NULL);
+ }
+
+ sArrayt *a = allocSArray();
+ if (!a) {
+ return(NULL);
+ }
+
+ forEachCCharP(array, e) {
+ sStringt *s = allocSStringTiny(*e);
+ if (!s) {
+ if (a) {
+ sArrayFreeTiny(a);
+ }
+ return(NULL);
+ }
+ sArrayPushTiny(&a, (smallt *) s);
+ }
+
+ sDictSetTiny(&(self->d), key, (smallt *)a);
+ return(self);
+}
+
internal smallDictt* setSmallBoolSmallDict(smallDictt *self, const char *key, smallBoolt *value) {
if (!key || !value) {
@@ -1521,6 +1569,12 @@ internal smallDictt* setArraycKCharSmallDict(smallDictt *self, char key, char **
return(setArraycSmallDict(self, s, array));
}
+internal smallDictt* setCArraycKCharSmallDict(smallDictt *self, char key, const char **array) {
+
+ charToS(s, key);
+ return(setCArraycSmallDict(self, s, array));
+}
+
internal smallDictt* setSmallBoolKCharSmallDict(smallDictt *self, char key, smallBoolt *value) {
charToS(s, key);
@@ -1586,14 +1640,14 @@ internal smallDictt* setNFreeSmallDict(smallDictt *self, const char *key, baset
return(self);
}
-internal smallDictt* setNFreeUndefinedSmallDict(smallDictt *self, const char *key, undefinedt *undefined) {
+internal smallDictt* setNFreeUndefinedSmallDict(smallDictt *self, const char *key, undefinedt *u) {
- if (!undefined) {
+ if (!u) {
return(NULL);
}
smallDictt *r = setUndefinedSmallDict(self, key);
if (r) {
- terminateO(undefined);
+ terminateO(u);
}
return(r);
}
@@ -1703,10 +1757,10 @@ internal smallDictt* setNFreeKCharSmallDict(smallDictt *self, char key, baset *v
return(setNFreeSmallDict(self, s, value));
}
-internal smallDictt* setNFreeUndefinedKCharSmallDict(smallDictt *self, char key, undefinedt *undefined) {
+internal smallDictt* setNFreeUndefinedKCharSmallDict(smallDictt *self, char key, undefinedt *u) {
charToS(s, key);
- return(setNFreeUndefinedSmallDict(self, s, undefined));
+ return(setNFreeUndefinedSmallDict(self, s, u));
}
internal smallDictt* setNFreeSKCharSmallDict(smallDictt *self, char key, char *string) {
@@ -2940,14 +2994,14 @@ internal double getNumSmallDict(smallDictt *self, const char *key) {
r = getValO((smallDoublet*)e);
}
elif (isOSmallInt(e)) {
- r = getValO((smallIntt*)e);
+ r = (double)getValO((smallIntt*)e);
}
finishO(e);
return(r);
}
-internal baset* cropElemSmallDict(smallDictt *self, char* key) {
+internal baset* cropElemSmallDict(smallDictt *self, const char* key) {
if (!key || !self->d) {
return(NULL);
@@ -2984,7 +3038,7 @@ internal baset* cropElemSmallDict(smallDictt *self, char* key) {
}
-internal undefinedt* cropElemUndefinedSmallDict(smallDictt *self, char* key) {
+internal undefinedt* cropElemUndefinedSmallDict(smallDictt *self, const char* key) {
if (!key || !self->d) {
return(NULL);
@@ -3010,7 +3064,7 @@ internal undefinedt* cropElemUndefinedSmallDict(smallDictt *self, char* key) {
return(r);
}
-internal bool cropElemBoolSmallDict(smallDictt *self, char* key) {
+internal bool cropElemBoolSmallDict(smallDictt *self, const char* key) {
if (!key || !self->d) {
return(false);
@@ -3044,7 +3098,7 @@ internal bool cropElemBoolSmallDict(smallDictt *self, char* key) {
return(false);
}
-internal double cropElemDoubleSmallDict(smallDictt *self, char* key) {
+internal double cropElemDoubleSmallDict(smallDictt *self, const char* key) {
if (!key || !self->d) {
return(0);
@@ -3078,7 +3132,7 @@ internal double cropElemDoubleSmallDict(smallDictt *self, char* key) {
return(0);
}
-internal int64_t cropElemIntSmallDict(smallDictt *self, char* key) {
+internal int64_t cropElemIntSmallDict(smallDictt *self, const char* key) {
if (!key || !self->d) {
return(0);
@@ -3112,7 +3166,7 @@ internal int64_t cropElemIntSmallDict(smallDictt *self, char* key) {
return(0);
}
-internal int32_t cropElemInt32SmallDict(smallDictt *self, char* key) {
+internal int32_t cropElemInt32SmallDict(smallDictt *self, const char* key) {
if (!key || !self->d) {
return(0);
@@ -3137,7 +3191,7 @@ internal int32_t cropElemInt32SmallDict(smallDictt *self, char* key) {
free(e->key);
e->key = NULL;
- int32_t r = o->f->get(o);
+ int32_t r = (int32_t)o->f->get(o);
terminateO(o);
return(r);
}
@@ -3146,7 +3200,7 @@ internal int32_t cropElemInt32SmallDict(smallDictt *self, char* key) {
return(0);
}
-internal uint64_t cropElemUintSmallDict(smallDictt *self, char* key) {
+internal uint64_t cropElemUintSmallDict(smallDictt *self, const char* key) {
if (!key || !self->d) {
return(0);
@@ -3171,7 +3225,7 @@ internal uint64_t cropElemUintSmallDict(smallDictt *self, char* key) {
free(e->key);
e->key = NULL;
- uint64_t r = o->f->get(o);
+ uint64_t r = (uint64_t)o->f->get(o);
terminateO(o);
return(r);
}
@@ -3180,7 +3234,7 @@ internal uint64_t cropElemUintSmallDict(smallDictt *self, char* key) {
return(0);
}
-internal uint32_t cropElemUint32SmallDict(smallDictt *self, char* key) {
+internal uint32_t cropElemUint32SmallDict(smallDictt *self, const char* key) {
if (!key || !self->d) {
return(0);
@@ -3205,7 +3259,7 @@ internal uint32_t cropElemUint32SmallDict(smallDictt *self, char* key) {
free(e->key);
e->key = NULL;
- uint32_t r = o->f->get(o);
+ uint32_t r = (uint32_t)o->f->get(o);
terminateO(o);
return(r);
}
@@ -3214,7 +3268,7 @@ internal uint32_t cropElemUint32SmallDict(smallDictt *self, char* key) {
return(0);
}
-internal char* cropElemSSmallDict(smallDictt *self, char* key) {
+internal char* cropElemSSmallDict(smallDictt *self, const char* key) {
if (!key || !self->d) {
return(NULL);
@@ -3248,7 +3302,7 @@ internal char* cropElemSSmallDict(smallDictt *self, char* key) {
return(NULL);
}
-internal smallDictt* cropElemDictSmallDict(smallDictt *self, char* key) {
+internal smallDictt* cropElemDictSmallDict(smallDictt *self, const char* key) {
if (!key || !self->d) {
return(NULL);
@@ -3276,7 +3330,7 @@ internal smallDictt* cropElemDictSmallDict(smallDictt *self, char* key) {
return(r);
}
-internal smallArrayt* cropElemArraySmallDict(smallDictt *self, char* key) {
+internal smallArrayt* cropElemArraySmallDict(smallDictt *self, const char* key) {
if (!key || !self->d) {
return(NULL);
@@ -3304,7 +3358,7 @@ internal smallArrayt* cropElemArraySmallDict(smallDictt *self, char* key) {
return(r);
}
-internal smallBoolt* cropElemSmallBoolSmallDict(smallDictt *self, char* key) {
+internal smallBoolt* cropElemSmallBoolSmallDict(smallDictt *self, const char* key) {
if (!key || !self->d) {
return(NULL);
@@ -3332,7 +3386,7 @@ internal smallBoolt* cropElemSmallBoolSmallDict(smallDictt *self, char* key) {
return(r);
}
-internal smallBytest* cropElemSmallBytesSmallDict(smallDictt *self, char* key) {
+internal smallBytest* cropElemSmallBytesSmallDict(smallDictt *self, const char* key) {
if (!key || !self->d) {
return(NULL);
@@ -3360,7 +3414,7 @@ internal smallBytest* cropElemSmallBytesSmallDict(smallDictt *self, char* key) {
return(r);
}
-internal smallDoublet* cropElemSmallDoubleSmallDict(smallDictt *self, char* key) {
+internal smallDoublet* cropElemSmallDoubleSmallDict(smallDictt *self, const char* key) {
if (!key || !self->d) {
return(NULL);
@@ -3388,7 +3442,7 @@ internal smallDoublet* cropElemSmallDoubleSmallDict(smallDictt *self, char* key)
return(r);
}
-internal smallIntt* cropElemSmallIntSmallDict(smallDictt *self, char* key) {
+internal smallIntt* cropElemSmallIntSmallDict(smallDictt *self, const char* key) {
if (!key || !self->d) {
return(NULL);
@@ -3416,7 +3470,7 @@ internal smallIntt* cropElemSmallIntSmallDict(smallDictt *self, char* key) {
return(r);
}
-internal smallJsont* cropElemSmallJsonSmallDict(smallDictt *self, char* key) {
+internal smallJsont* cropElemSmallJsonSmallDict(smallDictt *self, const char* key) {
if (!key || !self->d) {
return(NULL);
@@ -3448,7 +3502,7 @@ internal smallJsont* cropElemSmallJsonSmallDict(smallDictt *self, char* key) {
return(NULL);
}
-internal smallStringt* cropElemSmallStringSmallDict(smallDictt *self, char* key) {
+internal smallStringt* cropElemSmallStringSmallDict(smallDictt *self, const char* key) {
if (!key || !self->d) {
return(NULL);
@@ -3476,7 +3530,7 @@ internal smallStringt* cropElemSmallStringSmallDict(smallDictt *self, char* key)
return(r);
}
-internal void* cropElemVoidSmallDict(smallDictt *self, char* key) {
+internal void* cropElemVoidSmallDict(smallDictt *self, const char* key) {
if (!key || !self->d) {
return(NULL);
@@ -3510,7 +3564,7 @@ internal void* cropElemVoidSmallDict(smallDictt *self, char* key) {
return(NULL);
}
-internal smallContainert* cropElemSmallContainerSmallDict(smallDictt *self, char* key) {
+internal smallContainert* cropElemSmallContainerSmallDict(smallDictt *self, const char* key) {
if (!key || !self->d) {
return(NULL);
@@ -3626,14 +3680,14 @@ internal char* keyBySmallDict(smallDictt *self, baset *value) {
return(NULL);
}
-internal char* keyByUndefinedSmallDict(smallDictt *self, undefinedt *undefined) {
+internal char* keyByUndefinedSmallDict(smallDictt *self, undefinedt *u) {
// sanity checks
- if (!lenSmallDict(self) || !undefined) {
+ if (!lenSmallDict(self) || !u) {
return(NULL);
}
- if (checkObjectTypes && !isOUndefined(undefined)) {
+ if (checkObjectTypes && !isOUndefined(u)) {
return(NULL);
}
@@ -3801,6 +3855,32 @@ internal char* keyByArraycSmallDict(smallDictt *self, char **array) {
return(NULL);
}
+internal char* keyByCArraycSmallDict(smallDictt *self, const char **array) {
+
+ // sanity checks
+ if (!lenSmallDict(self) || !array) {
+ return(NULL);
+ }
+
+ // search object in elements
+ char *s = toStringListCSGF(array);
+ char *es = NULL;
+
+ forEachSDict(self->d, e) {
+ if (e->key && e->data->type == ARRAY) {
+ es = sToString(e->data);
+ if (eqS(es, s)) {
+ free(es);
+ free(s);
+ return(e->key);
+ }
+ free(es);
+ }
+ }
+ free(s);
+ return(NULL);
+}
+
internal char* keyBySmallBoolSmallDict(smallDictt *self, smallBoolt *value) {
// sanity checks
@@ -4120,6 +4200,32 @@ internal char* icKeyByArraycSmallDict(smallDictt *self, char **array) {
return(NULL);
}
+internal char* icKeyByCArraycSmallDict(smallDictt *self, const char **array) {
+
+ // sanity checks
+ if (!lenSmallDict(self) || !array) {
+ return(NULL);
+ }
+
+ // search object in elements
+ char *s = toStringListCSGF(array);
+ char *es = NULL;
+
+ forEachSDict(self->d, e) {
+ if (e->key && e->data->type == ARRAY) {
+ es = sToString(e->data);
+ if (icEqS(es, s)) {
+ free(es);
+ free(s);
+ return(e->key);
+ }
+ free(es);
+ }
+ }
+ free(s);
+ return(NULL);
+}
+
internal char* icKeyBySmallJsonSmallDict(smallDictt *self, smallJsont *string) {
// sanity checks
@@ -4236,7 +4342,7 @@ internal char** keysSmallDict(smallDictt *self) {
forEachSDict(self->d, e) {
if (e->key) {
- listPushS(&r, e->key);
+ pErrorNULL(listPushS(&r, e->key));
}
}
return(r);
@@ -4622,7 +4728,7 @@ internal baset* iterStartSmallDict(smallDictt *self) {
// get first element
range(i, self->d->count)
if ((&((self->d)->elements) + i)->key) {
- self->iterIndex = i;
+ self->iterIndex = (ssize_t)i;
break;
}
if (self->iterElementDataType != SH_DT_BASET) {
@@ -4653,7 +4759,7 @@ internal const char* iterStartKeySmallDict(smallDictt *self) {
// get first element
range(i, self->d->count)
if ((&((self->d)->elements) + i)->key) {
- self->iterIndex = i;
+ self->iterIndex = (ssize_t)i;
break;
}
if (self->iterElementDataType != SH_DT_BASET) {
@@ -4684,9 +4790,9 @@ internal baset* iterNextSmallDict(smallDictt *self) {
// free already created base object
finishO(self->iterElement);
}
- rangeFrom(i, self->iterIndex, self->d->count) {
+ rangeFrom(i, (size_t)self->iterIndex, self->d->count) {
if ((&((self->d)->elements) + i)->key) {
- self->iterIndex = i;
+ self->iterIndex = (ssize_t)i;
break;
}
if (!(&((self->d)->elements) + i)->key && (i == (self->d->count -1))) {
@@ -4723,9 +4829,9 @@ internal const char* iterNextKeySmallDict(smallDictt *self) {
// free already created base object
finishO(self->iterElement);
}
- rangeFrom(i, self->iterIndex, self->d->count) {
+ rangeFrom(i, (size_t)self->iterIndex, self->d->count) {
if ((&((self->d)->elements) + i)->key) {
- self->iterIndex = i;
+ self->iterIndex = (ssize_t)i;
break;
}
if (!(&((self->d)->elements) + i)->key && (i == (self->d->count -1))) {
@@ -4761,8 +4867,8 @@ internal const char* iterKeySmallDict(smallDictt *self) {
}
internal smallDictt* zipSmallDict(smallDictt *self, smallArrayt *keys, smallArrayt *values) {
- size_t len;
- size_t count;
+ size_t len;
+ uint32_t count;
if (!keys || !values) {
return(NULL);
@@ -4919,9 +5025,33 @@ internal smallDictt* zipSmallJsonVArraySmallDict(smallDictt *self, smallJsont *k
return(zipVArraySmallDict(self, &a, values));
}
+internal smallDictt* zipSmallJsonVCArraySmallDict(smallDictt *self, smallJsont *keys, const char** values) {
+
+ if (!keys || !values) {
+ return(NULL);
+ }
+
+ if (checkObjectTypes && !isOSmallJson(keys)) {
+ return(NULL);
+ }
+
+ const char *type = getTopTypeO(keys);
+
+ if (!eqS(type,"array")) {
+ return(NULL);
+ }
+
+ createSmallArray(a);
+ if (!a.f) {
+ return(NULL);
+ }
+ setsoO(&a, (sArrayt*)getsoO(keys));
+ return(zipVCArraySmallDict(self, &a, values));
+}
+
internal smallDictt* zipArraySmallDict(smallDictt *self, char** keys, smallArrayt *values) {
size_t len;
- size_t count;
+ uint32_t count;
if (!keys || !values) {
return(NULL);
@@ -4954,6 +5084,41 @@ internal smallDictt* zipArraySmallDict(smallDictt *self, char** keys, smallArray
return(self);
}
+internal smallDictt* zipCArraySmallDict(smallDictt *self, const char** keys, smallArrayt *values) {
+ size_t len;
+ uint32_t count;
+
+ if (!keys || !values) {
+ return(NULL);
+ }
+
+ if (checkObjectTypes && !isOSmallArray(values)) {
+ return(NULL);
+ }
+
+ if (!listLengthCS(keys) || !values->f->len(values)) {
+ return(self);
+ }
+
+ len = MIN(listLengthCS(keys), values->f->len(values));
+
+ count = 0;
+
+ forEachCS(keys, k) {
+ sDictSetTiny(&(self->d), k, sArrayGetTiny(values->a, count));
+ count++;
+ if (count == len) {
+ break;
+ }
+ }
+
+ //if keys->f->len(keys) != values->f->len(values)
+ // return 0
+ //else
+ // return 1
+ return(self);
+}
+
internal smallDictt* zipArraySmallJsonSmallDict(smallDictt *self, char** keys, smallJsont *values) {
if (!keys || !values) {
@@ -4978,6 +5143,30 @@ internal smallDictt* zipArraySmallJsonSmallDict(smallDictt *self, char** keys, s
return(zipArraySmallDict(self, keys, &a));
}
+internal smallDictt* zipCArraySmallJsonSmallDict(smallDictt *self, const char** keys, smallJsont *values) {
+
+ if (!keys || !values) {
+ return(NULL);
+ }
+
+ if (checkObjectTypes && !isOSmallJson(values)) {
+ return(NULL);
+ }
+
+ const char *type = getTopTypeO(values);
+
+ if (!eqS(type,"array")) {
+ return(NULL);
+ }
+
+ createSmallArray(a);
+ if (!a.f) {
+ return(NULL);
+ }
+ setsoO(&a, (sArrayt*)getsoO(values));
+ return(zipCArraySmallDict(self, keys, &a));
+}
+
internal smallDictt* zipArrayArraySmallDict(smallDictt *self, char** keys, char** values) {
size_t len;
size_t count;
@@ -5014,6 +5203,114 @@ internal smallDictt* zipArrayArraySmallDict(smallDictt *self, char** keys, char*
return(self);
}
+internal smallDictt* zipCArrayArraySmallDict(smallDictt *self, const char** keys, char** values) {
+ size_t len;
+ size_t count;
+
+ if (!keys || !values) {
+ return(NULL);
+ }
+
+ if (!listLengthCS(keys) || !listLengthS(values)) {
+ return(self);
+ }
+
+ len = MIN(listLengthCS(keys), listLengthS(values));
+
+ count = 0;
+
+ smallt *e;
+ forEachCS(keys, k) {
+ e = (smallt *) allocSStringTiny(values[count]);
+ if (!e) {
+ return(NULL);
+ }
+ sDictSetTiny(&(self->d), k, e);
+ count++;
+ if (count == len) {
+ break;
+ }
+ }
+
+ //if keys->f->len(keys) != values->f->len(values)
+ // return 0
+ //else
+ // return 1
+ return(self);
+}
+
+internal smallDictt* zipArrayCArraySmallDict(smallDictt *self, char** keys, const char** values) {
+ size_t len;
+ size_t count;
+
+ if (!keys || !values) {
+ return(NULL);
+ }
+
+ if (!listLengthS(keys) || !listLengthCS(values)) {
+ return(self);
+ }
+
+ len = MIN(listLengthS(keys), listLengthCS(values));
+
+ count = 0;
+
+ smallt *e;
+ forEachS(keys, k) {
+ e = (smallt *) allocSStringTiny(values[count]);
+ if (!e) {
+ return(NULL);
+ }
+ sDictSetTiny(&(self->d), k, e);
+ count++;
+ if (count == len) {
+ break;
+ }
+ }
+
+ //if keys->f->len(keys) != values->f->len(values)
+ // return 0
+ //else
+ // return 1
+ return(self);
+}
+
+internal smallDictt* zipCArrayCArraySmallDict(smallDictt *self, const char** keys, const char** values) {
+ size_t len;
+ size_t count;
+
+ if (!keys || !values) {
+ return(NULL);
+ }
+
+ if (!listLengthCS(keys) || !listLengthCS(values)) {
+ return(self);
+ }
+
+ len = MIN(listLengthCS(keys), listLengthCS(values));
+
+ count = 0;
+
+ smallt *e;
+ forEachCS(keys, k) {
+ e = (smallt *) allocSStringTiny(values[count]);
+ if (!e) {
+ return(NULL);
+ }
+ sDictSetTiny(&(self->d), k, e);
+ count++;
+ if (count == len) {
+ break;
+ }
+ }
+
+ //if keys->f->len(keys) != values->f->len(values)
+ // return 0
+ //else
+ // return 1
+ return(self);
+}
+
internal smallDictt* zipVArraySmallDict(smallDictt *self, smallArrayt *keys, char** values) {
size_t len;
size_t count;
@@ -5059,6 +5356,51 @@ internal smallDictt* zipVArraySmallDict(smallDictt *self, smallArrayt *keys, cha
return(self);
}
+internal smallDictt* zipVCArraySmallDict(smallDictt *self, smallArrayt *keys, const char** values) {
+ size_t len;
+ size_t count;
+
+ if (!keys || !values) {
+ return(NULL);
+ }
+
+ if (checkObjectTypes && !isOSmallArray(keys)) {
+ return(NULL);
+ }
+
+ if (!keys->f->len(keys) || !listLengthCS(values)) {
+ return(self);
+ }
+
+ len = MIN(keys->f->len(keys), listLengthCS(values));
+
+ count = 0;
+
+ smallt *e;
+ forEachSmallArray(keys, K) {
+ if (!isOSmallString(K)) {
+ finishO(K);
+ return(NULL);
+ }
+ e = (smallt *) allocSStringTiny(values[count]);
+ if (!e) {
+ return(NULL);
+ }
+ sDictSetTiny(&(self->d), ssGet(K), e);
+ finishO(K);
+ count++;
+ if (count == len) {
+ break;
+ }
+ }
+
+ //if keys->f->len(keys) != values->f->len(values)
+ // return 0
+ //else
+ // return 1
+ return(self);
+}
+
internal smallDictt* fromArraySmallDict(smallDictt *self, smallArrayt *items) {
if (!items) {
@@ -5085,7 +5427,7 @@ internal smallDictt* fromArraySmallDict(smallDictt *self, smallArrayt *items) {
setNFreeSmallDict(self, ssGet(s), a->f->get(a, 1));
finishO(s);
removeElemO(a, 1);
- delElemO(items, i);
+ delElemO(items, (int64_t)i);
cont:
finishO(E);
}
@@ -6116,7 +6458,7 @@ smallDictt* setArraycSmallDictG (smallDictt *self, const char *key, char **arr
smallDictt* setCArraycSmallDictG (smallDictt *self, const char *key, const char **array) {
- return(self->f->setArrayc(self,key,(char**)array));
+ return(self->f->setCArrayc(self,key,array));
}
smallDictt* setVoidSmallDictG (smallDictt *self, const char *key, void *value) {
@@ -6221,7 +6563,7 @@ smallDictt* setArraycKCharSmallDictG (smallDictt *self, char key, char **array
smallDictt* setCArraycKCharSmallDictG (smallDictt *self, char key, const char **array) {
- return(self->f->setArraycKChar(self, key, (char**)array));
+ return(self->f->setCArraycKChar(self, key, array));
}
smallDictt* setVoidKCharSmallDictG (smallDictt *self, char key, void *value) {
@@ -6335,9 +6677,9 @@ smallDictt* setNFreeKCharSmallDictG (smallDictt *self, char key, baset *
return(self->f->setNFreeKChar(self, key, value));
}
-smallDictt* setNFreeUndefinedKCharSmallDictG(smallDictt *self, char key, undefinedt *undefined) {
+smallDictt* setNFreeUndefinedKCharSmallDictG(smallDictt *self, char key, undefinedt *u) {
- return(self->f->setNFreeUndefinedKChar(self, key, undefined));
+ return(self->f->setNFreeUndefinedKChar(self, key, u));
}
smallDictt* setNFreeSKCharSmallDictG (smallDictt *self, char key, char *string) {
@@ -6534,97 +6876,97 @@ double getNumSmallDictG(smallDictt *self, const char *key) {
baset* cropElemSmallDictG (smallDictt *self, const char* key) {
- return(self->f->cropElem(self, (char*)key));
+ return(self->f->cropElem(self, key));
}
undefinedt* cropElemUndefinedSmallDictG (smallDictt *self, const char* key) {
- return(self->f->cropElemUndefined(self, (char*)key));
+ return(self->f->cropElemUndefined(self, key));
}
bool cropElemBoolSmallDictG (smallDictt *self, const char* key) {
- return(self->f->cropElemBool(self, (char*)key));
+ return(self->f->cropElemBool(self, key));
}
double cropElemDoubleSmallDictG (smallDictt *self, const char* key) {
- return(self->f->cropElemDouble(self, (char*)key));
+ return(self->f->cropElemDouble(self, key));
}
int64_t cropElemIntSmallDictG (smallDictt *self, const char* key) {
- return(self->f->cropElemInt(self, (char*)key));
+ return(self->f->cropElemInt(self, key));
}
int32_t cropElemInt32SmallDictG (smallDictt *self, const char* key) {
- return(self->f->cropElemInt32(self, (char*)key));
+ return(self->f->cropElemInt32(self, key));
}
uint64_t cropElemUintSmallDictG (smallDictt *self, const char* key) {
- return(self->f->cropElemUint(self, (char*)key));
+ return(self->f->cropElemUint(self, key));
}
uint32_t cropElemUint32SmallDictG (smallDictt *self, const char* key) {
- return(self->f->cropElemUint32(self, (char*)key));
+ return(self->f->cropElemUint32(self, key));
}
char* cropElemSSmallDictG (smallDictt *self, const char* key) {
- return(self->f->cropElemS(self, (char*)key));
+ return(self->f->cropElemS(self, key));
}
smallDictt* cropElemDictSmallDictG (smallDictt *self, const char* key) {
- return(self->f->cropElemDict(self, (char*)key));
+ return(self->f->cropElemDict(self, key));
}
smallArrayt* cropElemArraySmallDictG (smallDictt *self, const char* key) {
- return(self->f->cropElemArray(self, (char*)key));
+ return(self->f->cropElemArray(self, key));
}
smallBoolt* cropElemSmallBoolSmallDictG (smallDictt *self, const char* key) {
- return(self->f->cropElemSmallBool(self, (char*)key));
+ return(self->f->cropElemSmallBool(self, key));
}
smallBytest* cropElemSmallBytesSmallDictG (smallDictt *self, const char* key) {
- return(self->f->cropElemSmallBytes(self, (char*)key));
+ return(self->f->cropElemSmallBytes(self, key));
}
smallDoublet* cropElemSmallDoubleSmallDictG (smallDictt *self, const char* key) {
- return(self->f->cropElemSmallDouble(self, (char*)key));
+ return(self->f->cropElemSmallDouble(self, key));
}
smallIntt* cropElemSmallIntSmallDictG (smallDictt *self, const char* key) {
- return(self->f->cropElemSmallInt(self, (char*)key));
+ return(self->f->cropElemSmallInt(self, key));
}
smallJsont* cropElemSmallJsonSmallDictG (smallDictt *self, const char* key) {
- return(self->f->cropElemSmallJson(self, (char*)key));
+ return(self->f->cropElemSmallJson(self, key));
}
smallStringt* cropElemSmallStringSmallDictG (smallDictt *self, const char* key) {
- return(self->f->cropElemSmallString(self, (char*)key));
+ return(self->f->cropElemSmallString(self, key));
}
void* cropElemVoidSmallDictG (smallDictt *self, const char* key) {
- return(self->f->cropElemVoid(self, (char*)key));
+ return(self->f->cropElemVoid(self, key));
}
smallContainert* cropElemSmallContainerSmallDictG(smallDictt *self, const char* key) {
- return(self->f->cropElemSmallContainer(self, (char*)key));
+ return(self->f->cropElemSmallContainer(self, key));
}
smallDictt* delSmallDictG (smallDictt *self, const char *key, int unused UNUSED) {
@@ -6682,9 +7024,9 @@ char* keyBySmallDictG(smallDictt *self, baset *value) {
return(self->f->keyBy(self,value));
}
-char* keyByUndefinedSmallDictG(smallDictt *self, undefinedt *undefined) {
+char* keyByUndefinedSmallDictG(smallDictt *self, undefinedt *u) {
- return(self->f->keyByUndefined(self,undefined));
+ return(self->f->keyByUndefined(self,u));
}
char* keyByBoolSmallDictG(smallDictt *self, bool value) {
@@ -6729,7 +7071,7 @@ char* keyByArraycSmallDictG(smallDictt *self, char **array) {
char* keyByCArraycSmallDictG(smallDictt *self, const char **array) {
- return(self->f->keyByArrayc(self,(char**)array));
+ return(self->f->keyByCArrayc(self,array));
}
char* keyBySmallBoolSmallDictG(smallDictt *self, smallBoolt *value) {
@@ -6799,7 +7141,7 @@ char* icKeyByArraycSmallDictG(smallDictt *self, char **array) {
char* icKeyByCArraycSmallDictG(smallDictt *self, const char **array) {
- return(self->f->icKeyByArrayc(self,(char**)array));
+ return(self->f->icKeyByCArrayc(self,array));
}
char* icKeyBySmallJsonSmallDictG(smallDictt *self, smallJsont *string) {
@@ -6864,7 +7206,7 @@ smallDictt* zipSmallJsonVArraySmallDictG (smallDictt *self, smallJsont *keys,
smallDictt* zipSmallJsonVCArraySmallDictG (smallDictt *self, smallJsont *keys, const char **values) {
- return(self->f->zipSmallJsonVArray(self,keys,(char**)values));
+ return(self->f->zipSmallJsonVCArray(self,keys,values));
}
smallDictt* zipArraySmallDictG(smallDictt *self, char** keys, smallArrayt *values) {
@@ -6879,12 +7221,12 @@ smallDictt* zipArraySmallJsonSmallDictG (smallDictt *self, char** keys, smal
smallDictt* zipCArraySmallDictG(smallDictt *self, const char** keys, smallArrayt *values) {
- return(self->f->zipArray(self,(char**)keys,values));
+ return(self->f->zipCArray(self,keys,values));
}
smallDictt* zipCArraySmallJsonSmallDictG (smallDictt *self, const char** keys, smallJsont *values) {
- return(self->f->zipArraySmallJson(self,(char**)keys,values));
+ return(self->f->zipCArraySmallJson(self,keys,values));
}
smallDictt* zipArrayArraySmallDictG(smallDictt *self, char** keys, char** values) {
@@ -6894,17 +7236,17 @@ smallDictt* zipArrayArraySmallDictG(smallDictt *self, char** keys, char** values
smallDictt* zipCArrayArraySmallDictG(smallDictt *self, const char** keys, char** values) {
- return(self->f->zipArrayArray(self,(char**)keys,values));
+ return(self->f->zipCArrayArray(self,keys,values));
}
smallDictt* zipArrayCArraySmallDictG(smallDictt *self, char** keys, const char** values) {
- return(self->f->zipArrayArray(self,keys,(char**)values));
+ return(self->f->zipArrayCArray(self,keys,values));
}
smallDictt* zipCArrayCArraySmallDictG(smallDictt *self, const char** keys, const char** values) {
- return(self->f->zipArrayArray(self,(char**)keys,(char**)values));
+ return(self->f->zipCArrayCArray(self,keys,values));
}
smallDictt* zipVArraySmallDictG (smallDictt *self, smallArrayt *keys, char** values) {
@@ -6914,7 +7256,7 @@ smallDictt* zipVArraySmallDictG (smallDictt *self, smallArrayt *keys, char**
smallDictt* zipVCArraySmallDictG (smallDictt *self, smallArrayt *keys, const char** values) {
- return(self->f->zipVArray(self,keys,(char**)values));
+ return(self->f->zipVCArray(self,keys,values));
}
smallDictt* fromArraySmallDictG (smallDictt *self, smallArrayt *items) {
diff --git a/src/json/libsheepyCSmallDict.h b/src/json/libsheepyCSmallDict.h
@@ -134,6 +134,7 @@ typedef smallDictt* (*setCharSmallDictFt) (smallDictt *self, const c
typedef smallDictt* (*setDictSmallDictFt) (smallDictt *self, const char *key, smallDictt *dict);
typedef smallDictt* (*setArraySmallDictFt) (smallDictt *self, const char *key, smallArrayt *array);
typedef smallDictt* (*setArraycSmallDictFt) (smallDictt *self, const char *key, char **array);
+typedef smallDictt* (*setCArraycSmallDictFt) (smallDictt *self, const char *key, const char **array);
typedef smallDictt* (*setSmallBoolSmallDictFt) (smallDictt *self, const char *key, smallBoolt *value);
typedef smallDictt* (*setSmallBytesSmallDictFt) (smallDictt *self, const char *key, smallBytest *value);
typedef smallDictt* (*setSmallDoubleSmallDictFt) (smallDictt *self, const char *key, smallDoublet *value);
@@ -152,6 +153,7 @@ typedef smallDictt* (*setCharKCharSmallDictFt) (smallDictt *self, ch
typedef smallDictt* (*setDictKCharSmallDictFt) (smallDictt *self, char key, smallDictt *dict);
typedef smallDictt* (*setArrayKCharSmallDictFt) (smallDictt *self, char key, smallArrayt *array);
typedef smallDictt* (*setArraycKCharSmallDictFt) (smallDictt *self, char key, char **array);
+typedef smallDictt* (*setCArraycKCharSmallDictFt) (smallDictt *self, char key, const char **array);
typedef smallDictt* (*setSmallBoolKCharSmallDictFt) (smallDictt *self, char key, smallBoolt *value);
typedef smallDictt* (*setSmallBytesKCharSmallDictFt) (smallDictt *self, char key, smallBytest *value);
typedef smallDictt* (*setSmallDoubleKCharSmallDictFt) (smallDictt *self, char key, smallDoublet *value);
@@ -360,25 +362,25 @@ typedef double (*getNumSmallDictFt) (smallDictt *se
* element for key (you must free the pointer (terminate libsheepy objects))
* NULL error
*/
-typedef baset* (*cropElemSmallDictFt) (smallDictt *self, char* key);
-typedef undefinedt* (*cropElemUndefinedSmallDictFt) (smallDictt *self, char* key);
-typedef bool (*cropElemBoolSmallDictFt) (smallDictt *self, char* key);
-typedef double (*cropElemDoubleSmallDictFt) (smallDictt *self, char* key);
-typedef int64_t (*cropElemIntSmallDictFt) (smallDictt *self, char* key);
-typedef int32_t (*cropElemInt32SmallDictFt) (smallDictt *self, char* key);
-typedef uint64_t (*cropElemUintSmallDictFt) (smallDictt *self, char* key);
-typedef uint32_t (*cropElemUint32SmallDictFt) (smallDictt *self, char* key);
-typedef char* (*cropElemSSmallDictFt) (smallDictt *self, char* key);
-typedef smallDictt* (*cropElemDictSmallDictFt) (smallDictt *self, char* key);
-typedef smallArrayt* (*cropElemArraySmallDictFt) (smallDictt *self, char* key);
-typedef smallBoolt* (*cropElemSmallBoolSmallDictFt) (smallDictt *self, char* key);
-typedef smallBytest* (*cropElemSmallBytesSmallDictFt) (smallDictt *self, char* key);
-typedef smallDoublet* (*cropElemSmallDoubleSmallDictFt) (smallDictt *self, char* key);
-typedef smallIntt* (*cropElemSmallIntSmallDictFt) (smallDictt *self, char* key);
-typedef smallJsont* (*cropElemSmallJsonSmallDictFt) (smallDictt *self, char* key);
-typedef smallStringt* (*cropElemSmallStringSmallDictFt) (smallDictt *self, char* key);
-typedef void* (*cropElemVoidSmallDictFt) (smallDictt *self, char* key);
-typedef smallContainert* (*cropElemSmallContainerSmallDictFt) (smallDictt *self, char* key);
+typedef baset* (*cropElemSmallDictFt) (smallDictt *self, const char* key);
+typedef undefinedt* (*cropElemUndefinedSmallDictFt) (smallDictt *self, const char* key);
+typedef bool (*cropElemBoolSmallDictFt) (smallDictt *self, const char* key);
+typedef double (*cropElemDoubleSmallDictFt) (smallDictt *self, const char* key);
+typedef int64_t (*cropElemIntSmallDictFt) (smallDictt *self, const char* key);
+typedef int32_t (*cropElemInt32SmallDictFt) (smallDictt *self, const char* key);
+typedef uint64_t (*cropElemUintSmallDictFt) (smallDictt *self, const char* key);
+typedef uint32_t (*cropElemUint32SmallDictFt) (smallDictt *self, const char* key);
+typedef char* (*cropElemSSmallDictFt) (smallDictt *self, const char* key);
+typedef smallDictt* (*cropElemDictSmallDictFt) (smallDictt *self, const char* key);
+typedef smallArrayt* (*cropElemArraySmallDictFt) (smallDictt *self, const char* key);
+typedef smallBoolt* (*cropElemSmallBoolSmallDictFt) (smallDictt *self, const char* key);
+typedef smallBytest* (*cropElemSmallBytesSmallDictFt) (smallDictt *self, const char* key);
+typedef smallDoublet* (*cropElemSmallDoubleSmallDictFt) (smallDictt *self, const char* key);
+typedef smallIntt* (*cropElemSmallIntSmallDictFt) (smallDictt *self, const char* key);
+typedef smallJsont* (*cropElemSmallJsonSmallDictFt) (smallDictt *self, const char* key);
+typedef smallStringt* (*cropElemSmallStringSmallDictFt) (smallDictt *self, const char* key);
+typedef void* (*cropElemVoidSmallDictFt) (smallDictt *self, const char* key);
+typedef smallContainert* (*cropElemSmallContainerSmallDictFt) (smallDictt *self, const char* key);
/**
* delete element
@@ -457,6 +459,7 @@ typedef char* (*keyByCharSmallDictFt) (smallDictt *self, char c);
typedef char* (*keyByDictSmallDictFt) (smallDictt *self, smallDictt *dict);
typedef char* (*keyByArraySmallDictFt) (smallDictt *self, smallArrayt *array);
typedef char* (*keyByArraycSmallDictFt) (smallDictt *self, char **array);
+typedef char* (*keyByCArraycSmallDictFt) (smallDictt *self, const char **array);
typedef char* (*keyBySmallBoolSmallDictFt) (smallDictt *self, smallBoolt *value);
typedef char* (*keyBySmallBytesSmallDictFt) (smallDictt *self, smallBytest *value);
typedef char* (*keyBySmallDoubleSmallDictFt) (smallDictt *self, smallDoublet *value);
@@ -481,6 +484,7 @@ typedef char* (*icKeyByCharSmallDictFt) (smallDictt *self, char c);
typedef char* (*icKeyByDictSmallDictFt) (smallDictt *self, smallDictt *dict);
typedef char* (*icKeyByArraySmallDictFt) (smallDictt *self, smallArrayt *array);
typedef char* (*icKeyByArraycSmallDictFt) (smallDictt *self, char **array);
+typedef char* (*icKeyByCArraycSmallDictFt) (smallDictt *self, const char **array);
typedef char* (*icKeyBySmallJsonSmallDictFt) (smallDictt *self, smallJsont *string);
typedef char* (*icKeyBySmallStringSmallDictFt) (smallDictt *self, smallStringt *string);
@@ -596,10 +600,17 @@ typedef smallDictt* (*zipSmallJsonSmallDictFt) (smallDictt *se
typedef smallDictt* (*zipSmallJsonSmallArraySmallDictFt)(smallDictt *self, smallJsont *keys, smallArrayt *values);
typedef smallDictt* (*zipSmallJsonSmallJsonSmallDictFt) (smallDictt *self, smallJsont *keys, smallJsont *values);
typedef smallDictt* (*zipSmallJsonVArraySmallDictFt) (smallDictt *self, smallJsont *keys, char** values);
+typedef smallDictt* (*zipSmallJsonVCArraySmallDictFt) (smallDictt *self, smallJsont *keys, const char** values);
typedef smallDictt* (*zipArraySmallDictFt) (smallDictt *self, char** keys, smallArrayt *values);
+typedef smallDictt* (*zipCArraySmallDictFt) (smallDictt *self, const char** keys, smallArrayt *values);
typedef smallDictt* (*zipArraySmallJsonSmallDictFt) (smallDictt *self, char** keys, smallJsont *values);
+typedef smallDictt* (*zipCArraySmallJsonSmallDictFt) (smallDictt *self, const char** keys, smallJsont *values);
typedef smallDictt* (*zipArrayArraySmallDictFt) (smallDictt *self, char** keys, char** values);
+typedef smallDictt* (*zipCArrayArraySmallDictFt) (smallDictt *self, const char** keys, char** values);
+typedef smallDictt* (*zipArrayCArraySmallDictFt) (smallDictt *self, char** keys, const char** values);
+typedef smallDictt* (*zipCArrayCArraySmallDictFt) (smallDictt *self, const char** keys, const char** values);
typedef smallDictt* (*zipVArraySmallDictFt) (smallDictt *self, smallArrayt *keys, char** values);
+typedef smallDictt* (*zipVCArraySmallDictFt) (smallDictt *self, smallArrayt *keys, const char** values);
/**
* convert array to dictionary
@@ -748,6 +759,7 @@ typedef bool (*areAllEBytesSmallDictFt) (smallDictt *self);
setDictSmallDictFt setDict;\
setArraySmallDictFt setArray;\
setArraycSmallDictFt setArrayc;\
+ setCArraycSmallDictFt setCArrayc;\
setSmallBoolSmallDictFt setSmallBool;\
setSmallBytesSmallDictFt setSmallBytes;\
setSmallDoubleSmallDictFt setSmallDouble;\
@@ -765,6 +777,7 @@ typedef bool (*areAllEBytesSmallDictFt) (smallDictt *self);
setDictKCharSmallDictFt setDictKChar;\
setArrayKCharSmallDictFt setArrayKChar;\
setArraycKCharSmallDictFt setArraycKChar;\
+ setCArraycKCharSmallDictFt setCArraycKChar;\
setSmallBoolKCharSmallDictFt setSmallBoolKChar;\
setSmallBytesKCharSmallDictFt setSmallBytesKChar;\
setSmallDoubleKCharSmallDictFt setSmallDoubleKChar;\
@@ -938,6 +951,7 @@ typedef bool (*areAllEBytesSmallDictFt) (smallDictt *self);
keyByDictSmallDictFt keyByDict;\
keyByArraySmallDictFt keyByArray;\
keyByArraycSmallDictFt keyByArrayc;\
+ keyByCArraycSmallDictFt keyByCArrayc;\
keyBySmallBoolSmallDictFt keyBySmallBool;\
keyBySmallBytesSmallDictFt keyBySmallBytes;\
keyBySmallDoubleSmallDictFt keyBySmallDouble;\
@@ -951,6 +965,7 @@ typedef bool (*areAllEBytesSmallDictFt) (smallDictt *self);
icKeyByDictSmallDictFt icKeyByDict;\
icKeyByArraySmallDictFt icKeyByArray;\
icKeyByArraycSmallDictFt icKeyByArrayc;\
+ icKeyByCArraycSmallDictFt icKeyByCArrayc;\
icKeyBySmallJsonSmallDictFt icKeyBySmallJson;\
icKeyBySmallStringSmallDictFt icKeyBySmallString;\
trimSmallDictFt trim;\
@@ -984,10 +999,17 @@ typedef bool (*areAllEBytesSmallDictFt) (smallDictt *self);
zipSmallJsonSmallArraySmallDictFt zipSmallJsonSmallArray;\
zipSmallJsonSmallJsonSmallDictFt zipSmallJsonSmallJson;\
zipSmallJsonVArraySmallDictFt zipSmallJsonVArray;\
+ zipSmallJsonVCArraySmallDictFt zipSmallJsonVCArray;\
zipArraySmallDictFt zipArray;\
+ zipCArraySmallDictFt zipCArray;\
zipArraySmallJsonSmallDictFt zipArraySmallJson;\
+ zipCArraySmallJsonSmallDictFt zipCArraySmallJson;\
zipArrayArraySmallDictFt zipArrayArray;\
+ zipCArrayArraySmallDictFt zipCArrayArray;\
+ zipArrayCArraySmallDictFt zipArrayCArray;\
+ zipCArrayCArraySmallDictFt zipCArrayCArray;\
zipVArraySmallDictFt zipVArray;\
+ zipVCArraySmallDictFt zipVCArray;\
fromArraySmallDictFt fromArray;\
toArraySmallDictFt toArray;\
writeFileSmallDictFt writeFile;\
diff --git a/src/json/libsheepyCSmallDouble.c b/src/json/libsheepyCSmallDouble.c
@@ -485,10 +485,10 @@ internal smallDoublet* setSmallIntSmallDouble(smallDoublet* self, smallIntt* p2)
}
if (!self->value) {
- isError(self->value, allocSDouble(p2->f->get(p2))) return(NULL);
+ isError(self->value, allocSDouble((double)p2->f->get(p2))) return(NULL);
}
else {
- self->value->value = p2->f->get(p2);
+ self->value->value = (double)p2->f->get(p2);
}
return(self);
}
diff --git a/src/json/libsheepyCSmallInt.c b/src/json/libsheepyCSmallInt.c
@@ -476,10 +476,10 @@ internal smallIntt* setSmallDoubleSmallInt(smallIntt* self, smallDoublet* p2) {
}
if (!self->value) {
- isError(self->value, allocSInt(p2->f->get(p2))) return(NULL);
+ isError(self->value, allocSInt((int64_t)p2->f->get(p2))) return(NULL);
}
else {
- self->value->value = p2->f->get(p2);
+ self->value->value = (int64_t)p2->f->get(p2);
}
return(self);
}
diff --git a/src/json/libsheepyCSmallJson.c b/src/json/libsheepyCSmallJson.c
@@ -85,6 +85,7 @@ internal smallJsont* setTopCharSmallJson(smallJsont *self, char c);
internal smallJsont* setTopDictSmallJson(smallJsont *self, smallDictt *value);
internal smallJsont* setTopArraySmallJson(smallJsont *self, smallArrayt *value);
internal smallJsont* setTopArraycSmallJson(smallJsont *self, char **value);
+internal smallJsont* setTopCArraycSmallJson(smallJsont *self, const char **value);
internal smallJsont* setTopSmallBoolSmallJson(smallJsont *self, smallBoolt *value);
internal smallJsont* setTopSmallDoubleSmallJson(smallJsont *self, smallDoublet *value);
internal smallJsont* setTopSmallIntSmallJson(smallJsont *self, smallIntt *value);
@@ -104,6 +105,7 @@ internal smallJsont* setTopNFreeSmallIntSmallJson(smallJsont *self, smallIntt *v
internal smallJsont* setTopNFreeSmallJsonSmallJson(smallJsont *self, smallJsont *value);
internal smallJsont* setTopNFreeSmallStringSmallJson(smallJsont *self, smallStringt *value);
internal smallJsont* fromArraySmallJson(smallJsont *self, char **array, size_t size);
+internal smallJsont* fromCArraySmallJson(smallJsont *self, const char **array, size_t size);
internal smallJsont* fromArrayNFreeSmallJson(smallJsont *self, char **array, size_t size);
internal smallJsont* fromArrayDictSmallJson(smallJsont *self, smallArrayt *items);
internal smallArrayt* toArrayDictSmallJson(smallJsont *self);
@@ -147,6 +149,7 @@ internal smallJsont* setCharSmallJson(smallJsont *self, const char *key, char c)
internal smallJsont* setDictSmallJson(smallJsont *self, const char *key, smallDictt *dict);
internal smallJsont* setArraySmallJson(smallJsont *self, const char *key, smallArrayt *array);
internal smallJsont* setArraycSmallJson(smallJsont *self, const char *key, char **array);
+internal smallJsont* setCArraycSmallJson(smallJsont *self, const char *key, const char **array);
internal smallJsont* setSmallBoolSmallJson(smallJsont *self, const char *key, smallBoolt *value);
internal smallJsont* setSmallBytesSmallJson(smallJsont *self, const char *key, smallBytest *value);
internal smallJsont* setSmallDoubleSmallJson(smallJsont *self, const char *key, smallDoublet *value);
@@ -155,7 +158,7 @@ internal smallJsont* setSmallJsonSmallJson(smallJsont *self, const char *key, sm
internal smallJsont* setSmallStringSmallJson(smallJsont *self, const char *key, smallStringt *string);
internal smallJsont* setSmallContainerSmallJson(smallJsont *self, const char *key, smallContainert *container);
internal smallJsont* setNFreeSmallJson(smallJsont *self, const char *key, baset *value);
-internal smallJsont* setNFreeUndefinedSmallJson(smallJsont *self, const char *key, undefinedt *undefined);
+internal smallJsont* setNFreeUndefinedSmallJson(smallJsont *self, const char *key, undefinedt *u);
internal smallJsont* setNFreeSSmallJson(smallJsont *self, const char *key, char *string);
internal smallJsont* setNFreeDictSmallJson(smallJsont *self, const char *key, smallDictt *dict);
internal smallJsont* setNFreeArraySmallJson(smallJsont *self, const char *key, smallArrayt *array);
@@ -185,6 +188,7 @@ internal smallJsont* setAtCharSmallJson(smallJsont *self, int64_t index, char c)
internal smallJsont* setAtDictSmallJson(smallJsont *self, int64_t index, smallDictt *dict);
internal smallJsont* setAtArraySmallJson(smallJsont *self, int64_t index, smallArrayt *array);
internal smallJsont* setAtArraycSmallJson(smallJsont *self, int64_t index, char **array);
+internal smallJsont* setAtCArraycSmallJson(smallJsont *self, int64_t index, const char **array);
internal smallJsont* setAtSmallBoolSmallJson(smallJsont *self, int64_t index, smallBoolt *value);
internal smallJsont* setAtSmallBytesSmallJson(smallJsont *self, int64_t index, smallBytest *value);
internal smallJsont* setAtSmallDoubleSmallJson(smallJsont *self, int64_t index, smallDoublet *value);
@@ -193,7 +197,7 @@ internal smallJsont* setAtSmallJsonSmallJson(smallJsont *self, int64_t index, sm
internal smallJsont* setAtSmallStringSmallJson(smallJsont *self, int64_t index, smallStringt *string);
internal smallJsont* setAtSmallContainerSmallJson(smallJsont *self, int64_t index, smallContainert *container);
internal smallJsont* setAtNFreeSmallJson(smallJsont *self, int64_t index, baset *value);
-internal smallJsont* setAtNFreeUndefinedSmallJson(smallJsont *self, int64_t index, undefinedt *undefined);
+internal smallJsont* setAtNFreeUndefinedSmallJson(smallJsont *self, int64_t index, undefinedt *u);
internal smallJsont* setAtNFreeSSmallJson(smallJsont *self, int64_t index, char *string);
internal smallJsont* setAtNFreeDictSmallJson(smallJsont *self, int64_t index, smallDictt *dict);
internal smallJsont* setAtNFreeArraySmallJson(smallJsont *self, int64_t index, smallArrayt *array);
@@ -223,6 +227,7 @@ internal smallJsont* pushCharSmallJson(smallJsont *self, char c);
internal smallJsont* pushDictSmallJson(smallJsont *self, smallDictt *dict);
internal smallJsont* pushArraySmallJson(smallJsont *self, smallArrayt *array);
internal smallJsont* pushArraycSmallJson(smallJsont *self, char **array);
+internal smallJsont* pushCArraycSmallJson(smallJsont *self, const char **array);
internal smallJsont* pushSmallBoolSmallJson(smallJsont *self, smallBoolt *value);
internal smallJsont* pushSmallBytesSmallJson(smallJsont *self, smallBytest *value);
internal smallJsont* pushSmallDoubleSmallJson(smallJsont *self, smallDoublet *value);
@@ -231,7 +236,7 @@ internal smallJsont* pushSmallJsonSmallJson(smallJsont *self, smallJsont *value)
internal smallJsont* pushSmallStringSmallJson(smallJsont *self, smallStringt *string);
internal smallJsont* pushSmallContainerSmallJson(smallJsont *self, smallContainert *container);
internal smallJsont* pushNFreeSmallJson(smallJsont *self, baset *value);
-internal smallJsont* pushNFreeUndefinedSmallJson(smallJsont *self, undefinedt *undefined);
+internal smallJsont* pushNFreeUndefinedSmallJson(smallJsont *self, undefinedt *u);
internal smallJsont* pushNFreeSSmallJson(smallJsont *self, char *string);
internal smallJsont* pushNFreeDictSmallJson(smallJsont *self, smallDictt *dict);
internal smallJsont* pushNFreeArraySmallJson(smallJsont *self, smallArrayt *array);
@@ -277,6 +282,7 @@ internal smallJsont* prependCharSmallJson(smallJsont *self, char c);
internal smallJsont* prependDictSmallJson(smallJsont *self, smallDictt *dict);
internal smallJsont* prependArraySmallJson(smallJsont *self, smallArrayt *array);
internal smallJsont* prependArraycSmallJson(smallJsont *self, char **array);
+internal smallJsont* prependCArraycSmallJson(smallJsont *self, const char **array);
internal smallJsont* prependSmallBoolSmallJson(smallJsont *self, smallBoolt *value);
internal smallJsont* prependSmallBytesSmallJson(smallJsont *self, smallBytest *value);
internal smallJsont* prependSmallDoubleSmallJson(smallJsont *self, smallDoublet *value);
@@ -285,7 +291,7 @@ internal smallJsont* prependSmallJsonSmallJson(smallJsont *self, smallJsont *val
internal smallJsont* prependSmallStringSmallJson(smallJsont *self, smallStringt *string);
internal smallJsont* prependSmallContainerSmallJson(smallJsont *self, smallContainert *container);
internal smallJsont* prependNFreeSmallJson(smallJsont *self, baset *value);
-internal smallJsont* prependNFreeUndefinedSmallJson(smallJsont *self, undefinedt *undefined);
+internal smallJsont* prependNFreeUndefinedSmallJson(smallJsont *self, undefinedt *u);
internal smallJsont* prependNFreeSSmallJson(smallJsont *self, char *string);
internal smallJsont* prependNFreeDictSmallJson(smallJsont *self, smallDictt *dict);
internal smallJsont* prependNFreeArraySmallJson(smallJsont *self, smallArrayt *array);
@@ -326,6 +332,7 @@ internal smallJsont* mergeNSmashSmallJson(smallJsont *self, smallJsont *smallJso
internal smallJsont* appendSmallJson(smallJsont *self, smallArrayt *array);
internal smallJsont* appendNSmashSmallJson(smallJsont *self, smallArrayt *array);
internal smallJsont* appendArraySmallJson(smallJsont *self, char **array);
+internal smallJsont* appendCArraySmallJson(smallJsont *self, const char **array);
internal smallJsont* appendNSmashArraySmallJson(smallJsont *self, char **array);
internal smallJsont* shiftSmallJson(smallJsont *self, smallArrayt *array);
internal smallJsont* shiftNSmashSmallJson(smallJsont *self, smallArrayt *array);
@@ -357,25 +364,25 @@ internal smallJsont* cropElemAtSmallJsonSmallJson(smallJsont *self, int64_t inde
internal smallStringt* cropElemAtSmallStringSmallJson(smallJsont *self, int64_t index);
internal void* cropElemAtVoidSmallJson(smallJsont *self, int64_t index);
internal smallContainert* cropElemAtSmallContainerSmallJson(smallJsont *self, int64_t index);
-internal baset* cropElemKeySmallJson(smallJsont *self, char* key);
-internal undefinedt* cropElemKeyUndefinedSmallJson(smallJsont *self, char* key);
-internal bool cropElemKeyBoolSmallJson(smallJsont *self, char* key);
-internal double cropElemKeyDoubleSmallJson(smallJsont *self, char* key);
-internal int64_t cropElemKeyIntSmallJson(smallJsont *self, char* key);
-internal int32_t cropElemKeyInt32SmallJson(smallJsont *self, char* key);
-internal uint64_t cropElemKeyUintSmallJson(smallJsont *self, char* key);
-internal uint32_t cropElemKeyUint32SmallJson(smallJsont *self, char* key);
-internal char* cropElemKeySSmallJson(smallJsont *self, char* key);
-internal smallDictt* cropElemKeyDictSmallJson(smallJsont *self, char* key);
-internal smallArrayt* cropElemKeyArraySmallJson(smallJsont *self, char* key);
-internal smallBoolt* cropElemKeySmallBoolSmallJson(smallJsont *self, char* key);
-internal smallBytest* cropElemKeySmallBytesSmallJson(smallJsont *self, char* key);
-internal smallDoublet* cropElemKeySmallDoubleSmallJson(smallJsont *self, char* key);
-internal smallIntt* cropElemKeySmallIntSmallJson(smallJsont *self, char* key);
-internal smallJsont* cropElemKeySmallJsonSmallJson(smallJsont *self, char* key);
-internal smallStringt* cropElemKeySmallStringSmallJson(smallJsont *self, char* key);
-internal void* cropElemKeyVoidSmallJson(smallJsont *self, char* key);
-internal smallContainert* cropElemKeySmallContainerSmallJson(smallJsont *self, char* key);
+internal baset* cropElemKeySmallJson(smallJsont *self, const char* key);
+internal undefinedt* cropElemKeyUndefinedSmallJson(smallJsont *self, const char* key);
+internal bool cropElemKeyBoolSmallJson(smallJsont *self, const char* key);
+internal double cropElemKeyDoubleSmallJson(smallJsont *self, const char* key);
+internal int64_t cropElemKeyIntSmallJson(smallJsont *self, const char* key);
+internal int32_t cropElemKeyInt32SmallJson(smallJsont *self, const char* key);
+internal uint64_t cropElemKeyUintSmallJson(smallJsont *self, const char* key);
+internal uint32_t cropElemKeyUint32SmallJson(smallJsont *self, const char* key);
+internal char* cropElemKeySSmallJson(smallJsont *self, const char* key);
+internal smallDictt* cropElemKeyDictSmallJson(smallJsont *self, const char* key);
+internal smallArrayt* cropElemKeyArraySmallJson(smallJsont *self, const char* key);
+internal smallBoolt* cropElemKeySmallBoolSmallJson(smallJsont *self, const char* key);
+internal smallBytest* cropElemKeySmallBytesSmallJson(smallJsont *self, const char* key);
+internal smallDoublet* cropElemKeySmallDoubleSmallJson(smallJsont *self, const char* key);
+internal smallIntt* cropElemKeySmallIntSmallJson(smallJsont *self, const char* key);
+internal smallJsont* cropElemKeySmallJsonSmallJson(smallJsont *self, const char* key);
+internal smallStringt* cropElemKeySmallStringSmallJson(smallJsont *self, const char* key);
+internal void* cropElemKeyVoidSmallJson(smallJsont *self, const char* key);
+internal smallContainert* cropElemKeySmallContainerSmallJson(smallJsont *self, const char* key);
internal smallJsont* copySmallJson(smallJsont *self, int64_t start, int64_t end);
internal smallJsont* insertSmallJson(smallJsont *self, int64_t index, smallArrayt *toInsert);
internal smallJsont* insertNSmashSmallJson(smallJsont *self, int64_t index, smallArrayt *toInsert);
@@ -395,6 +402,7 @@ internal smallJsont* injectCharSmallJson(smallJsont *self, int64_t index, char c
internal smallJsont* injectDictSmallJson(smallJsont *self, int64_t index, smallDictt *toInject);
internal smallJsont* injectArraySmallJson(smallJsont *self, int64_t index, smallArrayt *toInject);
internal smallJsont* injectArraycSmallJson(smallJsont *self, int64_t index, char **toInject);
+internal smallJsont* injectCArraycSmallJson(smallJsont *self, int64_t index, const char **toInject);
internal smallJsont* injectSmallBoolSmallJson(smallJsont *self, int64_t index, smallBoolt *toInject);
internal smallJsont* injectSmallBytesSmallJson(smallJsont *self, int64_t index, smallBytest *toInject);
internal smallJsont* injectSmallDoubleSmallJson(smallJsont *self, int64_t index, smallDoublet *toInject);
@@ -403,7 +411,7 @@ internal smallJsont* injectSmallJsonSmallJson(smallJsont *self, int64_t index, s
internal smallJsont* injectSmallStringSmallJson(smallJsont *self, int64_t index, smallStringt *toInject);
internal smallJsont* injectSmallContainerSmallJson(smallJsont *self, int64_t index, smallContainert *toInject);
internal smallJsont* injectNFreeSmallJson(smallJsont *self, int64_t index, baset *toInject);
-internal smallJsont* injectNFreeUndefinedSmallJson(smallJsont *self, int64_t index, undefinedt *undefined);
+internal smallJsont* injectNFreeUndefinedSmallJson(smallJsont *self, int64_t index, undefinedt *u);
internal smallJsont* injectNFreeSSmallJson(smallJsont *self, int64_t index, char *toInject);
internal smallJsont* injectNFreeDictSmallJson(smallJsont *self, int64_t index, smallDictt *toInject);
internal smallJsont* injectNFreeArraySmallJson(smallJsont *self, int64_t index, smallArrayt *toInject);
@@ -434,7 +442,7 @@ internal smallJsont* icUniqSmallJson(smallJsont *self);
internal smallJsont* uniqCharSmallJson(smallJsont *self, char c);
internal smallJsont* icUniqCharSmallJson(smallJsont *self, char c);
internal bool hasSmallJson(smallJsont *self, baset *value);
-internal bool hasUndefinedSmallJson(smallJsont *self, undefinedt *undefined);
+internal bool hasUndefinedSmallJson(smallJsont *self, undefinedt *u);
internal bool hasBoolSmallJson(smallJsont *self, bool value);
internal bool hasDoubleSmallJson(smallJsont *self, double value);
internal bool hasIntSmallJson(smallJsont *self, int64_t value);
@@ -443,6 +451,7 @@ internal bool hasCharSmallJson(smallJsont *self, char c);
internal bool hasDictSmallJson(smallJsont *self, smallDictt *dict);
internal bool hasArraySmallJson(smallJsont *self, smallArrayt *array);
internal bool hasArraycSmallJson(smallJsont *self, char **array);
+internal bool hasCArraycSmallJson(smallJsont *self, const char **array);
internal bool hasSmallBoolSmallJson(smallJsont *self, smallBoolt *value);
internal bool hasSmallBytesSmallJson(smallJsont *self, smallBytest *value);
internal bool hasSmallDoubleSmallJson(smallJsont *self, smallDoublet *value);
@@ -455,7 +464,7 @@ internal smallJsont* findCharSmallJson(smallJsont *self, char c);
internal smallJsont* findSmallStringSmallJson(smallJsont *self, smallStringt *needle);
internal smallJsont* findJsonSmallJson(smallJsont *self, smallJsont *needle);
internal ssize_t indexOfSmallJson(smallJsont *self, baset *value);
-internal ssize_t indexOfUndefinedSmallJson(smallJsont *self, undefinedt *undefined);
+internal ssize_t indexOfUndefinedSmallJson(smallJsont *self, undefinedt *u);
internal ssize_t indexOfBoolSmallJson(smallJsont *self, bool value);
internal ssize_t indexOfDoubleSmallJson(smallJsont *self, double value);
internal ssize_t indexOfIntSmallJson(smallJsont *self, int64_t value);
@@ -464,6 +473,7 @@ internal ssize_t indexOfCharSmallJson(smallJsont *self, char c);
internal ssize_t indexOfDictSmallJson(smallJsont *self, smallDictt *dict);
internal ssize_t indexOfArraySmallJson(smallJsont *self, smallArrayt *array);
internal ssize_t indexOfArraycSmallJson(smallJsont *self, char **array);
+internal ssize_t indexOfCArraycSmallJson(smallJsont *self, const char **array);
internal ssize_t indexOfSmallBoolSmallJson(smallJsont *self, smallBoolt *value);
internal ssize_t indexOfSmallBytesSmallJson(smallJsont *self, smallBytest *value);
internal ssize_t indexOfSmallDoubleSmallJson(smallJsont *self, smallDoublet *value);
@@ -472,7 +482,7 @@ internal ssize_t indexOfSmallJsonSmallJson(smallJsont *self, smallJsont *value);
internal ssize_t indexOfSmallStringSmallJson(smallJsont *self, smallStringt *string);
internal ssize_t indexOfSmallContainerSmallJson(smallJsont *self UNUSED, smallContainert *container UNUSED);
internal ssize_t binarySearchSmallJson(smallJsont *self, baset *value);
-internal ssize_t binarySearchUndefinedSmallJson(smallJsont *self UNUSED, undefinedt *undefined UNUSED);
+internal ssize_t binarySearchUndefinedSmallJson(smallJsont *self UNUSED, undefinedt *u UNUSED);
internal ssize_t binarySearchBoolSmallJson(smallJsont *self, bool value);
internal ssize_t binarySearchDoubleSmallJson(smallJsont *self, double value);
internal ssize_t binarySearchIntSmallJson(smallJsont *self, int64_t value);
@@ -481,6 +491,7 @@ internal ssize_t binarySearchCharSmallJson(smallJsont *self, char c);
internal ssize_t binarySearchDictSmallJson(smallJsont *self, smallDictt *dict);
internal ssize_t binarySearchArraySmallJson(smallJsont *self, smallArrayt *array);
internal ssize_t binarySearchArraycSmallJson(smallJsont *self, char **array);
+internal ssize_t binarySearchCArraycSmallJson(smallJsont *self, const char **array);
internal ssize_t binarySearchSmallBoolSmallJson(smallJsont *self, smallBoolt *value);
internal ssize_t binarySearchSmallBytesSmallJson(smallJsont *self, smallBytest *value);
internal ssize_t binarySearchSmallDoubleSmallJson(smallJsont *self, smallDoublet *value);
@@ -494,6 +505,7 @@ internal bool icHasCharSmallJson(smallJsont *self, char c);
internal bool icHasDictSmallJson(smallJsont *self, smallDictt *dict);
internal bool icHasArraySmallJson(smallJsont *self, smallArrayt *array);
internal bool icHasArraycSmallJson(smallJsont *self, char **array);
+internal bool icHasCArraycSmallJson(smallJsont *self, const char **array);
internal bool icHasSmallStringSmallJson(smallJsont *self, smallStringt *string);
internal smallJsont* icFindSmallJson(smallJsont *self, const char *needle);
internal smallJsont* icFindCharSmallJson(smallJsont *self, char c);
@@ -505,6 +517,7 @@ internal ssize_t icIndexOfCharSmallJson(smallJsont *self, char c);
internal ssize_t icIndexOfDictSmallJson(smallJsont *self, smallDictt *dict);
internal ssize_t icIndexOfArraySmallJson(smallJsont *self, smallArrayt *array);
internal ssize_t icIndexOfArraycSmallJson(smallJsont *self, char **array);
+internal ssize_t icIndexOfCArraycSmallJson(smallJsont *self, const char **array);
internal ssize_t icIndexOfSmallStringSmallJson(smallJsont *self, smallStringt *string);
internal ssize_t icBinarySearchSmallJson(smallJsont *self, baset *value);
internal ssize_t icBinarySearchSSmallJson(smallJsont *self, const char *string);
@@ -512,9 +525,10 @@ internal ssize_t icBinarySearchCharSmallJson(smallJsont *self, char c);
internal ssize_t icBinarySearchDictSmallJson(smallJsont *self, smallDictt *dict);
internal ssize_t icBinarySearchArraySmallJson(smallJsont *self, smallArrayt *array);
internal ssize_t icBinarySearchArraycSmallJson(smallJsont *self, char **array);
+internal ssize_t icBinarySearchCArraycSmallJson(smallJsont *self, const char **array);
internal ssize_t icBinarySearchSmallStringSmallJson(smallJsont *self, smallStringt *string);
internal char* keyBySmallJson(smallJsont *self, baset *value);
-internal char* keyByUndefinedSmallJson(smallJsont *self, undefinedt *undefined);
+internal char* keyByUndefinedSmallJson(smallJsont *self, undefinedt *u);
internal char* keyByBoolSmallJson(smallJsont *self, bool value);
internal char* keyByDoubleSmallJson(smallJsont *self, double value);
internal char* keyByIntSmallJson(smallJsont *self, int64_t value);
@@ -523,6 +537,7 @@ internal char* keyByCharSmallJson(smallJsont *self, char c);
internal char* keyByDictSmallJson(smallJsont *self, smallDictt *dict);
internal char* keyByArraySmallJson(smallJsont *self, smallArrayt *array);
internal char* keyByArraycSmallJson(smallJsont *self, char **array);
+internal char* keyByCArraycSmallJson(smallJsont *self, const char **array);
internal char* keyBySmallBoolSmallJson(smallJsont *self, smallBoolt *value);
internal char* keyBySmallBytesSmallJson(smallJsont *self, smallBytest *value);
internal char* keyBySmallDoubleSmallJson(smallJsont *self, smallDoublet *value);
@@ -536,6 +551,7 @@ internal char* icKeyByCharSmallJson(smallJsont *self, char c);
internal char* icKeyByDictSmallJson(smallJsont *self, smallDictt *dict);
internal char* icKeyByArraySmallJson(smallJsont *self, smallArrayt *array);
internal char* icKeyByArraycSmallJson(smallJsont *self, char **array);
+internal char* icKeyByCArraycSmallJson(smallJsont *self, const char **array);
internal char* icKeyBySmallStringSmallJson(smallJsont *self, smallStringt *string);
internal smallJsont* replaceSmallJson(smallJsont *self, const char *olds, const char *news, size_t max);
internal smallJsont* replaceCharSSmallJson(smallJsont *self, char olds, const char *news, size_t max);
@@ -573,6 +589,7 @@ internal smallJsont* icReplaceCharJsonSmallJson(smallJsont *self, char olds, sma
internal smallJsont* icReplaceManySmallJson(smallJsont *self, const char *paramType, ...);
internal bool equalSmallJsonSmallArray(smallJsont *self, smallArrayt *array);
bool equalSmallJsonArray(smallJsont *self, char ** p2);
+bool equalSmallJsonCArray(smallJsont *self, const char ** p2);
bool equalSmallJsonBase(smallJsont *self, baset* p2);
internal bool equalSmallJsonCha(smallJsont* self, char p2);
internal bool equalSmallJsonChar(smallJsont* self, const char * p2);
@@ -591,6 +608,7 @@ internal bool equalSmallJsonSmallString(smallJsont* self, smallStringt* p2);
internal bool equalSmallJsonSmallDict(smallJsont* self, smallDictt* p2);
internal bool icEqualSmallJsonSmallArray(smallJsont *self, smallArrayt *array);
bool icEqualSmallJsonArray(smallJsont *self, char ** p2);
+bool icEqualSmallJsonCArray(smallJsont *self, const char ** p2);
bool icEqualSmallJsonBase(smallJsont *self, baset* p2);
internal bool icEqualSmallJsonSmallDict(smallJsont* self, smallDictt* p2);
internal bool icEqualSmallJsonSmallJson(smallJsont *self, smallJsont *string);
@@ -838,7 +856,7 @@ internal char **sDictToYML(sDictt* dict, int indent, int level);
internal char **sArrayToYML(sArrayt* array, int indent, int level);
internal char* toYMLSmallJson(smallJsont *self, int indent);
internal smallStringt* toYMLSmallStringSmallJson(smallJsont *self, int indent);
-internal bool parseSmallJson(smallJsont *self, char *input);
+internal bool parseSmallJson(smallJsont *self, const char *input);
internal bool parseSmallJsonSmallJson(smallJsont *self, smallJsont *input);
internal bool parseSmallStringSmallJson(smallJsont *self, smallStringt *input);
internal void addObject(smallJsont *self, smallt *obj);
@@ -847,7 +865,7 @@ internal int on_number(struct LaxJsonContext *context, char *x);
internal int on_primitive(struct LaxJsonContext *context, enum LaxJsonType type);
internal int on_begin(struct LaxJsonContext *context, enum LaxJsonType type);
internal int on_end(struct LaxJsonContext *context, enum LaxJsonType type UNUSED);
-internal bool parseYMLSmallJson(smallJsont *self, char *input);
+internal bool parseYMLSmallJson(smallJsont *self, const char *input);
internal bool parseYMLSmallJsonSmallJson(smallJsont *self, smallJsont *input);
internal bool parseYMLSmallStringSmallJson(smallJsont *self, smallStringt *input);
internal int on_stringY(smallJsont *self, const char *value, enum LaxJsonType type);
@@ -1447,7 +1465,7 @@ ssize_t icBinarySearchArraycSmallJsonG (smallJsont *self, char **array);
ssize_t icBinarySearchCArraycSmallJsonG (smallJsont *self, const char **array);
ssize_t icBinarySearchSmallStringSmallJsonG (smallJsont *self, smallStringt *string);
char* keyBySmallJsonG(smallJsont *self, baset *value);
-char* keyByUndefinedSmallJsonG(smallJsont *self, undefinedt *undefined);
+char* keyByUndefinedSmallJsonG(smallJsont *self, undefinedt *u);
char* keyByBoolSmallJsonG(smallJsont *self, bool value);
char* keyByDoubleSmallJsonG(smallJsont *self, double value);
char* keyByIntSmallJsonG(smallJsont *self, int64_t value);
@@ -1743,6 +1761,7 @@ void registerMethodsSmallJson(smallJsonFunctionst *f) {
f->setTopDict = setTopDictSmallJson;
f->setTopArray = setTopArraySmallJson;
f->setTopArrayc = setTopArraycSmallJson;
+ f->setTopCArrayc = setTopCArraycSmallJson;
f->setTopSmallBool = setTopSmallBoolSmallJson;
f->setTopSmallDouble = setTopSmallDoubleSmallJson;
f->setTopSmallInt = setTopSmallIntSmallJson;
@@ -1762,6 +1781,7 @@ void registerMethodsSmallJson(smallJsonFunctionst *f) {
f->setTopNFreeSmallJson = setTopNFreeSmallJsonSmallJson;
f->setTopNFreeSmallString = setTopNFreeSmallStringSmallJson;
f->fromArray = fromArraySmallJson;
+ f->fromCArray = fromCArraySmallJson;
f->fromArrayNFree = fromArrayNFreeSmallJson;
f->fromArrayDict = fromArrayDictSmallJson;
f->toArrayDict = toArrayDictSmallJson;
@@ -1803,6 +1823,7 @@ void registerMethodsSmallJson(smallJsonFunctionst *f) {
f->setDict = setDictSmallJson;
f->setArray = setArraySmallJson;
f->setArrayc = setArraycSmallJson;
+ f->setCArrayc = setCArraycSmallJson;
f->setSmallBool = setSmallBoolSmallJson;
f->setSmallBytes = setSmallBytesSmallJson;
f->setSmallDouble = setSmallDoubleSmallJson;
@@ -1841,6 +1862,7 @@ void registerMethodsSmallJson(smallJsonFunctionst *f) {
f->setAtDict = setAtDictSmallJson;
f->setAtArray = setAtArraySmallJson;
f->setAtArrayc = setAtArraycSmallJson;
+ f->setAtCArrayc = setAtCArraycSmallJson;
f->setAtSmallBool = setAtSmallBoolSmallJson;
f->setAtSmallBytes = setAtSmallBytesSmallJson;
f->setAtSmallDouble = setAtSmallDoubleSmallJson;
@@ -1975,6 +1997,7 @@ void registerMethodsSmallJson(smallJsonFunctionst *f) {
f->pushDict = pushDictSmallJson;
f->pushArray = pushArraySmallJson;
f->pushArrayc = pushArraycSmallJson;
+ f->pushCArrayc = pushCArraycSmallJson;
f->pushSmallBool = pushSmallBoolSmallJson;
f->pushSmallBytes = pushSmallBytesSmallJson;
f->pushSmallDouble = pushSmallDoubleSmallJson;
@@ -2030,6 +2053,7 @@ void registerMethodsSmallJson(smallJsonFunctionst *f) {
f->prependDict = prependDictSmallJson;
f->prependArray = prependArraySmallJson;
f->prependArrayc = prependArraycSmallJson;
+ f->prependCArrayc = prependCArraycSmallJson;
f->prependSmallBool = prependSmallBoolSmallJson;
f->prependSmallBytes = prependSmallBytesSmallJson;
f->prependSmallDouble = prependSmallDoubleSmallJson;
@@ -2082,6 +2106,7 @@ void registerMethodsSmallJson(smallJsonFunctionst *f) {
/* f->appendSmallJson = appendSmallJsonSmallJson */
/* f->appendSmallJsonNSmash = appendSmallJsonNSmashSmallJson */
f->appendArray = appendArraySmallJson;
+ f->appendCArray = appendCArraySmallJson;
f->appendNSmashArray = appendNSmashArraySmallJson;
f->shift = shiftSmallJson; {
f->shiftNSmash = shiftNSmashSmallJson; {
@@ -2151,6 +2176,7 @@ void registerMethodsSmallJson(smallJsonFunctionst *f) {
f->injectDict = injectDictSmallJson;
f->injectArray = injectArraySmallJson;
f->injectArrayc = injectArraycSmallJson;
+ f->injectCArrayc = injectCArraycSmallJson;
f->injectSmallBool = injectSmallBoolSmallJson;
f->injectSmallBytes = injectSmallBytesSmallJson;
f->injectSmallDouble = injectSmallDoubleSmallJson;
@@ -2188,6 +2214,7 @@ void registerMethodsSmallJson(smallJsonFunctionst *f) {
f->hasDict = hasDictSmallJson;
f->hasArray = hasArraySmallJson;
f->hasArrayc = hasArraycSmallJson;
+ f->hasCArrayc = hasCArraycSmallJson;
f->hasSmallBool = hasSmallBoolSmallJson;
f->hasSmallBytes = hasSmallBytesSmallJson;
f->hasSmallDouble = hasSmallDoubleSmallJson;
@@ -2209,6 +2236,7 @@ void registerMethodsSmallJson(smallJsonFunctionst *f) {
f->indexOfDict = indexOfDictSmallJson;
f->indexOfArray = indexOfArraySmallJson;
f->indexOfArrayc = indexOfArraycSmallJson;
+ f->indexOfCArrayc = indexOfCArraycSmallJson;
f->indexOfSmallBool = indexOfSmallBoolSmallJson;
f->indexOfSmallBytes = indexOfSmallBytesSmallJson;
f->indexOfSmallDouble = indexOfSmallDoubleSmallJson;
@@ -2226,6 +2254,7 @@ void registerMethodsSmallJson(smallJsonFunctionst *f) {
f->binarySearchDict = binarySearchDictSmallJson;
f->binarySearchArray = binarySearchArraySmallJson;
f->binarySearchArrayc = binarySearchArraycSmallJson;
+ f->binarySearchCArrayc = binarySearchCArraycSmallJson;
f->binarySearchSmallBool = binarySearchSmallBoolSmallJson;
f->binarySearchSmallBytes = binarySearchSmallBytesSmallJson;
f->binarySearchSmallDouble = binarySearchSmallDoubleSmallJson;
@@ -2239,6 +2268,7 @@ void registerMethodsSmallJson(smallJsonFunctionst *f) {
f->icHasDict = icHasDictSmallJson;
f->icHasArray = icHasArraySmallJson;
f->icHasArrayc = icHasArraycSmallJson;
+ f->icHasCArrayc = icHasCArraycSmallJson;
f->icHasSmallString = icHasSmallStringSmallJson;
f->icFind = icFindSmallJson;
f->icFindChar = icFindCharSmallJson;
@@ -2250,6 +2280,7 @@ void registerMethodsSmallJson(smallJsonFunctionst *f) {
f->icIndexOfDict = icIndexOfDictSmallJson;
f->icIndexOfArray = icIndexOfArraySmallJson;
f->icIndexOfArrayc = icIndexOfArraycSmallJson;
+ f->icIndexOfCArrayc = icIndexOfCArraycSmallJson;
f->icIndexOfSmallString = icIndexOfSmallStringSmallJson;
f->icBinarySearch = icBinarySearchSmallJson;
f->icBinarySearchS = icBinarySearchSSmallJson;
@@ -2257,6 +2288,7 @@ void registerMethodsSmallJson(smallJsonFunctionst *f) {
f->icBinarySearchDict = icBinarySearchDictSmallJson;
f->icBinarySearchArray = icBinarySearchArraySmallJson;
f->icBinarySearchArrayc = icBinarySearchArraycSmallJson;
+ f->icBinarySearchCArrayc = icBinarySearchCArraycSmallJson;
f->icBinarySearchSmallString = icBinarySearchSmallStringSmallJson;
f->keyBy = keyBySmallJson;
f->keyByUndefined = keyByUndefinedSmallJson;
@@ -2268,6 +2300,7 @@ void registerMethodsSmallJson(smallJsonFunctionst *f) {
f->keyByDict = keyByDictSmallJson;
f->keyByArray = keyByArraySmallJson;
f->keyByArrayc = keyByArraycSmallJson;
+ f->keyByCArrayc = keyByCArraycSmallJson;
f->keyBySmallBool = keyBySmallBoolSmallJson;
f->keyBySmallBytes = keyBySmallBytesSmallJson;
f->keyBySmallDouble = keyBySmallDoubleSmallJson;
@@ -2281,6 +2314,7 @@ void registerMethodsSmallJson(smallJsonFunctionst *f) {
f->icKeyByDict = icKeyByDictSmallJson;
f->icKeyByArray = icKeyByArraySmallJson;
f->icKeyByArrayc = icKeyByArraycSmallJson;
+ f->icKeyByCArrayc = icKeyByCArraycSmallJson;
f->icKeyBySmallString = icKeyBySmallStringSmallJson;
f->replace = replaceSmallJson;
f->replaceCharS = replaceCharSSmallJson;
@@ -2318,6 +2352,7 @@ void registerMethodsSmallJson(smallJsonFunctionst *f) {
f->icReplaceMany = icReplaceManySmallJson;
f->equalSmallArray = equalSmallJsonSmallArray;
f->equalArray = equalSmallJsonArray;
+ f->equalCArray = equalSmallJsonCArray;
f->equalBase = equalSmallJsonBase;
f->equalCha = equalSmallJsonCha;
f->equalChar = equalSmallJsonChar;
@@ -2336,6 +2371,7 @@ void registerMethodsSmallJson(smallJsonFunctionst *f) {
f->equalSmallDict = equalSmallJsonSmallDict;;
f->icEqualSmallArray = icEqualSmallJsonSmallArray;
f->icEqualArray = icEqualSmallJsonArray;
+ f->icEqualCArray = icEqualSmallJsonCArray;
f->icEqualBase = icEqualSmallJsonBase;
f->icEqualSmallDict = icEqualSmallJsonSmallDict;;
f->icEqualSmallJson = icEqualSmallJsonSmallJson;
@@ -2594,10 +2630,10 @@ smallJsont* createSJF(const char *paramType, ...) {
// push arguments to a list
va_start(pl, paramType);
- paramType = va_arg(pl, char *);
- while (paramType) {
- pushSSmallJson(r, (char *)paramType);
- paramType = va_arg(pl, char *);
+ char *param = va_arg(pl, char *);
+ while (param) {
+ pushSSmallJson(r, param);
+ param = va_arg(pl, char *);
}
va_end(pl);
return(r);
@@ -2702,6 +2738,8 @@ internal char* toStringSmallJson(smallJsont *self) {
return(sToString((smallt *)self->top));
case TOP_IS_ARRAY:
return(sToString((smallt *)self->topA));
+ default:;
+ logC("Unsupported type in smallJson object!");
}
// return never taken, avoid warning
return(NULL);
@@ -2769,9 +2807,11 @@ internal smallJsont* duplicateSmallJson(smallJsont *self) {
dup->iterKey = NULL;
dup->iterStep = self->iterStep;
if (dup->iterIndex != -1) {
- dup->iterElement = toBaset(sArrayGetTiny(dup->topA, dup->iterIndex));
+ dup->iterElement = toBaset(sArrayGetTiny(dup->topA, (uint32_t)dup->iterIndex));
}
break;
+ default:;
+ // self is empty, there is nothing to copy
}
return(dup);
}
@@ -2811,6 +2851,8 @@ internal void disposeSmallJson(smallJsont *self) {
self->topA = NULL;
}
break;
+ default:;
+ // self is empty, there is nothing to free
}
resetSmallJson(self);
@@ -2903,6 +2945,8 @@ internal smallt* getsoSmallJson(smallJsont *self) {
return((smallt*)self->top);
case TOP_IS_ARRAY:
return((smallt*)self->topA);
+ default:;
+ // self is empty, there is nothing to get
}
return(NULL);
}
@@ -2982,10 +3026,12 @@ internal smallJsont* mirrorSmallJson(smallJsont *self) {
mirror->iterKey = NULL;
mirror->iterStep = self->iterStep;
if (mirror->iterIndex != -1) {
- mirror->iterElement = toBaset(sArrayGetTiny(mirror->topA, mirror->iterIndex));
+ mirror->iterElement = toBaset(sArrayGetTiny(mirror->topA, (uint32_t)mirror->iterIndex));
}
}
break;
+ default:;
+ // there is no need to mirror other types
}
return(mirror);
}
@@ -3008,6 +3054,8 @@ internal const char* getTopTypeSmallJson(smallJsont *self) {
return(getSTypeS(self->top));
case TOP_IS_ARRAY:
return(getSTypeS(self->topA));
+ default:;
+ // self is empty, there is nothing to get
}
return(NULL);
}
@@ -3165,6 +3213,8 @@ internal smallJsont* setTopSmallJson(smallJsont *self, baset *value) {
sFree((smallt *)self->topA);
self->topA = v->topA;
break;
+ default:;
+ // value is empty, there is nothing to set
}
return(self);
}
@@ -3269,6 +3319,23 @@ internal smallJsont* setTopArraycSmallJson(smallJsont *self, char **value) {
return(r);
}
+internal smallJsont* setTopCArraycSmallJson(smallJsont *self, const char **value) {
+
+ if (!value) {
+ return(NULL);
+ }
+
+ smallArrayt *a = allocCArraySmallArray(value);
+ if (!a) {
+ return(NULL);
+ }
+ smallJsont *r = setTopNFreeArraySmallJson(self, a);
+ if (!r) {
+ terminateO(a);
+ }
+ return(r);
+}
+
internal smallJsont* setTopSmallBoolSmallJson(smallJsont *self, smallBoolt *value) {
if (checkObjectTypes && value && !isOSmallBool(value)) {
@@ -3515,6 +3582,52 @@ internal smallJsont* fromArraySmallJson(smallJsont *self, char **array, size_t s
return(self);
}
+// size 0 means NULL terminated array
+internal smallJsont* fromCArraySmallJson(smallJsont *self, const char **array, size_t size) {
+
+ // sanity checks
+ if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
+ return(NULL);
+ }
+
+ if (!array) {
+ return(NULL);
+ }
+
+ if (self->topIsA != SMALLJSON_IS_EMPTY) {
+ freeSmallJson(self);
+ }
+ self->topIsA = TOP_IS_ARRAY;
+
+ if (!size) {
+ forEachCCharP(array, e) {
+ sStringt *s = allocSStringTiny(*e);
+ if (!s) {
+ return(NULL);
+ }
+ sArrayPushTiny(&(self->topA), (smallt *) s);
+ }
+ return(self);
+ }
+
+ // copy array content
+ for (size_t i = 0 ; i < size ; i++) {
+ if (array[i]) {
+ // remove NULL strings
+ sStringt *s = allocSStringTiny(array[i]);
+ if (!s) {
+ return(NULL);
+ }
+ sArrayPushTiny(&(self->topA), (smallt *) s);
+ }
+ else {
+ sArrayPushTiny(&(self->topA), NULL);
+ }
+ }
+
+ return(self);
+}
+
internal smallJsont* fromArrayNFreeSmallJson(smallJsont *self, char **array, size_t size) {
smallJsont *r = fromArraySmallJson(self, array, size);
@@ -3619,6 +3732,8 @@ internal baset* getTopSmallJson(smallJsont *self) {
return((baset *)toBaset((smallt *)self->top));
case TOP_IS_ARRAY:
return((baset *)toBaset((smallt *)self->topA));
+ default:;
+ // self is empty, there is nothing to get
}
return(NULL);
}
@@ -3904,6 +4019,8 @@ internal jsonPathRest keyIsSmallJson(smallJsont *self UNUSED, const char *key) {
case IN_INDEX:
/* 2 [ following each other, not a path */
goto endKeyParse;
+ default:;
+ // do nothing
}
break;
case ']':
@@ -3918,6 +4035,8 @@ internal jsonPathRest keyIsSmallJson(smallJsont *self UNUSED, const char *key) {
case SEARCH:
/* missing [, not a path */
goto endKeyParse;
+ default:;
+ // do nothing
}
break;
default:
@@ -3939,6 +4058,8 @@ internal jsonPathRest keyIsSmallJson(smallJsont *self UNUSED, const char *key) {
escape = true;
}
break;
+ default:;
+ // do nothing
}
break;
}
@@ -3953,6 +4074,8 @@ internal jsonPathRest keyIsSmallJson(smallJsont *self UNUSED, const char *key) {
case '[':
keyIs = ARRAY_PATH;
break;
+ default:;
+ // do nothing
}
}
}
@@ -3982,13 +4105,13 @@ internal char* makeKeySmallJson(smallJsont *self UNUSED, const char *key) {
for (size_t i = 0 ; key[i] ; i++) {
if (key[i]=='"' || key[i]=='\\') {
- iAppendS(&r, BSLH);
+ pErrorNULL(iAppendS(&r, BSLH));
}
- iAppendCharS(&r, key[i]);
+ pErrorNULL(iAppendCharS(&r, key[i]));
}
// close quote
- iAppendS(&r, _);
+ pErrorNULL(iAppendS(&r, _));
return(r);
}
@@ -4155,6 +4278,12 @@ internal smallJsont* setArraycSmallJson(smallJsont *self, const char *key, char
// cg_c bug
}
+internal smallJsont* setCArraycSmallJson(smallJsont *self, const char *key, const char **array) {
+
+ mainSetJsonPath(if (!array) return NULL/*initValue*/, sArrayt *A = allocSArray(); if (!A) return NULL;forEachCCharP(array, e){sStringt *s = allocSStringTiny(*e);if (!s) {if (A) sArrayFreeTiny(A); return NULL;};sArrayPushTiny(&A, (smallt *) s);}o = (smallt *)A; isNew = true/*allocValue*/, setJsonPathsFree/*subSetJsonPath*/);
+ // cg_c bug
+}
+
internal smallJsont* setSmallBoolSmallJson(smallJsont *self, const char *key, smallBoolt *value) {
mainSetJsonPath(if (!value) return NULL; if (checkObjectTypes && value && !isOSmallBool(value)) return NULL/*initValue*/, if (!value->value) {isError(value->value, allocSBool(false)) return NULL;} o = (smallt*)value->value/*allocValue*/, setJsonPath/*subSetJsonPath*/);
@@ -4209,16 +4338,16 @@ internal smallJsont* setNFreeSmallJson(smallJsont *self, const char *key, baset
return(self);
}
-internal smallJsont* setNFreeUndefinedSmallJson(smallJsont *self, const char *key, undefinedt *undefined) {
+internal smallJsont* setNFreeUndefinedSmallJson(smallJsont *self, const char *key, undefinedt *u) {
- if (!undefined) {
+ if (!u) {
return(NULL);
}
smallJsont *r = setUndefinedSmallJson(self, key);
if (r) {
/* free parameter only when successfully stored in self */
- terminateO(undefined);
+ terminateO(u);
}
return(r);
}
@@ -4394,10 +4523,10 @@ internal smallJsont* setAtSmallJson(smallJsont *self, int64_t index, baset *valu
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- sArraySetTiny(self->topA, index, toSmallt(value));
+ sArraySetTiny(self->topA, (uint32_t)index, toSmallt(value));
return(self);
}
@@ -4414,14 +4543,14 @@ internal smallJsont* setAtUndefinedSmallJson(smallJsont *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
smallt *o = (smallt *) allocSUndefined();
if (!o) {
return(NULL);
}
- sArraySetTiny(self->topA, index, o);
+ sArraySetTiny(self->topA, (uint32_t)index, o);
return(self);
}
@@ -4438,14 +4567,14 @@ internal smallJsont* setAtBoolSmallJson(smallJsont *self, int64_t index, bool va
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
smallt *o = (smallt *) allocSBool(value);
if (!o) {
return(NULL);
}
- sArraySetTiny(self->topA, index, o);
+ sArraySetTiny(self->topA, (uint32_t)index, o);
return(self);
}
@@ -4462,14 +4591,14 @@ internal smallJsont* setAtDoubleSmallJson(smallJsont *self, int64_t index, doubl
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
smallt *o = (smallt *) allocSDouble(value);
if (!o) {
return(NULL);
}
- sArraySetTiny(self->topA, index, o);
+ sArraySetTiny(self->topA, (uint32_t)index, o);
return(self);
}
@@ -4486,14 +4615,14 @@ internal smallJsont* setAtIntSmallJson(smallJsont *self, int64_t index, int64_t
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
smallt *o = (smallt *) allocSInt(value);
if (!o) {
return(NULL);
}
- sArraySetTiny(self->topA, index, o);
+ sArraySetTiny(self->topA, (uint32_t)index, o);
return(self);
}
@@ -4510,7 +4639,7 @@ internal smallJsont* setAtSSmallJson(smallJsont *self, int64_t index, const char
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
smallt *o;
@@ -4518,7 +4647,7 @@ internal smallJsont* setAtSSmallJson(smallJsont *self, int64_t index, const char
if (!o) {
return(NULL);
}
- sArraySetTiny(self->topA, index, o);
+ sArraySetTiny(self->topA, (uint32_t)index, o);
return(self);
}
@@ -4549,14 +4678,14 @@ internal smallJsont* setAtDictSmallJson(smallJsont *self, int64_t index, smallDi
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
if (!dict->d) {
isError(dict->d, allocSDict()) return(NULL);
}
- sArraySetTiny(self->topA, index, (smallt *)dict->d);
+ sArraySetTiny(self->topA, (uint32_t)index, (smallt *)dict->d);
return(self);
}
@@ -4578,7 +4707,7 @@ internal smallJsont* setAtArraySmallJson(smallJsont *self, int64_t index, smallA
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
if (!array->a) {
@@ -4586,7 +4715,7 @@ internal smallJsont* setAtArraySmallJson(smallJsont *self, int64_t index, smallA
isError(array->a, allocSArray()) return(NULL);
}
- sArraySetTiny(self->topA, index, (smallt *)array->a);
+ sArraySetTiny(self->topA, (uint32_t)index, (smallt *)array->a);
return(self);
}
@@ -4603,7 +4732,7 @@ internal smallJsont* setAtArraycSmallJson(smallJsont *self, int64_t index, char
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
sArrayt *a = allocSArray();
@@ -4622,7 +4751,43 @@ internal smallJsont* setAtArraycSmallJson(smallJsont *self, int64_t index, char
sArrayPushTiny(&a, (smallt *) s);
}
- sArraySetTiny(self->topA, index, (smallt *)a);
+ sArraySetTiny(self->topA, (uint32_t)index, (smallt *)a);
+ return(self);
+}
+
+internal smallJsont* setAtCArraycSmallJson(smallJsont *self, int64_t index, const char **array) {
+
+ if (self->topIsA != TOP_IS_ARRAY || !array) {
+ return(NULL);
+ }
+
+ if (index >= (int64_t)lenSmallJson(self)) {
+ return(NULL);
+ }
+ if (index < -(int64_t)lenSmallJson(self)) {
+ return(NULL);
+ }
+ if (index < 0) {
+ index = (int64_t)lenSmallJson(self) + index;
+ }
+
+ sArrayt *a = allocSArray();
+ if (!a) {
+ return(NULL);
+ }
+
+ forEachCCharP(array, e) {
+ sStringt *s = allocSStringTiny(*e);
+ if (!s) {
+ if (a) {
+ sArrayFreeTiny(a);
+ }
+ return(NULL);
+ }
+ sArrayPushTiny(&a, (smallt *) s);
+ }
+
+ sArraySetTiny(self->topA, (uint32_t)index, (smallt *)a);
return(self);
}
@@ -4643,13 +4808,13 @@ internal smallJsont* setAtSmallBoolSmallJson(smallJsont *self, int64_t index, sm
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
if (!value->value) {
isError(value->value, allocSBool(false)) return(NULL);
}
- sArraySetTiny(self->topA, index, (smallt *) value->value);
+ sArraySetTiny(self->topA, (uint32_t)index, (smallt *) value->value);
return(self);
}
@@ -4670,13 +4835,13 @@ internal smallJsont* setAtSmallBytesSmallJson(smallJsont *self, int64_t index, s
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
if (!value->B) {
isError(value->B, allocSBytes()) return(NULL);
}
- sArraySetTiny(self->topA, index, (smallt*) value->B);
+ sArraySetTiny(self->topA, (uint32_t)index, (smallt*) value->B);
return(self);
}
@@ -4697,13 +4862,13 @@ internal smallJsont* setAtSmallDoubleSmallJson(smallJsont *self, int64_t index,
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
if (!value->value) {
isError(value->value, allocSDouble(0)) return(NULL);
}
- sArraySetTiny(self->topA, index, (smallt*) value->value);
+ sArraySetTiny(self->topA, (uint32_t)index, (smallt*) value->value);
return(self);
}
@@ -4724,13 +4889,13 @@ internal smallJsont* setAtSmallIntSmallJson(smallJsont *self, int64_t index, sma
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
if (!value->value) {
isError(value->value, allocSInt(0)) return(NULL);
}
- sArraySetTiny(self->topA, index, (smallt*) value->value);
+ sArraySetTiny(self->topA, (uint32_t)index, (smallt*) value->value);
return(self);
}
@@ -4751,7 +4916,7 @@ internal smallJsont* setAtSmallJsonSmallJson(smallJsont *self, int64_t index, sm
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
smallt *o = getsoO(value);
@@ -4761,7 +4926,7 @@ internal smallJsont* setAtSmallJsonSmallJson(smallJsont *self, int64_t index, sm
setsoO(value, o);
}
- sArraySetTiny(self->topA, index, o);
+ sArraySetTiny(self->topA, (uint32_t)index, o);
return(self);
}
@@ -4782,13 +4947,13 @@ internal smallJsont* setAtSmallStringSmallJson(smallJsont *self, int64_t index,
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
if (!string->data) {
isError(string->data, allocSStringTiny("")) return(NULL);
}
- sArraySetTiny(self->topA, index, (smallt *)string->data);
+ sArraySetTiny(self->topA, (uint32_t)index, (smallt *)string->data);
return(self);
}
@@ -4810,13 +4975,13 @@ internal smallJsont* setAtSmallContainerSmallJson(smallJsont *self, int64_t inde
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
if (!container->data) {
isError(container->data, allocSContainer(NULL)) return(NULL);
}
- sArraySetTiny(self->topA, index, (smallt *) container->data);
+ sArraySetTiny(self->topA, (uint32_t)index, (smallt *) container->data);
return(self);
}
@@ -4833,14 +4998,14 @@ internal smallJsont* setAtNFreeSmallJson(smallJsont *self, int64_t index, baset
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
smallt *o = toSmallt(value);
if (!o) {
return(NULL);
}
- sArraySetTiny(self->topA, index, o);
+ sArraySetTiny(self->topA, (uint32_t)index, o);
if (!(o->type == CONTAINER && (((sContainert*)o)->dataType == SH_DT_BASET))) {
finishO(value);
@@ -4848,7 +5013,7 @@ internal smallJsont* setAtNFreeSmallJson(smallJsont *self, int64_t index, baset
return(self);
}
-internal smallJsont* setAtNFreeUndefinedSmallJson(smallJsont *self, int64_t index, undefinedt *undefined) {
+internal smallJsont* setAtNFreeUndefinedSmallJson(smallJsont *self, int64_t index, undefinedt *u) {
if (self->topIsA != TOP_IS_ARRAY) {
return(NULL);
@@ -4856,7 +5021,7 @@ internal smallJsont* setAtNFreeUndefinedSmallJson(smallJsont *self, int64_t inde
smallJsont *r = setAtUndefinedSmallJson(self, index);;
if (r) {
- terminateO(undefined);
+ terminateO(u);
}
return(r);
}
@@ -5022,7 +5187,7 @@ internal smallJsont* setPAtDictSmallJson(smallJsont *self, int64_t index, smallD
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
if (!dict->d) {
@@ -5030,7 +5195,7 @@ internal smallJsont* setPAtDictSmallJson(smallJsont *self, int64_t index, smallD
return(NULL);
}
- sArraySetP(self->topA, index, (smallt *)dict->d);
+ sArraySetP(self->topA, (uint32_t)index, (smallt *)dict->d);
return(self);
}
@@ -5051,7 +5216,7 @@ internal smallJsont* setPAtArraySmallJson(smallJsont *self, int64_t index, small
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
if (!array->a) {
@@ -5059,7 +5224,7 @@ internal smallJsont* setPAtArraySmallJson(smallJsont *self, int64_t index, small
return(NULL);
}
- sArraySetP(self->topA, index, (smallt *)array->a);
+ sArraySetP(self->topA, (uint32_t)index, (smallt *)array->a);
return(self);
}
@@ -5080,7 +5245,7 @@ internal smallJsont* setPAtSmallJsonSmallJson(smallJsont *self, int64_t index, s
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
smallt *o;
@@ -5089,7 +5254,7 @@ internal smallJsont* setPAtSmallJsonSmallJson(smallJsont *self, int64_t index, s
// realloc error
return(NULL);
}
- sArraySetP(self->topA, index, o);
+ sArraySetP(self->topA, (uint32_t)index, o);
return(self);
}
@@ -5110,7 +5275,7 @@ internal smallJsont* setPAtSmallStringSmallJson(smallJsont *self, int64_t index,
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
if (!string->data) {
@@ -5119,7 +5284,7 @@ internal smallJsont* setPAtSmallStringSmallJson(smallJsont *self, int64_t index,
}
smallt *o = (smallt *) string->data;
- sArraySetP(self->topA, index, o);
+ sArraySetP(self->topA, (uint32_t)index, o);
return(self);
}
@@ -5140,7 +5305,7 @@ internal smallJsont* setPAtNFreeDictSmallJson(smallJsont *self, int64_t index, s
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
if (!dict->d) {
@@ -5148,7 +5313,7 @@ internal smallJsont* setPAtNFreeDictSmallJson(smallJsont *self, int64_t index, s
return(NULL);
}
- sArraySetP(self->topA, index, (smallt *)dict->d);
+ sArraySetP(self->topA, (uint32_t)index, (smallt *)dict->d);
finishO(dict);
return(self);
}
@@ -5171,7 +5336,7 @@ internal smallJsont* setPAtNFreeArraySmallJson(smallJsont *self, int64_t index,
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
if (!array->a) {
@@ -5179,7 +5344,7 @@ internal smallJsont* setPAtNFreeArraySmallJson(smallJsont *self, int64_t index,
return(NULL);
}
- sArraySetP(self->topA, index, (smallt *)array->a);
+ sArraySetP(self->topA, (uint32_t)index, (smallt *)array->a);
finishO(array);
return(self);
}
@@ -5201,7 +5366,7 @@ internal smallJsont* setPAtNFreeSmallJsonSmallJson(smallJsont *self, int64_t ind
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
smallt *o;
@@ -5210,7 +5375,7 @@ internal smallJsont* setPAtNFreeSmallJsonSmallJson(smallJsont *self, int64_t ind
// realloc error
return(NULL);
}
- sArraySetP(self->topA, index, o);
+ sArraySetP(self->topA, (uint32_t)index, o);
finishO(value);
return(self);
}
@@ -5232,7 +5397,7 @@ internal smallJsont* setPAtNFreeSmallStringSmallJson(smallJsont *self, int64_t i
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
if (!string->data) {
@@ -5242,7 +5407,7 @@ internal smallJsont* setPAtNFreeSmallStringSmallJson(smallJsont *self, int64_t i
smallt *o = (smallt *) string->data;
finishO(string);
- sArraySetP(self->topA, index, o);
+ sArraySetP(self->topA, (uint32_t)index, o);
return(self);
}
@@ -5474,6 +5639,40 @@ internal smallJsont* pushArraycSmallJson(smallJsont *self, char **array) {
return(self);
}
+internal smallJsont* pushCArraycSmallJson(smallJsont *self, const char **array) {
+
+ if (!array) {
+ return(NULL);
+ }
+
+ switch(self->topIsA) {
+ case SMALLJSON_IS_EMPTY:
+ self->topIsA = TOP_IS_ARRAY;
+ FALLTHRU;
+ case TOP_IS_ARRAY:
+ ;sArrayt *a = allocSArray();
+ if (!a) {
+ return(NULL);
+ }
+
+ forEachCCharP(array, e) {
+ sStringt *s = allocSStringTiny(*e);
+ if (!s) {
+ if (a) {
+ sArrayFreeTiny(a);
+ }
+ return(NULL);
+ }
+ sArrayPushTiny(&a, (smallt *) s);
+ }
+ sArrayPushTiny(&(self->topA), (smallt *) a);
+ break;
+ default:
+ return(NULL);
+ }
+ return(self);
+}
+
internal smallJsont* pushSmallBoolSmallJson(smallJsont *self, smallBoolt *value) {
if (!value) {
@@ -5718,11 +5917,11 @@ internal smallJsont* pushNFreeSmallJson(smallJsont *self, baset *value) {
return(self);
}
-internal smallJsont* pushNFreeUndefinedSmallJson(smallJsont *self, undefinedt *undefined) {
+internal smallJsont* pushNFreeUndefinedSmallJson(smallJsont *self, undefinedt *u) {
smallJsont *r = pushUndefinedSmallJson(self);;
if (r) {
- terminateO(undefined);
+ terminateO(u);
}
return(r);
}
@@ -5885,6 +6084,8 @@ internal smallJsont* pushManySmallJson(smallJsont *self, ...) {
finishO(r);
disposeO(&l);
break;
+ default:;
+ // self type doesn't support push, TODO return NULL to signal error
}
return(self);
}
@@ -5942,6 +6143,8 @@ internal smallJsont* pushManySSmallJson(smallJsont *self, ...) {
finishO(r);
freeO(&l);
break;
+ default:;
+ // self type doesn't support push, TODO return NULL to signal error
}
return(self);
}
@@ -6005,6 +6208,8 @@ internal smallJsont* pushNFreeManySmallJson(smallJsont *self, ...) {
//TODO self->_len = r->_len
finishO(r);
break;
+ default:;
+ // self type doesn't support push, TODO return NULL to signal error
}
return(self);
}
@@ -6062,6 +6267,8 @@ internal smallJsont* pushNFreeManySSmallJson(smallJsont *self, ...) {
finishO(r);
freeO(&l);
break;
+ default:;
+ // self type doesn't support push, TODO return NULL to signal error
}
return(self);
}
@@ -6596,7 +6803,7 @@ internal double popNumSmallJson(smallJsont *self) {
r = getValO((smallDoublet*)e);
}
elif (isOSmallInt(e)) {
- r = getValO((smallIntt*)e);
+ r = (double)getValO((smallIntt*)e);
}
terminateO(e);
return(r);
@@ -6734,6 +6941,9 @@ internal smallJsont* prependSSmallJson(smallJsont *self, const char *string) {
insertSSmallJson(self, 0, string);
break;
+ default:;
+ // not reachable
+ logC("Check this function!");
}
return(self);
}
@@ -6831,6 +7041,39 @@ internal smallJsont* prependArraycSmallJson(smallJsont *self, char **array) {
return(self);
}
+internal smallJsont* prependCArraycSmallJson(smallJsont *self, const char **array) {
+
+ if (!array) {
+ return(NULL);
+ }
+
+ if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
+ return(NULL);
+ }
+
+ if (self->topIsA == SMALLJSON_IS_EMPTY) {
+ self->topIsA = TOP_IS_ARRAY;
+ }
+
+ sArrayt *a = allocSArray();
+ if (!a) {
+ return(NULL);
+ }
+
+ forEachCCharP(array, e) {
+ sStringt *s = allocSStringTiny(*e);
+ if (!s) {
+ if ((a)) {
+ sArrayFreeTiny(a);
+ }
+ return(NULL);
+ }
+ sArrayPushTiny(&a, (smallt *) s);
+ }
+ sArrayPrependTiny(&(self->topA), (smallt *) a);
+ return(self);
+}
+
internal smallJsont* prependSmallBoolSmallJson(smallJsont *self, smallBoolt *value) {
if (!value) {
@@ -7003,6 +7246,9 @@ internal smallJsont* prependSmallStringSmallJson(smallJsont *self, smallStringt
insertStringSmallJson(self, 0, string);
break;
+ default:;
+ // not reachable
+ logC("Check this function!");
}
return(self);
}
@@ -7061,11 +7307,11 @@ internal smallJsont* prependNFreeSmallJson(smallJsont *self, baset *value) {
return(self);
}
-internal smallJsont* prependNFreeUndefinedSmallJson(smallJsont *self, undefinedt *undefined) {
+internal smallJsont* prependNFreeUndefinedSmallJson(smallJsont *self, undefinedt *u) {
smallJsont *r = prependUndefinedSmallJson(self);;
if (r) {
- terminateO(undefined);
+ terminateO(u);
}
return(r);
}
@@ -7225,7 +7471,7 @@ internal undefinedt* dequeueUndefinedSmallJson(smallJsont *self) {
size_t i;
for (i = 0 ; i < len ; i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
if (o) {
break;
}
@@ -7242,10 +7488,10 @@ internal undefinedt* dequeueUndefinedSmallJson(smallJsont *self) {
// finish dequeuing
smallt **arr = &(self->topA->data);
// shift list
- for (uint32_t j = i+1 ; j < self->topA->count ; j++) {
+ for (uint32_t j = (uint32_t)i+1 ; j < self->topA->count ; j++) {
arr[j-i-1] = arr[j];
}
- self->topA->count -= i+1;;
+ self->topA->count -= (uint32_t)i+1;
free(o);
return(allocUndefined());
@@ -7350,7 +7596,7 @@ internal smallDictt* dequeueDictSmallJson(smallJsont *self) {
size_t i;
for (i = 0 ; i < len ; i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
if (o) {
break;
}
@@ -7367,10 +7613,10 @@ internal smallDictt* dequeueDictSmallJson(smallJsont *self) {
// finish dequeuing
smallt **arr = &(self->topA->data);
// shift list
- for (uint32_t j = i+1 ; j < self->topA->count ; j++) {
+ for (uint32_t j = (uint32_t)i+1 ; j < self->topA->count ; j++) {
arr[j-i-1] = arr[j];
}
- self->topA->count -= i+1;;
+ self->topA->count -= (uint32_t)i+1;
return((smallDictt*) toBaset(o));
}
@@ -7390,7 +7636,7 @@ internal smallArrayt* dequeueArraySmallJson(smallJsont *self) {
size_t i;
for (i = 0 ; i < len ; i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
if (o) {
break;
}
@@ -7407,10 +7653,10 @@ internal smallArrayt* dequeueArraySmallJson(smallJsont *self) {
// finish dequeuing
smallt **arr = &(self->topA->data);
// shift list
- for (uint32_t j = i+1 ; j < self->topA->count ; j++) {
+ for (uint32_t j = (uint32_t)i+1 ; j < self->topA->count ; j++) {
arr[j-i-1] = arr[j];
}
- self->topA->count -= i+1;;
+ self->topA->count -= (uint32_t)i+1;
return((smallArrayt*) toBaset(o));
}
@@ -7430,7 +7676,7 @@ internal smallBoolt* dequeueSmallBoolSmallJson(smallJsont *self) {
size_t i;
for (i = 0 ; i < len ; i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
if (o) {
break;
}
@@ -7447,10 +7693,10 @@ internal smallBoolt* dequeueSmallBoolSmallJson(smallJsont *self) {
// finish dequeuing
smallt **arr = &(self->topA->data);
// shift list
- for (uint32_t j = i+1 ; j < self->topA->count ; j++) {
+ for (uint32_t j = (uint32_t)i+1 ; j < self->topA->count ; j++) {
arr[j-i-1] = arr[j];
}
- self->topA->count -= i+1;;
+ self->topA->count -= (uint32_t)i+1;
return((smallBoolt*) toBaset(o));
}
@@ -7470,7 +7716,7 @@ internal smallBytest* dequeueSmallBytesSmallJson(smallJsont *self) {
size_t i;
for (i = 0 ; i < len ; i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
if (o) {
break;
}
@@ -7487,10 +7733,10 @@ internal smallBytest* dequeueSmallBytesSmallJson(smallJsont *self) {
// finish dequeuing
smallt **arr = &(self->topA->data);
// shift list
- for (uint32_t j = i+1 ; j < self->topA->count ; j++) {
+ for (uint32_t j = (uint32_t)i+1 ; j < self->topA->count ; j++) {
arr[j-i-1] = arr[j];
}
- self->topA->count -= i+1;;
+ self->topA->count -= (uint32_t)i+1;
return((smallBytest*) toBaset(o));
}
@@ -7510,7 +7756,7 @@ internal smallDoublet* dequeueSmallDoubleSmallJson(smallJsont *self) {
size_t i;
for (i = 0 ; i < len ; i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
if (o) {
break;
}
@@ -7527,10 +7773,10 @@ internal smallDoublet* dequeueSmallDoubleSmallJson(smallJsont *self) {
// finish dequeuing
smallt **arr = &(self->topA->data);
// shift list
- for (uint32_t j = i+1 ; j < self->topA->count ; j++) {
+ for (uint32_t j = (uint32_t)i+1 ; j < self->topA->count ; j++) {
arr[j-i-1] = arr[j];
}
- self->topA->count -= i+1;;
+ self->topA->count -= (uint32_t)i+1;
return((smallDoublet*) toBaset(o));
}
@@ -7550,7 +7796,7 @@ internal smallIntt* dequeueSmallIntSmallJson(smallJsont *self) {
size_t i;
for (i = 0 ; i < len ; i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
if (o) {
break;
}
@@ -7567,10 +7813,10 @@ internal smallIntt* dequeueSmallIntSmallJson(smallJsont *self) {
// finish dequeuing
smallt **arr = &(self->topA->data);
// shift list
- for (uint32_t j = i+1 ; j < self->topA->count ; j++) {
+ for (uint32_t j = (uint32_t)i+1 ; j < self->topA->count ; j++) {
arr[j-i-1] = arr[j];
}
- self->topA->count -= i+1;;
+ self->topA->count -= (uint32_t)i+1;
return((smallIntt*) toBaset(o));
}
@@ -7590,7 +7836,7 @@ internal smallJsont* dequeueSmallJsonSmallJson(smallJsont *self) {
size_t i;
for (i = 0 ; i < len ; i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
if (o) {
break;
}
@@ -7607,10 +7853,10 @@ internal smallJsont* dequeueSmallJsonSmallJson(smallJsont *self) {
// finish dequeuing
smallt **arr = &(self->topA->data);
// shift list
- for (uint32_t j = i+1 ; j < self->topA->count ; j++) {
+ for (uint32_t j = (uint32_t)i+1 ; j < self->topA->count ; j++) {
arr[j-i-1] = arr[j];
}
- self->topA->count -= i+1;;
+ self->topA->count -= (uint32_t)i+1;
baset *e = toBaset(o);
@@ -7638,7 +7884,7 @@ internal smallStringt* dequeueSmallStringSmallJson(smallJsont *self) {
size_t i;
for (i = 0 ; i < len ; i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
if (o) {
break;
}
@@ -7655,10 +7901,10 @@ internal smallStringt* dequeueSmallStringSmallJson(smallJsont *self) {
// finish dequeuing
smallt **arr = &(self->topA->data);
// shift list
- for (uint32_t j = i+1 ; j < self->topA->count ; j++) {
+ for (uint32_t j = (uint32_t)i+1 ; j < self->topA->count ; j++) {
arr[j-i-1] = arr[j];
}
- self->topA->count -= i+1;;
+ self->topA->count -= (uint32_t)i+1;
return((smallStringt*) toBaset(o));
}
@@ -7690,7 +7936,7 @@ internal smallContainert* dequeueSmallContainerSmallJson(smallJsont *self) {
size_t i;
for (i = 0 ; i < len ; i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
if (o) {
break;
}
@@ -7711,10 +7957,10 @@ internal smallContainert* dequeueSmallContainerSmallJson(smallJsont *self) {
// finish dequeuing
smallt **arr = &(self->topA->data);
// shift list
- for (uint32_t j = i+1 ; j < self->topA->count ; j++) {
+ for (uint32_t j = (uint32_t)i+1 ; j < self->topA->count ; j++) {
arr[j-i-1] = arr[j];
}
- self->topA->count -= i+1;;
+ self->topA->count -= (uint32_t)i+1;
return((smallContainert*) toBaset(o));
}
@@ -7734,7 +7980,7 @@ internal double dequeueNumSmallJson(smallJsont *self) {
size_t i;
for (i = 0 ; i < len ; i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
if (o) {
break;
}
@@ -7751,10 +7997,10 @@ internal double dequeueNumSmallJson(smallJsont *self) {
// finish dequeuing
smallt **arr = &(self->topA->data);
// shift list
- for (uint32_t j = i+1 ; j < self->topA->count ; j++) {
+ for (uint32_t j = (uint32_t)i+1 ; j < self->topA->count ; j++) {
arr[j-i-1] = arr[j];
}
- self->topA->count -= i+1;;
+ self->topA->count -= (uint32_t)i+1;
baset *e = toBaset(o);
@@ -7763,7 +8009,7 @@ internal double dequeueNumSmallJson(smallJsont *self) {
r = getValO((smallDoublet*)e);
}
elif (isOSmallInt(e)) {
- r = getValO((smallIntt*)e);
+ r = (double)getValO((smallIntt*)e);
}
terminateO(e);
return(r);
@@ -7783,7 +8029,9 @@ internal smallJsont* reverseSmallJson(smallJsont *self) {
return(self);
}
- sArrayReverseTiny(self->topA);
+ if (!sArrayReverseTiny(self->topA)) {
+ return(NULL);
+ }
return(self);
}
@@ -7951,6 +8199,9 @@ internal smallJsont* mergeSmallJson(smallJsont *self, smallJsont *smallJson) {
sArrayPushTiny(&(self->topA), o);
}
break;
+ default:;
+ // not reachable
+ logC("Check this function!");
}
return(self);
}
@@ -8083,6 +8334,34 @@ internal smallJsont* appendArraySmallJson(smallJsont *self, char **array) {
return(self);
}
+internal smallJsont* appendCArraySmallJson(smallJsont *self, const char **array) {
+
+ if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
+ return(NULL);
+ }
+
+ if (!array) {
+ return(NULL);
+ }
+
+ if (!*array) {
+ return(self);
+ }
+
+ if (self->topIsA == SMALLJSON_IS_EMPTY) {
+ self->topIsA = TOP_IS_ARRAY;
+ }
+
+ forEachCCharP(array, e) {
+ sStringt *s = allocSStringTiny(*e);
+ if (!s) {
+ return(NULL);
+ }
+ sArrayPushTiny(&(self->topA), (smallt *) s);
+ }
+ return(self);
+}
+
internal smallJsont* appendNSmashArraySmallJson(smallJsont *self, char **array) {
if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
@@ -8230,20 +8509,20 @@ internal smallJsont* sliceSmallJson(smallJsont *self, int64_t start, int64_t end
return(NULL);
}
if (end > (int64_t)len) {
- end = len;
+ end = (int64_t)len;
}
if (start <= -(int64_t)len) {
- start = -len;
+ start = -(int64_t)len;
}
if (end <= -(int64_t)len) {
emptySmallJson(self);
return(NULL);
}
if (start < 0) {
- start = len + start;
+ start = (int64_t)len + start;
}
if (end <= 0) {
- end = len + end;
+ end = (int64_t)len + end;
}
if (end < start) {
emptySmallJson(self);
@@ -8260,8 +8539,8 @@ internal smallJsont* sliceSmallJson(smallJsont *self, int64_t start, int64_t end
else {
// start < end < len
- sArrayDelRangeTiny(self->topA, end, len);
- sArrayDelRangeTiny(self->topA, 0, start);
+ sArrayDelRangeTiny(self->topA, (uint32_t)end, (uint32_t)len);
+ sArrayDelRangeTiny(self->topA, 0, (uint32_t)start);
}
break;
case TOP_IS_STRING:
@@ -8272,17 +8551,20 @@ internal smallJsont* sliceSmallJson(smallJsont *self, int64_t start, int64_t end
// start < end < len
// copy range to a new smallString
n = end - start;
- s = malloc(n+1);
+ s = malloc((size_t)n+1);
if (!s) {
return(NULL);
}
- s = strncpy(s, sStringGetTiny(self->topS) + start, n);
+ s = strncpy(s, sStringGetTiny(self->topS) + start, (size_t)n);
s[n] = 0;
}
freeSmallJson(self);
setTopNFreeStringSmallJson(self, s);
break;
+ default:
+ // not reachable
+ logC("Check this function!");
}
return(self);
}
@@ -8298,7 +8580,7 @@ internal smallJsont* cropSmallJson(smallJsont *self, int64_t start, int64_t end)
return(NULL);
}
- len = lenSmallJson(self);
+ len = (int64_t)lenSmallJson(self);
if (!len) {
return(NULL);
@@ -8337,6 +8619,9 @@ internal smallJsont* cropSmallJson(smallJsont *self, int64_t start, int64_t end)
case TOP_IS_STRING:
setTypeStringSmallJson(r);
break;
+ default:
+ // not reachable
+ logC("Check this function!");
}
if (start < end) {
@@ -8345,7 +8630,7 @@ internal smallJsont* cropSmallJson(smallJsont *self, int64_t start, int64_t end)
case TOP_IS_ARRAY:
// start < end < len
for (int64_t i=0;i < n;i++) {
- o = sArrayGetTiny(self->topA, start+i);
+ o = sArrayGetTiny(self->topA, (uint32_t)(start+i));
sArrayPushTiny(&(r->topA), o);
}
@@ -8356,24 +8641,27 @@ internal smallJsont* cropSmallJson(smallJsont *self, int64_t start, int64_t end)
arr[start+i] = arr[end + i];
}
- self->topA->count -= end - start;
+ self->topA->count -= (uint32_t)(end - start);
break;
case TOP_IS_STRING:
// start < end < len
- l = malloc((n+1) * sizeof(char));
+ l = malloc(((size_t)n+1) * sizeof(char));
if (!l) {
terminateO(r);
return(NULL);
}
char *string = sStringGetTiny(self->topS);
- strLCpy(l, (n+1) * sizeof(char), string+start);
- strLCpy(string+start, len-end+1, string+end);
+ pErrorNULL(strLCpy(l, ((size_t)n+1) * sizeof(char), string+start));
+ memmove(string+start, string+end, (size_t)(len-end+1));
// TODO self->_len -= n
sFree((smallt*)r->topS);
r->topS = allocSStringTiny(l);;
free(l);
break;
+ default:
+ // not reachable
+ logC("Check this function!");
}
}
return(r);
@@ -8388,7 +8676,7 @@ internal char* cropSSmallJson(smallJsont *self, int64_t start, int64_t end) {
return(NULL);
}
- len = lenSmallJson(self);
+ len = (int64_t)lenSmallJson(self);
if (!len) {
return(NULL);
@@ -8420,13 +8708,13 @@ internal char* cropSSmallJson(smallJsont *self, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = malloc((n+1) * sizeof(char));
+ l = malloc(((size_t)n+1) * sizeof(char));
if (!l) {
return(NULL);
}
char *string = sStringGetTiny(self->topS);
- strLCpy(l, (n+1) * sizeof(char), string+start);
- strLCpy(string+start, len-end+1, string+end);
+ pErrorNULL(strLCpy(l, ((size_t)n+1) * sizeof(char), string+start));
+ memmove(string+start, string+end, (size_t)(len-end+1));
// TODO self->_len -= n
}
else {
@@ -8470,10 +8758,10 @@ internal baset* cropElemAtSmallJson(smallJsont *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);;
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);;
if (!o) {
return(NULL);
}
@@ -8524,10 +8812,10 @@ internal undefinedt* cropElemAtUndefinedSmallJson(smallJsont *self, int64_t inde
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);;
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);;
if (!o) {
return(NULL);
}
@@ -8563,11 +8851,11 @@ internal bool cropElemAtBoolSmallJson(smallJsont *self, int64_t index) {
return(false);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
bool r = false;
- smallt *o = sArrayGetTiny(self->topA, index);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
if (!o) {
return(false);
}
@@ -8610,11 +8898,11 @@ internal double cropElemAtDoubleSmallJson(smallJsont *self, int64_t index) {
return(0);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
double r = 0;
- smallt *o = sArrayGetTiny(self->topA, index);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
if (!o) {
return(0);
}
@@ -8657,11 +8945,11 @@ internal int64_t cropElemAtIntSmallJson(smallJsont *self, int64_t index) {
return(0);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
int64_t r = 0;
- smallt *o = sArrayGetTiny(self->topA, index);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
if (!o) {
return(0);
}
@@ -8704,11 +8992,11 @@ internal int32_t cropElemAtInt32SmallJson(smallJsont *self, int64_t index) {
return(0);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
int32_t r = 0;
- smallt *o = sArrayGetTiny(self->topA, index);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
if (!o) {
return(0);
}
@@ -8721,7 +9009,7 @@ internal int32_t cropElemAtInt32SmallJson(smallJsont *self, int64_t index) {
finishO(e);
return(0);
}
- r = e->f->get(e);
+ r = (int32_t)e->f->get(e);
terminateO(e);
// copy pointers from range index+1, array->count to index
@@ -8751,11 +9039,11 @@ internal uint64_t cropElemAtUintSmallJson(smallJsont *self, int64_t index) {
return(0);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
uint64_t r = 0;
- smallt *o = sArrayGetTiny(self->topA, index);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
if (!o) {
return(0);
}
@@ -8768,7 +9056,7 @@ internal uint64_t cropElemAtUintSmallJson(smallJsont *self, int64_t index) {
finishO(e);
return(0);
}
- r = e->f->get(e);
+ r = (uint64_t)e->f->get(e);
terminateO(e);
// copy pointers from range index+1, array->count to index
@@ -8798,11 +9086,11 @@ internal uint32_t cropElemAtUint32SmallJson(smallJsont *self, int64_t index) {
return(0);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
uint32_t r = 0;
- smallt *o = sArrayGetTiny(self->topA, index);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
if (!o) {
return(0);
}
@@ -8815,7 +9103,7 @@ internal uint32_t cropElemAtUint32SmallJson(smallJsont *self, int64_t index) {
finishO(e);
return(0);
}
- r = e->f->get(e);
+ r = (uint32_t)e->f->get(e);
terminateO(e);
// copy pointers from range index+1, array->count to index
@@ -8845,11 +9133,11 @@ internal char* cropElemAtSSmallJson(smallJsont *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
char *r = NULL;
- smallt *o = sArrayGetTiny(self->topA, index);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -8891,7 +9179,7 @@ internal char cropElemAtCharSmallJson(smallJsont *self, int64_t index) {
return(0);
}
- len = lenSmallJson(self);
+ len = (int64_t)lenSmallJson(self);
if (index >= len) {
return(0);
}
@@ -8910,7 +9198,7 @@ internal char cropElemAtCharSmallJson(smallJsont *self, int64_t index) {
string[len-1] = 0;
}
else {
- strLCpy(string+index, len - index, string+index+1);
+ memmove(string+index, string+index+1, (size_t)(len - index));
}
return(r);
@@ -8930,10 +9218,10 @@ internal smallDictt* cropElemAtDictSmallJson(smallJsont *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -8972,10 +9260,10 @@ internal smallArrayt* cropElemAtArraySmallJson(smallJsont *self, int64_t index)
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -9014,10 +9302,10 @@ internal smallBoolt* cropElemAtSmallBoolSmallJson(smallJsont *self, int64_t inde
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -9056,10 +9344,10 @@ internal smallBytest* cropElemAtSmallBytesSmallJson(smallJsont *self, int64_t in
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -9098,10 +9386,10 @@ internal smallDoublet* cropElemAtSmallDoubleSmallJson(smallJsont *self, int64_t
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -9140,10 +9428,10 @@ internal smallIntt* cropElemAtSmallIntSmallJson(smallJsont *self, int64_t index)
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -9182,10 +9470,10 @@ internal smallJsont* cropElemAtSmallJsonSmallJson(smallJsont *self, int64_t inde
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -9230,10 +9518,10 @@ internal smallStringt* cropElemAtSmallStringSmallJson(smallJsont *self, int64_t
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -9272,11 +9560,11 @@ internal void* cropElemAtVoidSmallJson(smallJsont *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
void *r = NULL;
- smallt *o = sArrayGetTiny(self->topA, index);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -9319,10 +9607,10 @@ internal smallContainert* cropElemAtSmallContainerSmallJson(smallJsont *self, in
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -9348,7 +9636,7 @@ internal smallContainert* cropElemAtSmallContainerSmallJson(smallJsont *self, in
}
-internal baset* cropElemKeySmallJson(smallJsont *self, char* key) {
+internal baset* cropElemKeySmallJson(smallJsont *self, const char* key) {
if (self->topIsA != TOP_IS_DICT) {
return(NULL);
@@ -9389,7 +9677,7 @@ internal baset* cropElemKeySmallJson(smallJsont *self, char* key) {
}
-internal undefinedt* cropElemKeyUndefinedSmallJson(smallJsont *self, char* key) {
+internal undefinedt* cropElemKeyUndefinedSmallJson(smallJsont *self, const char* key) {
if (self->topIsA != TOP_IS_DICT) {
return(NULL);
@@ -9422,7 +9710,7 @@ internal undefinedt* cropElemKeyUndefinedSmallJson(smallJsont *self, char* key)
}
-internal bool cropElemKeyBoolSmallJson(smallJsont *self, char* key) {
+internal bool cropElemKeyBoolSmallJson(smallJsont *self, const char* key) {
if (self->topIsA != TOP_IS_DICT) {
return(no);
@@ -9464,7 +9752,7 @@ internal bool cropElemKeyBoolSmallJson(smallJsont *self, char* key) {
}
-internal double cropElemKeyDoubleSmallJson(smallJsont *self, char* key) {
+internal double cropElemKeyDoubleSmallJson(smallJsont *self, const char* key) {
if (self->topIsA != TOP_IS_DICT) {
return(0);
@@ -9506,7 +9794,7 @@ internal double cropElemKeyDoubleSmallJson(smallJsont *self, char* key) {
}
-internal int64_t cropElemKeyIntSmallJson(smallJsont *self, char* key) {
+internal int64_t cropElemKeyIntSmallJson(smallJsont *self, const char* key) {
if (self->topIsA != TOP_IS_DICT) {
return(0);
@@ -9548,7 +9836,7 @@ internal int64_t cropElemKeyIntSmallJson(smallJsont *self, char* key) {
}
-internal int32_t cropElemKeyInt32SmallJson(smallJsont *self, char* key) {
+internal int32_t cropElemKeyInt32SmallJson(smallJsont *self, const char* key) {
if (self->topIsA != TOP_IS_DICT) {
return(0);
@@ -9580,7 +9868,7 @@ internal int32_t cropElemKeyInt32SmallJson(smallJsont *self, char* key) {
free(e->key);
e->key = NULL;
- int32_t r = o->f->get(o);
+ int32_t r = (int32_t)o->f->get(o);
terminateO(o);
return(r);
}
@@ -9590,7 +9878,7 @@ internal int32_t cropElemKeyInt32SmallJson(smallJsont *self, char* key) {
}
-internal uint64_t cropElemKeyUintSmallJson(smallJsont *self, char* key) {
+internal uint64_t cropElemKeyUintSmallJson(smallJsont *self, const char* key) {
if (self->topIsA != TOP_IS_DICT) {
return(0);
@@ -9622,7 +9910,7 @@ internal uint64_t cropElemKeyUintSmallJson(smallJsont *self, char* key) {
free(e->key);
e->key = NULL;
- uint64_t r = o->f->get(o);
+ uint64_t r = (uint64_t)o->f->get(o);
terminateO(o);
return(r);
}
@@ -9632,7 +9920,7 @@ internal uint64_t cropElemKeyUintSmallJson(smallJsont *self, char* key) {
}
-internal uint32_t cropElemKeyUint32SmallJson(smallJsont *self, char* key) {
+internal uint32_t cropElemKeyUint32SmallJson(smallJsont *self, const char* key) {
if (self->topIsA != TOP_IS_DICT) {
return(0);
@@ -9664,7 +9952,7 @@ internal uint32_t cropElemKeyUint32SmallJson(smallJsont *self, char* key) {
free(e->key);
e->key = NULL;
- uint32_t r = o->f->get(o);
+ uint32_t r = (uint32_t)o->f->get(o);
terminateO(o);
return(r);
}
@@ -9674,7 +9962,7 @@ internal uint32_t cropElemKeyUint32SmallJson(smallJsont *self, char* key) {
}
-internal char* cropElemKeySSmallJson(smallJsont *self, char* key) {
+internal char* cropElemKeySSmallJson(smallJsont *self, const char* key) {
if (self->topIsA != TOP_IS_DICT) {
return(NULL);
@@ -9716,7 +10004,7 @@ internal char* cropElemKeySSmallJson(smallJsont *self, char* key) {
}
-internal smallDictt* cropElemKeyDictSmallJson(smallJsont *self, char* key) {
+internal smallDictt* cropElemKeyDictSmallJson(smallJsont *self, const char* key) {
if (self->topIsA != TOP_IS_DICT) {
return(NULL);
@@ -9752,7 +10040,7 @@ internal smallDictt* cropElemKeyDictSmallJson(smallJsont *self, char* key) {
}
-internal smallArrayt* cropElemKeyArraySmallJson(smallJsont *self, char* key) {
+internal smallArrayt* cropElemKeyArraySmallJson(smallJsont *self, const char* key) {
if (self->topIsA != TOP_IS_DICT) {
return(NULL);
@@ -9788,7 +10076,7 @@ internal smallArrayt* cropElemKeyArraySmallJson(smallJsont *self, char* key) {
}
-internal smallBoolt* cropElemKeySmallBoolSmallJson(smallJsont *self, char* key) {
+internal smallBoolt* cropElemKeySmallBoolSmallJson(smallJsont *self, const char* key) {
if (self->topIsA != TOP_IS_DICT) {
return(NULL);
@@ -9824,7 +10112,7 @@ internal smallBoolt* cropElemKeySmallBoolSmallJson(smallJsont *self, char* key)
}
-internal smallBytest* cropElemKeySmallBytesSmallJson(smallJsont *self, char* key) {
+internal smallBytest* cropElemKeySmallBytesSmallJson(smallJsont *self, const char* key) {
if (self->topIsA != TOP_IS_DICT) {
return(NULL);
@@ -9860,7 +10148,7 @@ internal smallBytest* cropElemKeySmallBytesSmallJson(smallJsont *self, char* key
}
-internal smallDoublet* cropElemKeySmallDoubleSmallJson(smallJsont *self, char* key) {
+internal smallDoublet* cropElemKeySmallDoubleSmallJson(smallJsont *self, const char* key) {
if (self->topIsA != TOP_IS_DICT) {
return(NULL);
@@ -9896,7 +10184,7 @@ internal smallDoublet* cropElemKeySmallDoubleSmallJson(smallJsont *self, char* k
}
-internal smallIntt* cropElemKeySmallIntSmallJson(smallJsont *self, char* key) {
+internal smallIntt* cropElemKeySmallIntSmallJson(smallJsont *self, const char* key) {
if (self->topIsA != TOP_IS_DICT) {
return(NULL);
@@ -9932,7 +10220,7 @@ internal smallIntt* cropElemKeySmallIntSmallJson(smallJsont *self, char* key) {
}
-internal smallJsont* cropElemKeySmallJsonSmallJson(smallJsont *self, char* key) {
+internal smallJsont* cropElemKeySmallJsonSmallJson(smallJsont *self, const char* key) {
if (self->topIsA != TOP_IS_DICT) {
return(NULL);
@@ -9973,7 +10261,7 @@ internal smallJsont* cropElemKeySmallJsonSmallJson(smallJsont *self, char* key)
}
-internal smallStringt* cropElemKeySmallStringSmallJson(smallJsont *self, char* key) {
+internal smallStringt* cropElemKeySmallStringSmallJson(smallJsont *self, const char* key) {
if (self->topIsA != TOP_IS_DICT) {
return(NULL);
@@ -10009,7 +10297,7 @@ internal smallStringt* cropElemKeySmallStringSmallJson(smallJsont *self, char* k
}
-internal void* cropElemKeyVoidSmallJson(smallJsont *self, char* key) {
+internal void* cropElemKeyVoidSmallJson(smallJsont *self, const char* key) {
if (self->topIsA != TOP_IS_DICT) {
return(NULL);
@@ -10051,7 +10339,7 @@ internal void* cropElemKeyVoidSmallJson(smallJsont *self, char* key) {
}
-internal smallContainert* cropElemKeySmallContainerSmallJson(smallJsont *self, char* key) {
+internal smallContainert* cropElemKeySmallContainerSmallJson(smallJsont *self, const char* key) {
if (self->topIsA != TOP_IS_DICT) {
return(NULL);
@@ -10107,19 +10395,19 @@ internal smallJsont* copySmallJson(smallJsont *self, int64_t start, int64_t end)
return(NULL);
}
if (end > (int64_t)len) {
- end = len;
+ end = (int64_t)len;
}
if (start <= -(int64_t)len) {
- start = -len;
+ start = -(int64_t)len;
}
if (end <= -(int64_t)len) {
return(NULL);
}
if (start < 0) {
- start = len + start;
+ start = (int64_t)len + start;
}
if (end <= 0) {
- end = len + end;
+ end = (int64_t)len + end;
}
if (end < start) {
return(NULL);
@@ -10143,7 +10431,7 @@ internal smallJsont* copySmallJson(smallJsont *self, int64_t start, int64_t end)
n = end - start;
for (int64_t i=0;i < n;i++) {
- o = sArrayGetTiny(self->topA, start+i);
+ o = sArrayGetTiny(self->topA, (uint32_t)(start+i));
sArrayPushTiny(&(r->topA), sDuplicate(o));
}
}
@@ -10158,23 +10446,26 @@ internal smallJsont* copySmallJson(smallJsont *self, int64_t start, int64_t end)
// start < end < len
// copy range to a new smallString
n = end - start;
- s = malloc(n+1);
+ s = malloc((size_t)n+1);
if (!s) {
return(NULL);
}
- s = strncpy(s, sStringGetTiny(self->topS) + start, n);
+ s = strncpy(s, sStringGetTiny(self->topS) + start, (size_t)n);
s[n] = 0;
}
r->f->setTopNFreeString(r, s);
break;
+ default:
+ // not reachable
+ logC("Check this function!");
}
return(r);
}
internal smallJsont* insertSmallJson(smallJsont *self, int64_t index, smallArrayt *toInsert) {
- size_t len;;
+ size_t len;
//sanity checks
if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
@@ -10218,7 +10509,7 @@ internal smallJsont* insertSmallJson(smallJsont *self, int64_t index, smallArray
return(NULL);
}
if (neg) {
- index = len + index;
+ index = (int64_t)len + index;
}
if (!toInsert->f->len(toInsert)) {
@@ -10235,26 +10526,26 @@ internal smallJsont* insertSmallJson(smallJsont *self, int64_t index, smallArray
if (index == 0) {
// insert at beginning
for (int64_t i=0;i < (int64_t)toInsert->f->len(toInsert);i++) {
- o = sArrayGetTiny(toInsert->a, i);
+ o = sArrayGetTiny(toInsert->a, (uint32_t)i);
sArrayPushTiny(&a, o);
}
for (int64_t i=0;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
else {
for (int64_t i=0;i < index;i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o);
}
for (int64_t i=0;i < (int64_t)toInsert->f->len(toInsert);i++) {
- o = sArrayGetTiny(toInsert->a, i);
+ o = sArrayGetTiny(toInsert->a, (uint32_t)i);
sArrayPushTiny(&a, o);
}
for (int64_t i=index;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -10275,7 +10566,7 @@ internal smallJsont* insertNSmashSmallJson(smallJsont *self, int64_t index, smal
}
internal smallJsont* insertSmallJsonSmallJson(smallJsont *self, int64_t index, smallJsont *toInsert) {
- size_t len;;
+ size_t len;
//sanity checks
if (self->topIsA != TOP_IS_ARRAY || !toInsert) {
@@ -10311,7 +10602,7 @@ internal smallJsont* insertSmallJsonSmallJson(smallJsont *self, int64_t index, s
return(NULL);
}
if (neg) {
- index = len + index;
+ index = (int64_t)len + index;
}
if (toInsert->topIsA != TOP_IS_ARRAY) {
@@ -10332,26 +10623,26 @@ internal smallJsont* insertSmallJsonSmallJson(smallJsont *self, int64_t index, s
if (index == 0) {
// insert at beginning
for (int64_t i=0;i < (int64_t)toInsert->f->len(toInsert);i++) {
- o = sArrayGetTiny(toInsert->topA, i);
+ o = sArrayGetTiny(toInsert->topA, (uint32_t)i);
sArrayPushTiny(&a, o);
}
for (int64_t i=0;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
else {
for (int64_t i=0;i < index;i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o);
}
for (int64_t i=0;i < (int64_t)toInsert->f->len(toInsert);i++) {
- o = sArrayGetTiny(toInsert->topA, i);
+ o = sArrayGetTiny(toInsert->topA, (uint32_t)i);
sArrayPushTiny(&a, o);
}
for (int64_t i=index;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -10423,7 +10714,7 @@ internal smallJsont* insertStringSmallJson(smallJsont *self, int64_t index, smal
return(NULL);
}
if (neg) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
if (!toInsert->data || !toInsert->_len) {
@@ -10494,7 +10785,7 @@ internal smallJsont* insertSSmallJson(smallJsont *self, int64_t index, const cha
return(NULL);
}
if (neg) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
if (!*toInsert) {
@@ -10574,7 +10865,7 @@ internal smallJsont* injectSmallJson(smallJsont *self, int64_t index, baset *toI
return(NULL);
}
if (neg) {
- index = len + index;
+ index = (int64_t)len + index;
}
@@ -10593,7 +10884,7 @@ internal smallJsont* injectSmallJson(smallJsont *self, int64_t index, baset *toI
// inject at beginning
sArrayPushTiny(&a, o);
for (int64_t i=0;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -10601,12 +10892,12 @@ internal smallJsont* injectSmallJson(smallJsont *self, int64_t index, baset *toI
smallt *o2;
for (int64_t i=0;i < index;i++) {
- o2 = sArrayGetTiny(self->topA, i);
+ o2 = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o2);
}
sArrayPushTiny(&a, o);
for (int64_t i=index;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -10648,7 +10939,7 @@ internal smallJsont* injectUndefinedSmallJson(smallJsont *self, int64_t index) {
return(NULL);
}
if (neg) {
- index = len + index;
+ index = (int64_t)len + index;
}
@@ -10667,7 +10958,7 @@ internal smallJsont* injectUndefinedSmallJson(smallJsont *self, int64_t index) {
// inject at beginning
sArrayPushTiny(&a, o);
for (int64_t i=0;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -10675,12 +10966,12 @@ internal smallJsont* injectUndefinedSmallJson(smallJsont *self, int64_t index) {
smallt *o2;
for (int64_t i=0;i < index;i++) {
- o2 = sArrayGetTiny(self->topA, i);
+ o2 = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o2);
}
sArrayPushTiny(&a, o);
for (int64_t i=index;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -10722,7 +11013,7 @@ internal smallJsont* injectBoolSmallJson(smallJsont *self, int64_t index, bool t
return(NULL);
}
if (neg) {
- index = len + index;
+ index = (int64_t)len + index;
}
@@ -10742,7 +11033,7 @@ internal smallJsont* injectBoolSmallJson(smallJsont *self, int64_t index, bool t
// inject at beginning
sArrayPushTiny(&a, o);
for (int64_t i=0;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -10750,12 +11041,12 @@ internal smallJsont* injectBoolSmallJson(smallJsont *self, int64_t index, bool t
smallt *o2;
for (int64_t i=0;i < index;i++) {
- o2 = sArrayGetTiny(self->topA, i);
+ o2 = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o2);
}
sArrayPushTiny(&a, o);
for (int64_t i=index;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -10797,7 +11088,7 @@ internal smallJsont* injectDoubleSmallJson(smallJsont *self, int64_t index, doub
return(NULL);
}
if (neg) {
- index = len + index;
+ index = (int64_t)len + index;
}
@@ -10817,7 +11108,7 @@ internal smallJsont* injectDoubleSmallJson(smallJsont *self, int64_t index, doub
// inject at beginning
sArrayPushTiny(&a, o);
for (int64_t i=0;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -10825,12 +11116,12 @@ internal smallJsont* injectDoubleSmallJson(smallJsont *self, int64_t index, doub
smallt *o2;
for (int64_t i=0;i < index;i++) {
- o2 = sArrayGetTiny(self->topA, i);
+ o2 = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o2);
}
sArrayPushTiny(&a, o);
for (int64_t i=index;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -10872,7 +11163,7 @@ internal smallJsont* injectIntSmallJson(smallJsont *self, int64_t index, int64_t
return(NULL);
}
if (neg) {
- index = len + index;
+ index = (int64_t)len + index;
}
@@ -10892,7 +11183,7 @@ internal smallJsont* injectIntSmallJson(smallJsont *self, int64_t index, int64_t
// inject at beginning
sArrayPushTiny(&a, o);
for (int64_t i=0;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -10900,12 +11191,12 @@ internal smallJsont* injectIntSmallJson(smallJsont *self, int64_t index, int64_t
smallt *o2;
for (int64_t i=0;i < index;i++) {
- o2 = sArrayGetTiny(self->topA, i);
+ o2 = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o2);
}
sArrayPushTiny(&a, o);
for (int64_t i=index;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -10955,7 +11246,7 @@ internal smallJsont* injectSSmallJson(smallJsont *self, int64_t index, const cha
return(NULL);
}
if (neg) {
- index = len + index;
+ index = (int64_t)len + index;
}
@@ -10974,7 +11265,7 @@ internal smallJsont* injectSSmallJson(smallJsont *self, int64_t index, const cha
// inject at beginning
sArrayPushTiny(&a, o);
for (int64_t i=0;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -10982,12 +11273,12 @@ internal smallJsont* injectSSmallJson(smallJsont *self, int64_t index, const cha
smallt *o2;
for (int64_t i=0;i < index;i++) {
- o2 = sArrayGetTiny(self->topA, i);
+ o2 = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o2);
}
sArrayPushTiny(&a, o);
for (int64_t i=index;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -11043,7 +11334,7 @@ internal smallJsont* injectDictSmallJson(smallJsont *self, int64_t index, smallD
return(NULL);
}
if (neg) {
- index = len + index;
+ index = (int64_t)len + index;
}
@@ -11062,7 +11353,7 @@ internal smallJsont* injectDictSmallJson(smallJsont *self, int64_t index, smallD
// inject at beginning
sArrayPushTiny(&a, o);
for (int64_t i=0;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -11070,12 +11361,12 @@ internal smallJsont* injectDictSmallJson(smallJsont *self, int64_t index, smallD
smallt *o2;
for (int64_t i=0;i < index;i++) {
- o2 = sArrayGetTiny(self->topA, i);
+ o2 = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o2);
}
sArrayPushTiny(&a, o);
for (int64_t i=index;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -11125,7 +11416,7 @@ internal smallJsont* injectArraySmallJson(smallJsont *self, int64_t index, small
return(NULL);
}
if (neg) {
- index = len + index;
+ index = (int64_t)len + index;
}
@@ -11144,7 +11435,7 @@ internal smallJsont* injectArraySmallJson(smallJsont *self, int64_t index, small
// inject at beginning
sArrayPushTiny(&a, o);
for (int64_t i=0;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -11152,12 +11443,12 @@ internal smallJsont* injectArraySmallJson(smallJsont *self, int64_t index, small
smallt *o2;
for (int64_t i=0;i < index;i++) {
- o2 = sArrayGetTiny(self->topA, i);
+ o2 = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o2);
}
sArrayPushTiny(&a, o);
for (int64_t i=index;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -11203,7 +11494,7 @@ internal smallJsont* injectArraycSmallJson(smallJsont *self, int64_t index, char
return(NULL);
}
if (neg) {
- index = len + index;
+ index = (int64_t)len + index;
}
@@ -11236,7 +11527,99 @@ internal smallJsont* injectArraycSmallJson(smallJsont *self, int64_t index, char
// inject at beginning
sArrayPushTiny(&a, o);
for (int64_t i=0;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
+ sArrayPushTiny(&a, o);
+ }
+ }
+ else {
+
+ smallt *o2;
+ for (int64_t i=0;i < index;i++) {
+ o2 = sArrayGetTiny(self->topA, (uint32_t)i);
+ sArrayPushTiny(&a, o2);
+ }
+ sArrayPushTiny(&a, o);
+ for (int64_t i=index;i < (int64_t)len;i++) {
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
+ sArrayPushTiny(&a, o);
+ }
+ }
+
+ free(self->topA);
+ self->topA = a;
+ return(self);
+}
+
+internal smallJsont* injectCArraycSmallJson(smallJsont *self, int64_t index, const char **toInject) {
+ size_t len;
+
+ if (!toInject) {
+ return(NULL);
+ }
+
+ if (self->topIsA != SMALLJSON_IS_EMPTY && self->topIsA != TOP_IS_ARRAY) {
+ return(NULL);
+ }
+
+ if (self->topIsA == SMALLJSON_IS_EMPTY) {
+ self->topIsA = TOP_IS_ARRAY;
+ }
+
+ len = lenSmallJson(self);
+
+ if (!len && index == -1) {
+ // empty string, index -1 is equal to 0
+ index = 0;
+ }
+ bool neg = false;
+ if (index < 0) {
+ neg = true;
+ }
+
+ if (index > (int64_t)len) {
+ return(NULL);
+ }
+ if (neg) {
+ index++;
+ }
+ if (index < -(int64_t)len) {
+ return(NULL);
+ }
+ if (neg) {
+ index = (int64_t)len + index;
+ }
+
+
+ sArrayt *a = allocSArray();;
+ if (!a) {
+ return(NULL);
+ }
+
+ smallt *o = NULL;
+ sArrayt *aa = allocSArray();
+ if (!aa) {
+ sArrayFreeTiny(a);
+ return(NULL);
+ }
+
+ forEachCCharP(toInject, e) {
+ sStringt *s = allocSStringTiny(*e);
+ if (!s) {
+ sArrayFreeTiny(a);
+ if (aa) {
+ sArrayFreeTiny(aa);
+ }
+ return(NULL);
+ }
+ sArrayPushTiny(&aa, (smallt *) s);
+ }
+ o = (smallt *) aa;
+
+ if (index == 0) {
+ // inject at beginning
+ sArrayPushTiny(&a, o);
+ for (int64_t i=0;i < (int64_t)len;i++) {
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -11244,12 +11627,12 @@ internal smallJsont* injectArraycSmallJson(smallJsont *self, int64_t index, char
smallt *o2;
for (int64_t i=0;i < index;i++) {
- o2 = sArrayGetTiny(self->topA, i);
+ o2 = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o2);
}
sArrayPushTiny(&a, o);
for (int64_t i=index;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -11425,7 +11808,7 @@ internal smallJsont* injectNFreeSmallJson(smallJsont *self, int64_t index, baset
return(NULL);
}
if (neg) {
- index = len + index;
+ index = (int64_t)len + index;
}
@@ -11448,7 +11831,7 @@ internal smallJsont* injectNFreeSmallJson(smallJsont *self, int64_t index, baset
// inject at beginning
sArrayPushTiny(&a, o);
for (int64_t i=0;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -11456,12 +11839,12 @@ internal smallJsont* injectNFreeSmallJson(smallJsont *self, int64_t index, baset
smallt *o2;
for (int64_t i=0;i < index;i++) {
- o2 = sArrayGetTiny(self->topA, i);
+ o2 = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o2);
}
sArrayPushTiny(&a, o);
for (int64_t i=index;i < (int64_t)len;i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
sArrayPushTiny(&a, o);
}
}
@@ -11471,11 +11854,11 @@ internal smallJsont* injectNFreeSmallJson(smallJsont *self, int64_t index, baset
return(self);
}
-internal smallJsont* injectNFreeUndefinedSmallJson(smallJsont *self, int64_t index, undefinedt *undefined) {
+internal smallJsont* injectNFreeUndefinedSmallJson(smallJsont *self, int64_t index, undefinedt *u) {
smallJsont *r = injectUndefinedSmallJson(self, index);;
if (r) {
- terminateO(undefined);
+ terminateO(u);
}
return(r);
}
@@ -11738,6 +12121,8 @@ internal smallJsont* uniqSmallJson(smallJsont *self) {
freeO(B);
}
break;
+ default:
+ logC("Unsupported object type!");
}
}
if (pushE) {
@@ -11757,8 +12142,8 @@ internal smallJsont* uniqSmallJson(smallJsont *self) {
internal int sortSCmp(const void * a, const void * b) {
// sanity checks
- smallt *A = (*((smallt **)a));
- smallt *B = (*((smallt **)b));
+ smallt *A = (*((smallt *const*)a));
+ smallt *B = (*((smallt *const*)b));
if (!A && !B) {
return(0);
}
@@ -11876,8 +12261,8 @@ internal smallJsont* sortSmallJson(smallJsont *self) {
internal int sortFCmp(void *func, const void *a, const void *b) {
shCmpt cmp;
- smallt *A = (*((smallt **)a));
- smallt *B = (*((smallt **)b));
+ smallt *A = (*((smallt *const*)a));
+ smallt *B = (*((smallt *const*)b));
baset *aO = toBaset(A);;
baset *bO = toBaset(B);;
@@ -11897,8 +12282,8 @@ internal int sortFCmp(void *func, const void *a, const void *b) {
internal int sortFCmp(const void *a, const void *b, void *func) {
shCmpt cmp;
- smallt *A = (*((smallt **)a));
- smallt *B = (*((smallt **)b));
+ smallt *A = (*((smallt *const*)a));
+ smallt *B = (*((smallt *const*)b));
baset *aO = toBaset(A);;
baset *bO = toBaset(B);;
@@ -11919,8 +12304,8 @@ internal int sortFCmp(const void *a, const void *b, void *func) {
internal int icSortSCmp(const void * a, const void * b) {
// sanity checks
- smallt *A = (*((smallt **)a));
- smallt *B = (*((smallt **)b));
+ smallt *A = (*((smallt *const*)a));
+ smallt *B = (*((smallt *const*)b));
if (!A && !B) {
return(0);
}
@@ -12193,6 +12578,8 @@ internal smallJsont* icUniqSmallJson(smallJsont *self) {
freeO(B);
}
break;
+ default:
+ logC("Unsupported object type!");
}
}
if (pushE) {
@@ -12282,17 +12669,17 @@ internal bool hasSmallJson(smallJsont *self, baset *value) {
return(true);
}
-internal bool hasUndefinedSmallJson(smallJsont *self, undefinedt *undefined) {
+internal bool hasUndefinedSmallJson(smallJsont *self, undefinedt *u) {
- if (!undefined) {
+ if (!u) {
return(false);
}
- if (checkObjectTypes && !isOUndefined(undefined)) {
+ if (checkObjectTypes && !isOUndefined(u)) {
return(false);
}
- if (indexOfUndefinedSmallJson(self, undefined) == -1) {
+ if (indexOfUndefinedSmallJson(self, u) == -1) {
return(false);
}
@@ -12401,6 +12788,19 @@ internal bool hasArraycSmallJson(smallJsont *self, char **array) {
return(true);
}
+internal bool hasCArraycSmallJson(smallJsont *self, const char **array) {
+
+ if (!array) {
+ return(false);
+ }
+
+ if (indexOfCArraycSmallJson(self, array) == -1) {
+ return(false);
+ }
+
+ return(true);
+}
+
internal bool hasSmallBoolSmallJson(smallJsont *self, smallBoolt *value) {
if (!value) {
@@ -12605,7 +13005,7 @@ internal ssize_t indexOfSmallJson(smallJsont *self, baset *value) {
if (strEq(es, s)) {
free(es);
free(s);
- return(i);
+ return((ssize_t)i);
}
free(es);
}
@@ -12613,18 +13013,18 @@ internal ssize_t indexOfSmallJson(smallJsont *self, baset *value) {
return(-1);
}
-internal ssize_t indexOfUndefinedSmallJson(smallJsont *self, undefinedt *undefined) {
+internal ssize_t indexOfUndefinedSmallJson(smallJsont *self, undefinedt *u) {
// sanity checks
if (self->topIsA != TOP_IS_ARRAY) {
return(-1);
}
- if (!lenSmallJson(self) || !undefined) {
+ if (!lenSmallJson(self) || !u) {
return(-1);
}
- if (checkObjectTypes && !isOUndefined(undefined)) {
+ if (checkObjectTypes && !isOUndefined(u)) {
return(-1);
}
@@ -12634,7 +13034,7 @@ internal ssize_t indexOfUndefinedSmallJson(smallJsont *self, undefinedt *undefin
continue;
}
if (e->type == UNDEFINED) {
- return(i);
+ return((ssize_t)i);
}
}
return(-1);
@@ -12657,7 +13057,7 @@ internal ssize_t indexOfBoolSmallJson(smallJsont *self, bool value) {
continue;
}
if (e->type == BOOL && ((sBoolt*)e)->value == value) {
- return(i);
+ return((ssize_t)i);
}
}
return(-1);
@@ -12680,7 +13080,7 @@ internal ssize_t indexOfDoubleSmallJson(smallJsont *self, double value) {
continue;
}
if (e->type == DOUBLE && ((sDoublet*)e)->value == value) {
- return(i);
+ return((ssize_t)i);
}
}
return(-1);
@@ -12703,7 +13103,7 @@ internal ssize_t indexOfIntSmallJson(smallJsont *self, int64_t value) {
continue;
}
if (e->type == INT && ((sIntt*)e)->value == value) {
- return(i);
+ return((ssize_t)i);
}
}
return(-1);
@@ -12731,12 +13131,15 @@ internal ssize_t indexOfSSmallJson(smallJsont *self, const char *string) {
continue;
}
if (e->type == STRING && strEq(sStringGetTiny((sStringt*)e), string)) {
- return(i);
+ return((ssize_t)i);
}
}
break;
case TOP_IS_STRING:
- return(indexOfS(sStringGetTiny((sStringt*)self->topS), string));
+ return((ssize_t)indexOfS(sStringGetTiny((sStringt*)self->topS), string));
+ default:;
+ // not reachable
+ logC("Check this function!");
}
return(-1);
}
@@ -12744,7 +13147,7 @@ internal ssize_t indexOfSSmallJson(smallJsont *self, const char *string) {
internal ssize_t indexOfCharSmallJson(smallJsont *self, char c) {
charToS(s, c);
- return(indexOfSSmallJson(self, s));
+ return((ssize_t)indexOfSSmallJson(self, s));
}
internal ssize_t indexOfDictSmallJson(smallJsont *self, smallDictt *dict) {
@@ -12775,7 +13178,7 @@ internal ssize_t indexOfDictSmallJson(smallJsont *self, smallDictt *dict) {
if (strEq(es, s)) {
free(es);
free(s);
- return(i);
+ return((ssize_t)i);
}
free(es);
}
@@ -12812,7 +13215,7 @@ internal ssize_t indexOfArraySmallJson(smallJsont *self, smallArrayt *array) {
if (strEq(es, s)) {
free(es);
free(s);
- return(i);
+ return((ssize_t)i);
}
free(es);
}
@@ -12845,7 +13248,40 @@ internal ssize_t indexOfArraycSmallJson(smallJsont *self, char **array) {
if (strEq(es, s)) {
free(es);
free(s);
- return(i);
+ return((ssize_t)i);
+ }
+ free(es);
+ }
+ }
+ free(s);
+ return(-1);
+}
+
+internal ssize_t indexOfCArraycSmallJson(smallJsont *self, const char **array) {
+
+ // sanity checks
+ if (self->topIsA != TOP_IS_ARRAY) {
+ return(-1);
+ }
+
+ if (!lenSmallJson(self) || !array) {
+ return(-1);
+ }
+
+ // search object in elements
+ char *s = toStringListCSGF(array);
+ char *es = NULL;;
+
+ enumerateSArray(self->topA, e, i) {
+ if (not e) {
+ continue;
+ }
+ if (e->type == ARRAY) {
+ es = sToString(e);
+ if (strEq(es, s)) {
+ free(es);
+ free(s);
+ return((ssize_t)i);
}
free(es);
}
@@ -12877,7 +13313,7 @@ internal ssize_t indexOfSmallBoolSmallJson(smallJsont *self, smallBoolt *value)
continue;
}
if (e->type == BOOL && ((sBoolt*)e)->value == b) {
- return(i);
+ return((ssize_t)i);
}
}
return(-1);
@@ -12907,7 +13343,7 @@ internal ssize_t indexOfSmallBytesSmallJson(smallJsont *self, smallBytest *value
continue;
}
if (e->type == BYTES && ((sBytest*)e)->count == count && !memcmp(&(((sBytest*)e)->data), b, count)) {
- return(i);
+ return((ssize_t)i);
}
}
return(-1);
@@ -12936,7 +13372,7 @@ internal ssize_t indexOfSmallDoubleSmallJson(smallJsont *self, smallDoublet *val
continue;
}
if (e->type == DOUBLE && ((sDoublet*)e)->value == v) {
- return(i);
+ return((ssize_t)i);
}
}
return(-1);
@@ -12965,7 +13401,7 @@ internal ssize_t indexOfSmallIntSmallJson(smallJsont *self, smallIntt *value) {
continue;
}
if (e->type == INT && ((sIntt*)e)->value == v) {
- return(i);
+ return((ssize_t)i);
}
}
return(-1);
@@ -13026,6 +13462,8 @@ internal ssize_t indexOfSmallJsonSmallJson(smallJsont *self, smallJsont *value)
r = indexOfArraySmallJson(self, (smallArrayt*)O);;
finishO(O);
break;
+ default:
+ logC("Unsupported smallJson type!");
}
return(r);
}
@@ -13063,12 +13501,15 @@ internal ssize_t indexOfSmallStringSmallJson(smallJsont *self, smallStringt *str
continue;
}
if (e->type == STRING && strEq(sStringGetTiny((sStringt*)e), s)) {
- return(i);
+ return((ssize_t)i);
}
}
break;
case TOP_IS_STRING:
return(indexOfS(sStringGetTiny((sStringt*)self->topS), s));
+ default:
+ // not reachable
+ logC("Check this function!");
}
return(-1);
}
@@ -13093,10 +13534,10 @@ internal ssize_t binarySearchSmallJson(smallJsont *self, baset *value) {
char *m = NULL;
ssize_t r = -1;
- last = lenSmallJson(self) - 1;
+ last = (ssize_t)lenSmallJson(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- m = sToString(sArrayGetTiny(self->topA, middle));
+ m = sToString(sArrayGetTiny(self->topA, (uint32_t)middle));
if (!m) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -13120,7 +13561,7 @@ internal ssize_t binarySearchSmallJson(smallJsont *self, baset *value) {
return(r);
}
-internal ssize_t binarySearchUndefinedSmallJson(smallJsont *self UNUSED, undefinedt *undefined UNUSED) {
+internal ssize_t binarySearchUndefinedSmallJson(smallJsont *self UNUSED, undefinedt *u UNUSED) {
// ssize_t first = 0, middle, last
// it doesn't make sense to search for undefined
@@ -13169,10 +13610,10 @@ internal ssize_t binarySearchBoolSmallJson(smallJsont *self, bool value) {
sBoolt *m = NULL;
ssize_t r = -1;
- last = lenSmallJson(self) - 1;
+ last = (ssize_t)lenSmallJson(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- m = (sBoolt*)(sArrayGetTiny(self->topA, middle));
+ m = (sBoolt*)(sArrayGetTiny(self->topA, (uint32_t)middle));
if (!m) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -13208,10 +13649,10 @@ internal ssize_t binarySearchDoubleSmallJson(smallJsont *self, double value) {
sDoublet *m = NULL;
ssize_t r = -1;
- last = lenSmallJson(self) - 1;
+ last = (ssize_t)lenSmallJson(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- m = (sDoublet*)(sArrayGetTiny(self->topA, middle));
+ m = (sDoublet*)(sArrayGetTiny(self->topA, (uint32_t)middle));
if (!m) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -13246,10 +13687,10 @@ internal ssize_t binarySearchIntSmallJson(smallJsont *self, int64_t value) {
sIntt *m = NULL;
ssize_t r = -1;
- last = lenSmallJson(self) - 1;
+ last = (ssize_t)lenSmallJson(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- m = (sIntt*)(sArrayGetTiny(self->topA, middle));
+ m = (sIntt*)(sArrayGetTiny(self->topA, (uint32_t)middle));
if (!m) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -13283,10 +13724,10 @@ internal ssize_t binarySearchSSmallJson(smallJsont *self, const char *string) {
smallt *e = NULL;
- last = lenSmallJson(self) - 1;
+ last = (ssize_t)lenSmallJson(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- e = sArrayGetTiny(self->topA, middle);
+ e = sArrayGetTiny(self->topA, (uint32_t)middle);
if (!e) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -13332,10 +13773,10 @@ internal ssize_t binarySearchDictSmallJson(smallJsont *self, smallDictt *dict) {
char *m = NULL;
ssize_t r = -1;
- last = lenSmallJson(self) - 1;
+ last = (ssize_t)lenSmallJson(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- e = sArrayGetTiny(self->topA, middle);
+ e = sArrayGetTiny(self->topA, (uint32_t)middle);
if (!e) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -13387,10 +13828,10 @@ internal ssize_t binarySearchArraySmallJson(smallJsont *self, smallArrayt *array
char *m = NULL;
ssize_t r = -1;
- last = lenSmallJson(self) - 1;
+ last = (ssize_t)lenSmallJson(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- e = sArrayGetTiny(self->topA, middle);
+ e = sArrayGetTiny(self->topA, (uint32_t)middle);
if (!e) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -13438,10 +13879,61 @@ internal ssize_t binarySearchArraycSmallJson(smallJsont *self, char **array) {
char *m = NULL;
ssize_t r = -1;
- last = lenSmallJson(self) - 1;
+ last = (ssize_t)lenSmallJson(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- e = sArrayGetTiny(self->topA, middle);
+ e = sArrayGetTiny(self->topA, (uint32_t)middle);
+ if (!e) {
+ // there are null element in the array
+ // the array needs to be trimmed or compacted
+ goto finish;
+ }
+ // cg_c bug, can't use comma operator, extra code
+ if (e->type == ARRAY) {
+ m = sToString(e);
+ }
+ // cg_c bug, can't use comma operator
+ /* if e->type < ARRAY || ((e->type = ARRAY) && strcmp((m=sToString(e),m), s) < 0) */
+ if (e->type < ARRAY || ((e->type == ARRAY) && strcmp(m, s) < 0)) {
+ first = middle + 1;
+ }
+ else if ((e->type == ARRAY) && strcmp(m, s) == 0) {
+ r = middle;
+ free(m);
+ goto finish;
+ }
+ else {
+ last = middle -1;
+ }
+ if (e->type == ARRAY) {
+ free(m);
+ }
+ }
+ finish:
+ free(s);
+ return(r);
+}
+
+internal ssize_t binarySearchCArraycSmallJson(smallJsont *self, const char **array) {
+ ssize_t first = 0, middle, last;;
+
+ if (self->topIsA != TOP_IS_ARRAY) {
+ return(-1);
+ }
+
+ if (!lenSmallJson(self) || !array) {
+ return(-1);
+ }
+
+ char *s = toStringListCSGF(array);
+ smallt *e = NULL;
+ char *m = NULL;
+
+ ssize_t r = -1;
+ last = (ssize_t)lenSmallJson(self) - 1;
+ while (first <= last) {
+ middle = (first+last)/2;
+ e = sArrayGetTiny(self->topA, (uint32_t)middle);
if (!e) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -13492,10 +13984,10 @@ internal ssize_t binarySearchSmallBoolSmallJson(smallJsont *self, smallBoolt *va
sBoolt *m = NULL;
ssize_t r = -1;
- last = lenSmallJson(self) - 1;
+ last = (ssize_t)lenSmallJson(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- m = (sBoolt*)(sArrayGetTiny(self->topA, middle));
+ m = (sBoolt*)(sArrayGetTiny(self->topA, (uint32_t)middle));
if (!m) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -13536,10 +14028,10 @@ internal ssize_t binarySearchSmallBytesSmallJson(smallJsont *self, smallBytest *
sBytest *m = NULL;
ssize_t r = -1;
- last = lenSmallJson(self) - 1;
+ last = (ssize_t)lenSmallJson(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- m = (sBytest*)(sArrayGetTiny(self->topA, middle));
+ m = (sBytest*)(sArrayGetTiny(self->topA, (uint32_t)middle));
if (!m) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -13579,10 +14071,10 @@ internal ssize_t binarySearchSmallDoubleSmallJson(smallJsont *self, smallDoublet
sDoublet *m = NULL;
ssize_t r = -1;
- last = lenSmallJson(self) - 1;
+ last = (ssize_t)lenSmallJson(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- m = (sDoublet*)(sArrayGetTiny(self->topA, middle));
+ m = (sDoublet*)(sArrayGetTiny(self->topA, (uint32_t)middle));
if (!m) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -13622,10 +14114,10 @@ internal ssize_t binarySearchSmallIntSmallJson(smallJsont *self, smallIntt *valu
sIntt *m = NULL;
ssize_t r = -1;
- last = lenSmallJson(self) - 1;
+ last = (ssize_t)lenSmallJson(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- m = (sIntt*)(sArrayGetTiny(self->topA, middle));
+ m = (sIntt*)(sArrayGetTiny(self->topA, (uint32_t)middle));
if (!m) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -13700,6 +14192,8 @@ internal ssize_t binarySearchSmallJsonSmallJson(smallJsont *self, smallJsont *va
r = binarySearchArraySmallJson(self, (smallArrayt*)O);;
finishO(O);
break;
+ default:
+ logC("Unsupported object type!");
}
return(r);
}
@@ -13726,10 +14220,10 @@ internal ssize_t binarySearchSmallStringSmallJson(smallJsont *self, smallStringt
char *s = sStringGetTiny(string->data);
smallt *e = NULL;
- last = lenSmallJson(self) - 1;
+ last = (ssize_t)lenSmallJson(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- e = sArrayGetTiny(self->topA, middle);
+ e = sArrayGetTiny(self->topA, (uint32_t)middle);
if (!e) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -13812,26 +14306,39 @@ internal bool icHasDictSmallJson(smallJsont *self, smallDictt *dict) {
return(true);
}
-internal bool icHasArraySmallJson(smallJsont *self, smallArrayt *array) {
+internal bool icHasArraySmallJson(smallJsont *self, smallArrayt *array) {
+
+ if (!array) {
+ return(false);
+ }
+
+ if (icIndexOfArraySmallJson(self, array) == -1) {
+ return(false);
+ }
+
+ return(true);
+}
+
+internal bool icHasArraycSmallJson(smallJsont *self, char **array) {
if (!array) {
return(false);
}
- if (icIndexOfArraySmallJson(self, array) == -1) {
+ if (icIndexOfArraycSmallJson(self, array) == -1) {
return(false);
}
return(true);
}
-internal bool icHasArraycSmallJson(smallJsont *self, char **array) {
+internal bool icHasCArraycSmallJson(smallJsont *self, const char **array) {
if (!array) {
return(false);
}
- if (icIndexOfArraycSmallJson(self, array) == -1) {
+ if (icIndexOfCArraycSmallJson(self, array) == -1) {
return(false);
}
@@ -13944,7 +14451,7 @@ internal ssize_t icIndexOfSmallJson(smallJsont *self, baset *value) {
if (icEqS(es, s)) {
free(es);
free(s);
- return(i);
+ return((ssize_t)i);
}
free(es);
}
@@ -13974,12 +14481,15 @@ internal ssize_t icIndexOfSSmallJson(smallJsont *self, const char *string) {
continue;
}
if (e->type == STRING && icEqS(sStringGetTiny((sStringt*)e), string)) {
- return(i);
+ return((ssize_t)i);
}
}
break;
case TOP_IS_STRING:
- return(icIndexOfS(sStringGetTiny((sStringt*)self->topS), string));
+ return((ssize_t)icIndexOfS(sStringGetTiny((sStringt*)self->topS), string));
+ default:;
+ // not reachable
+ logC("Check this function!");
}
return(-1);
}
@@ -13987,7 +14497,7 @@ internal ssize_t icIndexOfSSmallJson(smallJsont *self, const char *string) {
internal ssize_t icIndexOfCharSmallJson(smallJsont *self, char c) {
charToS(s, c);
- return(icIndexOfSSmallJson(self, s));
+ return((ssize_t)icIndexOfSSmallJson(self, s));
}
internal ssize_t icIndexOfDictSmallJson(smallJsont *self, smallDictt *dict) {
@@ -14018,7 +14528,7 @@ internal ssize_t icIndexOfDictSmallJson(smallJsont *self, smallDictt *dict) {
if (icEqS(es, s)) {
free(es);
free(s);
- return(i);
+ return((ssize_t)i);
}
free(es);
}
@@ -14055,7 +14565,7 @@ internal ssize_t icIndexOfArraySmallJson(smallJsont *self, smallArrayt *array) {
if (icEqS(es, s)) {
free(es);
free(s);
- return(i);
+ return((ssize_t)i);
}
free(es);
}
@@ -14088,7 +14598,40 @@ internal ssize_t icIndexOfArraycSmallJson(smallJsont *self, char **array) {
if (icEqS(es, s)) {
free(es);
free(s);
- return(i);
+ return((ssize_t)i);
+ }
+ free(es);
+ }
+ }
+ free(s);
+ return(-1);
+}
+
+internal ssize_t icIndexOfCArraycSmallJson(smallJsont *self, const char **array) {
+
+ // sanity checks
+ if (self->topIsA != TOP_IS_ARRAY) {
+ return(-1);
+ }
+
+ if (!lenSmallJson(self) || !array) {
+ return(-1);
+ }
+
+ // search object in elements
+ char *s = toStringListCSGF(array);
+ char *es = NULL;;
+
+ enumerateSArray(self->topA, e, i) {
+ if (not e) {
+ continue;
+ }
+ if (e->type == ARRAY) {
+ es = sToString(e);
+ if (icEqS(es, s)) {
+ free(es);
+ free(s);
+ return((ssize_t)i);
}
free(es);
}
@@ -14130,12 +14673,15 @@ internal ssize_t icIndexOfSmallStringSmallJson(smallJsont *self, smallStringt *s
continue;
}
if (e->type == STRING && icEqS(sStringGetTiny((sStringt*)e), s)) {
- return(i);
+ return((ssize_t)i);
}
}
break;
case TOP_IS_STRING:
return(icIndexOfS(sStringGetTiny((sStringt*)self->topS), s));
+ default:
+ // not reachable
+ logC("Check this function!");
}
return(-1);
}
@@ -14155,10 +14701,10 @@ internal ssize_t icBinarySearchSmallJson(smallJsont *self, baset *value) {
char *m = NULL;
ssize_t r = -1;
- last = lenSmallJson(self) - 1;
+ last = (ssize_t)lenSmallJson(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- m = sToString(sArrayGetTiny(self->topA, middle));
+ m = sToString(sArrayGetTiny(self->topA, (uint32_t)middle));
if (!m) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -14195,10 +14741,10 @@ internal ssize_t icBinarySearchSSmallJson(smallJsont *self, const char *string)
smallt *e = NULL;
- last = lenSmallJson(self) - 1;
+ last = (ssize_t)lenSmallJson(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- e = sArrayGetTiny(self->topA, middle);
+ e = sArrayGetTiny(self->topA, (uint32_t)middle);
if (!e) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -14244,10 +14790,10 @@ internal ssize_t icBinarySearchDictSmallJson(smallJsont *self, smallDictt *dict)
char *m = NULL;
ssize_t r = -1;
- last = lenSmallJson(self) - 1;
+ last = (ssize_t)lenSmallJson(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- e = sArrayGetTiny(self->topA, middle);
+ e = sArrayGetTiny(self->topA, (uint32_t)middle);
if (!e) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -14299,10 +14845,10 @@ internal ssize_t icBinarySearchArraySmallJson(smallJsont *self, smallArrayt *arr
char *m = NULL;
ssize_t r = -1;
- last = lenSmallJson(self) - 1;
+ last = (ssize_t)lenSmallJson(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- e = sArrayGetTiny(self->topA, middle);
+ e = sArrayGetTiny(self->topA, (uint32_t)middle);
if (!e) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -14350,10 +14896,61 @@ internal ssize_t icBinarySearchArraycSmallJson(smallJsont *self, char **array) {
char *m = NULL;
ssize_t r = -1;
- last = lenSmallJson(self) - 1;
+ last = (ssize_t)lenSmallJson(self) - 1;
+ while (first <= last) {
+ middle = (first+last)/2;
+ e = sArrayGetTiny(self->topA, (uint32_t)middle);
+ if (!e) {
+ // there are null element in the array
+ // the array needs to be trimmed or compacted
+ goto finish;
+ }
+ // cg_c bug, can't use comma operator, extra code
+ if (e->type == ARRAY) {
+ m = sToString(e);
+ }
+ // cg_c bug, can't use comma operator
+ /* if e->type < ARRAY || ((e->type = ARRAY) && strcmp((m=sToString(e),m), s) < 0) */
+ if (e->type < ARRAY || ((e->type == ARRAY) && strcasecmp(m, s) < 0)) {
+ first = middle + 1;
+ }
+ else if ((e->type == ARRAY) && strcasecmp(m, s) == 0) {
+ r = middle;
+ free(m);
+ goto finish;
+ }
+ else {
+ last = middle -1;
+ }
+ if (e->type == ARRAY) {
+ free(m);
+ }
+ }
+ finish:
+ free(s);
+ return(r);
+}
+
+internal ssize_t icBinarySearchCArraycSmallJson(smallJsont *self, const char **array) {
+ ssize_t first = 0, middle, last;;
+
+ if (self->topIsA != TOP_IS_ARRAY) {
+ return(-1);
+ }
+
+ if (!lenSmallJson(self) || !array) {
+ return(-1);
+ }
+
+ char *s = toStringListCSGF(array);
+ smallt *e = NULL;
+ char *m = NULL;
+
+ ssize_t r = -1;
+ last = (ssize_t)lenSmallJson(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- e = sArrayGetTiny(self->topA, middle);
+ e = sArrayGetTiny(self->topA, (uint32_t)middle);
if (!e) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -14407,10 +15004,10 @@ internal ssize_t icBinarySearchSmallStringSmallJson(smallJsont *self, smallStrin
char *s = sStringGetTiny(string->data);
smallt *e = NULL;
- last = lenSmallJson(self) - 1;
+ last = (ssize_t)lenSmallJson(self) - 1;
while (first <= last) {
middle = (first+last)/2;
- e = sArrayGetTiny(self->topA, middle);
+ e = sArrayGetTiny(self->topA, (uint32_t)middle);
if (!e) {
// there are null element in the array
// the array needs to be trimmed or compacted
@@ -14460,18 +15057,18 @@ internal char* keyBySmallJson(smallJsont *self, baset *value) {
return(NULL);
}
-internal char* keyByUndefinedSmallJson(smallJsont *self, undefinedt *undefined) {
+internal char* keyByUndefinedSmallJson(smallJsont *self, undefinedt *u) {
// sanity checks
if (self->topIsA != TOP_IS_DICT) {
return(NULL);
}
- if (!lenSmallJson(self) || !undefined) {
+ if (!lenSmallJson(self) || !u) {
return(NULL);
}
- if (checkObjectTypes && !isOUndefined(undefined)) {
+ if (checkObjectTypes && !isOUndefined(u)) {
return(NULL);
}
@@ -14667,6 +15264,36 @@ internal char* keyByArraycSmallJson(smallJsont *self, char **array) {
return(NULL);
}
+internal char* keyByCArraycSmallJson(smallJsont *self, const char **array) {
+
+ // sanity checks
+ if (self->topIsA != TOP_IS_DICT) {
+ return(NULL);
+ }
+
+ if (!lenSmallJson(self) || !array) {
+ return(NULL);
+ }
+
+ // search object in elements
+ char *s = toStringListCSGF(array);
+ char *es = NULL;;
+
+ forEachSDict(self->top, e) {
+ if (e->key && e->data->type == ARRAY) {
+ es = sToString(e->data);
+ if (eqS(es, s)) {
+ free(es);
+ free(s);
+ return(e->key);
+ }
+ free(es);
+ }
+ }
+ free(s);
+ return(NULL);
+}
+
internal char* keyBySmallBoolSmallJson(smallJsont *self, smallBoolt *value) {
// sanity checks
@@ -14827,6 +15454,8 @@ internal char* keyBySmallJsonSmallJson(smallJsont *self, smallJsont *value) {
r = keyByArraySmallJson(self, (smallArrayt*)O);;
finishO(O);
break;
+ default:
+ logC("Unsupported smallJson type!");
}
return(r);
}
@@ -15035,6 +15664,36 @@ internal char* icKeyByArraycSmallJson(smallJsont *self, char **array) {
return(NULL);
}
+internal char* icKeyByCArraycSmallJson(smallJsont *self, const char **array) {
+
+ // sanity checks
+ if (self->topIsA != TOP_IS_DICT) {
+ return(NULL);
+ }
+
+ if (!lenSmallJson(self) || !array) {
+ return(NULL);
+ }
+
+ // search object in elements
+ char *s = toStringListCSGF(array);
+ char *es = NULL;;
+
+ forEachSDict(self->top, e) {
+ if (e->key && e->data->type == ARRAY) {
+ es = sToString(e->data);
+ if (icEqS(es, s)) {
+ free(es);
+ free(s);
+ return(e->key);
+ }
+ free(es);
+ }
+ }
+ free(s);
+ return(NULL);
+}
+
internal char* icKeyBySmallStringSmallJson(smallJsont *self, smallStringt *string) {
// sanity checks
@@ -15077,8 +15736,6 @@ internal smallJsont* replaceSmallJson(smallJsont *self, const char *olds, const
char *ins = NULL;
size_t count;
size_t lfront;
- bool freeNewsStatus = false;;
- char *internalNews = NULL;
// sanity checks and initialization
// count the number of replacements needed
@@ -15109,11 +15766,7 @@ internal smallJsont* replaceSmallJson(smallJsont *self, const char *olds, const
}
if (!news) {
// empty smallString for NULL
- freeNewsStatus = true;
- emptyS(internalNews)
- }
- else {
- internalNews = (char *) news;
+ news = "";
}
// count the number of replacements needed
@@ -15128,16 +15781,13 @@ internal smallJsont* replaceSmallJson(smallJsont *self, const char *olds, const
size_t lnews;
- lnews = strlen(internalNews);
+ lnews = strlen(news);
// allocate result
// +1 for 0 at the end +1 for sType at the start
size_t rLen = lenSmallJson(self) + (lnews - lolds) * count + 2;;
tmp = r = malloc(rLen);
if (!r) {
- if (freeNewsStatus) {
- free(internalNews);
- }
return(NULL);
}
@@ -15150,17 +15800,14 @@ internal smallJsont* replaceSmallJson(smallJsont *self, const char *olds, const
// s is the remainder of s after end of olds
while (count--) {
ins = strstr(workingS, olds);
- lfront = ins - workingS;
+ lfront = (size_t)(ins - workingS);
tmp = strncpy(tmp, workingS, lfront) + lfront;
- tmp = strcpy(tmp, internalNews) + lnews;
+ tmp = strcpy(tmp, news) + lnews;
workingS += lfront + lolds;
}
// copy end of smallString
strcpy(tmp, workingS);
- if (freeNewsStatus) {
- free(internalNews);
- }
free(self->topS);
self->topS = (sStringt *)r;
@@ -15503,8 +16150,8 @@ internal smallJsont* replaceCharJsonSmallJson(smallJsont *self, char olds, small
internal smallJsont* replaceManySmallJson(smallJsont *self, const char *paramType, ...) {
va_list pl;
- char *olds = NULL;
- char *news = NULL;
+ const char *olds = NULL;
+ const char *news = NULL;
// sanity checks
if (self->topIsA != TOP_IS_STRING) {
@@ -15515,11 +16162,11 @@ internal smallJsont* replaceManySmallJson(smallJsont *self, const char *paramTyp
return(self);
}
- olds = (char *) paramType;;
+ olds = paramType;
// add arguments to a list
va_start(pl, paramType);
- paramType = va_arg(pl, char *);
+ paramType = va_arg(pl, const char *);
if (!paramType) {
// missing news
va_end(pl);
@@ -15527,10 +16174,10 @@ internal smallJsont* replaceManySmallJson(smallJsont *self, const char *paramTyp
}
while (paramType) {
if (!olds) {
- olds = (char *) paramType;
+ olds = paramType;
}
else if (!news) {
- news = (char *) paramType;
+ news = paramType;
smallJsont *r = replaceSmallJson(self, olds, news, 0);
if (!r) {
// replace error
@@ -15541,7 +16188,7 @@ internal smallJsont* replaceManySmallJson(smallJsont *self, const char *paramTyp
news = NULL;
}
- paramType = va_arg(pl, char *);
+ paramType = va_arg(pl, const char *);
}
va_end(pl);
return(self);
@@ -15555,8 +16202,6 @@ internal smallJsont* icReplaceSmallJson(smallJsont *self, const char *olds, cons
char *ins = NULL;
size_t count;
size_t lfront;
- bool freeNewsStatus = false;;
- char *internalNews = NULL;
// sanity checks and initialization
// count the number of replacements needed
@@ -15587,11 +16232,7 @@ internal smallJsont* icReplaceSmallJson(smallJsont *self, const char *olds, cons
}
if (!news) {
// empty smallString for NULL
- freeNewsStatus = true;
- emptyS(internalNews)
- }
- else {
- internalNews = (char *) news;
+ news = "";
}
// count the number of replacements needed
@@ -15606,16 +16247,13 @@ internal smallJsont* icReplaceSmallJson(smallJsont *self, const char *olds, cons
size_t lnews;
- lnews = strlen(internalNews);
+ lnews = strlen(news);
// allocate result
// +1 for 0 at the end +1 for sType at the start
size_t rLen = lenSmallJson(self) + (lnews - lolds) * count + 2;;
tmp = r = malloc(rLen);
if (!r) {
- if (freeNewsStatus) {
- free(internalNews);
- }
return(NULL);
}
@@ -15628,17 +16266,14 @@ internal smallJsont* icReplaceSmallJson(smallJsont *self, const char *olds, cons
// s is the remainder of s after end of olds
while (count--) {
ins = strcasestr(workingS, olds);
- lfront = ins - workingS;
+ lfront = (size_t)(ins - workingS);
tmp = strncpy(tmp, workingS, lfront) + lfront;
- tmp = strcpy(tmp, internalNews) + lnews;
+ tmp = strcpy(tmp, news) + lnews;
workingS += lfront + lolds;
}
// copy end of smallString
strcpy(tmp, workingS);
- if (freeNewsStatus) {
- free(internalNews);
- }
free(self->topS);
self->topS = (sStringt *)r;
@@ -15985,8 +16620,8 @@ internal smallJsont* icReplaceCharJsonSmallJson(smallJsont *self, char olds, sma
internal smallJsont* icReplaceManySmallJson(smallJsont *self, const char *paramType, ...) {
va_list pl;
- char *olds = NULL;
- char *news = NULL;
+ const char *olds = NULL;
+ const char *news = NULL;
// sanity checks
if (self->topIsA != TOP_IS_STRING) {
@@ -15997,11 +16632,11 @@ internal smallJsont* icReplaceManySmallJson(smallJsont *self, const char *paramT
return(self);
}
- olds = (char *) paramType;;
+ olds = paramType;
// add arguments to a list
va_start(pl, paramType);
- paramType = va_arg(pl, char *);
+ paramType = va_arg(pl, const char *);
if (!paramType) {
// missing news
va_end(pl);
@@ -16009,10 +16644,10 @@ internal smallJsont* icReplaceManySmallJson(smallJsont *self, const char *paramT
}
while (paramType) {
if (!olds) {
- olds = (char *) paramType;
+ olds = paramType;
}
else if (!news) {
- news = (char *) paramType;
+ news = paramType;
smallJsont *r = icReplaceSmallJson(self, olds, news, 0);
if (!r) {
// replace error
@@ -16023,7 +16658,7 @@ internal smallJsont* icReplaceManySmallJson(smallJsont *self, const char *paramT
news = NULL;
}
- paramType = va_arg(pl, char *);
+ paramType = va_arg(pl, const char *);
}
va_end(pl);
return(self);
@@ -16056,28 +16691,28 @@ internal bool equalSmallJsonSmallArray(smallJsont *self, smallArrayt *array) {
char *as = NULL;
enumerateSArray(self->topA, e, i) {
if (not e) {
- if (not sArrayGetTiny(array->a, i)) {
+ if (not sArrayGetTiny(array->a, (uint32_t)i)) {
continue;
}
else {
return(false);
}
}
- if ((e->type != sArrayGetTiny(array->a, i)->type)) {
+ if ((e->type != sArrayGetTiny(array->a, (uint32_t)i)->type)) {
return(false);
}
else {
switch (e->type) {
// not needed always equal - case UNDEFINED:
case BOOL:
- if (((sBoolt*)e)->value != ((sBoolt*)sArrayGetTiny(array->a, i))->value) {
+ if (((sBoolt*)e)->value != ((sBoolt*)sArrayGetTiny(array->a, (uint32_t)i))->value) {
return(false);
}
break;
// TODO case CONTAINER:
case DICT:
es = sToString(e);
- as = sToString(sArrayGetTiny(array->a, i));
+ as = sToString(sArrayGetTiny(array->a, (uint32_t)i));
if (!strEq(es, as)) {
free(es);
free(as);
@@ -16087,23 +16722,23 @@ internal bool equalSmallJsonSmallArray(smallJsont *self, smallArrayt *array) {
free(as);
break;
case DOUBLE:
- if (((sDoublet*)e)->value != ((sDoublet*)sArrayGetTiny(array->a, i))->value) {
+ if (((sDoublet*)e)->value != ((sDoublet*)sArrayGetTiny(array->a, (uint32_t)i))->value) {
return(false);
}
break;
case INT:
- if (((sIntt*)e)->value != ((sIntt*)sArrayGetTiny(array->a, i))->value) {
+ if (((sIntt*)e)->value != ((sIntt*)sArrayGetTiny(array->a, (uint32_t)i))->value) {
return(false);
}
break;
case STRING:
- if (!strEq(sStringGetTiny((sStringt*)e), sStringGetTiny((sStringt*)sArrayGetTiny(array->a, i)))) {
+ if (!strEq(sStringGetTiny((sStringt*)e), sStringGetTiny((sStringt*)sArrayGetTiny(array->a, (uint32_t)i)))) {
return(false);
}
break;
case ARRAY:
es = sToString(e);
- as = sToString(sArrayGetTiny(array->a, i));
+ as = sToString(sArrayGetTiny(array->a, (uint32_t)i));
if (!strEq(es, as)) {
free(es);
free(as);
@@ -16113,13 +16748,15 @@ internal bool equalSmallJsonSmallArray(smallJsont *self, smallArrayt *array) {
free(as);
break;
case BYTES:
- if (((sBytest*)e)->count != ((sBytest*)sArrayGetTiny(array->a, i))->count) {
+ if (((sBytest*)e)->count != ((sBytest*)sArrayGetTiny(array->a, (uint32_t)i))->count) {
return(false);
}
- if (memcmp(&((sBytest*)e)->data, &((sBytest*)sArrayGetTiny(array->a, i))->data, ((sBytest*)e)->count)) {
+ if (memcmp(&((sBytest*)e)->data, &((sBytest*)sArrayGetTiny(array->a, (uint32_t)i))->data, ((sBytest*)e)->count)) {
return(false);
}
break;
+ default:
+ logC("Unsupported object type!");
}
}
}
@@ -16161,6 +16798,40 @@ bool equalSmallJsonArray(smallJsont *self, char ** p2) {
return(true);
}
+bool equalSmallJsonCArray(smallJsont *self, const char ** p2) {
+
+ // sanity checks
+ if (!lenSmallJson(self) && !listLengthCS(p2)) {
+ // both arrays are empty
+ return(true);
+ }
+ if (self->topIsA != TOP_IS_ARRAY) {
+ return(false);
+ }
+
+ if (!lenSmallJson(self) || !listLengthCS(p2)) {
+ return(false);
+ }
+ if (lenSmallJson(self) != listLengthCS(p2)) {
+ return(false);
+ }
+
+ // compare elements
+ enumerateSArray(self->topA, e, i) {
+ if (not e) {
+ return(false);
+ }
+ if (e->type != STRING) {
+ return(false);
+ }
+ if (!strEq(sStringGetTiny((sStringt*)e), p2[i])) {
+ return(false);
+ }
+ }
+
+ return(true);
+}
+
bool equalSmallJsonBase(smallJsont *self, baset* p2) {
char *s = NULL;
bool r;
@@ -16214,10 +16885,10 @@ bool equalSmallJsonBase(smallJsont *self, baset* p2) {
free(s);
return(r);
case TOP_IS_STRING:
- s = sStringGetTiny(self->topS);
+ s = sStringGetTiny(self->topS);
char *p2s = toStringO(p2);
- bool r = eqS(s, p2s);
+ r = eqS(s, p2s);
free(p2s);
return(r);
case TOP_IS_DICT:
@@ -16237,6 +16908,8 @@ bool equalSmallJsonBase(smallJsont *self, baset* p2) {
cast(smallArrayt *, arr, p2);
return(equalSmallJsonSmallArray(self, arr));
+ default:
+ logC("Unsupported object type!");
}
return(false);
}
@@ -16263,6 +16936,8 @@ internal bool equalSmallJsonCha(smallJsont* self, char p2) {
}
return(sStringGetTiny(self->topS)[0] == p2);;
break;
+ default:;
+ // return false
}
return(false);
}
@@ -16299,6 +16974,8 @@ internal bool equalSmallJsonChar(smallJsont* self, const char * p2) {
return(false);
}
return(strcmp(sStringGetTiny(self->topS),p2) == 0);;
+ default:;
+ // return false
}
return(false);
}
@@ -16321,6 +16998,8 @@ internal bool equalSmallJsonBool(smallJsont* self, bool p2) {
return(!p2);
}
break;
+ default:;
+ // return false
}
return(false);
}
@@ -16341,6 +17020,8 @@ internal bool equalSmallJsonDouble(smallJsont* self, double p2) {
}
double selfValue = parseDoubleSmallJson(self);
return(selfValue == p2);;
+ default:;
+ // return false
}
return(false);
}
@@ -16361,6 +17042,8 @@ internal bool equalSmallJsonInt64(smallJsont* self, int64_t p2) {
}
int64_t selfValue = parseIntSmallJson(self);
return(selfValue == p2);;
+ default:;
+ // return false
}
return(false);
}
@@ -16381,6 +17064,8 @@ internal bool equalSmallJsonInt32(smallJsont* self, int32_t p2) {
}
int64_t selfValue = parseIntSmallJson(self);
return(selfValue == p2);;
+ default:;
+ // return false
}
return(false);
}
@@ -16399,8 +17084,10 @@ internal bool equalSmallJsonUint32(smallJsont* self, uint32_t p2) {
if (!isInt(s)) {
return(false);
}
- uint32_t selfValue = parseIntSmallJson(self);
+ uint32_t selfValue = (uint32_t)parseIntSmallJson(self);
return(selfValue == p2);;
+ default:;
+ // return false
}
return(false);
}
@@ -16419,8 +17106,10 @@ internal bool equalSmallJsonUint64(smallJsont* self, uint64_t p2) {
if (!isInt(s)) {
return(false);
}
- uint64_t selfValue = parseIntSmallJson(self);
+ uint64_t selfValue = (uint64_t)parseIntSmallJson(self);
return(selfValue == p2);;
+ default:;
+ // return false
}
return(false);
}
@@ -16499,6 +17188,8 @@ internal bool equalSmallJsonSmallBytes(smallJsont* self, smallBytest* p2) {
}
return(equalSO(p2, sStringGetTiny(self->topS)));
break;
+ default:;
+ // return false
}
return(false);
}
@@ -16527,6 +17218,8 @@ internal bool equalSmallJsonSmallDouble(smallJsont* self, smallDoublet* p2) {
}
double selfValue = parseDoubleSmallJson(self);
return(selfValue == p2->value->value);;
+ default:;
+ // return false
}
return(false);
}
@@ -16555,6 +17248,8 @@ internal bool equalSmallJsonSmallInt(smallJsont* self, smallIntt* p2) {
}
int64_t selfValue = parseIntSmallJson(self);
return(selfValue == p2->value->value);;
+ default:;
+ // return false
}
return(false);
}
@@ -16606,6 +17301,8 @@ internal bool equalSmallJsonSmallJson(smallJsont* self, smallJsont* p2) {
r = equalSmallJsonSmallArray(self, (smallArrayt*)O);;
finishO(O);
break;
+ default:;
+ // return false
}
return(r);
}
@@ -16653,6 +17350,8 @@ internal bool equalSmallJsonSmallString(smallJsont* self, smallStringt* p2) {
}
return(strcmp(sStringGetTiny(self->topS),sStringGetTiny(p2->data)) == 0);;
break;
+ default:;
+ // return false
}
return(false);
}
@@ -16721,28 +17420,28 @@ internal bool icEqualSmallJsonSmallArray(smallJsont *self, smallArrayt *array) {
char *as = NULL;
enumerateSArray(self->topA, e, i) {
if (not e) {
- if (not sArrayGetTiny(array->a, i)) {
+ if (not sArrayGetTiny(array->a, (uint32_t)i)) {
continue;
}
else {
return(false);
}
}
- if ((e->type != sArrayGetTiny(array->a, i)->type)) {
+ if ((e->type != sArrayGetTiny(array->a, (uint32_t)i)->type)) {
return(false);
}
else {
switch (e->type) {
// not needed always equal - case UNDEFINED:
case BOOL:
- if (((sBoolt*)e)->value != ((sBoolt*)sArrayGetTiny(array->a, i))->value) {
+ if (((sBoolt*)e)->value != ((sBoolt*)sArrayGetTiny(array->a, (uint32_t)i))->value) {
return(false);
}
break;
// TODO case CONTAINER:
case DICT:
es = sToString(e);
- as = sToString(sArrayGetTiny(array->a, i));
+ as = sToString(sArrayGetTiny(array->a, (uint32_t)i));
if (!icEqS(es, as)) {
free(es);
free(as);
@@ -16752,23 +17451,23 @@ internal bool icEqualSmallJsonSmallArray(smallJsont *self, smallArrayt *array) {
free(as);
break;
case DOUBLE:
- if (((sDoublet*)e)->value != ((sDoublet*)sArrayGetTiny(array->a, i))->value) {
+ if (((sDoublet*)e)->value != ((sDoublet*)sArrayGetTiny(array->a, (uint32_t)i))->value) {
return(false);
}
break;
case INT:
- if (((sIntt*)e)->value != ((sIntt*)sArrayGetTiny(array->a, i))->value) {
+ if (((sIntt*)e)->value != ((sIntt*)sArrayGetTiny(array->a, (uint32_t)i))->value) {
return(false);
}
break;
case STRING:
- if (!icEqS(sStringGetTiny((sStringt*)e), sStringGetTiny((sStringt*)sArrayGetTiny(array->a, i)))) {
+ if (!icEqS(sStringGetTiny((sStringt*)e), sStringGetTiny((sStringt*)sArrayGetTiny(array->a, (uint32_t)i)))) {
return(false);
}
break;
case ARRAY:
es = sToString(e);
- as = sToString(sArrayGetTiny(array->a, i));
+ as = sToString(sArrayGetTiny(array->a, (uint32_t)i));
if (!icEqS(es, as)) {
free(es);
free(as);
@@ -16778,13 +17477,15 @@ internal bool icEqualSmallJsonSmallArray(smallJsont *self, smallArrayt *array) {
free(as);
break;
case BYTES:
- if (((sBytest*)e)->count != ((sBytest*)sArrayGetTiny(array->a, i))->count) {
+ if (((sBytest*)e)->count != ((sBytest*)sArrayGetTiny(array->a, (uint32_t)i))->count) {
return(false);
}
- if (memcmp(&((sBytest*)e)->data, &((sBytest*)sArrayGetTiny(array->a, i))->data, ((sBytest*)e)->count)) {
+ if (memcmp(&((sBytest*)e)->data, &((sBytest*)sArrayGetTiny(array->a, (uint32_t)i))->data, ((sBytest*)e)->count)) {
return(false);
}
break;
+ default:
+ logC("Unsupported object type!");
}
}
}
@@ -16825,6 +17526,39 @@ bool icEqualSmallJsonArray(smallJsont *self, char ** p2) {
return(true);
}
+bool icEqualSmallJsonCArray(smallJsont *self, const char ** p2) {
+
+ // sanity checks
+ if (self->topIsA != TOP_IS_ARRAY) {
+ return(false);
+ }
+ if (!lenSmallJson(self) && !listLengthCS(p2)) {
+ // both arrays are empty
+ return(true);
+ }
+ if (!lenSmallJson(self) || !listLengthCS(p2)) {
+ return(false);
+ }
+ if (lenSmallJson(self) != listLengthCS(p2)) {
+ return(false);
+ }
+
+ // compare elements
+ enumerateSArray(self->topA, e, i) {
+ if (not e) {
+ return(false);
+ }
+ if (e->type != STRING) {
+ return(false);
+ }
+ if (!icEqS(sStringGetTiny((sStringt*)e), p2[i])) {
+ return(false);
+ }
+ }
+
+ return(true);
+}
+
bool icEqualSmallJsonBase(smallJsont *self, baset* p2) {
if (!lenSmallJson(self) || !p2) {
@@ -16961,6 +17695,8 @@ internal bool icEqualCharSmallJson(smallJsont *self, char c) {
break;
case TOP_IS_STRING:
return(icEqualSSmallJson(self, s));
+ default:;
+ // return false
}
return(false);
}
@@ -17535,7 +18271,7 @@ internal smallJsont* upperSmallJson(smallJsont *self) {
char *string = sStringGetTiny(self->topS);
while (*string != 0) {
- *string = toupper(*string);
+ *string = (char)toupper(*string);
string++;
}
return(self);
@@ -17549,7 +18285,7 @@ internal smallJsont* lowerSmallJson(smallJsont *self) {
char *string = sStringGetTiny(self->topS);
while (*string != 0) {
- *string = tolower(*string);
+ *string = (char)tolower(*string);
string++;
}
return(self);
@@ -17573,7 +18309,7 @@ internal smallJsont* trimSmallJson(smallJsont *self) {
}
for (size_t i = 0 ; i < lenSmallJson(self); i++) {
- o = sArrayGetTiny(self->topA, i);
+ o = sArrayGetTiny(self->topA, (uint32_t)i);
if (o) {
sArrayPushTiny(&a, o);
}
@@ -17635,7 +18371,7 @@ internal smallJsont* trimSmallJson(smallJsont *self) {
}
// copy range to new smallString
- len = end - workingS + 2;
+ len = (size_t)(end - workingS + 2);
isError(r, malloc(len)) return(NULL);
r = strncpy(r, workingS, len - 1);
r[len - 1] = 0;
@@ -17646,6 +18382,9 @@ internal smallJsont* trimSmallJson(smallJsont *self) {
return(NULL);
}
break;
+ default:
+ // not reachable
+ logC("Check this function!");
}
return(self);
}
@@ -17720,7 +18459,7 @@ internal char** keysSmallJson(smallJsont *self) {
forEachSDict(self->top, e) {
if (e->key) {
- listPushS(&r, e->key);
+ pErrorNULL(listPushS(&r, e->key));
}
}
return(r);
@@ -17835,6 +18574,8 @@ internal smallJsont* compactSmallJson(smallJsont *self) {
sFree(e);
}
break;
+ default:
+ logC("Unsupported object type!");
}
}
}
@@ -17895,6 +18636,8 @@ internal bool isEmptySmallJson(smallJsont *self) {
break;
case TOP_IS_STRING:
return(false);
+ default:;
+ // do nothing for other types
}
return(true);
}
@@ -17950,6 +18693,8 @@ internal bool isBlankSmallJson(smallJsont *self) {
return(false);
}
break;
+ default:
+ logC("Unsupported object type!");
}
}
}
@@ -18056,7 +18801,7 @@ internal smallStringt* joinSmallJson(smallJsont *self, const char* delim) {
isError(r, allocSmallString(sStringGetTiny((sStringt*)e))) return(NULL);
}
else {
- r->f->appendS(r, (char*)delim);
+ r->f->appendS(r, delim);
r->f->appendS(r, sStringGetTiny((sStringt*)e));
}
break;
@@ -18066,7 +18811,7 @@ internal smallStringt* joinSmallJson(smallJsont *self, const char* delim) {
isError(r, allocSmallString(s)) return(NULL);
}
else {
- r->f->appendS(r, (char*)delim);
+ r->f->appendS(r, delim);
r->f->appendS(r, s);
}
free(s);
@@ -18133,8 +18878,8 @@ internal char* joinSSmallJson(smallJsont *self, const char* delim) {
r = strdup(sStringGetTiny((sStringt*)e));
}
else {
- iAppendS(&r, delim);
- iAppendS(&r, sStringGetTiny((sStringt*)e));
+ pErrorNULL(iAppendS(&r, delim));
+ pErrorNULL(iAppendS(&r, sStringGetTiny((sStringt*)e)));
}
break;
default:
@@ -18147,8 +18892,8 @@ internal char* joinSSmallJson(smallJsont *self, const char* delim) {
r = strdup(s);
}
else {
- iAppendS(&r, delim);
- iAppendS(&r, s);
+ pErrorNULL(iAppendS(&r, delim));
+ pErrorNULL(iAppendS(&r, s));
}
free(s);
}
@@ -18260,7 +19005,7 @@ internal char** splitSSmallJson(smallJsont *self, const char *delim) {
if (!*delim || !*sStringGetTiny(self->topS)) {
// empty delimiter or empty string
- listPushS(&r, sStringGetTiny(self->topS));
+ pErrorNULL(listPushS(&r, sStringGetTiny(self->topS)));
return(r);
}
@@ -18270,7 +19015,7 @@ internal char** splitSSmallJson(smallJsont *self, const char *delim) {
line = workingSmallString;
while (strlen(workingSmallString) != 0) {
token = tokS(line, delim, &workingSmallString);
- listPushS(&r, token);
+ pErrorNULL(listPushS(&r, token));
// mac os sets workingSmallString to NULL at the end
if (!workingSmallString) {
break; //LCOV_EXCL_LINE
@@ -18286,7 +19031,7 @@ internal char** splitSSmallJson(smallJsont *self, const char *delim) {
size_t lenD = strlen(delim);
// +1 for sType
if (eqS(sStringGetTiny(self->topS)+(lenSmallJson(self)-lenD), delim)) {
- listPushS(&r, "");
+ pErrorNULL(listPushS(&r, ""));
}
return(r);
@@ -18353,12 +19098,12 @@ internal smallJsont* extractSmallJson(smallJsont *self, const char* delim1, cons
}
// remove first element
- iListSliceS(&tmp, 1, 0);
+ pErrorNULL(iListSliceS(&tmp, 1, 0));
forEachCharP(tmp, e) {
char **tmp2 = split(*e, delim2);
if (listLengthS(tmp2) > 1) {
- listPushS(&r, tmp2[0]);
+ pErrorNULL(listPushS(&r, tmp2[0]));
}
listFreeS(tmp2);
}
@@ -18659,7 +19404,7 @@ internal char** icSplitSSmallJson(smallJsont *self, const char *delim) {
if (!*delim || !*sStringGetTiny(self->topS)) {
// empty delimiter or empty string
- listPushS(&r, sStringGetTiny(self->topS));
+ pErrorNULL(listPushS(&r, sStringGetTiny(self->topS)));
return(r);
}
@@ -18669,7 +19414,7 @@ internal char** icSplitSSmallJson(smallJsont *self, const char *delim) {
line = workingSmallString;
while (strlen(workingSmallString) != 0) {
token = icTokS(line, delim, &workingSmallString);
- listPushS(&r, token);
+ pErrorNULL(listPushS(&r, token));
// mac os sets workingSmallString to NULL at the end
if (!workingSmallString) {
break; //LCOV_EXCL_LINE
@@ -18685,7 +19430,7 @@ internal char** icSplitSSmallJson(smallJsont *self, const char *delim) {
size_t lenD = strlen(delim);
// +1 for sType
if (icEqS(sStringGetTiny(self->topS)+(lenSmallJson(self)-lenD), delim)) {
- listPushS(&r, "");
+ pErrorNULL(listPushS(&r, ""));
}
return(r);
@@ -18752,12 +19497,12 @@ internal smallJsont* icExtractSmallJson(smallJsont *self, const char* delim1, co
}
// remove first element
- iListSliceS(&tmp, 1, 0);
+ pErrorNULL(iListSliceS(&tmp, 1, 0));
forEachCharP(tmp, e) {
char **tmp2 = icSplit(*e, delim2);
if (listLengthS(tmp2) > 1) {
- listPushS(&r, tmp2[0]);
+ pErrorNULL(listPushS(&r, tmp2[0]));
}
listFreeS(tmp2);
}
@@ -19052,7 +19797,7 @@ internal smallJsont* zipSmallJson(smallJsont *self, smallArrayt *array1, smallAr
return(NULL);
}
pushNFreeO(a, E1);
- pushNFreeO(a, getO(array2, i));
+ pushNFreeO(a, getO(array2, (int64_t)i));
pushNFreeArraySmallJson(self, a);
count++;
if (count == len) {
@@ -19069,7 +19814,7 @@ internal smallJsont* zipSmallJson(smallJsont *self, smallArrayt *array1, smallAr
finishO(K);
return(NULL);
}
- sDictSetTiny(&(self->top), ssGet(K), sArrayGetTiny(array2->a, count));
+ sDictSetTiny(&(self->top), ssGet(K), sArrayGetTiny(array2->a, (uint32_t)count));
finishO(K);
count++;
if (count == len) {
@@ -19117,7 +19862,7 @@ internal smallJsont* zipArraySmallJson(smallJsont *self, char** array1, smallArr
return(NULL);
}
a->f->pushNFreeS(a, E1);
- pushNFreeO(a, getO(array2, i));
+ pushNFreeO(a, getO(array2, (int64_t)i));
pushNFreeArraySmallJson(self, a);
count++;
if (count == len) {
@@ -19130,7 +19875,7 @@ internal smallJsont* zipArraySmallJson(smallJsont *self, char** array1, smallArr
count = 0;
forEachS(array1, k) {
- sDictSetTiny(&(self->top), k, sArrayGetTiny(array2->a, count));
+ sDictSetTiny(&(self->top), k, sArrayGetTiny(array2->a, (uint32_t)count));
count++;
if (count == len) {
break;
@@ -19157,11 +19902,11 @@ internal smallJsont* zipCArraySmallJson(smallJsont *self, const char** array1, s
return(NULL);
}
- if (!listLengthS((char**)array1) || !array2->f->len(array2)) {
+ if (!listLengthCS(array1) || !array2->f->len(array2)) {
return(self);
}
- len = MIN(listLengthS((char**)array1), array2->f->len(array2));;
+ len = MIN(listLengthCS(array1), array2->f->len(array2));;
if (self->topIsA == SMALLJSON_IS_EMPTY) {
self->topIsA = TOP_IS_ARRAY;
@@ -19170,13 +19915,13 @@ internal smallJsont* zipCArraySmallJson(smallJsont *self, const char** array1, s
if (self->topIsA == TOP_IS_ARRAY) {
count = 0;
- enumerateS((char**)array1, E1, i) {
+ enumerateCS(array1, E1, i) {
createAllocateSmallArray(a);
if (!a) {
return(NULL);
}
a->f->pushS(a, E1);
- pushNFreeO(a, getO(array2, i));
+ pushNFreeO(a, getO(array2, (int64_t)i));
pushNFreeArraySmallJson(self, a);
count++;
if (count == len) {
@@ -19188,8 +19933,8 @@ internal smallJsont* zipCArraySmallJson(smallJsont *self, const char** array1, s
else if (self->topIsA == TOP_IS_DICT) {
count = 0;
- forEachS((char**)array1, k) {
- sDictSetTiny(&(self->top), k, sArrayGetTiny(array2->a, count));
+ forEachCS(array1, k) {
+ sDictSetTiny(&(self->top), k, sArrayGetTiny(array2->a, (uint32_t)count));
count++;
if (count == len) {
break;
@@ -19286,11 +20031,11 @@ internal smallJsont* zipCCharSmallJson(smallJsont *self, smallArrayt *array1, co
return(NULL);
}
- if (!array1->f->len(array1) || !listLengthS((char**)array2)) {
+ if (!array1->f->len(array1) || !listLengthCS(array2)) {
return(self);
}
- len = MIN(array1->f->len(array1), listLengthS((char**)array2));;
+ len = MIN(array1->f->len(array1), listLengthCS(array2));;
if (self->topIsA == SMALLJSON_IS_EMPTY) {
self->topIsA = TOP_IS_ARRAY;
@@ -19409,11 +20154,11 @@ internal smallJsont* zipCArrayCharSmallJson(smallJsont *self, const char** array
return(NULL);
}
- if (!listLengthS((char**)array1) || !listLengthS(array2)) {
+ if (!listLengthCS(array1) || !listLengthS(array2)) {
return(self);
}
- len = MIN(listLengthS((char**)array1), listLengthS(array2));;
+ len = MIN(listLengthCS(array1), listLengthS(array2));;
if (self->topIsA == SMALLJSON_IS_EMPTY) {
self->topIsA = TOP_IS_ARRAY;
@@ -19422,7 +20167,7 @@ internal smallJsont* zipCArrayCharSmallJson(smallJsont *self, const char** array
if (self->topIsA == TOP_IS_ARRAY) {
count = 0;
- enumerateS((char**)array1, E1, i) {
+ enumerateCS(array1, E1, i) {
createAllocateSmallArray(a);
if (!a) {
return(NULL);
@@ -19441,7 +20186,7 @@ internal smallJsont* zipCArrayCharSmallJson(smallJsont *self, const char** array
count = 0;
smallt *e;
- forEachS((char**)array1, k) {
+ forEachCS(array1, k) {
isError(e, (smallt *) allocSStringTiny(array2[count])) return(NULL);
sDictSetTiny(&(self->top), k, e);
count++;
@@ -19466,11 +20211,11 @@ internal smallJsont* zipArrayCCharSmallJson(smallJsont *self, char** array1, con
return(NULL);
}
- if (!listLengthS(array1) || !listLengthS((char**)array2)) {
+ if (!listLengthS(array1) || !listLengthCS(array2)) {
return(self);
}
- len = MIN(listLengthS(array1), listLengthS((char**)array2));;
+ len = MIN(listLengthS(array1), listLengthCS(array2));;
if (self->topIsA == SMALLJSON_IS_EMPTY) {
self->topIsA = TOP_IS_ARRAY;
@@ -19523,11 +20268,11 @@ internal smallJsont* zipCArrayCCharSmallJson(smallJsont *self, const char** arra
return(NULL);
}
- if (!listLengthS((char**)array1) || !listLengthS((char**)array2)) {
+ if (!listLengthCS(array1) || !listLengthCS(array2)) {
return(self);
}
- len = MIN(listLengthS((char**)array1), listLengthS((char**)array2));;
+ len = MIN(listLengthCS(array1), listLengthCS(array2));;
if (self->topIsA == SMALLJSON_IS_EMPTY) {
self->topIsA = TOP_IS_ARRAY;
@@ -19536,7 +20281,7 @@ internal smallJsont* zipCArrayCCharSmallJson(smallJsont *self, const char** arra
if (self->topIsA == TOP_IS_ARRAY) {
count = 0;
- enumerateS((char**)array1, E1, i) {
+ enumerateCS(array1, E1, i) {
createAllocateSmallArray(a);
if (!a) {
return(NULL);
@@ -19555,7 +20300,7 @@ internal smallJsont* zipCArrayCCharSmallJson(smallJsont *self, const char** arra
count = 0;
smallt *e;
- forEachS((char**)array1, k) {
+ forEachCS(array1, k) {
isError(e, (smallt *) allocSStringTiny(array2[count])) return(NULL);
sDictSetTiny(&(self->top), k, e);
count++;
@@ -19608,7 +20353,7 @@ smallJsont* zipJsonSmallJson(smallJsont *self, smallJsont *array1, smallJsont *a
return(NULL);
}
pushNFreeO(a, E1);
- pushNFreeO(a, getAtO(array2, i));
+ pushNFreeO(a, getAtO(array2, (int64_t)i));
pushNFreeArraySmallJson(self, a);
count++;
if (count == len) {
@@ -19625,7 +20370,7 @@ smallJsont* zipJsonSmallJson(smallJsont *self, smallJsont *array1, smallJsont *a
finishO(K);
return(NULL);
}
- sDictSetTiny(&(self->top), ssGet(K), sArrayGetTiny(array2->topA, count));
+ sDictSetTiny(&(self->top), ssGet(K), sArrayGetTiny(array2->topA, (uint32_t)count));
finishO(K);
count++;
if (count == len) {
@@ -19678,7 +20423,7 @@ smallJsont* zipJsonSmallArraySmallJson(smallJsont *self, smallJsont *array1, sma
return(NULL);
}
pushNFreeO(a, E1);
- pushNFreeO(a, getAtO(array2, i));
+ pushNFreeO(a, getAtO(array2, (int64_t)i));
pushNFreeArraySmallJson(self, a);
count++;
if (count == len) {
@@ -19695,7 +20440,7 @@ smallJsont* zipJsonSmallArraySmallJson(smallJsont *self, smallJsont *array1, sma
finishO(K);
return(NULL);
}
- sDictSetTiny(&(self->top), ssGet(K), sArrayGetTiny(array2->a, count));
+ sDictSetTiny(&(self->top), ssGet(K), sArrayGetTiny(array2->a, (uint32_t)count));
finishO(K);
count++;
if (count == len) {
@@ -19802,11 +20547,11 @@ smallJsont* zipJsonCArraySmallJson(smallJsont *self, smallJsont *array1, const c
return(NULL);
}
- if (!array1->f->len(array1) || !listLengthS((char**)array2)) {
+ if (!array1->f->len(array1) || !listLengthCS(array2)) {
return(self);
}
- len = MIN(array1->f->len(array1), listLengthS((char**)array2));;
+ len = MIN(array1->f->len(array1), listLengthCS(array2));;
if (self->topIsA == SMALLJSON_IS_EMPTY) {
self->topIsA = TOP_IS_ARRAY;
@@ -19896,7 +20641,7 @@ smallJsont* zipSmallArrayJsonSmallJson(smallJsont *self, smallArrayt *array1, sm
return(NULL);
}
pushNFreeO(a, E1);
- pushNFreeO(a, getAtO(array2, i));
+ pushNFreeO(a, getAtO(array2, (int64_t)i));
pushNFreeArraySmallJson(self, a);
count++;
if (count == len) {
@@ -19913,7 +20658,7 @@ smallJsont* zipSmallArrayJsonSmallJson(smallJsont *self, smallArrayt *array1, sm
finishO(K);
return(NULL);
}
- sDictSetTiny(&(self->top), ssGet(K), sArrayGetTiny(array2->topA, count));
+ sDictSetTiny(&(self->top), ssGet(K), sArrayGetTiny(array2->topA, (uint32_t)count));
finishO(K);
count++;
if (count == len) {
@@ -19965,7 +20710,7 @@ smallJsont* zipArrayJsonSmallJson(smallJsont *self, char** array1, smallJsont *a
return(NULL);
}
a->f->pushNFreeS(a, E1);
- pushNFreeO(a, getAtO(array2, i));
+ pushNFreeO(a, getAtO(array2, (int64_t)i));
pushNFreeArraySmallJson(self, a);
count++;
if (count == len) {
@@ -19978,7 +20723,7 @@ smallJsont* zipArrayJsonSmallJson(smallJsont *self, char** array1, smallJsont *a
count = 0;
forEachS(array1, k) {
- sDictSetTiny(&(self->top), k, sArrayGetTiny(array2->topA, count));
+ sDictSetTiny(&(self->top), k, sArrayGetTiny(array2->topA, (uint32_t)count));
count++;
if (count == len) {
break;
@@ -20009,11 +20754,11 @@ smallJsont* zipCArrayJsonSmallJson(smallJsont *self, const char** array1, smallJ
return(NULL);
}
- if (!listLengthS((char**)array1) || !array2->f->len(array2)) {
+ if (!listLengthCS(array1) || !array2->f->len(array2)) {
return(self);
}
- len = MIN(listLengthS((char**)array1), array2->f->len(array2));;
+ len = MIN(listLengthCS(array1), array2->f->len(array2));;
if (self->topIsA == SMALLJSON_IS_EMPTY) {
self->topIsA = TOP_IS_ARRAY;
@@ -20022,13 +20767,13 @@ smallJsont* zipCArrayJsonSmallJson(smallJsont *self, const char** array1, smallJ
if (self->topIsA == TOP_IS_ARRAY) {
count = 0;
- enumerateS((char**)array1, E1, i) {
+ enumerateCS(array1, E1, i) {
createAllocateSmallArray(a);
if (!a) {
return(NULL);
}
a->f->pushS(a, E1);
- pushNFreeO(a, getAtO(array2, i));
+ pushNFreeO(a, getAtO(array2, (int64_t)i));
pushNFreeArraySmallJson(self, a);
count++;
if (count == len) {
@@ -20040,8 +20785,8 @@ smallJsont* zipCArrayJsonSmallJson(smallJsont *self, const char** array1, smallJ
else if (self->topIsA == TOP_IS_DICT) {
count = 0;
- forEachS((char**)array1, k) {
- sDictSetTiny(&(self->top), k, sArrayGetTiny(array2->topA, count));
+ forEachCS(array1, k) {
+ sDictSetTiny(&(self->top), k, sArrayGetTiny(array2->topA, (uint32_t)count));
count++;
if (count == len) {
break;
@@ -20068,7 +20813,7 @@ internal baset* iterStartSmallJson(smallJsont *self) {
// get first element
range(i, self->top->count)
if ((&((self->top)->elements) + i)->key) {
- self->iterIndex = i;
+ self->iterIndex = (ssize_t)i;
break;
}
if (self->iterElementDataType != SH_DT_BASET) {
@@ -20089,8 +20834,8 @@ internal baset* iterStartSmallJson(smallJsont *self) {
// get first element
// find first non NULL element, deleted element can be at index 0
range(i, self->topA->count)
- if (sArrayGetTiny(self->topA, i)) {
- self->iterIndex = i;
+ if (sArrayGetTiny(self->topA, (uint32_t)i)) {
+ self->iterIndex = (ssize_t)i;
break;
}
self->iterStep = 1;
@@ -20099,7 +20844,7 @@ internal baset* iterStartSmallJson(smallJsont *self) {
finishO(self->iterElement);
}
// TODO find first non NULL element, deleted element can be at index 0
- o = sArrayGetTiny(self->topA, self->iterIndex);
+ o = sArrayGetTiny(self->topA, (uint32_t)self->iterIndex);
if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
self->iterElementDataType = SH_DT_BASET;
}
@@ -20108,6 +20853,8 @@ internal baset* iterStartSmallJson(smallJsont *self) {
}
self->iterElement = toBaset(o);
break;
+ default:;
+ // return NULL (self->iterElement is NULL)
}
return(self->iterElement);
}
@@ -20128,7 +20875,7 @@ internal const char* iterStartKeySmallJson(smallJsont *self) {
// get first element
range(i, self->top->count)
if ((&((self->top)->elements) + i)->key) {
- self->iterIndex = i;
+ self->iterIndex = (ssize_t)i;
break;
}
if (self->iterElementDataType != SH_DT_BASET) {
@@ -20164,7 +20911,7 @@ internal baset* iterStartLastSmallJson(smallJsont *self) {
// get first element
// find first non NULL element, deleted element can be at index 0
rangeDown(i, self->topA->count)
- if (sArrayGetTiny(self->topA, i)) {
+ if (sArrayGetTiny(self->topA, (uint32_t)i)) {
self->iterIndex = i;
break;
}
@@ -20173,7 +20920,7 @@ internal baset* iterStartLastSmallJson(smallJsont *self) {
// free already created base object
finishO(self->iterElement);
}
- smallt *o = sArrayGetTiny(self->topA, self->iterIndex);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)self->iterIndex);
if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
self->iterElementDataType = SH_DT_BASET;
}
@@ -20204,14 +20951,14 @@ internal baset* iterStartFromSmallJson(smallJsont *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
// get first element
// find first non NULL element, deleted element can be at index 0
- rangeFrom(i, index, self->topA->count)
- if (sArrayGetTiny(self->topA, i)) {
- self->iterIndex = i;
+ rangeFrom(i, (size_t)index, self->topA->count)
+ if (sArrayGetTiny(self->topA, (uint32_t)i)) {
+ self->iterIndex = (ssize_t)i;
break;
}
if (self->iterIndex == -1) {
@@ -20223,7 +20970,7 @@ internal baset* iterStartFromSmallJson(smallJsont *self, int64_t index) {
// free already created base object
finishO(self->iterElement);
}
- smallt *o = sArrayGetTiny(self->topA, self->iterIndex);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t) self->iterIndex);
if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
self->iterElementDataType = SH_DT_BASET;
}
@@ -20259,14 +21006,14 @@ internal baset* iterStartFromStepSmallJson(smallJsont *self, int64_t index, int6
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
// get first element
// find first non NULL element, deleted element can be at index 0
- rangeFromStep(i, index, self->topA->count, step)
- if (sArrayGetTiny(self->topA, i)) {
- self->iterIndex = i;
+ rangeFromStep(i, (size_t)index, self->topA->count, step)
+ if (sArrayGetTiny(self->topA, (uint32_t)i)) {
+ self->iterIndex = (ssize_t)i;
break;
}
if (self->iterIndex == -1) {
@@ -20278,7 +21025,7 @@ internal baset* iterStartFromStepSmallJson(smallJsont *self, int64_t index, int6
// free already created base object
finishO(self->iterElement);
}
- smallt *o = sArrayGetTiny(self->topA, self->iterIndex);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)self->iterIndex);
if ((o->type == CONTAINER) && (((sContainert*)o)->dataType == SH_DT_BASET)) {
self->iterElementDataType = SH_DT_BASET;
}
@@ -20297,16 +21044,16 @@ internal baset* iterNextSmallJson(smallJsont *self) {
}
switch(self->topIsA) {
- case TOP_IS_DICT:
+ case TOP_IS_DICT: {
// get next element
self->iterIndex++;
// free already created base object
if (self->iterElementDataType != SH_DT_BASET) {
finishO(self->iterElement);
}
- rangeFrom(i, self->iterIndex, self->top->count) {
+ rangeFrom(i, (size_t)self->iterIndex, self->top->count) {
if ((&((self->top)->elements) + i)->key) {
- self->iterIndex = i;
+ self->iterIndex = (ssize_t)i;
break;
}
if (!(&((self->top)->elements) + i)->key && (i == (self->top->count -1))) {
@@ -20328,8 +21075,9 @@ internal baset* iterNextSmallJson(smallJsont *self) {
self->iterElementDataType = SH_DT_UNKNOWN;
}
self->iterElement = toBaset(o);
+ }
break;
- case TOP_IS_ARRAY:
+ case TOP_IS_ARRAY: {
// free already created base object
if (self->iterElementDataType != SH_DT_BASET) {
finishO(self->iterElement);
@@ -20341,12 +21089,12 @@ internal baset* iterNextSmallJson(smallJsont *self) {
while (!self->iterElement) {
// get next element
self->iterIndex += self->iterStep;
- if ((self->iterIndex >= (ssize_t)lenSmallJson(self) || self->iterIndex < 0)) {
+ if ((self->iterIndex >= (int64_t)lenSmallJson(self) || self->iterIndex < 0)) {
// the index is outside the array, the iteration is finished
self->iterIndex = -1;
return(NULL);
}
- smallt *o = sArrayGetTiny(self->topA, self->iterIndex);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)self->iterIndex);
if (!o) {
continue;
}
@@ -20358,7 +21106,11 @@ internal baset* iterNextSmallJson(smallJsont *self) {
}
self->iterElement = toBaset(o);
}
+ }
break;
+ default:
+ logC("Check iterator!");
+ return(NULL);
}
return(self->iterElement);
}
@@ -20379,9 +21131,9 @@ internal const char* iterNextKeySmallJson(smallJsont *self) {
if (self->iterElementDataType != SH_DT_BASET) {
finishO(self->iterElement);
}
- rangeFrom(i, self->iterIndex, self->top->count) {
+ rangeFrom(i, (size_t)self->iterIndex, self->top->count) {
if ((&((self->top)->elements) + i)->key) {
- self->iterIndex = i;
+ self->iterIndex = (ssize_t)i;
break;
}
if (!(&((self->top)->elements) + i)->key && (i == (self->top->count -1))) {
@@ -21105,10 +21857,10 @@ baset* getAtSmallJson(smallJsont *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);;
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);;
if (!o) {
return(NULL);
}
@@ -21130,10 +21882,10 @@ internal undefinedt* getAtUndefinedSmallJson(smallJsont *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);;
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);;
if (!o) {
return(NULL);
}
@@ -21312,10 +22064,10 @@ internal smallDictt* getAtDictSmallJson(smallJsont *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);;
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);;
if (!o) {
return(NULL);
}
@@ -21338,10 +22090,10 @@ internal smallArrayt* getAtArraySmallJson(smallJsont *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);;
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);;
if (!o) {
return(NULL);
}
@@ -21364,10 +22116,10 @@ internal smallBoolt* getAtSmallBoolSmallJson(smallJsont *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);;
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);;
if (!o) {
return(NULL);
}
@@ -21390,10 +22142,10 @@ internal smallBytest* getAtSmallBytesSmallJson(smallJsont *self, int64_t index)
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);;
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);;
if (!o) {
return(NULL);
}
@@ -21416,10 +22168,10 @@ internal smallDoublet* getAtSmallDoubleSmallJson(smallJsont *self, int64_t index
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);;
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);;
if (!o) {
return(NULL);
}
@@ -21442,10 +22194,10 @@ internal smallIntt* getAtSmallIntSmallJson(smallJsont *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);;
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);;
if (!o) {
return(NULL);
}
@@ -21468,10 +22220,10 @@ internal smallJsont* getAtSmallJsonSmallJson(smallJsont *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);;
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);;
if (!o) {
return(NULL);
}
@@ -21502,10 +22254,10 @@ internal smallStringt* getAtSmallStringSmallJson(smallJsont *self, int64_t index
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);;
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);;
if (!o) {
return(NULL);
}
@@ -21540,10 +22292,10 @@ internal smallContainert* getAtSmallContainerSmallJson(smallJsont *self, int64_t
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);;
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);;
if (!o) {
return(NULL);
}
@@ -21569,10 +22321,10 @@ baset* getAtNDupSmallJson(smallJsont *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -21601,10 +22353,10 @@ internal undefinedt* getAtNDupUndefinedSmallJson(smallJsont *self, int64_t index
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -21711,10 +22463,10 @@ internal smallDictt* getAtNDupDictSmallJson(smallJsont *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -21737,10 +22489,10 @@ internal smallArrayt* getAtNDupArraySmallJson(smallJsont *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -21763,10 +22515,10 @@ internal smallBoolt* getAtNDupSmallBoolSmallJson(smallJsont *self, int64_t index
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -21789,10 +22541,10 @@ internal smallBytest* getAtNDupSmallBytesSmallJson(smallJsont *self, int64_t ind
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -21815,10 +22567,10 @@ internal smallDoublet* getAtNDupSmallDoubleSmallJson(smallJsont *self, int64_t i
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -21841,10 +22593,10 @@ internal smallIntt* getAtNDupSmallIntSmallJson(smallJsont *self, int64_t index)
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -21867,10 +22619,10 @@ internal smallJsont* getAtNDupSmallJsonSmallJson(smallJsont *self, int64_t index
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -21902,10 +22654,10 @@ internal smallStringt* getAtNDupSmallStringSmallJson(smallJsont *self, int64_t i
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -21940,10 +22692,10 @@ internal smallContainert* getAtNDupSmallContainerSmallJson(smallJsont *self, int
return(NULL);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *o = sArrayGetTiny(self->topA, index);
+ smallt *o = sArrayGetTiny(self->topA, (uint32_t)index);
if (!o) {
return(NULL);
}
@@ -21978,7 +22730,7 @@ internal double getNumSmallJson(smallJsont *self, const char *key) {
r = getValO((smallDoublet*)e);
}
elif (isOSmallInt(e)) {
- r = getValO((smallIntt*)e);
+ r = (double)getValO((smallIntt*)e);
}
finishO(e);
return(r);
@@ -21999,10 +22751,10 @@ internal double getNumAtSmallJson(smallJsont *self, int64_t index) {
return(0);
}
if (index < 0) {
- index = lenSmallJson(self) + index;
+ index = (int64_t)lenSmallJson(self) + index;
}
- smallt *e = sArrayGetTiny(self->topA, index);
+ smallt *e = sArrayGetTiny(self->topA, (uint32_t)index);
if (!e) {
return(0);
}
@@ -22017,7 +22769,7 @@ internal double getNumAtSmallJson(smallJsont *self, int64_t index) {
r = getValO((smallDoublet*)o);
}
elif (isOSmallInt(o)) {
- r = getValO((smallIntt*)o);
+ r = (double)getValO((smallIntt*)o);
}
finishO(o);
return(r);
@@ -22045,22 +22797,22 @@ internal smallJsont* delSmallJson(smallJsont *self, int64_t start, int64_t end)
}
if (start >= (int64_t)len) {
- start = len;
+ start = (int64_t)len;
}
if (end > (int64_t)len) {
- end = len;
+ end = (int64_t)len;
}
if (start <= -(int64_t)len) {
- start = -len;
+ start = -(int64_t)len;
}
if (end <= -(int64_t)len) {
- end = -len;
+ end = -(int64_t)len;
}
if (start < 0) {
- start = len + start;
+ start = (int64_t)len + start;
}
if (end <= 0) {
- end = len + end;
+ end = (int64_t)len + end;
}
if (end < start) {
return(NULL);
@@ -22075,14 +22827,14 @@ internal smallJsont* delSmallJson(smallJsont *self, int64_t start, int64_t end)
int64_t n;
n = end - start;
// +2 for sType at the beginning
- s = malloc(len - n +2);
+ s = malloc(len - (size_t)n +2);
if (!s) {
return(NULL);
}
// +1 for sType
- strncpy(s, (char *)self->topS, start+1);
- strncpy(s+start+1, (char *)self->topS + end +1, len - end);
- s[len - n +1] = 0;
+ strncpy(s, (char *)self->topS, (size_t)start+1);
+ strncpy(s+start+1, (char *)self->topS + end +1, len - (size_t)end);
+ s[len - (size_t)n +1] = 0;
free(self->topS);
self->topS = (sStringt *)s;
@@ -22096,22 +22848,22 @@ internal smallJsont* delSmallJson(smallJsont *self, int64_t start, int64_t end)
}
if (start >= (int64_t)len) {
- start = len;
+ start = (int64_t)len;
}
if (end > (int64_t)len) {
- end = len;
+ end = (int64_t)len;
}
if (start <= -(int64_t)len) {
- start = -len;
+ start = -(int64_t)len;
}
if (end <= -(int64_t)len) {
- end = -len;
+ end = -(int64_t)len;
}
if (start < 0) {
- start = len + start;
+ start = (int64_t)len + start;
}
if (end <= 0) {
- end = len + end;
+ end = (int64_t)len + end;
}
if (end < start) {
return(NULL);
@@ -22122,7 +22874,7 @@ internal smallJsont* delSmallJson(smallJsont *self, int64_t start, int64_t end)
}
// start < end < len
- sArrayDelRangeTiny(self->topA, start, end);
+ sArrayDelRangeTiny(self->topA, (uint32_t)start, (uint32_t)end);
return(self);
default:
return(NULL);
@@ -22145,7 +22897,7 @@ internal smallJsont* delElemIndexSmallJson(smallJsont *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = len + index;
+ index = (int64_t)len + index;
}
// copy range to a new smallString
@@ -22155,8 +22907,8 @@ internal smallJsont* delElemIndexSmallJson(smallJsont *self, int64_t index) {
return(NULL);
}
// +1 for sType
- strncpy(s, (char *)self->topS, index+1);
- strncpy(s+index+1, (char *)self->topS + index+1 +1, len - (index+1));
+ strncpy(s, (char *)self->topS, (size_t)index+1);
+ strncpy(s+index+1, (char *)self->topS + index+1 +1, len - ((size_t)index+1));
s[len - 1 +1] = 0;
free(self->topS);
@@ -22172,10 +22924,10 @@ internal smallJsont* delElemIndexSmallJson(smallJsont *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = len + index;
+ index = (int64_t)len + index;
}
- sArrayDelTiny(self->topA, index);
+ sArrayDelTiny(self->topA, (uint32_t)index);
return(self);
default:
return(NULL);
@@ -22203,22 +22955,22 @@ internal smallJsont* removeSmallJson(smallJsont *self, int64_t start, int64_t en
}
if (start >= (int64_t)len) {
- start = len;
+ start = (int64_t)len;
}
if (end > (int64_t)len) {
- end = len;
+ end = (int64_t)len;
}
if (start <= -(int64_t)len) {
- start = -len;
+ start = -(int64_t)len;
}
if (end <= -(int64_t)len) {
- end = -len;
+ end = -(int64_t)len;
}
if (start < 0) {
- start = len + start;
+ start = (int64_t)len + start;
}
if (end <= 0) {
- end = len + end;
+ end = (int64_t)len + end;
}
if (end < start) {
return(NULL);
@@ -22233,14 +22985,14 @@ internal smallJsont* removeSmallJson(smallJsont *self, int64_t start, int64_t en
int64_t n;
n = end - start;
// +2 for sType at the beginning
- s = malloc(len - n +2);
+ s = malloc(len - (size_t)n +2);
if (!s) {
return(NULL);
}
// +1 for sType
- strncpy(s, (char *)self->topS, start+1);
- strncpy(s+start+1, (char *)self->topS + end +1, len - end);
- s[len - n +1] = 0;
+ strncpy(s, (char *)self->topS, (size_t)start+1);
+ strncpy(s+start+1, (char *)self->topS + end +1, len - (size_t)end);
+ s[len - (size_t)n +1] = 0;
free(self->topS);
self->topS = (sStringt *)s;
@@ -22254,22 +23006,22 @@ internal smallJsont* removeSmallJson(smallJsont *self, int64_t start, int64_t en
}
if (start >= (int64_t)len) {
- start = len;
+ start = (int64_t)len;
}
if (end > (int64_t)len) {
- end = len;
+ end = (int64_t)len;
}
if (start <= -(int64_t)len) {
- start = -len;
+ start = -(int64_t)len;
}
if (end <= -(int64_t)len) {
- end = -len;
+ end = -(int64_t)len;
}
if (start < 0) {
- start = len + start;
+ start = (int64_t)len + start;
}
if (end <= 0) {
- end = len + end;
+ end = (int64_t)len + end;
}
if (end < start) {
return(NULL);
@@ -22280,7 +23032,7 @@ internal smallJsont* removeSmallJson(smallJsont *self, int64_t start, int64_t en
}
// start < end < len
- for (uint32_t i = start ; i < end ; i++) {
+ for (uint32_t i = (uint32_t)start ; i < end ; i++) {
sArraySetShortTiny(self->topA, i, NULL);
}
return(self);
@@ -22305,7 +23057,7 @@ internal smallJsont* removeElemIndexSmallJson(smallJsont *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = len + index;
+ index = (int64_t)len + index;
}
// copy range to a new smallString
@@ -22315,8 +23067,8 @@ internal smallJsont* removeElemIndexSmallJson(smallJsont *self, int64_t index) {
return(NULL);
}
// +1 for sType
- strncpy(s, (char *)self->topS, index+1);
- strncpy(s+index+1, (char *)self->topS + index+1 +1, len - (index+1));
+ strncpy(s, (char *)self->topS, (size_t)index+1);
+ strncpy(s+index+1, (char *)self->topS + index+1 +1, len - ((size_t)index+1));
s[len - 1 +1] = 0;
free(self->topS);
@@ -22332,10 +23084,10 @@ internal smallJsont* removeElemIndexSmallJson(smallJsont *self, int64_t index) {
return(NULL);
}
if (index < 0) {
- index = len + index;
+ index = (int64_t)len + index;
}
- sArraySetShortTiny(self->topA, index, NULL);
+ sArraySetShortTiny(self->topA, (uint32_t)index, NULL);
return(self);
default:
return(NULL);
@@ -22354,57 +23106,57 @@ internal char** sDictStringifyForeach(sDictElemt *e, char *indentS2, int indent,
if (isSType(obj, STRING) || isSType(obj, CONTAINER)) {
// add quotes for strings
- iAppendS(&line, ": \"");
+ pErrorNULL(iAppendS(&line, ": \""));
char *s;
s = sToStringTiny(obj);
if (hasS(s, "\\") || hasS(s, "\"")) {
char *q = replaceS_max(s, "\\", "\\\\");
- iReplaceS_max(&q, "\"", "\\\"");
- iAppendS(&line, q);
+ pErrorNULL(iReplaceS_max(&q, "\"", "\\\""));
+ pErrorNULL(iAppendS(&line, q));
free(q);
}
else {
- iAppendS(&line, s);
+ pErrorNULL(iAppendS(&line, s));
}
free(s);
- iAppendS(&line, "\",\n");
- iListPushS(&r, line);
+ pErrorNULL(iAppendS(&line, "\",\n"));
+ pErrorNULL(iListPushS(&r, line));
}
if (!isSType(obj, STRING) && !isSType(obj, CONTAINER) && !isSType(obj, DICT) && !isSType(obj, ARRAY)) {
- iAppendS(&line, ": ");
+ pErrorNULL(iAppendS(&line, ": "));
char *s;
s = sToStringTiny(obj);
- iAppendS(&line, s);
+ pErrorNULL(iAppendS(&line, s));
free(s);
- iAppendS(&line, ",\n");
- iListPushS(&r, line);
+ pErrorNULL(iAppendS(&line, ",\n"));
+ pErrorNULL(iListPushS(&r, line));
}
if (isSType(obj, DICT)) {
- iAppendS(&line, ": ");
- iListPushS(&r, line);
+ pErrorNULL(iAppendS(&line, ": "));
+ pErrorNULL(iListPushS(&r, line));
char **nextLevel = sDictStringify((sDictt *)obj, indent, level+1); {
- iListAppendS(&r, nextLevel);
+ pErrorNULL(iListAppendS(&r, nextLevel));
size_t len = listLengthS(r);;
- setS(r[len-1], -1, ',');
- iAppendS(&(r[len-1]), "\n");
+ pErrorNULL(setS(r[len-1], -1, ','));
+ pErrorNULL(iAppendS(&(r[len-1]), "\n"));
free(nextLevel);
}
}
if (isSType(obj, ARRAY)) {
- iAppendS(&line, ": ");
- iListPushS(&r, line);
+ pErrorNULL(iAppendS(&line, ": "));
+ pErrorNULL(iListPushS(&r, line));
char **nextLevel = sArrayStringify((sArrayt *)obj, indent, level+1); {
- iListAppendS(&r, nextLevel);
+ pErrorNULL(iListAppendS(&r, nextLevel));
size_t len = listLengthS(r);;
- setS(r[len-1], -1, ',');
- iAppendS(&(r[len-1]), "\n");
+ pErrorNULL(setS(r[len-1], -1, ','));
+ pErrorNULL(iAppendS(&(r[len-1]), "\n"));
free(nextLevel);
}
}
@@ -22417,7 +23169,7 @@ internal char** sDictStringify(sDictt *dict, int indent, int level) {
char indentS2[800];
if (!dict || !dict->count) {
- listPushS(&r, "{}\n");
+ pErrorNULL(listPushS(&r, "{}\n"));
return(r);
}
@@ -22432,11 +23184,11 @@ internal char** sDictStringify(sDictt *dict, int indent, int level) {
}
indentS2[c+c2] = 0;
- listPushS(&r, "{\n");
+ pErrorNULL(listPushS(&r, "{\n"));
forEachSDict(dict, e) {
if (e->key) {
char **list = sDictStringifyForeach(e, indentS2, indent, level); {
- iListAppendS(&r, list);
+ pErrorNULL(iListAppendS(&r, list));
free(list);
}
}
@@ -22446,9 +23198,9 @@ internal char** sDictStringify(sDictt *dict, int indent, int level) {
// "hash": "hello, Im string",
size_t len;
len = listLengthS(r);
- iDelS(&(r[len-1]), -2, -1);
+ pErrorNULL(iDelS(&(r[len-1]), -2, -1));
- iListPushS(&r, catS(indentS, "}\n"));
+ pErrorNULL(iListPushS(&r, catS(indentS, "}\n")));
return(r);
}
@@ -22460,7 +23212,7 @@ internal char** sArrayStringify(sArrayt *array, int indent, int level) {
char indentS2[800];
if (!array || !array->count) {
- listPushS(&r, "[]\n");
+ pErrorNULL(listPushS(&r, "[]\n"));
return(r);
}
@@ -22475,7 +23227,7 @@ internal char** sArrayStringify(sArrayt *array, int indent, int level) {
}
indentS2[c+c2] = 0;
- listPushS(&r, "[\n");
+ pErrorNULL(listPushS(&r, "[\n"));
forEachSArray(array, o) {
if (!o) {
// empty slot
@@ -22489,7 +23241,7 @@ internal char** sArrayStringify(sArrayt *array, int indent, int level) {
s = sToStringTiny(o);
if (hasS(s, "\\") || hasS(s, "\"")) {
char *q = replaceS_max(s, "\\", "\\\\");
- iReplaceS_max(&q, "\"", "\\\"");
+ pErrorNULL(iReplaceS_max(&q, "\"", "\\\""));
line = catS(indentS2, "\"", q, "\"");;
free(q);
}
@@ -22497,8 +23249,8 @@ internal char** sArrayStringify(sArrayt *array, int indent, int level) {
line = catS(indentS2, "\"", s, "\"");;
}
free(s);
- iAppendS(&line, ",\n");
- iListPushS(&r, line);
+ pErrorNULL(iAppendS(&line, ",\n"));
+ pErrorNULL(iListPushS(&r, line));
}
if (!isSType(o, STRING) && !isSType(o, CONTAINER) && !isSType(o, DICT) && !isSType(o, ARRAY)) {
@@ -22507,8 +23259,8 @@ internal char** sArrayStringify(sArrayt *array, int indent, int level) {
s = sToStringTiny(o);
line = catS(indentS2, s);;
free(s);
- iAppendS(&line, ",\n");
- iListPushS(&r, line);
+ pErrorNULL(iAppendS(&line, ",\n"));
+ pErrorNULL(iListPushS(&r, line));
}
if (isSType(o, DICT)) {
@@ -22516,13 +23268,13 @@ internal char** sArrayStringify(sArrayt *array, int indent, int level) {
// shift {
char *line = catS(indentS2, nextLevel[0]);
- iListSetS(nextLevel, 0, line);
+ pErrorNULL(iListSetS(nextLevel, 0, line));
// add ,
size_t nextLevelLen = listLengthS(nextLevel);
- setS(nextLevel[nextLevelLen-1], -1, ',');
- iAppendS(&(nextLevel[nextLevelLen-1]), "\n");
- iListAppendS(&r, nextLevel);
+ pErrorNULL(setS(nextLevel[nextLevelLen-1], -1, ','));
+ pErrorNULL(iAppendS(&(nextLevel[nextLevelLen-1]), "\n"));
+ pErrorNULL(iListAppendS(&r, nextLevel));
free(nextLevel);
}
}
@@ -22532,13 +23284,13 @@ internal char** sArrayStringify(sArrayt *array, int indent, int level) {
// shift [
char *line = catS(indentS2, nextLevel[0]);
- iListSetS(nextLevel, 0, line);
+ pErrorNULL(iListSetS(nextLevel, 0, line));
// add ,
size_t nextLevelLen = listLengthS(nextLevel);
- setS(nextLevel[nextLevelLen-1], -1, ',');
- iAppendS(&(nextLevel[nextLevelLen-1]), "\n");
- iListAppendS(&r, nextLevel);
+ pErrorNULL(setS(nextLevel[nextLevelLen-1], -1, ','));
+ pErrorNULL(iAppendS(&(nextLevel[nextLevelLen-1]), "\n"));
+ pErrorNULL(iListAppendS(&r, nextLevel));
free(nextLevel);
}
}
@@ -22547,9 +23299,9 @@ internal char** sArrayStringify(sArrayt *array, int indent, int level) {
// remove the comma on the line before ]
// "hash": "hello, Im string",
len = listLengthS(r);
- iDelS(&(r[len-1]), -2, -1);
+ pErrorNULL(iDelS(&(r[len-1]), -2, -1));
- iListPushS(&r, catS(indentS, "]\n"));
+ pErrorNULL(iListPushS(&r, catS(indentS, "]\n")));
return(r);
}
@@ -22582,6 +23334,10 @@ internal char* stringifySmallJson(smallJsont *self, int indent) {
list = sArrayStringify(self->topA, indent, 0); {
break;
}
+ default:
+ // not reachable
+ logC("Check this function!");
+ return(NULL);
}
r = join(list, "");
@@ -22617,48 +23373,48 @@ internal char** sDictToYMLForeach(sDictElemt *e, char *indentS2, int indent, int
s = sToStringTiny(obj);
// quote string if there are special characters
if (hasS(s, ":") || hasS(s, "{") || hasS(s, "}") || hasS(s, "[") || hasS(s, "]") || hasS(s, ",") || hasS(s, "&") || hasS(s, "*") || hasS(s, "#") || hasS(s, "?") || hasS(s, "|") || hasS(s, "-") || hasS(s, "<") || hasS(s, ">") || hasS(s, "==") || hasS(s, "!") || hasS(s, "%") || hasS(s, "@") || hasS(s, "\\") || hasS(s, "\"") || isBlankS(s) || isNumber(s)) {
- iAppendS(&line, ": \"");
+ pErrorNULL(iAppendS(&line, ": \""));
char *q = replaceS_max(s, "\\", "\\\\");
- iReplaceS_max(&q, "\"", "\\\"");
- iAppendNFreeS(&line, q);
+ pErrorNULL(iReplaceS_max(&q, "\"", "\\\""));
+ pErrorNULL(iAppendNFreeS(&line, q));
free(s);
- iAppendS(&line, "\"\n");
+ pErrorNULL(iAppendS(&line, "\"\n"));
}
else {
- iAppendS(&line, ": ");
- iAppendNFreeS(&line, s);
- iAppendS(&line, "\n");
+ pErrorNULL(iAppendS(&line, ": "));
+ pErrorNULL(iAppendNFreeS(&line, s));
+ pErrorNULL(iAppendS(&line, "\n"));
}
- iListPushS(&r, line);
+ pErrorNULL(iListPushS(&r, line));
}
if (!isSType(obj, STRING) && !isSType(obj, CONTAINER) && !isSType(obj, DICT) && !isSType(obj, ARRAY)) {
- iAppendS(&line, ": ");
+ pErrorNULL(iAppendS(&line, ": "));
char *s;
s = sToStringTiny(obj);
- iAppendS(&line, s);
+ pErrorNULL(iAppendS(&line, s));
free(s);
- iAppendS(&line, "\n");
- iListPushS(&r, line);
+ pErrorNULL(iAppendS(&line, "\n"));
+ pErrorNULL(iListPushS(&r, line));
}
if (isSType(obj, DICT)) {
- iAppendS(&line, ":\n");
- iListPushS(&r, line);
+ pErrorNULL(iAppendS(&line, ":\n"));
+ pErrorNULL(iListPushS(&r, line));
char **nextLevel = sDictToYML((sDictt *)obj, indent, level+1);
- iListAppendS(&r, nextLevel);
+ pErrorNULL(iListAppendS(&r, nextLevel));
free(nextLevel);
}
if (isSType(obj, ARRAY)) {
- iAppendS(&line, ":\n");
- iListPushS(&r, line);
+ pErrorNULL(iAppendS(&line, ":\n"));
+ pErrorNULL(iListPushS(&r, line));
char **nextLevel = sArrayToYML((sArrayt *)obj, indent, level+1);
- iListAppendS(&r, nextLevel);
+ pErrorNULL(iListAppendS(&r, nextLevel));
free(nextLevel);
}
@@ -22680,14 +23436,14 @@ internal char **sDictToYML(sDictt* dict, int indent, int level) {
indentS2[c+c2] = 0;
if (!dict || !dict->count) {
- iListPushS(&r, catS(indentS2, "{}\n"));
+ pErrorNULL(iListPushS(&r, catS(indentS2, "{}\n")));
return(r);
}
forEachSDict(dict, e) {
if (e->key) {
char **list = sDictToYMLForeach(e, indentS2, indent, level);
- iListAppendS(&r, list);
+ pErrorNULL(iListAppendS(&r, list));
free(list);
}
}
@@ -22710,7 +23466,7 @@ internal char **sArrayToYML(sArrayt* array, int indent, int level) {
indentS2[c+c2] = 0;
if (!array || !array->count) {
- iListPushS(&r, catS(indentS2, "[]\n"));
+ pErrorNULL(iListPushS(&r, catS(indentS2, "[]\n")));
return(r);
}
@@ -22727,7 +23483,7 @@ internal char **sArrayToYML(sArrayt* array, int indent, int level) {
// quote string if there are special characters
if (hasS(s, ":") || hasS(s, "{") || hasS(s, "}") || hasS(s, "[") || hasS(s, "]") || hasS(s, ",") || hasS(s, "&") || hasS(s, "*") || hasS(s, "#") || hasS(s, "?") || hasS(s, "|") || hasS(s, "-") || hasS(s, "<") || hasS(s, ">") || hasS(s, "==") || hasS(s, "!") || hasS(s, "%") || hasS(s, "@") || hasS(s, "\\") || hasS(s, "\"") || isBlankS(s) || isNumber(s)) {
char *q = replaceS_max(s, "\\", "\\\\");
- iReplaceS_max(&q, "\"", "\\\"");
+ pErrorNULL(iReplaceS_max(&q, "\"", "\\\""));
line = catS(indentS2, "- \"", q, "\"\n");;
free(q);
}
@@ -22735,7 +23491,7 @@ internal char **sArrayToYML(sArrayt* array, int indent, int level) {
line = catS(indentS2, "- ", s, "\n");;
}
free(s);
- iListPushS(&r, line);
+ pErrorNULL(iListPushS(&r, line));
}
if (!isSType(o, STRING) && !isSType(o, CONTAINER) && !isSType(o, DICT) && !isSType(o, ARRAY)) {
@@ -22744,7 +23500,7 @@ internal char **sArrayToYML(sArrayt* array, int indent, int level) {
s = sToStringTiny(o);
line = catS(indentS2, "- ", s, "\n");;
free(s);
- iListPushS(&r, line);
+ pErrorNULL(iListPushS(&r, line));
}
if (isSType(o, DICT)) {
@@ -22752,9 +23508,9 @@ internal char **sArrayToYML(sArrayt* array, int indent, int level) {
// detect when array is empty, add '-'
//if !tommy_hashlin_count(&(obj->h))
- setS(nextLevel[0], c+c2, '-');
+ pErrorNULL(setS(nextLevel[0], (int64_t)(c+c2), '-'));
- iListAppendS(&r, nextLevel);
+ pErrorNULL(iListAppendS(&r, nextLevel));
free(nextLevel);
}
@@ -22763,9 +23519,9 @@ internal char **sArrayToYML(sArrayt* array, int indent, int level) {
// detect when array is empty, add '-'
//if !tommy_arrayblk_size(obj->arr)
- setS(nextLevel[0], c+c2, '-');
+ pErrorNULL(setS(nextLevel[0], (int64_t)(c+c2), '-'));
- iListAppendS(&r, nextLevel);
+ pErrorNULL(iListAppendS(&r, nextLevel));
free(nextLevel);
}
}
@@ -22803,8 +23559,8 @@ internal char* toYMLSmallJson(smallJsont *self, int indent) {
return(r);
case TOP_IS_STRING:
s = sToString((smallt *)self->topS);
- iReplaceS_max(&s, "\\", "\\\\");
- iReplaceS_max(&s, "\"", "\\\"");
+ pErrorNULL(iReplaceS_max(&s, "\\", "\\\\"));
+ pErrorNULL(iReplaceS_max(&s, "\"", "\\\""));
r = catS("---\n \"", s, "\"");
free(s);
return(r);
@@ -22814,8 +23570,12 @@ internal char* toYMLSmallJson(smallJsont *self, int indent) {
case TOP_IS_ARRAY:
list = sArrayToYML(self->topA, indent, 0);
break;
+ default:
+ // not reachable
+ logC("Check this function!");
+ return(NULL);
}
- listPrependS(&list, "---\n");
+ pErrorNULL(listPrependS(&list, "---\n"));
r = join(list, "");
listFreeS(list);
@@ -22832,7 +23592,7 @@ internal smallStringt* toYMLSmallStringSmallJson(smallJsont *self, int indent) {
// smallJson parsing functions
-internal bool parseSmallJson(smallJsont *self, char *input) {
+internal bool parseSmallJson(smallJsont *self, const char *input) {
if (isBlankS(input)) {
return(false);
@@ -22860,7 +23620,7 @@ internal bool parseSmallJson(smallJsont *self, char *input) {
context->begin = on_begin;
context->end = on_end;
- int err = lax_json_feed(context, jsLen, input);
+ int err = lax_json_feed(context, (int32_t)jsLen, input);
if (err) {
eprintf("Line %d, column %d: %s\n", context->line, context->column, lax_json_str_err(err));
lax_json_destroy(context);
@@ -22962,13 +23722,13 @@ internal void addObject(smallJsont *self, smallt *obj) {
//print 'addObject top count %d', self->top->count
//print 'addObject stack count %d props %s', self->stack->count, sToStringTiny((smallt *)self->parseP)
//print 'addObject stack types %s', sTypesTiny((smallt *)self->stack)
- if (isSType(sArrayGetTiny(self->stack, self->istack), DICT)) {
+ if (isSType(sArrayGetTiny(self->stack, (uint32_t)self->istack), DICT)) {
//print 'addObject to dict'
- sDictt *parseD = (sDictt *) sArrayGetTiny(self->stack, self->istack);
+ sDictt *parseD = (sDictt *) sArrayGetTiny(self->stack, (uint32_t)self->istack);
//print 'add key: iProp %d istack %d %s - %s', self->iProp, self->istack, sStringGetTiny((sStringt *) sArrayGetTiny(self->parseP, self->iProp)), sToStringTiny(obj)
smallt *s = sArrayPopTiny(self->parseP);
sDictPushTiny(&parseD, sStringGetTiny((sStringt *) s), obj);
- sArraySetShortTiny(self->stack, self->istack, (smallt *) parseD);
+ sArraySetShortTiny(self->stack, (uint32_t)self->istack, (smallt *) parseD);
self->iProp--;
free(s);
if (self->istack == 0) {
@@ -22976,12 +23736,12 @@ internal void addObject(smallJsont *self, smallt *obj) {
self->top = parseD;
}
}
- else if (isSType(sArrayGetTiny(self->stack, self->istack), ARRAY)) {
+ else if (isSType(sArrayGetTiny(self->stack, (uint32_t)self->istack), ARRAY)) {
//print 'addObject to array'
- sArrayt *parseA = (sArrayt *) sArrayGetTiny(self->stack, self->istack);
+ sArrayt *parseA = (sArrayt *) sArrayGetTiny(self->stack, (uint32_t)self->istack);
//print 'addObject element %s', sToStringTiny(obj)
sArrayPushTiny(&parseA, obj);
- sArraySetShortTiny(self->stack, self->istack, (smallt *) parseA);
+ sArraySetShortTiny(self->stack, (uint32_t)self->istack, (smallt *) parseA);
if (self->istack == 0) {
// update top dict pointer in object
self->topA = parseA;
@@ -23148,13 +23908,13 @@ internal int on_end(struct LaxJsonContext *context, enum LaxJsonType type UNUSED
//print 'on_end top count %d', self->top->count
//print 'on_end stack types %s', sTypesTiny((smallt *)self->stack)
if (self->istack) {
- if (isSType(sArrayGetTiny(self->stack, self->istack-1), DICT)) {
+ if (isSType(sArrayGetTiny(self->stack, (uint32_t)self->istack-1), DICT)) {
//print 'on_end to dict'
- sDictt *parseD = (sDictt *) sArrayGetTiny(self->stack, self->istack -1);
+ sDictt *parseD = (sDictt *) sArrayGetTiny(self->stack, (uint32_t)self->istack -1);
smallt *s = sArrayPopTiny(self->parseP);
smallt *v = sArrayPopTiny(self->stack);
sDictPushTiny(&parseD, sStringGetTiny((sStringt *) s), v);
- sArraySetShortTiny(self->stack, self->istack-1, (smallt *) parseD);
+ sArraySetShortTiny(self->stack, (uint32_t)self->istack-1, (smallt *) parseD);
self->iProp--;
free(s);
if (self->istack == 1) {
@@ -23162,11 +23922,11 @@ internal int on_end(struct LaxJsonContext *context, enum LaxJsonType type UNUSED
self->top = parseD;
}
}
- else if (isSType(sArrayGetTiny(self->stack, self->istack - 1), ARRAY)) {
+ else if (isSType(sArrayGetTiny(self->stack, (uint32_t)self->istack - 1), ARRAY)) {
//print 'on_end to array'
- sArrayt *parseA = (sArrayt *) sArrayGetTiny(self->stack, self->istack -1);
+ sArrayt *parseA = (sArrayt *) sArrayGetTiny(self->stack, (uint32_t)self->istack -1);
sArrayPushTiny(&parseA, sArrayPopTiny(self->stack));
- sArraySetShortTiny(self->stack, self->istack-1, (smallt *) parseA);
+ sArraySetShortTiny(self->stack, (uint32_t)self->istack-1, (smallt *) parseA);
if (self->istack == 1) {
// update top dict pointer in object
self->topA = parseA;
@@ -23184,7 +23944,7 @@ internal int on_end(struct LaxJsonContext *context, enum LaxJsonType type UNUSED
// yml parsing functions
-internal bool parseYMLSmallJson(smallJsont *self, char *input) {
+internal bool parseYMLSmallJson(smallJsont *self, const char *input) {
yaml_parser_t parser;
yaml_event_t event;
@@ -23193,7 +23953,7 @@ internal bool parseYMLSmallJson(smallJsont *self, char *input) {
self->parseP = NULL;
self->iProp = -1;;
self->propertyOrValue = NULL;
- listPush(&(self->propertyOrValue), (void*)1);
+ pErrorNULL(listPush(&(self->propertyOrValue), (void*)1));
sFree((smallt *)self->top);
sFree((smallt *)self->topA);
@@ -23259,7 +24019,7 @@ internal bool parseYMLSmallJson(smallJsont *self, char *input) {
if (self->istack > -1) {
// an array or dict has to be on the stack before this event (invalid yml when this condition is false)
//printf("Got scalar (value %s)\n", event.data.scalar.value);
- if (isSType(sArrayGetTiny(self->stack, self->istack), ARRAY)) {
+ if (isSType(sArrayGetTiny(self->stack, (uint32_t)self->istack), ARRAY)) {
//on_stringY(event.data.scalar.value, LaxJsonTypeString);
pushTypeY(self, (char *)event.data.scalar.value);
}
@@ -23276,6 +24036,8 @@ internal bool parseYMLSmallJson(smallJsont *self, char *input) {
}
break;
+ default:;
+ // do nothing
}
if (event.type != YAML_STREAM_END_EVENT) {
yaml_event_delete(&event);
@@ -23361,7 +24123,7 @@ internal int on_stringY(smallJsont *self, const char *value, enum LaxJsonType ty
internal int on_beginYDict(smallJsont *self) {
self->istack++;
- listPush(&(self->propertyOrValue), (void*)1);
+ pErrorNULL(listPush(&(self->propertyOrValue), (void*)1));
if (self->istack == 0) {
self->topIsA = TOP_IS_DICT;
@@ -23380,7 +24142,7 @@ internal int on_beginYDict(smallJsont *self) {
internal int on_beginYArray(smallJsont *self) {
self->istack++;
- listPush(&(self->propertyOrValue), (void*)1);
+ pErrorNULL(listPush(&(self->propertyOrValue), (void*)1));
if (self->istack == 0) {
self->topIsA = TOP_IS_ARRAY;
@@ -23399,12 +24161,12 @@ internal int on_beginYArray(smallJsont *self) {
internal int on_endY(smallJsont *self) {
if (self->istack) {
- if (isSType(sArrayGetTiny(self->stack, self->istack-1), DICT)) {
- sDictt *parseD = (sDictt *) sArrayGetTiny(self->stack, self->istack -1);
+ if (isSType(sArrayGetTiny(self->stack, (uint32_t)self->istack-1), DICT)) {
+ sDictt *parseD = (sDictt *) sArrayGetTiny(self->stack, (uint32_t)self->istack -1);
smallt *s = sArrayPopTiny(self->parseP);
smallt *v = sArrayPopTiny(self->stack);
sDictPushTiny(&parseD, sStringGetTiny((sStringt *) s), v);
- sArraySetShortTiny(self->stack, self->istack-1, (smallt *) parseD);
+ sArraySetShortTiny(self->stack, (uint32_t)self->istack-1, (smallt *) parseD);
self->iProp--;
free(s);
if (self->istack == 1) {
@@ -23412,10 +24174,10 @@ internal int on_endY(smallJsont *self) {
self->top = parseD;
}
}
- if (isSType(sArrayGetTiny(self->stack, self->istack - 1), ARRAY)) {
- sArrayt *parseA = (sArrayt *) sArrayGetTiny(self->stack, self->istack -1);
+ if (isSType(sArrayGetTiny(self->stack, (uint32_t)self->istack - 1), ARRAY)) {
+ sArrayt *parseA = (sArrayt *) sArrayGetTiny(self->stack, (uint32_t)self->istack -1);
sArrayPushTiny(&parseA, sArrayPopTiny(self->stack));
- sArraySetShortTiny(self->stack, self->istack-1, (smallt *) parseA);
+ sArraySetShortTiny(self->stack, (uint32_t)self->istack-1, (smallt *) parseA);
if (self->istack == 1) {
// update top dict pointer in object
self->topA = parseA;
@@ -23542,9 +24304,13 @@ internal smallBytest* serialSmallJson(smallJsont *self) {
case TOP_IS_ARRAY:
o = (smallt *)self->topA;
break;
+ default:
+ // not reachable
+ logC("Check this function");
+ return(NULL);
}
- sBytest *B = sSerial(o);;
+ sBytest *B = sSerial(o);
if (!B) {
return(NULL);
@@ -23565,7 +24331,7 @@ internal smallJsont* deserialSmallJson(smallJsont *self, smallBytest *data) {
return(self);
}
- smallt *o = sDeserial(data->B);;
+ smallt *o = sDeserial(data->B);
if (!o) {
return(self);
@@ -23627,7 +24393,7 @@ internal smallJsont* readFileSmallJson(smallJsont *self, const char *filePath) {
if (!tmp) {
return(NULL);
}
- iLowerS(&tmp);
+ pErrorNULL(iLowerS(&tmp));
if (endsWithS(tmp, ".json")) {
s = readFileToS(filePath);;
if (!s) {
@@ -23723,7 +24489,7 @@ internal int writeFileSmallJson(smallJsont *self, const char *filePath) {
}
char *tmp = strdup(filePath);
- iLowerS(&tmp);
+ pErrorNULL(iLowerS(&tmp));
char *s = NULL;
@@ -23808,7 +24574,7 @@ internal int appendFileSmallJson(smallJsont *self, const char *filePath) {
if (!tmp) {
return(0);
}
- iLowerS(&tmp);
+ pErrorNULL(iLowerS(&tmp));
char *s = NULL;
@@ -24180,10 +24946,10 @@ internal char typeAtSmallJson(smallJsont *self, int64_t index) {
return(0);
}
if (index < 0) {
- index = len + index;
+ index = (int64_t)len + index;
}
- smallt *r = sArrayGetTiny(self->topA, index);
+ smallt *r = sArrayGetTiny(self->topA, (uint32_t)index);
if (!r) {
return(0);
}
@@ -24220,7 +24986,7 @@ internal smallJsont* typeStringsSmallJson(smallJsont *self) {
return(r);
case TOP_IS_ARRAY:
- ;char** a = sArrayTypeStrings(self->topA);
+ ;const char** a = sArrayTypeStrings(self->topA);
// the strings in a are const char*, just free the array, not the strings
if (!a) {
return(NULL);
@@ -24230,9 +24996,11 @@ internal smallJsont* typeStringsSmallJson(smallJsont *self) {
free(a);
return(NULL);
}
- setTopArraycSmallJson(ra, a);
+ setTopCArraycSmallJson(ra, a);
free(a);
return(ra);
+ default:;
+ // return NULL
}
return(NULL);
}
@@ -24548,12 +25316,14 @@ internal bool areAllETypeSmallJson(smallJsont *self, const char *type) {
}
range(i, len) {
- if (!eqS(SMALL_TYPE_NAMES[(size_t)typeAtSmallJson(self, i)], type)) {
+ if (!eqS(SMALL_TYPE_NAMES[(size_t)typeAtSmallJson(self, (int64_t)i)], type)) {
r = false;
break;
}
}
return(r);
+ default:;
+ // return false
}
return(false);
}
@@ -24669,7 +25439,7 @@ smallJsont* setTopArraycSmallJsonG (smallJsont *self, char **value) {
smallJsont* setTopCArraycSmallJsonG (smallJsont *self, const char **value) {
- return(self->f->setTopArrayc(self, (char**)value));
+ return(self->f->setTopCArrayc(self, value));
}
smallJsont* setTopSmallBoolSmallJsonG (smallJsont *self, smallBoolt *value) {
@@ -24769,7 +25539,7 @@ smallJsont* fromArraySmallJsonG (smallJsont *self, char **array, size_t size
smallJsont* fromCArraySmallJsonG (smallJsont *self, const char **array, size_t size) {
- return(self->f->fromArray(self, (char**)array, size));
+ return(self->f->fromCArray(self, array, size));
}
@@ -24931,7 +25701,7 @@ smallJsont* pushArraycSmallJsonG (smallJsont *self, char **array) {
smallJsont* pushCArraycSmallJsonG (smallJsont *self, const char **array) {
- return(self->f->pushArrayc(self,(char**)array));
+ return(self->f->pushCArrayc(self,array));
}
smallJsont* pushVoidSmallJsonG (smallJsont *self, void *value) {
@@ -25196,7 +25966,7 @@ smallJsont* setArraycSmallJsonG (smallJsont *self, const char *key, char **arr
smallJsont* setCArraycSmallJsonG (smallJsont *self, const char *key, const char **array) {
- return(self->f->setArrayc(self,key,(char**)array));
+ return(self->f->setCArrayc(self,key,array));
}
smallJsont* setVoidSmallJsonG (smallJsont *self, const char *key, void *value) {
@@ -25413,7 +26183,7 @@ smallJsont* setAtArraycSmallJsonG (smallJsont *self, int64_t index, char **arr
smallJsont* setAtCArraycSmallJsonG (smallJsont *self, int64_t index, const char **array) {
- return(self->f->setAtArrayc(self,index,(char**)array));
+ return(self->f->setAtCArrayc(self,index,array));
}
smallJsont* setAtVoidSmallJsonG (smallJsont *self, int64_t index, void *value) {
@@ -26094,7 +26864,7 @@ smallJsont* prependArraycSmallJsonG (smallJsont *self, char **array) {
smallJsont* prependCArraycSmallJsonG (smallJsont *self, const char **array) {
- return(self->f->prependArrayc(self,(char**)array));
+ return(self->f->prependCArrayc(self,array));
}
smallJsont* prependVoidSmallJsonG (smallJsont *self, void *value) {
@@ -26361,7 +27131,7 @@ smallJsont* appendNSmashArraySmallJsonG (smallJsont *self, char **array) {
smallJsont* appendCArraySmallJsonG (smallJsont *self, const char **array) {
- return(self->f->appendArray(self, (char**)array));
+ return(self->f->appendCArray(self, array));
}
smallJsont* shiftSmallJsonG (smallJsont *self, smallArrayt *array) {
@@ -26524,97 +27294,97 @@ smallContainert* cropElemAtSmallContainerSmallJsonG (smallJsont *self, int64_t i
baset* cropElemKeySmallJsonG (smallJsont *self, const char* key) {
- return(self->f->cropElemKey(self, (char*)key));
+ return(self->f->cropElemKey(self, key));
}
undefinedt* cropElemKeyUndefinedSmallJsonG (smallJsont *self, const char* key) {
- return(self->f->cropElemKeyUndefined(self, (char*)key));
+ return(self->f->cropElemKeyUndefined(self, key));
}
bool cropElemKeyBoolSmallJsonG (smallJsont *self, const char* key) {
- return(self->f->cropElemKeyBool(self, (char*)key));
+ return(self->f->cropElemKeyBool(self, key));
}
double cropElemKeyDoubleSmallJsonG (smallJsont *self, const char* key) {
- return(self->f->cropElemKeyDouble(self, (char*)key));
+ return(self->f->cropElemKeyDouble(self, key));
}
int64_t cropElemKeyIntSmallJsonG (smallJsont *self, const char* key) {
- return(self->f->cropElemKeyInt(self, (char*)key));
+ return(self->f->cropElemKeyInt(self, key));
}
int32_t cropElemKeyInt32SmallJsonG (smallJsont *self, const char* key) {
- return(self->f->cropElemKeyInt32(self, (char*)key));
+ return(self->f->cropElemKeyInt32(self, key));
}
uint64_t cropElemKeyUintSmallJsonG (smallJsont *self, const char* key) {
- return(self->f->cropElemKeyUint(self, (char*)key));
+ return(self->f->cropElemKeyUint(self, key));
}
uint32_t cropElemKeyUint32SmallJsonG (smallJsont *self, const char* key) {
- return(self->f->cropElemKeyUint32(self, (char*)key));
+ return(self->f->cropElemKeyUint32(self, key));
}
char* cropElemKeySSmallJsonG (smallJsont *self, const char* key) {
- return(self->f->cropElemKeyS(self, (char*)key));
+ return(self->f->cropElemKeyS(self, key));
}
smallDictt* cropElemKeyDictSmallJsonG (smallJsont *self, const char* key) {
- return(self->f->cropElemKeyDict(self, (char*)key));
+ return(self->f->cropElemKeyDict(self, key));
}
smallArrayt* cropElemKeyArraySmallJsonG (smallJsont *self, const char* key) {
- return(self->f->cropElemKeyArray(self, (char*)key));
+ return(self->f->cropElemKeyArray(self, key));
}
smallBoolt* cropElemKeySmallBoolSmallJsonG (smallJsont *self, const char* key) {
- return(self->f->cropElemKeySmallBool(self, (char*)key));
+ return(self->f->cropElemKeySmallBool(self, key));
}
smallBytest* cropElemKeySmallBytesSmallJsonG (smallJsont *self, const char* key) {
- return(self->f->cropElemKeySmallBytes(self, (char*)key));
+ return(self->f->cropElemKeySmallBytes(self, key));
}
smallDoublet* cropElemKeySmallDoubleSmallJsonG (smallJsont *self, const char* key) {
- return(self->f->cropElemKeySmallDouble(self, (char*)key));
+ return(self->f->cropElemKeySmallDouble(self, key));
}
smallIntt* cropElemKeySmallIntSmallJsonG (smallJsont *self, const char* key) {
- return(self->f->cropElemKeySmallInt(self, (char*)key));
+ return(self->f->cropElemKeySmallInt(self, key));
}
smallJsont* cropElemKeySmallJsonSmallJsonG (smallJsont *self, const char* key) {
- return(self->f->cropElemKeySmallJson(self, (char*)key));
+ return(self->f->cropElemKeySmallJson(self, key));
}
smallStringt* cropElemKeySmallStringSmallJsonG (smallJsont *self, const char* key) {
- return(self->f->cropElemKeySmallString(self, (char*)key));
+ return(self->f->cropElemKeySmallString(self, key));
}
void* cropElemKeyVoidSmallJsonG (smallJsont *self, const char* key) {
- return(self->f->cropElemKeyVoid(self, (char*)key));
+ return(self->f->cropElemKeyVoid(self, key));
}
smallContainert* cropElemKeySmallContainerSmallJsonG(smallJsont *self, const char* key) {
- return(self->f->cropElemKeySmallContainer(self, (char*)key));
+ return(self->f->cropElemKeySmallContainer(self, key));
}
smallJsont* copySmallJsonG (smallJsont *self, int64_t start, int64_t end) {
@@ -26715,7 +27485,7 @@ smallJsont* injectArraycSmallJsonG (smallJsont *self, int64_t index, char **ar
smallJsont* injectCArraycSmallJsonG (smallJsont *self, int64_t index, const char **array) {
- return(self->f->injectArrayc(self,index,(char**)array));
+ return(self->f->injectCArrayc(self,index,array));
}
smallJsont* injectVoidSmallJsonG (smallJsont *self, int64_t index, void *value) {
@@ -26920,7 +27690,7 @@ bool hasArraycSmallJsonG (smallJsont *self, char **array) {
bool hasCArraycSmallJsonG (smallJsont *self, const char **array) {
- return(self->f->hasArrayc(self,(char**)array));
+ return(self->f->hasCArrayc(self,array));
}
bool hasSmallBoolSmallJsonG (smallJsont *self, smallBoolt *value) {
@@ -27030,7 +27800,7 @@ ssize_t indexOfArraycSmallJsonG (smallJsont *self, char **array) {
ssize_t indexOfCArraycSmallJsonG (smallJsont *self, const char **array) {
- return(self->f->indexOfArrayc(self,(char**)array));
+ return(self->f->indexOfCArrayc(self,array));
}
ssize_t indexOfSmallBoolSmallJsonG (smallJsont *self, smallBoolt *value) {
@@ -27120,7 +27890,7 @@ ssize_t binarySearchArraycSmallJsonG (smallJsont *self, char **array) {
ssize_t binarySearchCArraycSmallJsonG (smallJsont *self, const char **array) {
- return(self->f->binarySearchArrayc(self,(char**)array));
+ return(self->f->binarySearchCArrayc(self,array));
}
ssize_t binarySearchSmallBoolSmallJsonG (smallJsont *self, smallBoolt *value) {
@@ -27190,7 +27960,7 @@ bool icHasArraycSmallJsonG (smallJsont *self, char **array) {
bool icHasCArraycSmallJsonG (smallJsont *self, const char **array) {
- return(self->f->icHasArrayc(self,(char**)array));
+ return(self->f->icHasCArrayc(self,array));
}
bool icHasSmallStringSmallJsonG (smallJsont *self, smallStringt *string) {
@@ -27250,7 +28020,7 @@ ssize_t icIndexOfArraycSmallJsonG (smallJsont *self, char **array) {
ssize_t icIndexOfCArraycSmallJsonG (smallJsont *self, const char **array) {
- return(self->f->icIndexOfArrayc(self,(char**)array));
+ return(self->f->icIndexOfCArrayc(self,array));
}
ssize_t icIndexOfSmallStringSmallJsonG (smallJsont *self, smallStringt *string) {
@@ -27290,7 +28060,7 @@ ssize_t icBinarySearchArraycSmallJsonG (smallJsont *self, char **array) {
ssize_t icBinarySearchCArraycSmallJsonG (smallJsont *self, const char **array) {
- return(self->f->icBinarySearchArrayc(self,(char**)array));
+ return(self->f->icBinarySearchCArrayc(self,array));
}
ssize_t icBinarySearchSmallStringSmallJsonG (smallJsont *self, smallStringt *string) {
@@ -27303,9 +28073,9 @@ char* keyBySmallJsonG(smallJsont *self, baset *value) {
return(self->f->keyBy(self,value));
}
-char* keyByUndefinedSmallJsonG(smallJsont *self, undefinedt *undefined) {
+char* keyByUndefinedSmallJsonG(smallJsont *self, undefinedt *u) {
- return(self->f->keyByUndefined(self,undefined));
+ return(self->f->keyByUndefined(self,u));
}
char* keyByBoolSmallJsonG(smallJsont *self, bool value) {
@@ -27350,7 +28120,7 @@ char* keyByArraycSmallJsonG(smallJsont *self, char **array) {
char* keyByCArraycSmallJsonG(smallJsont *self, const char **array) {
- return(self->f->keyByArrayc(self,(char**)array));
+ return(self->f->keyByCArrayc(self,array));
}
char* keyBySmallBoolSmallJsonG(smallJsont *self, smallBoolt *value) {
@@ -27420,7 +28190,7 @@ char* icKeyByArraycSmallJsonG(smallJsont *self, char **array) {
char* icKeyByCArraycSmallJsonG(smallJsont *self, const char **array) {
- return(self->f->icKeyByArrayc(self,(char**)array));
+ return(self->f->icKeyByCArrayc(self,array));
}
char* icKeyBySmallStringSmallJsonG(smallJsont *self, smallStringt *string) {
@@ -27602,7 +28372,7 @@ bool equalSmallJsonArrayG(smallJsont *self, char ** p2) {
bool equalSmallJsonCArrayG(smallJsont *self, const char ** p2) {
- return(self->f->equalArray(self, (char**)p2));
+ return(self->f->equalCArray(self, p2));
}
bool equalSmallJsonBaseG(smallJsont *self, baset* p2) {
@@ -27697,7 +28467,7 @@ bool icEqualSmallJsonArrayG(smallJsont *self, char ** p2) {
bool icEqualSmallJsonCArrayG(smallJsont *self, const char ** p2) {
- return(self->f->icEqualArray(self, (char**)p2));
+ return(self->f->icEqualCArray(self, p2));
}
bool icEqualSmallJsonBaseG(smallJsont *self, baset* p2) {
@@ -28325,7 +29095,7 @@ smallStringt* toYMLSmallStringSmallJsonG(smallJsont *self, int indent) {
bool parseSmallJsonG (smallJsont *self, const char *input) {
- return(self->f->parse(self, (char*)input));
+ return(self->f->parse(self, input));
}
bool parseSmallJsonSmallJsonG(smallJsont *self, smallJsont *input) {
@@ -28340,7 +29110,7 @@ bool parseSmallStringSmallJsonG(smallJsont *self, smallStringt *input) {
bool parseYMLSmallJsonG (smallJsont *self, const char *input) {
- return(self->f->parseYML(self, (char*)input));
+ return(self->f->parseYML(self, input));
}
bool parseYMLSmallJsonSmallJsonG(smallJsont *self, smallJsont *input) {
diff --git a/src/json/libsheepyCSmallJson.h b/src/json/libsheepyCSmallJson.h
@@ -160,6 +160,7 @@ typedef smallJsont* (*setTopCharSmallJsonFt) (smallJsont *self, char c);
typedef smallJsont* (*setTopDictSmallJsonFt) (smallJsont *self, smallDictt *value);
typedef smallJsont* (*setTopArraySmallJsonFt) (smallJsont *self, smallArrayt *value);
typedef smallJsont* (*setTopArraycSmallJsonFt) (smallJsont *self, char **value);
+typedef smallJsont* (*setTopCArraycSmallJsonFt) (smallJsont *self, const char **value);
typedef smallJsont* (*setTopSmallBoolSmallJsonFt) (smallJsont *self, smallBoolt *value);
typedef smallJsont* (*setTopSmallDoubleSmallJsonFt)(smallJsont *self, smallDoublet *value);
typedef smallJsont* (*setTopSmallIntSmallJsonFt) (smallJsont *self, smallIntt *value);
@@ -199,8 +200,9 @@ typedef smallJsont* (*setTopNFreeSmallStringSmallJsonFt)(smallJsont *self, sma
* empty list when size is 0
* NULL when array is NULL
*/
-typedef smallJsont* (*fromArraySmallJsonFt)(smallJsont *self, char **array, size_t size);
-typedef smallJsont* (*fromArrayNFreeSmallJsonFt)(smallJsont *self, char **array, size_t size);
+typedef smallJsont* (*fromArraySmallJsonFt) (smallJsont *self, char **array, size_t size);
+typedef smallJsont* (*fromCArraySmallJsonFt) (smallJsont *self, const char **array, size_t size);
+typedef smallJsont* (*fromArrayNFreeSmallJsonFt)(smallJsont *self, char **array, size_t size);
/**
* convert array to dictionary
@@ -370,6 +372,7 @@ typedef smallJsont* (*setCharSmallJsonFt) (smallJsont *self, const char *k
typedef smallJsont* (*setDictSmallJsonFt) (smallJsont *self, const char *key, smallDictt *dict);
typedef smallJsont* (*setArraySmallJsonFt) (smallJsont *self, const char *key, smallArrayt *array);
typedef smallJsont* (*setArraycSmallJsonFt) (smallJsont *self, const char *key, char **array);
+typedef smallJsont* (*setCArraycSmallJsonFt) (smallJsont *self, const char *key, const char **array);
typedef smallJsont* (*setSmallBoolSmallJsonFt) (smallJsont *self, const char *key, smallBoolt *value);
typedef smallJsont* (*setSmallBytesSmallJsonFt) (smallJsont *self, const char *key, smallBytest *value);
typedef smallJsont* (*setSmallDoubleSmallJsonFt) (smallJsont *self, const char *key, smallDoublet *value);
@@ -456,6 +459,7 @@ typedef smallJsont* (*setAtCharSmallJsonFt) (smallJsont *self, int64
typedef smallJsont* (*setAtDictSmallJsonFt) (smallJsont *self, int64_t index, smallDictt *dict);
typedef smallJsont* (*setAtArraySmallJsonFt) (smallJsont *self, int64_t index, smallArrayt *array);
typedef smallJsont* (*setAtArraycSmallJsonFt) (smallJsont *self, int64_t index, char **array);
+typedef smallJsont* (*setAtCArraycSmallJsonFt) (smallJsont *self, int64_t index, const char **array);
typedef smallJsont* (*setAtSmallBoolSmallJsonFt) (smallJsont *self, int64_t index, smallBoolt *value);
typedef smallJsont* (*setAtSmallBytesSmallJsonFt) (smallJsont *self, int64_t index, smallBytest *value);
typedef smallJsont* (*setAtSmallDoubleSmallJsonFt) (smallJsont *self, int64_t index, smallDoublet *value);
@@ -800,6 +804,7 @@ typedef smallJsont* (*pushCharSmallJsonFt) (smallJsont *self, char c
typedef smallJsont* (*pushDictSmallJsonFt) (smallJsont *self, smallDictt *dict);
typedef smallJsont* (*pushArraySmallJsonFt) (smallJsont *self, smallArrayt *array);
typedef smallJsont* (*pushArraycSmallJsonFt) (smallJsont *self, char **array);
+typedef smallJsont* (*pushCArraycSmallJsonFt) (smallJsont *self, const char **array);
typedef smallJsont* (*pushSmallBoolSmallJsonFt) (smallJsont *self, smallBoolt *value);
typedef smallJsont* (*pushSmallBytesSmallJsonFt) (smallJsont *self, smallBytest *value);
typedef smallJsont* (*pushSmallDoubleSmallJsonFt) (smallJsont *self, smallDoublet *value);
@@ -935,6 +940,7 @@ typedef smallJsont* (*prependCharSmallJsonFt) (smallJson
typedef smallJsont* (*prependDictSmallJsonFt) (smallJsont *self, smallDictt *dict);
typedef smallJsont* (*prependArraySmallJsonFt) (smallJsont *self, smallArrayt *array);
typedef smallJsont* (*prependArraycSmallJsonFt) (smallJsont *self, char **array);
+typedef smallJsont* (*prependCArraycSmallJsonFt) (smallJsont *self, const char **array);
typedef smallJsont* (*prependSmallBoolSmallJsonFt) (smallJsont *self, smallBoolt *value);
typedef smallJsont* (*prependSmallBytesSmallJsonFt) (smallJsont *self, smallBytest *value);
typedef smallJsont* (*prependSmallDoubleSmallJsonFt) (smallJsont *self, smallDoublet *value);
@@ -1045,6 +1051,7 @@ typedef smallJsont* (*appendNSmashSmallJsonFt) (smallJsont *self, s
// not used, included in mergeSmallJson - typedef smallJsont* (*appendSmallJsonSmallJsonFt) (smallJsont *self, smallJsont *array);
// not used, included in mergeSmallJson - typedef smallJsont* (*appendSmallJsonNSmashSmallJsonFt)(smallJsont *self, smallJsont *array);
typedef smallJsont* (*appendArraySmallJsonFt) (smallJsont *self, char **array);
+typedef smallJsont* (*appendCArraySmallJsonFt) (smallJsont *self, const char **array);
typedef smallJsont* (*appendNSmashArraySmallJsonFt)(smallJsont *self, char **array);
/**
@@ -1167,25 +1174,25 @@ typedef smallContainert* (*cropElemAtSmallContainerSmallJsonFt) (smallJsont *se
* element for key (you must free the pointer (terminate libsheepy objects))
* NULL error
*/
-typedef baset* (*cropElemKeySmallJsonFt) (smallJsont *self, char* key);
-typedef undefinedt* (*cropElemKeyUndefinedSmallJsonFt) (smallJsont *self, char* key);
-typedef bool (*cropElemKeyBoolSmallJsonFt) (smallJsont *self, char* key);
-typedef double (*cropElemKeyDoubleSmallJsonFt) (smallJsont *self, char* key);
-typedef int64_t (*cropElemKeyIntSmallJsonFt) (smallJsont *self, char* key);
-typedef int32_t (*cropElemKeyInt32SmallJsonFt) (smallJsont *self, char* key);
-typedef uint64_t (*cropElemKeyUintSmallJsonFt) (smallJsont *self, char* key);
-typedef uint32_t (*cropElemKeyUint32SmallJsonFt) (smallJsont *self, char* key);
-typedef char* (*cropElemKeySSmallJsonFt) (smallJsont *self, char* key);
-typedef smallDictt* (*cropElemKeyDictSmallJsonFt) (smallJsont *self, char* key);
-typedef smallArrayt* (*cropElemKeyArraySmallJsonFt) (smallJsont *self, char* key);
-typedef smallBoolt* (*cropElemKeySmallBoolSmallJsonFt) (smallJsont *self, char* key);
-typedef smallBytest* (*cropElemKeySmallBytesSmallJsonFt) (smallJsont *self, char* key);
-typedef smallDoublet* (*cropElemKeySmallDoubleSmallJsonFt) (smallJsont *self, char* key);
-typedef smallIntt* (*cropElemKeySmallIntSmallJsonFt) (smallJsont *self, char* key);
-typedef smallJsont* (*cropElemKeySmallJsonSmallJsonFt) (smallJsont *self, char* key);
-typedef smallStringt* (*cropElemKeySmallStringSmallJsonFt) (smallJsont *self, char* key);
-typedef void* (*cropElemKeyVoidSmallJsonFt) (smallJsont *self, char* key);
-typedef smallContainert* (*cropElemKeySmallContainerSmallJsonFt) (smallJsont *self, char* key);
+typedef baset* (*cropElemKeySmallJsonFt) (smallJsont *self, const char* key);
+typedef undefinedt* (*cropElemKeyUndefinedSmallJsonFt) (smallJsont *self, const char* key);
+typedef bool (*cropElemKeyBoolSmallJsonFt) (smallJsont *self, const char* key);
+typedef double (*cropElemKeyDoubleSmallJsonFt) (smallJsont *self, const char* key);
+typedef int64_t (*cropElemKeyIntSmallJsonFt) (smallJsont *self, const char* key);
+typedef int32_t (*cropElemKeyInt32SmallJsonFt) (smallJsont *self, const char* key);
+typedef uint64_t (*cropElemKeyUintSmallJsonFt) (smallJsont *self, const char* key);
+typedef uint32_t (*cropElemKeyUint32SmallJsonFt) (smallJsont *self, const char* key);
+typedef char* (*cropElemKeySSmallJsonFt) (smallJsont *self, const char* key);
+typedef smallDictt* (*cropElemKeyDictSmallJsonFt) (smallJsont *self, const char* key);
+typedef smallArrayt* (*cropElemKeyArraySmallJsonFt) (smallJsont *self, const char* key);
+typedef smallBoolt* (*cropElemKeySmallBoolSmallJsonFt) (smallJsont *self, const char* key);
+typedef smallBytest* (*cropElemKeySmallBytesSmallJsonFt) (smallJsont *self, const char* key);
+typedef smallDoublet* (*cropElemKeySmallDoubleSmallJsonFt) (smallJsont *self, const char* key);
+typedef smallIntt* (*cropElemKeySmallIntSmallJsonFt) (smallJsont *self, const char* key);
+typedef smallJsont* (*cropElemKeySmallJsonSmallJsonFt) (smallJsont *self, const char* key);
+typedef smallStringt* (*cropElemKeySmallStringSmallJsonFt) (smallJsont *self, const char* key);
+typedef void* (*cropElemKeyVoidSmallJsonFt) (smallJsont *self, const char* key);
+typedef smallContainert* (*cropElemKeySmallContainerSmallJsonFt) (smallJsont *self, const char* key);
/**
* keep elements from start and end in list, free the other elements
@@ -1270,6 +1277,7 @@ typedef smallJsont* (*injectCharSmallJsonFt) (smallJsont *self, int64_t inde
typedef smallJsont* (*injectDictSmallJsonFt) (smallJsont *self, int64_t index, smallDictt *toInject);
typedef smallJsont* (*injectArraySmallJsonFt) (smallJsont *self, int64_t index, smallArrayt *toInject);
typedef smallJsont* (*injectArraycSmallJsonFt) (smallJsont *self, int64_t index, char **toInject);
+typedef smallJsont* (*injectCArraycSmallJsonFt) (smallJsont *self, int64_t index, const char **toInject);
typedef smallJsont* (*injectSmallBoolSmallJsonFt) (smallJsont *self, int64_t index, smallBoolt *toInject);
typedef smallJsont* (*injectSmallBytesSmallJsonFt) (smallJsont *self, int64_t index, smallBytest *toInject);
typedef smallJsont* (*injectSmallDoubleSmallJsonFt) (smallJsont *self, int64_t index, smallDoublet *toInject);
@@ -1405,6 +1413,7 @@ typedef bool (*hasCharSmallJsonFt) (smallJsont *self, char c);
typedef bool (*hasDictSmallJsonFt) (smallJsont *self, smallDictt *dict);
typedef bool (*hasArraySmallJsonFt) (smallJsont *self, smallArrayt *array);
typedef bool (*hasArraycSmallJsonFt) (smallJsont *self, char **array);
+typedef bool (*hasCArraycSmallJsonFt) (smallJsont *self, const char **array);
typedef bool (*hasSmallBoolSmallJsonFt) (smallJsont *self, smallBoolt *value);
typedef bool (*hasSmallBytesSmallJsonFt) (smallJsont *self, smallBytest *value);
typedef bool (*hasSmallDoubleSmallJsonFt) (smallJsont *self, smallDoublet *value);
@@ -1448,6 +1457,7 @@ typedef ssize_t (*indexOfCharSmallJsonFt) (smallJsont *self, char c);
typedef ssize_t (*indexOfDictSmallJsonFt) (smallJsont *self, smallDictt *dict);
typedef ssize_t (*indexOfArraySmallJsonFt) (smallJsont *self, smallArrayt *array);
typedef ssize_t (*indexOfArraycSmallJsonFt) (smallJsont *self, char **array);
+typedef ssize_t (*indexOfCArraycSmallJsonFt) (smallJsont *self, const char **array);
typedef ssize_t (*indexOfSmallBoolSmallJsonFt) (smallJsont *self, smallBoolt *value);
typedef ssize_t (*indexOfSmallBytesSmallJsonFt) (smallJsont *self, smallBytest *value);
typedef ssize_t (*indexOfSmallDoubleSmallJsonFt) (smallJsont *self, smallDoublet *value);
@@ -1476,6 +1486,7 @@ typedef ssize_t (*binarySearchCharSmallJsonFt) (smallJsont *self, char
typedef ssize_t (*binarySearchDictSmallJsonFt) (smallJsont *self, smallDictt *dict);
typedef ssize_t (*binarySearchArraySmallJsonFt) (smallJsont *self, smallArrayt *array);
typedef ssize_t (*binarySearchArraycSmallJsonFt) (smallJsont *self, char **array);
+typedef ssize_t (*binarySearchCArraycSmallJsonFt) (smallJsont *self, const char **array);
typedef ssize_t (*binarySearchSmallBoolSmallJsonFt) (smallJsont *self, smallBoolt *value);
typedef ssize_t (*binarySearchSmallBytesSmallJsonFt) (smallJsont *self, smallBytest *value);
typedef ssize_t (*binarySearchSmallDoubleSmallJsonFt) (smallJsont *self, smallDoublet *value);
@@ -1498,6 +1509,7 @@ typedef bool (*icHasCharSmallJsonFt) (smallJsont *self, char c);
typedef bool (*icHasDictSmallJsonFt) (smallJsont *self, smallDictt *dict);
typedef bool (*icHasArraySmallJsonFt) (smallJsont *self, smallArrayt *array);
typedef bool (*icHasArraycSmallJsonFt) (smallJsont *self, char **array);
+typedef bool (*icHasCArraycSmallJsonFt) (smallJsont *self, const char **array);
typedef bool (*icHasSmallStringSmallJsonFt) (smallJsont *self, smallStringt *string);
/**
@@ -1531,6 +1543,7 @@ typedef ssize_t (*icIndexOfCharSmallJsonFt) (smallJsont *self, char c)
typedef ssize_t (*icIndexOfDictSmallJsonFt) (smallJsont *self, smallDictt *dict);
typedef ssize_t (*icIndexOfArraySmallJsonFt) (smallJsont *self, smallArrayt *array);
typedef ssize_t (*icIndexOfArraycSmallJsonFt) (smallJsont *self, char **array);
+typedef ssize_t (*icIndexOfCArraycSmallJsonFt) (smallJsont *self, const char **array);
typedef ssize_t (*icIndexOfSmallStringSmallJsonFt) (smallJsont *self, smallStringt *string);
/**
@@ -1549,6 +1562,7 @@ typedef ssize_t (*icBinarySearchCharSmallJsonFt) (smallJsont *self, ch
typedef ssize_t (*icBinarySearchDictSmallJsonFt) (smallJsont *self, smallDictt *dict);
typedef ssize_t (*icBinarySearchArraySmallJsonFt) (smallJsont *self, smallArrayt *array);
typedef ssize_t (*icBinarySearchArraycSmallJsonFt) (smallJsont *self, char **array);
+typedef ssize_t (*icBinarySearchCArraycSmallJsonFt) (smallJsont *self, const char **array);
typedef ssize_t (*icBinarySearchSmallStringSmallJsonFt) (smallJsont *self, smallStringt *string);
/**
@@ -1571,6 +1585,7 @@ typedef char* (*keyByCharSmallJsonFt) (smallJsont *self, char c);
typedef char* (*keyByDictSmallJsonFt) (smallJsont *self, smallDictt *dict);
typedef char* (*keyByArraySmallJsonFt) (smallJsont *self, smallArrayt *array);
typedef char* (*keyByArraycSmallJsonFt) (smallJsont *self, char **array);
+typedef char* (*keyByCArraycSmallJsonFt) (smallJsont *self, const char **array);
typedef char* (*keyBySmallBoolSmallJsonFt) (smallJsont *self, smallBoolt *value);
typedef char* (*keyBySmallBytesSmallJsonFt) (smallJsont *self, smallBytest *value);
typedef char* (*keyBySmallDoubleSmallJsonFt) (smallJsont *self, smallDoublet *value);
@@ -1595,6 +1610,7 @@ typedef char* (*icKeyByCharSmallJsonFt) (smallJsont *self, char c);
typedef char* (*icKeyByDictSmallJsonFt) (smallJsont *self, smallDictt *dict);
typedef char* (*icKeyByArraySmallJsonFt) (smallJsont *self, smallArrayt *array);
typedef char* (*icKeyByArraycSmallJsonFt) (smallJsont *self, char **array);
+typedef char* (*icKeyByCArraycSmallJsonFt) (smallJsont *self, const char **array);
typedef char* (*icKeyBySmallStringSmallJsonFt) (smallJsont *self, smallStringt *string);
/**
@@ -1718,6 +1734,7 @@ typedef smallJsont* (*icReplaceManySmallJsonFt)(smallJsont *self, const cha
*/
typedef bool (*equalSmallJsonSmallArrayFt) (smallJsont *self, smallArrayt *array);
typedef bool (*equalSmallJsonArrayFt) (smallJsont *self, char ** p2);
+typedef bool (*equalSmallJsonCArrayFt) (smallJsont *self, const char ** p2);
typedef bool (*equalSmallJsonBaseFt) (smallJsont *self, baset* p2);
typedef bool (*equalSmallJsonChaFt) (smallJsont* self, char p2);
typedef bool (*equalSmallJsonCharFt) (smallJsont* self, const char * p2);
@@ -1746,6 +1763,7 @@ typedef bool (*equalSmallJsonSmallDictFt) (smallJsont* self, smallDictt* p2);
*/
typedef bool (*icEqualSmallJsonSmallArrayFt) (smallJsont *self, smallArrayt *array);
typedef bool (*icEqualSmallJsonArrayFt) (smallJsont *self, char ** p2);
+typedef bool (*icEqualSmallJsonCArrayFt) (smallJsont *self, const char ** p2);
typedef bool (*icEqualSmallJsonBaseFt) (smallJsont *self, baset* p2);
typedef bool (*icEqualSmallJsonSmallDictFt) (smallJsont* self, smallDictt* p2);
typedef bool (*icEqualSmallJsonSmallJsonFt) (smallJsont *self, smallJsont *string);
@@ -2310,14 +2328,14 @@ typedef smallStringt* (*toYMLSmallStringSmallJsonFt) (smallJsont *self, int ind
/**
* parse a smallJson string
*/
-typedef bool (*parseSmallJsonFt) (smallJsont *self, char *input);
+typedef bool (*parseSmallJsonFt) (smallJsont *self, const char *input);
typedef bool (*parseSmallJsonSmallJsonFt) (smallJsont *self, smallJsont *input);
typedef bool (*parseSmallStringSmallJsonFt)(smallJsont *self, smallStringt *input);
/**
* parse a yml string
*/
-typedef bool (*parseYMLSmallJsonFt) (smallJsont *self, char *input);
+typedef bool (*parseYMLSmallJsonFt) (smallJsont *self, const char *input);
typedef bool (*parseYMLSmallJsonSmallJsonFt) (smallJsont *self, smallJsont *input);
typedef bool (*parseYMLSmallStringSmallJsonFt)(smallJsont *self, smallStringt *input);
@@ -2617,6 +2635,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
setTopDictSmallJsonFt setTopDict;\
setTopArraySmallJsonFt setTopArray;\
setTopArraycSmallJsonFt setTopArrayc;\
+ setTopCArraycSmallJsonFt setTopCArrayc;\
setTopSmallBoolSmallJsonFt setTopSmallBool;\
setTopSmallDoubleSmallJsonFt setTopSmallDouble;\
setTopSmallIntSmallJsonFt setTopSmallInt;\
@@ -2636,6 +2655,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
setTopNFreeSmallJsonSmallJsonFt setTopNFreeSmallJson;\
setTopNFreeSmallStringSmallJsonFt setTopNFreeSmallString;\
fromArraySmallJsonFt fromArray;\
+ fromCArraySmallJsonFt fromCArray;\
fromArrayNFreeSmallJsonFt fromArrayNFree;\
fromArrayDictSmallJsonFt fromArrayDict;\
toArrayDictSmallJsonFt toArrayDict;\
@@ -2677,6 +2697,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
setDictSmallJsonFt setDict;\
setArraySmallJsonFt setArray;\
setArraycSmallJsonFt setArrayc;\
+ setCArraycSmallJsonFt setCArrayc;\
setSmallBoolSmallJsonFt setSmallBool;\
setSmallBytesSmallJsonFt setSmallBytes;\
setSmallDoubleSmallJsonFt setSmallDouble;\
@@ -2715,6 +2736,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
setAtDictSmallJsonFt setAtDict;\
setAtArraySmallJsonFt setAtArray;\
setAtArraycSmallJsonFt setAtArrayc;\
+ setAtCArraycSmallJsonFt setAtCArrayc;\
setAtSmallBoolSmallJsonFt setAtSmallBool;\
setAtSmallBytesSmallJsonFt setAtSmallBytes;\
setAtSmallDoubleSmallJsonFt setAtSmallDouble;\
@@ -2849,6 +2871,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
pushDictSmallJsonFt pushDict;\
pushArraySmallJsonFt pushArray;\
pushArraycSmallJsonFt pushArrayc;\
+ pushCArraycSmallJsonFt pushCArrayc;\
pushSmallBoolSmallJsonFt pushSmallBool;\
pushSmallBytesSmallJsonFt pushSmallBytes;\
pushSmallDoubleSmallJsonFt pushSmallDouble;\
@@ -2904,6 +2927,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
prependDictSmallJsonFt prependDict;\
prependArraySmallJsonFt prependArray;\
prependArraycSmallJsonFt prependArrayc;\
+ prependCArraycSmallJsonFt prependCArrayc;\
prependSmallBoolSmallJsonFt prependSmallBool;\
prependSmallBytesSmallJsonFt prependSmallBytes;\
prependSmallDoubleSmallJsonFt prependSmallDouble;\
@@ -2953,6 +2977,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
appendSmallJsonFt append;\
appendNSmashSmallJsonFt appendNSmash;\
appendArraySmallJsonFt appendArray;\
+ appendCArraySmallJsonFt appendCArray;\
appendNSmashArraySmallJsonFt appendNSmashArray;\
shiftSmallJsonFt shift;\
shiftNSmashSmallJsonFt shiftNSmash;\
@@ -3022,6 +3047,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
injectDictSmallJsonFt injectDict;\
injectArraySmallJsonFt injectArray;\
injectArraycSmallJsonFt injectArrayc;\
+ injectCArraycSmallJsonFt injectCArrayc;\
injectSmallBoolSmallJsonFt injectSmallBool;\
injectSmallBytesSmallJsonFt injectSmallBytes;\
injectSmallDoubleSmallJsonFt injectSmallDouble;\
@@ -3059,6 +3085,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
hasDictSmallJsonFt hasDict;\
hasArraySmallJsonFt hasArray;\
hasArraycSmallJsonFt hasArrayc;\
+ hasCArraycSmallJsonFt hasCArrayc;\
hasSmallBoolSmallJsonFt hasSmallBool;\
hasSmallBytesSmallJsonFt hasSmallBytes;\
hasSmallDoubleSmallJsonFt hasSmallDouble;\
@@ -3080,6 +3107,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
indexOfDictSmallJsonFt indexOfDict;\
indexOfArraySmallJsonFt indexOfArray;\
indexOfArraycSmallJsonFt indexOfArrayc;\
+ indexOfCArraycSmallJsonFt indexOfCArrayc;\
indexOfSmallBoolSmallJsonFt indexOfSmallBool;\
indexOfSmallBytesSmallJsonFt indexOfSmallBytes;\
indexOfSmallDoubleSmallJsonFt indexOfSmallDouble;\
@@ -3097,6 +3125,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
binarySearchDictSmallJsonFt binarySearchDict;\
binarySearchArraySmallJsonFt binarySearchArray;\
binarySearchArraycSmallJsonFt binarySearchArrayc;\
+ binarySearchCArraycSmallJsonFt binarySearchCArrayc;\
binarySearchSmallBoolSmallJsonFt binarySearchSmallBool;\
binarySearchSmallBytesSmallJsonFt binarySearchSmallBytes;\
binarySearchSmallDoubleSmallJsonFt binarySearchSmallDouble;\
@@ -3110,6 +3139,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
icHasDictSmallJsonFt icHasDict;\
icHasArraySmallJsonFt icHasArray;\
icHasArraycSmallJsonFt icHasArrayc;\
+ icHasCArraycSmallJsonFt icHasCArrayc;\
icHasSmallStringSmallJsonFt icHasSmallString;\
icFindSmallJsonFt icFind;\
icFindCharSmallJsonFt icFindChar;\
@@ -3121,6 +3151,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
icIndexOfDictSmallJsonFt icIndexOfDict;\
icIndexOfArraySmallJsonFt icIndexOfArray;\
icIndexOfArraycSmallJsonFt icIndexOfArrayc;\
+ icIndexOfCArraycSmallJsonFt icIndexOfCArrayc;\
icIndexOfSmallStringSmallJsonFt icIndexOfSmallString;\
icBinarySearchSmallJsonFt icBinarySearch;\
icBinarySearchSSmallJsonFt icBinarySearchS;\
@@ -3128,6 +3159,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
icBinarySearchDictSmallJsonFt icBinarySearchDict;\
icBinarySearchArraySmallJsonFt icBinarySearchArray;\
icBinarySearchArraycSmallJsonFt icBinarySearchArrayc;\
+ icBinarySearchCArraycSmallJsonFt icBinarySearchCArrayc;\
icBinarySearchSmallStringSmallJsonFt icBinarySearchSmallString;\
keyBySmallJsonFt keyBy;\
keyByUndefinedSmallJsonFt keyByUndefined;\
@@ -3138,7 +3170,8 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
keyByCharSmallJsonFt keyByChar;\
keyByDictSmallJsonFt keyByDict;\
keyByArraySmallJsonFt keyByArray;\
- keyByArraycSmallJsonFt keyByArrayc;\
+ keyByArraycSmallJsonFt keyByArrayc;\
+ keyByCArraycSmallJsonFt keyByCArrayc;\
keyBySmallBoolSmallJsonFt keyBySmallBool;\
keyBySmallBytesSmallJsonFt keyBySmallBytes;\
keyBySmallDoubleSmallJsonFt keyBySmallDouble;\
@@ -3152,6 +3185,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
icKeyByDictSmallJsonFt icKeyByDict;\
icKeyByArraySmallJsonFt icKeyByArray;\
icKeyByArraycSmallJsonFt icKeyByArrayc;\
+ icKeyByCArraycSmallJsonFt icKeyByCArrayc;\
icKeyBySmallStringSmallJsonFt icKeyBySmallString;\
replaceSmallJsonFt replace;\
replaceCharSSmallJsonFt replaceCharS;\
@@ -3189,6 +3223,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
icReplaceManySmallJsonFt icReplaceMany;\
equalSmallJsonSmallArrayFt equalSmallArray;\
equalSmallJsonArrayFt equalArray;\
+ equalSmallJsonCArrayFt equalCArray;\
equalSmallJsonBaseFt equalBase;\
equalSmallJsonChaFt equalCha;\
equalSmallJsonCharFt equalChar;\
@@ -3207,6 +3242,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
equalSmallJsonSmallDictFt equalSmallDict;\
icEqualSmallJsonSmallArrayFt icEqualSmallArray;\
icEqualSmallJsonArrayFt icEqualArray;\
+ icEqualSmallJsonCArrayFt icEqualCArray;\
icEqualSmallJsonBaseFt icEqualBase;\
icEqualSmallJsonSmallDictFt icEqualSmallDict;\
icEqualSmallJsonSmallJsonFt icEqualSmallJson;\
@@ -3589,7 +3625,7 @@ smallJsont* setTopNFreeSmallIntSmallJsonG (smallJsont *self, smallIntt *value)
smallJsont* setTopNFreeSmallJsonSmallJsonG (smallJsont *self, smallJsont *value);
smallJsont* setTopNFreeSmallStringSmallJsonG(smallJsont *self, smallStringt *value);
-smallJsont* fromArraySmallJsonG(smallJsont *self, char **array, size_t size);
+smallJsont* fromArraySmallJsonG (smallJsont *self, char **array, size_t size);
smallJsont* fromCArraySmallJsonG(smallJsont *self, const char **array, size_t size);
baset* getTopSmallJsonG (smallJsont *self,baset* retType UNUSED);
@@ -3625,7 +3661,7 @@ smallJsont* pushSSmallJsonG (smallJsont *self, const char *string);
smallJsont* pushCharSmallJsonG (smallJsont *self, char c);
smallJsont* pushDictSmallJsonG (smallJsont *self, smallDictt *dict);
smallJsont* pushArraySmallJsonG (smallJsont *self, smallArrayt *array);
-smallJsont* pushArraycSmallJsonG (smallJsont *self, char **array);
+smallJsont* pushArraycSmallJsonG (smallJsont *self, char **array);
smallJsont* pushCArraycSmallJsonG (smallJsont *self, const char **array);
smallJsont* pushVoidSmallJsonG (smallJsont *self, void *value);
smallJsont* pushSmallBoolSmallJsonG (smallJsont *self, smallBoolt *value);
@@ -4078,7 +4114,7 @@ ssize_t binarySearchCharSmallJsonG (smallJsont *self, char c);
ssize_t binarySearchDictSmallJsonG (smallJsont *self, smallDictt *dict);
ssize_t binarySearchArraySmallJsonG (smallJsont *self, smallArrayt *array);
ssize_t binarySearchArraycSmallJsonG (smallJsont *self, char **array);
-ssize_t binarySearchCArraycSmallJsonG (smallJsont *self, const char **array);
+ssize_t binarySearchCArraycSmallJsonG (smallJsont *self, const char **array);
ssize_t binarySearchSmallBoolSmallJsonG (smallJsont *self, smallBoolt *value);
ssize_t binarySearchSmallBytesSmallJsonG (smallJsont *self, smallBytest *value);
ssize_t binarySearchSmallDoubleSmallJsonG (smallJsont *self, smallDoublet *value);
@@ -4358,7 +4394,7 @@ bool appendTextJsonSmallJsonG (smallJsont *self, smallJsont *filePath);
*/
#define forEachSmallJson(array, element) \
size_t UNIQVAR(libsheepyInternalIndex) = 0; \
- for (baset *element = array->f->getAt(array, 0); UNIQVAR(libsheepyInternalIndex) < array->f->len(array) ; UNIQVAR(libsheepyInternalIndex)++, element = array->f->getAt(array, UNIQVAR(libsheepyInternalIndex))) \
+ for (baset *element = array->f->getAt(array, 0); UNIQVAR(libsheepyInternalIndex) < array->f->len(array) ; UNIQVAR(libsheepyInternalIndex)++, element = array->f->getAt(array, (int64_t)UNIQVAR(libsheepyInternalIndex))) \
if (element)
/**
@@ -4376,7 +4412,7 @@ bool appendTextJsonSmallJsonG (smallJsont *self, smallJsont *filePath);
*/
#define enumerateSmallJson(array, element, index) \
size_t index = 0; \
- for (baset *element = array->f->getAt(array, 0); index < array->f->len(array) ; index++, element = array->f->getAt(array, index)) \
+ for (baset *element = array->f->getAt(array, 0); index < array->f->len(array) ; index++, element = array->f->getAt(array, (int64_t)index)) \
if (element)
// end class smallJson
diff --git a/src/json/libsheepyCSmallJsonInternal.h b/src/json/libsheepyCSmallJsonInternal.h
@@ -58,8 +58,8 @@ declareRecycle(smallJsont);
/* array index */\
const char *next = findS((key+i+1), "]");\
if (next) {\
- size_t keyLen = next - (key+i+1);\
- char *keyInPath = sliceS((key+i+1), 0, keyLen);\
+ size_t keyLen = (size_t)(next - (key+i+1));\
+ char *keyInPath = sliceS((key+i+1), 0, (int64_t)keyLen);\
\
if (oo) {\
/* oo is from the smallJson and is an array */\
@@ -83,7 +83,7 @@ declareRecycle(smallJsont);
break;\
}\
else {\
- oo = sArrayGetP(*a, idx);\
+ oo = sArrayGetP(*a, (uint32_t)idx);\
getSmallObj;\
}\
free(keyInPath);\
@@ -96,7 +96,7 @@ declareRecycle(smallJsont);
status = 0;\
const char *next = key+i;\
size_t keyLen = i - keyIdx;\
- char *keyInPath = sliceS((key+keyIdx), 0, keyLen);\
+ char *keyInPath = sliceS((key+keyIdx), 0, (int64_t)keyLen);\
\
if (oo) {\
/* oo is from the smallJson and is a dict */\
@@ -131,55 +131,55 @@ declareRecycle(smallJsont);
// (it means baset was not a smallObject, it was a user class instead)
// - free the sObjects that not stored in a smallObject (newly allocated)
#define setJsonPath\
- walkJsonPath(if (!oo) {free(keyInPath); if(isNew){free(o);} return NULL;}/*getSmallObj*/, sArraySetTiny(*a, idx, o)/*arrayCode*/, sDictSetTiny(d, keyInPath, o)/*dictCode*/, /*returnFail*/, sDictSetTiny(&(self->top), key, o); return self/*directHit*/, if(isNew){free(o);} return NULL/*keyErrorReturn*/)
+ walkJsonPath(if (!oo) {free(keyInPath); if(isNew){free(o);} return NULL;}/*getSmallObj*/, sArraySetTiny(*a, (uint32_t)idx, o)/*arrayCode*/, sDictSetTiny(d, keyInPath, o)/*dictCode*/, /*returnFail*/, sDictSetTiny(&(self->top), key, o); return self/*directHit*/, if(isNew){free(o);} return NULL/*keyErrorReturn*/)
// for setArrayc, the strings are newly allocated so sFree has to used instead
// of free to avoid memory leaks
#define setJsonPathsFree\
- walkJsonPath(if (!oo) {free(keyInPath); if(isNew){sFree(o);} return NULL;}/*getSmallObj*/, sArraySetTiny(*a, idx, o)/*arrayCode*/, sDictSetTiny(d, keyInPath, o)/*dictCode*/, /*returnFail*/, sDictSetTiny(&(self->top), key, o); return self/*directHit*/, if(isNew){sFree(o);} return NULL/*keyErrorReturn*/)
+ walkJsonPath(if (!oo) {free(keyInPath); if(isNew){sFree(o);} return NULL;}/*getSmallObj*/, sArraySetTiny(*a, (uint32_t)idx, o)/*arrayCode*/, sDictSetTiny(d, keyInPath, o)/*dictCode*/, /*returnFail*/, sDictSetTiny(&(self->top), key, o); return self/*directHit*/, if(isNew){sFree(o);} return NULL/*keyErrorReturn*/)
#define setJsonPathWithoutReturn\
- walkJsonPath(if (!oo) {free(keyInPath);if(isNew){free(o);}return NULL;}/*getSmallObj*/, sArraySetTiny(*a, idx, o)/*arrayCode*/, sDictSetTiny(d, keyInPath, o)/*dictCode*/, /*returnFail*/, sDictSetTiny(&(self->top), key, o); goto UNIQVAR(walkEnd)/*directHit*/, if(isNew){free(o);}return NULL/*keyErrorReturn*/)
+ walkJsonPath(if (!oo) {free(keyInPath);if(isNew){free(o);}return NULL;}/*getSmallObj*/, sArraySetTiny(*a, (uint32_t)idx, o)/*arrayCode*/, sDictSetTiny(d, keyInPath, o)/*dictCode*/, /*returnFail*/, sDictSetTiny(&(self->top), key, o); goto UNIQVAR(walkEnd)/*directHit*/, if(isNew){free(o);}return NULL/*keyErrorReturn*/)
#define setPJsonPath(objP)\
- walkJsonPath(if (!oo) {free(keyInPath);return NULL;}/*getSmallObj*/, sArraySetP(*a, idx, objP)/*arrayCode*/, sDictSetP(d, keyInPath, objP)/*dictCode*/, /*returnFail*/, sDictSetP(&(self->top), key, objP); return self/*directHit*/, return NULL/*keyErrorReturn*/)
+ walkJsonPath(if (!oo) {free(keyInPath);return NULL;}/*getSmallObj*/, sArraySetP(*a, (uint32_t)idx, objP)/*arrayCode*/, sDictSetP(d, keyInPath, objP)/*dictCode*/, /*returnFail*/, sDictSetP(&(self->top), key, objP); return self/*directHit*/, return NULL/*keyErrorReturn*/)
#define setPNFreeJsonPath(objP, finishArg)\
- walkJsonPath(if (!oo) {free(keyInPath);return NULL;}/*getSmallObj*/, sArraySetP(*a, idx, objP)/*arrayCode*/, sDictSetP(d, keyInPath, objP)/*dictCode*/, /*returnFail*/, sDictSetP(&(self->top), key, objP); finishArg ; return self/*directHit*/, return NULL/*keyErrorReturn*/)
+ walkJsonPath(if (!oo) {free(keyInPath);return NULL;}/*getSmallObj*/, sArraySetP(*a, (uint32_t)idx, objP)/*arrayCode*/, sDictSetP(d, keyInPath, objP)/*dictCode*/, /*returnFail*/, sDictSetP(&(self->top), key, objP); finishArg ; return self/*directHit*/, return NULL/*keyErrorReturn*/)
// this macro jumps to the 'fail' label when there is an error
// and jumps to the 'pass' label when the element is found and the o variable is set
#define getJsonPath\
- walkJsonPath(if (!oo) {free(keyInPath);goto fail;} o = *oo/*getSmallObj*/, if (!*a) {free(keyInPath);goto fail;} o = sArrayGetTiny(*a, idx)/*arrayCode*/, if (!*d) {free(keyInPath);goto fail;} o = sDictGetTiny(*d, keyInPath)/*dictCode*/, if (!self->top) goto fail/*returnFail*/, o = sDictGetTiny(self->top, key); goto pass/*directHit*/, goto fail/*keyErrorReturn*/)
+ walkJsonPath(if (!oo) {free(keyInPath);goto fail;} o = *oo/*getSmallObj*/, if (!*a) {free(keyInPath);goto fail;} o = sArrayGetTiny(*a, (uint32_t)idx)/*arrayCode*/, if (!*d) {free(keyInPath);goto fail;} o = sDictGetTiny(*d, keyInPath)/*dictCode*/, if (!self->top) goto fail/*returnFail*/, o = sDictGetTiny(self->top, key); goto pass/*directHit*/, goto fail/*keyErrorReturn*/)
#define delJsonPath\
- walkJsonPath(if (!oo) {free(keyInPath);return NULL;}/*getSmallObj*/, if (!*a) {free(keyInPath);return NULL;} sArrayDelTiny(*a, idx)/*arrayCode*/, if (!*d) {free(keyInPath);return NULL;} sDictDelTiny(*d, keyInPath)/*dictCode*/, if (!self->top) return NULL/*returnFail*/, sDictDelTiny(self->top, key) ; return self/*directHit*/, return NULL/*keyErrorReturn*/)
+ walkJsonPath(if (!oo) {free(keyInPath);return NULL;}/*getSmallObj*/, if (!*a) {free(keyInPath);return NULL;} sArrayDelTiny(*a, (uint32_t)idx)/*arrayCode*/, if (!*d) {free(keyInPath);return NULL;} sDictDelTiny(*d, keyInPath)/*dictCode*/, if (!self->top) return NULL/*returnFail*/, sDictDelTiny(self->top, key) ; return self/*directHit*/, return NULL/*keyErrorReturn*/)
#define removeJsonPath\
- walkJsonPath(if (!oo) {free(keyInPath);return NULL;}/*getSmallObj*/, if (!*a) {free(keyInPath);return NULL;} sArraySetShortTiny(*a, idx, NULL)/*arrayCode*/, if (!*d) {free(keyInPath);return NULL;} forEachSDict(*d, e) {if (e->key && eqS(keyInPath, e->key)) { free(e->key); e->key = NULL; break;} }/*dictCode*/, if (!self->top) return NULL/*returnFail*/, forEachSDict(self->top, e) {if (e->key && eqS(key, e->key)) { free(e->key); e->key = NULL; break;} } ; return self/*directHit*/, return NULL/*keyErrorReturn*/)
+ walkJsonPath(if (!oo) {free(keyInPath);return NULL;}/*getSmallObj*/, if (!*a) {free(keyInPath);return NULL;} sArraySetShortTiny(*a, (uint32_t)idx, NULL)/*arrayCode*/, if (!*d) {free(keyInPath);return NULL;} forEachSDict(*d, e) {if (e->key && eqS(keyInPath, e->key)) { free(e->key); e->key = NULL; break;} }/*dictCode*/, if (!self->top) return NULL/*returnFail*/, forEachSDict(self->top, e) {if (e->key && eqS(key, e->key)) { free(e->key); e->key = NULL; break;} } ; return self/*directHit*/, return NULL/*keyErrorReturn*/)
#define typeStringJsonPath\
- walkJsonPath(if (!oo) {free(keyInPath);return NULL;}/*getSmallObj*/, if (!*a) {free(keyInPath);return NULL;} o = sArrayGetTiny(*a, idx)/*arrayCode*/, if (!*d) {free(keyInPath);return NULL;} o = sDictGetTiny(*d, keyInPath)/*dictCode*/, if (!self->top) return NULL/*returnFail*/, o = sDictGet(self->top, key) ; if (!o) return NULL; return SMALL_TYPE_NAMES[(size_t)o->type]/*directHit*/, return NULL/*keyErrorReturn*/)
+ walkJsonPath(if (!oo) {free(keyInPath);return NULL;}/*getSmallObj*/, if (!*a) {free(keyInPath);return NULL;} o = sArrayGetTiny(*a, (uint32_t)idx)/*arrayCode*/, if (!*d) {free(keyInPath);return NULL;} o = sDictGetTiny(*d, keyInPath)/*dictCode*/, if (!self->top) return NULL/*returnFail*/, o = sDictGet(self->top, key) ; if (!o) return NULL; return SMALL_TYPE_NAMES[(size_t)o->type]/*directHit*/, return NULL/*keyErrorReturn*/)
#define typeJsonPath\
- walkJsonPath(if (!oo) {free(keyInPath);return 0;}/*getSmallObj*/, if (!*a) {free(keyInPath);return 0;} o = sArrayGetTiny(*a, idx)/*arrayCode*/, if (!*d) {free(keyInPath);return 0;} o = sDictGetTiny(*d, keyInPath)/*dictCode*/, if (!self->top) return 0/*returnFail*/, o = sDictGet(self->top, key) ; if (!o) return 0; return o->type/*directHit*/, return 0/*keyErrorReturn*/)
+ walkJsonPath(if (!oo) {free(keyInPath);return 0;}/*getSmallObj*/, if (!*a) {free(keyInPath);return 0;} o = sArrayGetTiny(*a, (uint32_t)idx)/*arrayCode*/, if (!*d) {free(keyInPath);return 0;} o = sDictGetTiny(*d, keyInPath)/*dictCode*/, if (!self->top) return 0/*returnFail*/, o = sDictGet(self->top, key) ; if (!o) return 0; return o->type/*directHit*/, return 0/*keyErrorReturn*/)
#define isEJsonPath(test)\
- walkJsonPath(if (!oo) {free(keyInPath);return 0;}/*getSmallObj*/, if (!*a) {free(keyInPath);return 0;} o = sArrayGetTiny(*a, idx)/*arrayCode*/, if (!*d) {free(keyInPath);return 0;} o = sDictGetTiny(*d, keyInPath)/*dictCode*/, if (!self->top) return 0/*returnFail*/, o = sDictGet(self->top, key) ; if (!o) return false; return test/*directHit*/, return 0/*keyErrorReturn*/)
+ walkJsonPath(if (!oo) {free(keyInPath);return 0;}/*getSmallObj*/, if (!*a) {free(keyInPath);return 0;} o = sArrayGetTiny(*a, (uint32_t)idx)/*arrayCode*/, if (!*d) {free(keyInPath);return 0;} o = sDictGetTiny(*d, keyInPath)/*dictCode*/, if (!self->top) return 0/*returnFail*/, o = sDictGet(self->top, key) ; if (!o) return false; return test/*directHit*/, return 0/*keyErrorReturn*/)
#define mainSetJsonPathWithoutReturn(initValue, allocValue, subSetJsonPath) \
smallt *o = NULL;\
if (!key)\
return NULL;\
- jsonPathRest keyType = keyIsSmallJson(self, key);\
- if (self->topIsA != SMALLJSON_IS_EMPTY && ((keyType == ARRAY_PATH && self->topIsA != TOP_IS_ARRAY) || ((keyType == NOT_A_PATH || keyType == DICT_PATH) && self->topIsA != TOP_IS_DICT)))\
+ jsonPathRest kType = keyIsSmallJson(self, key);\
+ if (self->topIsA != SMALLJSON_IS_EMPTY && ((kType == ARRAY_PATH && self->topIsA != TOP_IS_ARRAY) || ((kType == NOT_A_PATH || kType == DICT_PATH) && self->topIsA != TOP_IS_DICT)))\
return NULL;\
initValue;\
switch(self->topIsA) {\
case SMALLJSON_IS_EMPTY:\
- if (keyType == NOT_A_PATH || keyType == DICT_PATH)\
+ if (kType == NOT_A_PATH || kType == DICT_PATH)\
self->topIsA = TOP_IS_DICT;\
- else if (keyType == ARRAY_PATH)\
+ else if (kType == ARRAY_PATH)\
self->topIsA = TOP_IS_ARRAY;\
FALLTHRU;\
case TOP_IS_ARRAY:\
@@ -189,6 +189,7 @@ declareRecycle(smallJsont);
allocValue;\
subSetJsonPath;\
break;\
+ default:; /* do nothing */\
}
diff --git a/src/json/libsheepyCSmallString.c b/src/json/libsheepyCSmallString.c
@@ -77,7 +77,7 @@ internal smallStringt* setNFreeSmallString(smallStringt *self, char *string);
internal smallStringt* appendSmallString(smallStringt *self, smallStringt *string);
internal smallStringt* appendSmallJsonSmallString(smallStringt *self, smallJsont *string);
internal smallStringt* appendNSmashSmallString(smallStringt *self, smallStringt *string);
-internal smallStringt* appendSSmallString(smallStringt *self, char *string);
+internal smallStringt* appendSSmallString(smallStringt *self, const char *string);
internal smallStringt* appendCharSmallString(smallStringt *self, char c);
internal smallStringt* appendNSmashSmallJsonSmallString(smallStringt *self, smallJsont *string);
internal smallStringt* appendNSmashSSmallString(smallStringt *self, char *string);
@@ -85,7 +85,7 @@ internal smallStringt* prependSmallString(smallStringt *self, smallStringt *stri
internal smallStringt* prependSmallJsonSmallString(smallStringt *self, smallJsont *json);
internal smallStringt* prependNSmashSmallString(smallStringt *self, smallStringt *string);
internal smallStringt* prependNSmashSmallJsonSmallString(smallStringt *self, smallJsont *json);
-internal smallStringt* prependSSmallString(smallStringt *self, char *string);
+internal smallStringt* prependSSmallString(smallStringt *self, const char *string);
internal smallStringt* prependCharSmallString(smallStringt *self, char c);
internal smallStringt* prependNSmashSSmallString(smallStringt *self, char *string);
internal smallStringt* catSmallString(smallStringt *self, ...);
@@ -829,7 +829,7 @@ smallStringt* allocSmallString(const char *string) {
if (!r) {
return(NULL);
}
- r->f->set(r, (char *)string);
+ r->f->set(r, string);
return(r);
}
@@ -864,10 +864,10 @@ smallStringt* createSF(const char *paramType, ...) {
// add arguments to a list
va_start(pl, paramType);
- paramType = va_arg(pl, char *);
+ paramType = va_arg(pl, const char *);
while (paramType) {
- l.f->pushS(&l, (char *)paramType);
- paramType = va_arg(pl, char *);
+ l.f->pushS(&l, paramType);
+ paramType = va_arg(pl, const char *);
}
va_end(pl);
// join list with empty delimiter
@@ -1025,7 +1025,7 @@ internal smallStringt* setUint32SmallString(smallStringt* self, uint32_t p2) {
internal smallStringt* setUint64SmallString(smallStringt* self, uint64_t p2) {
- intToSmallString(self, p2);
+ intToSmallString(self, (int64_t)p2);
return(self);
}
@@ -1300,7 +1300,7 @@ internal smallStringt* appendNSmashSmallString(smallStringt *self, smallStringt
return(self);
}
-internal smallStringt* appendSSmallString(smallStringt *self, char *string) {
+internal smallStringt* appendSSmallString(smallStringt *self, const char *string) {
// sanity
if (!string) {
@@ -1477,7 +1477,7 @@ internal smallStringt* prependNSmashSmallJsonSmallString(smallStringt *self, sma
return(r);
}
-internal smallStringt* prependSSmallString(smallStringt *self, char *string) {
+internal smallStringt* prependSSmallString(smallStringt *self, const char *string) {
// sanity
if (!string) {
@@ -1660,8 +1660,6 @@ internal smallStringt* replaceSmallString(smallStringt *self, const char *olds,
char *ins = NULL;
size_t count;
size_t lfront;
- bool freeNewsStatus = false;;
- char *internalNews = NULL;
// sanity checks and initialization
// count the number of replacements needed
@@ -1687,12 +1685,8 @@ internal smallStringt* replaceSmallString(smallStringt *self, const char *olds,
return(NULL);
}
if (!news) {
- // empty smallString for NULL
- freeNewsStatus = true;
- emptyS(internalNews)
- }
- else {
- internalNews = (char *) news;
+ // empty string for NULL
+ news = "";
}
// count the number of replacements needed
@@ -1707,16 +1701,13 @@ internal smallStringt* replaceSmallString(smallStringt *self, const char *olds,
size_t lnews;
- lnews = strlen(internalNews);
+ lnews = strlen(news);
// allocate result
// +1 for 0 at the end +1 for sType at the start
size_t rLen = self->_len + (lnews - lolds) * count + 2;;
tmp = r = malloc(rLen);
if (!r) {
- if (freeNewsStatus) {
- free(internalNews);
- }
return(NULL);
}
@@ -1729,17 +1720,14 @@ internal smallStringt* replaceSmallString(smallStringt *self, const char *olds,
// s is the remainder of s after end of olds
while (count--) {
ins = strstr(workingS, olds);
- lfront = ins - workingS;
+ lfront = (size_t)(ins - workingS);
tmp = strncpy(tmp, workingS, lfront) + lfront;
- tmp = strcpy(tmp, internalNews) + lnews;
+ tmp = strcpy(tmp, news) + lnews;
workingS += lfront + lolds;
}
// copy end of smallString
strcpy(tmp, workingS);
- if (freeNewsStatus) {
- free(internalNews);
- }
free(self->data);
self->data = (sStringt *)r;
@@ -2108,8 +2096,8 @@ internal smallStringt* replaceCharSmallStringSmallString(smallStringt *self, cha
internal smallStringt* replaceManySmallString(smallStringt *self, const char *paramType, ...) {
va_list pl;
- char *olds = NULL;
- char *news = NULL;
+ const char *olds = NULL;
+ const char *news = NULL;
// sanity checks
if (!self->data) {
@@ -2120,11 +2108,11 @@ internal smallStringt* replaceManySmallString(smallStringt *self, const char *pa
return(self);
}
- olds = (char *) paramType;;
+ olds = paramType;;
// add arguments to a list
va_start(pl, paramType);
- paramType = va_arg(pl, char *);
+ paramType = va_arg(pl, const char *);
if (!paramType) {
// missing news
va_end(pl);
@@ -2132,10 +2120,10 @@ internal smallStringt* replaceManySmallString(smallStringt *self, const char *pa
}
while (paramType) {
if (!olds) {
- olds = (char *) paramType;
+ olds = paramType;
}
else if (!news) {
- news = (char *) paramType;
+ news = paramType;
smallStringt *r = replaceSmallString(self, olds, news, 0);
if (!r) {
// replace error
@@ -2146,7 +2134,7 @@ internal smallStringt* replaceManySmallString(smallStringt *self, const char *pa
news = NULL;
}
- paramType = va_arg(pl, char *);
+ paramType = va_arg(pl, const char *);
}
va_end(pl);
return(self);
@@ -2160,8 +2148,6 @@ internal smallStringt* icReplaceSmallString(smallStringt *self, const char *olds
char *ins = NULL;
size_t count;
size_t lfront;
- bool freeNewsStatus = false;;
- char *internalNews = NULL;
// sanity checks and initialization
// count the number of replacements needed
@@ -2187,12 +2173,8 @@ internal smallStringt* icReplaceSmallString(smallStringt *self, const char *olds
return(NULL);
}
if (!news) {
- // empty smallString for NULL
- freeNewsStatus = true;
- emptyS(internalNews)
- }
- else {
- internalNews = (char *) news;
+ // empty string for NULL
+ news = "";
}
// count the number of replacements needed
@@ -2207,16 +2189,13 @@ internal smallStringt* icReplaceSmallString(smallStringt *self, const char *olds
size_t lnews;
- lnews = strlen(internalNews);
+ lnews = strlen(news);
// allocate result
// +1 for 0 at the end +1 for sType at the start
size_t rLen = self->_len + (lnews - lolds) * count + 2;;
tmp = r = malloc(rLen);
if (!r) {
- if (freeNewsStatus) {
- free(internalNews);
- }
return(NULL);
}
@@ -2229,17 +2208,14 @@ internal smallStringt* icReplaceSmallString(smallStringt *self, const char *olds
// s is the remainder of s after end of olds
while (count--) {
ins = strcasestr(workingS, olds);
- lfront = ins - workingS;
+ lfront = (size_t)(ins - workingS);
tmp = strncpy(tmp, workingS, lfront) + lfront;
- tmp = strcpy(tmp, internalNews) + lnews;
+ tmp = strcpy(tmp, news) + lnews;
workingS += lfront + lolds;
}
// copy end of smallString
strcpy(tmp, workingS);
- if (freeNewsStatus) {
- free(internalNews);
- }
free(self->data);
self->data = (sStringt *)r;
@@ -2608,8 +2584,8 @@ internal smallStringt* icReplaceCharSmallStringSmallString(smallStringt *self, c
internal smallStringt* icReplaceManySmallString(smallStringt *self, const char *paramType, ...) {
va_list pl;
- char *olds = NULL;
- char *news = NULL;
+ const char *olds = NULL;
+ const char *news = NULL;
// sanity checks
if (!self->data) {
@@ -2620,11 +2596,11 @@ internal smallStringt* icReplaceManySmallString(smallStringt *self, const char *
return(self);
}
- olds = (char *) paramType;;
+ olds = paramType;;
// add arguments to a list
va_start(pl, paramType);
- paramType = va_arg(pl, char *);
+ paramType = va_arg(pl, const char *);
if (!paramType) {
// missing news
va_end(pl);
@@ -2632,10 +2608,10 @@ internal smallStringt* icReplaceManySmallString(smallStringt *self, const char *
}
while (paramType) {
if (!olds) {
- olds = (char *) paramType;
+ olds = paramType;
}
else if (!news) {
- news = (char *) paramType;
+ news = paramType;
smallStringt *r = icReplaceSmallString(self, olds, news, 0);;
if (!r) {
// replace error
@@ -2646,7 +2622,7 @@ internal smallStringt* icReplaceManySmallString(smallStringt *self, const char *
news = NULL;
}
- paramType = va_arg(pl, char *);
+ paramType = va_arg(pl, const char *);
}
va_end(pl);
return(self);
@@ -2772,7 +2748,7 @@ internal bool equalSmallStringInt32(smallStringt* self, int32_t p2) {
return(false);
}
- int64_t selfValue = parseIntSmallString(self);
+ int32_t selfValue = (int32_t)parseIntSmallString(self);
return(selfValue == p2);;
}
@@ -2789,7 +2765,7 @@ internal bool equalSmallStringUint32(smallStringt* self, uint32_t p2) {
return(false);
}
- uint32_t selfValue = parseIntSmallString(self);
+ uint32_t selfValue = (uint32_t)parseIntSmallString(self);
return(selfValue == p2);;
}
@@ -2806,7 +2782,7 @@ internal bool equalSmallStringUint64(smallStringt* self, uint64_t p2) {
return(false);
}
- uint64_t selfValue = parseIntSmallString(self);
+ uint64_t selfValue = (uint64_t)parseIntSmallString(self);
return(selfValue == p2);;
}
@@ -3546,7 +3522,7 @@ internal smallStringt* upperSmallString(smallStringt *self) {
char *string = sStringGetTiny(self->data);
while (*string != 0) {
- *string = toupper(*string);
+ *string = (char)toupper(*string);
string++;
}
return(self);
@@ -3560,7 +3536,7 @@ internal smallStringt* lowerSmallString(smallStringt *self) {
char *string = sStringGetTiny(self->data);
while (*string != 0) {
- *string = tolower(*string);
+ *string = (char)tolower(*string);
string++;
}
return(self);
@@ -3601,7 +3577,7 @@ internal smallStringt* trimSmallString(smallStringt *self) {
}
// copy range to new smallString
- len = end - workingS + 2;
+ len = (size_t)(end - workingS + 2);
isError(r, malloc(len)) return(NULL);
r = strncpy(r, workingS, len - 1);
r[len - 1] = 0;
@@ -3705,7 +3681,7 @@ internal smallStringt* icUniqSmallString(smallStringt *self, char c) {
char *string = sStringGetTiny(self->data);
- c = tolower(c);
+ c = (char)tolower(c);
// index in r
size_t j = 1;;
@@ -3737,7 +3713,7 @@ internal char getAtSmallString(smallStringt *self, int64_t index) {
return(0);
}
if (index < 0) {
- index = self->_len + index;
+ index = (int64_t)self->_len + index;
}
return(*(sStringGetTiny(self->data)+index));
@@ -3756,7 +3732,7 @@ internal smallStringt* setAtSmallString(smallStringt *self, int64_t index, char
return(NULL);
}
if (index < 0) {
- index = self->_len + index;
+ index = (int64_t)self->_len + index;
}
*(sStringGetTiny(self->data)+index) = c;
@@ -3776,20 +3752,20 @@ internal smallStringt* sliceSmallString(smallStringt *self, int64_t start, int64
return(NULL);
}
if (end > (int64_t)self->_len) {
- end = self->_len;
+ end = (int64_t)self->_len;
}
if (start <= -(int64_t)self->_len) {
- start = -self->_len;
+ start = -(int64_t)self->_len;
}
if (end <= -(int64_t)self->_len) {
emptySmallString(self);
return(NULL);
}
if (start < 0) {
- start = self->_len + start;
+ start = (int64_t)self->_len + start;
}
if (end <= 0) {
- end = self->_len + end;
+ end = (int64_t)self->_len + end;
}
if (end < start) {
emptySmallString(self);
@@ -3804,11 +3780,11 @@ internal smallStringt* sliceSmallString(smallStringt *self, int64_t start, int64
// start < end < len
// copy range to a new smallString
n = end - start;
- s = malloc(n+1);
+ s = malloc((size_t)n+1);
if (!s) {
return(NULL);
}
- s = strncpy(s, sStringGetTiny(self->data) + start, n);
+ s = strncpy(s, sStringGetTiny(self->data) + start, (size_t)n);
s[n] = 0;
}
@@ -3842,7 +3818,7 @@ internal char* cropSSmallString(smallStringt *self, int64_t start, int64_t end)
return(NULL);
}
- len = self->_len;
+ len = (int64_t)self->_len;
if (start > len) {
return(NULL);
@@ -3870,14 +3846,14 @@ internal char* cropSSmallString(smallStringt *self, int64_t start, int64_t end)
// start < end < len
int64_t n;
n = end - start;
- l = malloc((n+1) * sizeof(char));
+ l = malloc((size_t)(n+1) * sizeof(char));
if (!l) {
return(NULL);
}
char *string = sStringGetTiny(self->data);
- strLCpy(l, (n+1) * sizeof(char), string+start);
- strLCpy(string+start, len-end+1, string+end);
- self->_len -= n;
+ pErrorNULL(strLCpy(l, (size_t)(n+1) * sizeof(char), string+start));
+ memmove(string+start, string+end, (size_t)(len-end+1));
+ self->_len -= (size_t)n;
}
else {
// start = end, return empty string
@@ -3917,7 +3893,7 @@ internal char cropElemSmallString(smallStringt *self, int64_t index) {
return(0);
}
- len = self->_len;
+ len = (int64_t)self->_len;
if (index >= len) {
return(0);
}
@@ -3936,7 +3912,7 @@ internal char cropElemSmallString(smallStringt *self, int64_t index) {
string[len-1] = 0;
}
else {
- strLCpy(string+index, len - index, string+index+1);
+ memmove(string+index, string+index+1, (size_t)(len - index));
}
self->_len--;
@@ -3958,19 +3934,19 @@ internal smallStringt* copySmallString(smallStringt *self, int64_t start, int64_
return(NULL);
}
if (end > (int64_t)self->_len) {
- end = self->_len;
+ end = (int64_t)self->_len;
}
if (start <= -(int64_t)self->_len) {
- start = -self->_len;
+ start = -(int64_t)self->_len;
}
if (end <= -(int64_t)self->_len) {
return(NULL);
}
if (start < 0) {
- start = self->_len + start;
+ start = (int64_t)self->_len + start;
}
if (end <= 0) {
- end = self->_len + end;
+ end = (int64_t)self->_len + end;
}
if (end < start) {
return(NULL);
@@ -3984,11 +3960,11 @@ internal smallStringt* copySmallString(smallStringt *self, int64_t start, int64_
// start < end < len
// copy range to a new smallString
n = end - start;
- s = malloc(n+1);
+ s = malloc((size_t)n+1);
if (!s) {
return(NULL);
}
- s = strncpy(s, sStringGetTiny(self->data) + start, n);
+ s = strncpy(s, sStringGetTiny(self->data) + start, (size_t)n);
s[n] = 0;
}
@@ -4041,7 +4017,7 @@ internal smallStringt* insertSmallString(smallStringt *self, int64_t index, smal
return(NULL);
}
if (neg) {
- index = self->_len + index;
+ index = (int64_t)self->_len + index;
}
if (!toInsert->data || !toInsert->_len) {
@@ -4127,7 +4103,7 @@ internal smallStringt* insertSSmallString(smallStringt *self, int64_t index, con
return(NULL);
}
if (neg) {
- index = self->_len + index;
+ index = (int64_t)self->_len + index;
}
if (!*toInsert) {
@@ -4213,7 +4189,7 @@ internal smallStringt* injectSmallString(smallStringt *self, int64_t index, char
return(NULL);
}
if (neg) {
- index = self->_len + index;
+ index = (int64_t)self->_len + index;
}
@@ -4247,22 +4223,22 @@ internal smallStringt* delSmallString(smallStringt *self, int64_t start, int64_t
}
if (start >= (int64_t)self->_len) {
- start = self->_len;
+ start = (int64_t)self->_len;
}
if (end > (int64_t)self->_len) {
- end = self->_len;
+ end = (int64_t)self->_len;
}
if (start <= -(int64_t)self->_len) {
- start = -self->_len;
+ start = -(int64_t)self->_len;
}
if (end <= -(int64_t)self->_len) {
- end = -self->_len;
+ end = -(int64_t)self->_len;
}
if (start < 0) {
- start = self->_len + start;
+ start = (int64_t)self->_len + start;
}
if (end <= 0) {
- end = self->_len + end;
+ end = (int64_t)self->_len + end;
}
if (end < start) {
return(NULL);
@@ -4277,18 +4253,18 @@ internal smallStringt* delSmallString(smallStringt *self, int64_t start, int64_t
int64_t n;
n = end - start;
// +2 for sType at the beginning
- s = malloc(self->_len - n +2);
+ s = malloc(self->_len - (size_t)n +2);
if (!s) {
return(NULL);
}
// +1 for sType
- strncpy(s, (char *)self->data, start+1);
- strncpy(s+start+1, (char *)self->data + end +1, self->_len - end);
- s[self->_len - n +1] = 0;
+ strncpy(s, (char *)self->data, (size_t)start+1);
+ strncpy(s+start+1, (char *)self->data + end +1, self->_len - (size_t)end);
+ s[self->_len - (size_t)n +1] = 0;
free(self->data);
self->data = (sStringt *)s;
- self->_len -= n;
+ self->_len -= (size_t)n;
return(self);
}
@@ -4307,7 +4283,7 @@ internal smallStringt* delElemSmallString(smallStringt *self, int64_t index) {
return(0);
}
if (index < 0) {
- index = self->_len + index;
+ index = (int64_t)self->_len + index;
}
// copy range to a new smallString
@@ -4317,8 +4293,8 @@ internal smallStringt* delElemSmallString(smallStringt *self, int64_t index) {
return(NULL);
}
// +1 for sType
- strncpy(s, (char *)self->data, index+1);
- strncpy(s+index+1, (char *)self->data + index+1 +1, self->_len - (index+1));
+ strncpy(s, (char *)self->data, (size_t)index+1);
+ strncpy(s+index+1, (char *)self->data + index+1 +1, self->_len - (size_t)(index+1));
s[self->_len - 1 +1] = 0;
free(self->data);
@@ -4765,7 +4741,7 @@ internal char** splitSSmallString(smallStringt *self, const char *delim) {
if (!*delim || !*sStringGetTiny(self->data)) {
// empty delimiter or empty string
- listPushS(&r, sStringGetTiny(self->data));
+ pErrorNULL(listPushS(&r, sStringGetTiny(self->data)));
return(r);
}
@@ -4775,7 +4751,7 @@ internal char** splitSSmallString(smallStringt *self, const char *delim) {
line = workingSmallString;
while (strlen(workingSmallString) != 0) {
token = tokS(line, delim, &workingSmallString);
- listPushS(&r, token);
+ pErrorNULL(listPushS(&r, token));
// mac os sets workingSmallString to NULL at the end
if (!workingSmallString) {
break; //LCOV_EXCL_LINE
@@ -4791,7 +4767,7 @@ internal char** splitSSmallString(smallStringt *self, const char *delim) {
size_t lenD = strlen(delim);
// +1 for sType
if (strEq(sStringGetTiny(self->data)+(self->_len-lenD), delim)) {
- listPushS(&r, "");
+ pErrorNULL(listPushS(&r, ""));
}
return(r);
@@ -4856,12 +4832,12 @@ internal smallArrayt* extractSmallString(smallStringt *self, const char* delim1,
}
// remove first element
- iListSliceS(&tmp, 1, 0);
+ pErrorNULL(iListSliceS(&tmp, 1, 0));
forEachCharP(tmp, e) {
char **tmp2 = split(*e, delim2);
if (listLengthS(tmp2) > 1) {
- listPushS(&r, tmp2[0]);
+ pErrorNULL(listPushS(&r, tmp2[0]));
}
listFreeS(tmp2);
}
@@ -5188,7 +5164,7 @@ internal char** icSplitSSmallString(smallStringt *self, const char *delim) {
if (!*delim || !*sStringGetTiny(self->data)) {
// empty delimiter or empty string
- listPushS(&r, sStringGetTiny(self->data));
+ pErrorNULL(listPushS(&r, sStringGetTiny(self->data)));
return(r);
}
@@ -5198,7 +5174,7 @@ internal char** icSplitSSmallString(smallStringt *self, const char *delim) {
line = workingSmallString;
while (strlen(workingSmallString) != 0) {
token = icTokS(line, delim, &workingSmallString);
- listPushS(&r, token);
+ pErrorNULL(listPushS(&r, token));
// mac os sets workingSmallString to NULL at the end
if (!workingSmallString) {
break; //LCOV_EXCL_LINE
@@ -5214,7 +5190,7 @@ internal char** icSplitSSmallString(smallStringt *self, const char *delim) {
size_t lenD = strlen(delim);
// +1 for sType
if (icEqS(sStringGetTiny(self->data)+(self->_len-lenD), delim)) {
- listPushS(&r, "");
+ pErrorNULL(listPushS(&r, ""));
}
return(r);
@@ -5279,12 +5255,12 @@ internal smallArrayt* icExtractSmallString(smallStringt *self, const char* delim
}
// remove first element
- iListSliceS(&tmp, 1, 0);
+ pErrorNULL(iListSliceS(&tmp, 1, 0));
forEachCharP(tmp, e) {
char **tmp2 = icSplit(*e, delim2);
if (listLengthS(tmp2) > 1) {
- listPushS(&r, tmp2[0]);
+ pErrorNULL(listPushS(&r, tmp2[0]));
}
listFreeS(tmp2);
}
@@ -5584,7 +5560,7 @@ internal smallStringt* readFileSmallString(smallStringt *self, const char *fileP
free(self->data);
// +1 to add \0 at the end
- self->data = malloc(len+2);
+ self->data = malloc((size_t)len+2);
if (!self->data) {
return(NULL);
}
@@ -5595,7 +5571,7 @@ internal smallStringt* readFileSmallString(smallStringt *self, const char *fileP
shEPrintfS("The path was: \"%s\"\n", filePath);
return(NULL);
}
- readStatus = fread(((char *)self->data)+1, 1, len , f);
+ readStatus = fread(((char *)self->data)+1, 1, (size_t)len , f);
fclose(f);
self->data->type = STRING;
@@ -5607,7 +5583,7 @@ internal smallStringt* readFileSmallString(smallStringt *self, const char *fileP
}
*((char*)self->data+len+1) = 0;
- self->_len = len;
+ self->_len = (size_t)len;
return(self);
}
@@ -5661,12 +5637,12 @@ internal smallStringt* readStreamSmallString(smallStringt *self, FILE *fp) {
free(self->data);
// +1 to add \0 at the end
- self->data = malloc(len+2);
+ self->data = malloc((size_t)len+2);
if (!self->data) {
return(NULL);
}
- readStatus = fread(&self->data->data, 1, len , fp);
+ readStatus = fread(&self->data->data, 1, (size_t)len , fp);
self->data->type = STRING;
@@ -5676,7 +5652,7 @@ internal smallStringt* readStreamSmallString(smallStringt *self, FILE *fp) {
}
*(&self->data->data+len) = 0;
- self->_len = len;
+ self->_len = (size_t)len;
return(self);
}
@@ -5916,7 +5892,7 @@ smallStringt* appendSmallJsonSmallStringG(smallStringt *self, smallJsont *string
smallStringt* appendSSmallStringG (smallStringt *self, const char *string) {
- return(self->f->appendS(self, (char*)string));
+ return(self->f->appendS(self, string));
}
smallStringt* appendCharSmallStringG(smallStringt *self, char c) {
@@ -5952,7 +5928,7 @@ smallStringt* prependSmallJsonSmallStringG(smallStringt *self, smallJsont *json)
smallStringt* prependSSmallStringG (smallStringt *self, const char *string) {
- return(self->f->prependS(self, (char*)string));
+ return(self->f->prependS(self, string));
}
smallStringt* prependCharSmallStringG(smallStringt *self, char c) {
diff --git a/src/json/libsheepyCSmallString.h b/src/json/libsheepyCSmallString.h
@@ -98,7 +98,7 @@ typedef smallStringt* (*setSmallStringSmallStringFt)(smallStringt* self, sma
*/
typedef smallStringt* (*appendSmallStringFt) (smallStringt *self, smallStringt *string);
typedef smallStringt* (*appendSmallJsonSmallStringFt) (smallStringt *self, smallJsont *string);
-typedef smallStringt* (*appendSSmallStringFt) (smallStringt *self, char *string);
+typedef smallStringt* (*appendSSmallStringFt) (smallStringt *self, const char *string);
typedef smallStringt* (*appendCharSmallStringFt) (smallStringt *self, char c);
typedef smallStringt* (*appendNSmashSmallStringFt) (smallStringt *self, smallStringt *string);
typedef smallStringt* (*appendNSmashSmallJsonSmallStringFt)(smallStringt *self, smallJsont *string);
@@ -114,7 +114,7 @@ typedef smallStringt* (*appendNSmashSSmallStringFt) (smallStringt *se
*/
typedef smallStringt* (*prependSmallStringFt) (smallStringt *self, smallStringt *string);
typedef smallStringt* (*prependSmallJsonSmallStringFt) (smallStringt *self, smallJsont *json);
-typedef smallStringt* (*prependSSmallStringFt) (smallStringt *self, char *string);
+typedef smallStringt* (*prependSSmallStringFt) (smallStringt *self, const char *string);
typedef smallStringt* (*prependCharSmallStringFt) (smallStringt *self, char c);
typedef smallStringt* (*prependNSmashSmallStringFt) (smallStringt *self, smallStringt *string);
typedef smallStringt* (*prependNSmashSmallJsonSmallStringFt)(smallStringt *self, smallJsont *json);
diff --git a/src/json/libsheepyObject.c b/src/json/libsheepyObject.c
@@ -274,7 +274,7 @@ char getSG(const char *string, int retType UNUSED, int64_t index);
char *listGetG(char **list, int retType UNUSED, int64_t index);
char *listGetCG(const char **list, int retType UNUSED, int64_t index);
char *iListGetG(char **list, int retType UNUSED, int64_t index);
-char *iListGetCG(const char **list, int retType UNUSED, int64_t index);
+const char *iListGetCG(const char **list, int retType UNUSED, int64_t index);
char *listPopG(char ***list, int retType UNUSED);
char *listDequeueG(char ***list, int retType UNUSED);
char **listDupCG(const char **list);
@@ -304,7 +304,7 @@ bool equalChaDoubleG(char c, double value);
bool equalChaInt64G(char c, int64_t value);
bool equalChaInt32G(char c, int32_t value);
bool equalChaUint32G(char c, uint32_t value);
-bool equalChaUint64G(char c, uint32_t value);
+bool equalChaUint64G(char c, uint64_t value);
bool equalChaSmallBytesG(char c, smallBytest* value);
bool equalChaSmallDoubleG(char c, smallDoublet* value);
bool equalChaSmallIntG(char c, smallIntt* value);
@@ -464,8 +464,8 @@ bool icEqualCharPSmallStringG(const char *s, smallStringt* value);
bool icEqualArrayOG(char ** p1, baset* p2);
bool icEqualCArrayOG(const char ** p1, baset* p2);
bool icEqualArraySmallJsonG(char ** p1, smallJsont* p2);
-bool icEqualArraySmallArrayG(char ** p1, smallArrayt* p2);
bool icEqualCArraySmallJsonG(const char ** p1, smallJsont* p2);
+bool icEqualArraySmallArrayG(char ** p1, smallArrayt* p2);
bool icEqualCArraySmallArrayG(const char ** p1, smallArrayt* p2);
bool icEqualOCharG(baset* p1, const char * p2);
bool icEqualOChaG(baset* p1, char p2);
@@ -535,13 +535,13 @@ smallDictt *shSysinfo(void) {
}
setIntO(r, "uptime", info.uptime);
- setIntO(r, "loads", info.loads[0]);
- setIntO(r, "totalram", info.totalram);
- setIntO(r, "freeram", info.freeram);
- setIntO(r, "sharedram", info.sharedram);
- setIntO(r, "bufferram", info.bufferram);
- setIntO(r, "totalswap", info.totalswap);
- setIntO(r, "freeswap", info.freeswap);
+ setIntO(r, "loads", (int64_t)info.loads[0]);
+ setIntO(r, "totalram", (int64_t)info.totalram);
+ setIntO(r, "freeram", (int64_t)info.freeram);
+ setIntO(r, "sharedram", (int64_t)info.sharedram);
+ setIntO(r, "bufferram", (int64_t)info.bufferram);
+ setIntO(r, "totalswap", (int64_t)info.totalswap);
+ setIntO(r, "freeswap", (int64_t)info.freeswap);
setIntO(r, "procs", info.procs);
return(r);
}
@@ -723,11 +723,12 @@ int systemNFreeOF(smallStringt *command, int line, const char *thisFunc, const c
* %m printf type specifier to print baset objects
*/
int print_m(FILE *stream, const struct printf_info *info, const void *const *args) {
- baset *o = NULL;
+ const baset *o = NULL;
char *b = NULL;
- size_t len;
+ int len;
- o = *((baset**) args[0]);
+ o = *((baset*const*) args[0]);
+ // warning OK: toString discards const qualifier -Wdiscarded-qualifiers
b = toStringO(o);
/* Pad to the minimum field width and print to the stream. */
@@ -871,7 +872,8 @@ void putsInt32PGF(int32_t* object) {
void putsUintGF(uint64_t object) {
char *s = NULL;
- s = intToS(object);
+ // TODO create uintToS
+ s = intToS((int64_t)object);
if (s) {
puts(s);
}
@@ -884,7 +886,8 @@ void putsUintPGF(uint64_t* object) {
if (!object) {
return;
}
- s = intToS(*object);
+ // TODO create uintToS
+ s = intToS((int64_t)*object);
if (s) {
puts(s);
}
@@ -924,12 +927,12 @@ void putsSGF(const char* object) {
void putsListSGF(char** object) {
- listPrintS(object);
+ pError0(listPrintS(object));
}
void putsListCSGF(const char** object) {
- listPrintS((char**)object);
+ pError0(listPrintCS(object));
}
void putsDictGF(smallDictt* object) {
@@ -1101,7 +1104,7 @@ char *toStringFloatGF(float object) {
char *s = NULL;
isError(s, malloc(256*sizeof(char))) return(NULL);
- snprintf(s,256, "%f", object);
+ snprintf(s,256, "%f", (double)object);
return(s);
}
@@ -1112,7 +1115,7 @@ char *toStringFloatPGF(float* object) {
return(NULL);
}
isError(s, malloc(256*sizeof(char))) return(NULL);
- snprintf(s,256, "%f", *object);
+ snprintf(s,256, "%f", (double)*object);
return(s);
}
@@ -1176,7 +1179,8 @@ char *toStringInt16PGF(int16_t* object) {
char *toStringUintGF(uint64_t object) {
- return(intToS(object));
+ // TODO create uintToS
+ return(intToS((int64_t)object));
}
char *toStringUintPGF(uint64_t* object) {
@@ -1184,7 +1188,8 @@ char *toStringUintPGF(uint64_t* object) {
if (!object) {
return(NULL);
}
- return(intToS(*object));
+ // TODO create uintToS
+ return(intToS((int64_t)*object));
}
char *toStringUint32GF(uint32_t object) {
@@ -1259,7 +1264,7 @@ char *toStringListCSGF(const char** object) {
if (!object) {
return(NULL);
}
- char *s = join((char**)object, "\",\"");
+ char *s = joinCS(object, "\",\"");
if (!s) {
return(NULL);
}
@@ -1393,7 +1398,7 @@ int execO(const char *cmd, smallArrayt *out, smallArrayt *err UNUSED) {
fp = popen(cmd, "r");
if (!fp) {
pFuncError
- shEPrintfS("The command was: \"%s\"\n", ssGet(cmd));
+ shEPrintfS("The command was: \"%s\"\n", cmd);
return(0);//LCOV_EXCL_LINE
}
@@ -2228,7 +2233,7 @@ smallStringt *normalizePathO(smallStringt *path) {
char **pathL = splitSO(path, "/");
// remove empty elements
- iListCompactS(&pathL);
+ pErrorNULL(iListCompactS(&pathL));
if (listIsEmptyS(pathL)) {
listFreeS(pathL);
@@ -2248,7 +2253,7 @@ smallStringt *normalizePathO(smallStringt *path) {
if (strEq(*level, "..")) {
if (onlyLeadingDoubleDots) {
// keep leading ..
- listPushS(&list, "..");
+ pErrorNULL(listPushS(&list, ".."));
}
else {
// remove .. in path
@@ -2258,7 +2263,7 @@ smallStringt *normalizePathO(smallStringt *path) {
}
else if (!strEq(*level, ".")) {
// remove . and add elements
- listPushS(&list, *level);
+ pErrorNULL(listPushS(&list, *level));
// an element is pushed, so this is the end of leading double dots
onlyLeadingDoubleDots = false;
}
@@ -2271,7 +2276,7 @@ smallStringt *normalizePathO(smallStringt *path) {
// handle /.: add empty string
if (path->f->equalS(path, "/.")) {
- listPushS(&list, "");
+ pErrorNULL(listPushS(&list, ""));
}
// keep leading /
@@ -2282,7 +2287,7 @@ smallStringt *normalizePathO(smallStringt *path) {
path->f->set(path, "/");
return(path);
}
- listPrependS(&list, "");
+ pErrorNULL(listPrependS(&list, ""));
}
// create new path
@@ -2654,12 +2659,12 @@ bool writeTextStreamG(char **list, FILE *fp) {
bool writeTextCG(const char **list, const char *filePath) {
- return(writeText(filePath, (char**)list));
+ return(writeCText(filePath, list));
}
bool writeTextStreamCG(const char **list, FILE *fp) {
- return(writeStream(fp, (char**)list));
+ return(writeCStream(fp, list));
}
bool appendFileSG(const char *string, const char *filePath) {
@@ -2674,7 +2679,7 @@ bool appendTextSG(char **list, const char *filePath) {
bool appendTextCG(const char **list, const char *filePath) {
- return(appendText(filePath, (char**)list));
+ return(appendCText(filePath, list));
}
int mkdirParentsSmallJsonO(smallJsont* path) {
@@ -3290,14 +3295,14 @@ smallJsont *readSmallJsonO(void) {
#define startMax 20
smallStringt *readO(void) {
- int max = startMax;;
+ size_t max = startMax;;
char *s = malloc(max);
if (!s) {
return(NULL);
}
- int i = 0;
+ size_t i = 0;
while (1) {
#ifndef unitTest
int c = getchar();
@@ -3314,7 +3319,7 @@ smallStringt *readO(void) {
s[i] = 0;
break;
}
- s[i] = c;
+ s[i] = (char)c;
if (i == max-1) {
// buffer full
max += max;
@@ -3399,7 +3404,7 @@ char **listFromArrayG(char **retType UNUSED, char **array, size_t size) {
char **listFromCArrayG(char **retType UNUSED, const char **array, size_t size) {
- return(listFromArrayS((char**)array, size));
+ return(listFromCArrayS(array, size));
}
char getSG(const char *string, int retType UNUSED, int64_t index) {
@@ -3414,7 +3419,7 @@ char *listGetG(char **list, int retType UNUSED, int64_t index) {
char *listGetCG(const char **list, int retType UNUSED, int64_t index) {
- return(listGetS((char**)list, index));
+ return(listGetCS(list, index));
}
char *iListGetG(char **list, int retType UNUSED, int64_t index) {
@@ -3422,9 +3427,9 @@ char *iListGetG(char **list, int retType UNUSED, int64_t index) {
return(iListGetS(list, index));
}
-char *iListGetCG(const char **list, int retType UNUSED, int64_t index) {
+const char *iListGetCG(const char **list, int retType UNUSED, int64_t index) {
- return(iListGetS((char**)list, index));
+ return(iListGetCS(list, index));
}
char *listPopG(char ***list, int retType UNUSED) {
@@ -3439,102 +3444,103 @@ char *listDequeueG(char ***list, int retType UNUSED) {
char **listDupCG(const char **list) {
- return(listDupS((char**)list));
+ return(listDupCS(list));
}
bool listEqCG(char **list1, const char **list2) {
- return(listEqS(list1, (char**)list2));
+ return(listEqCS(list1, list2));
}
bool listEqC1G(const char **list1, char **list2) {
- return(listEqS((char**)list1, list2));
+ return(listEqC1S(list1, list2));
}
bool listEqCCG(const char **list1, const char **list2) {
- return(listEqS((char**)list1, (char**)list2));
+ return(listEqCCS(list1, list2));
}
bool icListEqCG(char **list1, const char **list2) {
- return(icListEqS(list1, (char**)list2));
+ return(icListEqCS(list1, list2));
}
bool icListEqC1G(const char **list1, char **list2) {
- return(icListEqS((char**)list1, list2));
+ return(icListEqC1S(list1, list2));
}
bool icListEqCCG(const char **list1, const char **list2) {
- return(icListEqS((char**)list1, (char**)list2));
+ return(icListEqCCS(list1, list2));
}
size_t listLengthCG(const char **list) {
- return(listLengthS((char**)list));
+ return(listLengthCS(list));
}
ssize_t listIndexOfCG(const char **list, const char *string) {
- return(listIndexOfS((char**)list, string));
+ return(listIndexOfCS(list, string));
}
ssize_t listIndexOfCharCG(const char **list, char c) {
- return(listIndexOfCharS((char**)list, c));
+ return(listIndexOfCharCS(list, c));
}
ssize_t icListIndexOfCG(const char **list, const char *string) {
- return(icListIndexOfS((char**)list, string));
+ return(icListIndexOfCS(list, string));
}
ssize_t icListIndexOfCharCG(const char **list, char c) {
- return(icListIndexOfCharS((char**)list, c));
+ return(icListIndexOfCharCS(list, c));
}
bool listHasCharCG(const char **list, char c) {
- return(listHasCharS((char**)list, c));
+ return(listHasCharCS(list, c));
}
bool listHasCG(const char **list, const char *string) {
- return(listHasS((char**)list, string));
+ return(listHasCS(list, string));
}
bool icListHasCG(const char **list, const char *string) {
- return(icListHasS((char**)list, string));
+ return(icListHasCS(list, string));
}
bool icListHasCharCG(const char **list, char c) {
- return(icListHasCharS((char**)list, c));
+ return(icListHasCharCS(list, c));
}
char *joinCG(const char **list, const char* delim) {
- return(join((char**)list, delim));
+ return(joinCS(list, delim));
}
char *joinCharCG(const char **list, char delim) {
- return(joinChar((char**)list, delim));
+ charToS(s, delim);
+ return(joinCS(list, s));
}
char **listAddCG(char **list1, const char **list2) {
- return(listAddS(list1, (char**)list2));
+ return(listAddCS(list1, list2));
}
int listPrintCG(const char **list) {
- return(listPrintS((char**)list));
+ return(listPrintCS(list));
}
bool eqCharChar(char c, char value) {
@@ -3577,7 +3583,7 @@ bool equalChaUint32G(char c, uint32_t value) {
return(equalUint32CharG(value, s));
}
-bool equalChaUint64G(char c, uint32_t value) {
+bool equalChaUint64G(char c, uint64_t value) {
charToS(s, c);
return(equalUint64CharG(value, s));
@@ -3779,7 +3785,32 @@ bool equalArrayOG(char ** p1, baset* p2) {
bool equalCArrayOG(const char ** p1, baset* p2) {
- return(equalArrayOG((char**)p1, p2));
+ if (!p1 || !p2) {
+ return(false);
+ }
+
+ if (!isOType(p2, "smallArray")) {
+ return(false);
+ }
+
+ cast(smallArrayt *, arr, p2);
+
+ if (!listLengthCS(p1) || !lenO(arr)) {
+ return(false);
+ }
+
+ // compare elements
+ // TODO compare any types of element, not only strings
+ enumerateSArray(arr->a, e, i) {
+ if (not e) {
+ return(false);
+ }
+ if (!strEq(sStringGetTiny((sStringt*)e), p1[i])) {
+ return(false);
+ }
+ }
+
+ return(true);
}
bool equalArraySmallJsonG(char ** p1, smallJsont* p2) {
@@ -3816,12 +3847,34 @@ bool equalArraySmallArrayG(char ** p1, smallArrayt* p2) {
bool equalCArraySmallJsonG(const char ** p1, smallJsont* p2) {
- return(equalArraySmallJsonG((char**)p1, p2));
+ if (!p1 || !p2) {
+ return(false);
+ }
+
+ if (checkObjectTypes && !isOSmallJson(p2)) {
+ return(false);
+ }
+
+ const char *type = getTopTypeO(p2);
+
+ if (!eqS(type,"array")) {
+ return(false);
+ }
+
+ return(p2->f->equalCArray(p2, p1));
}
bool equalCArraySmallArrayG(const char ** p1, smallArrayt* p2) {
- return(equalArraySmallArrayG((char**)p1, p2));
+ if (!p2) {
+ return(false);
+ }
+
+ if (checkObjectTypes && !isOSmallArray(p2)) {
+ return(false);
+ }
+
+ return(p2->f->equalCArray(p2, p1));
}
bool equalOCharG(baset* p1, const char * p2) {
@@ -3841,7 +3894,7 @@ bool equalOArrayG(baset* p1, char ** p2) {
bool equalOCArrayG(baset* p1, const char ** p2) {
- return(equalArrayOG((char**)p2, p1));
+ return(equalCArrayOG(p2, p1));
}
bool equalOOG(baset* p1, baset* p2) {
@@ -4481,7 +4534,7 @@ bool equalInt32CharG(int32_t p1, const char * p2) {
return(false);
}
- int32_t value = parseInt(p2);
+ int32_t value = (int32_t)parseInt(p2);
return(p1 == value);;
}
@@ -4499,7 +4552,7 @@ bool equalInt32BaseG(int32_t p1, baset* p2) {
return(false);
}
- int32_t value = parseInt(s);
+ int32_t value = (int32_t)parseInt(s);
bool r;
if (p1 == value) {
@@ -4575,7 +4628,7 @@ bool equalInt32SmallBytesG(int32_t p1, smallBytest* p2) {
return(false);
}
- int32_t p2Value = parseInt(s);
+ int32_t p2Value = (int32_t)parseInt(s);
return(p2Value == p1);;
}
@@ -4623,7 +4676,7 @@ bool equalInt32SmallStringG(int32_t p1, smallStringt* p2) {
return(false);
}
- int32_t p2Value = parseIntO(p2);
+ int32_t p2Value = (int32_t)parseIntO(p2);
return(p2Value == p1);;
}
@@ -4643,7 +4696,7 @@ bool equalUint32CharG(uint32_t p1, const char * p2) {
return(false);
}
- uint32_t value = parseInt(p2);
+ uint32_t value = (uint32_t)parseInt(p2);
return(p1 == value);;
}
@@ -4661,7 +4714,7 @@ bool equalUint32BaseG(uint32_t p1, baset* p2) {
return(false);
}
- uint32_t value = parseInt(s);
+ uint32_t value = (uint32_t)parseInt(s);
bool r;
if (p1 == value) {
@@ -4737,7 +4790,7 @@ bool equalUint32SmallBytesG(uint32_t p1, smallBytest* p2) {
return(false);
}
- uint32_t p2Value = parseInt(s);
+ uint32_t p2Value = (uint32_t)parseInt(s);
return(p2Value == p1);;
}
@@ -4785,7 +4838,7 @@ bool equalUint32SmallStringG(uint32_t p1, smallStringt* p2) {
return(false);
}
- uint32_t p2Value = parseIntO(p2);
+ uint32_t p2Value = (uint32_t)parseIntO(p2);
return(p2Value == p1);;
}
@@ -4805,7 +4858,7 @@ bool equalUint64CharG(uint64_t p1, const char * p2) {
return(false);
}
- uint64_t value = parseInt(p2);
+ uint64_t value = (uint64_t)parseInt(p2);
return(p1 == value);;
}
@@ -4823,7 +4876,7 @@ bool equalUint64BaseG(uint64_t p1, baset* p2) {
return(false);
}
- uint64_t value = parseInt(s);
+ uint64_t value = (uint64_t)parseInt(s);
bool r;
if (p1 == value) {
@@ -4899,7 +4952,7 @@ bool equalUint64SmallBytesG(uint64_t p1, smallBytest* p2) {
return(false);
}
- uint64_t p2Value = parseInt(s);
+ uint64_t p2Value = (uint64_t)parseInt(s);
return(p2Value == p1);;
}
@@ -4947,7 +5000,7 @@ bool equalUint64SmallStringG(uint64_t p1, smallStringt* p2) {
return(false);
}
- uint64_t p2Value = parseIntO(p2);
+ uint64_t p2Value = (uint64_t)parseIntO(p2);
return(p2Value == p1);;
}
@@ -5135,7 +5188,32 @@ bool icEqualArrayOG(char ** p1, baset* p2) {
bool icEqualCArrayOG(const char ** p1, baset* p2) {
- return(icEqualArrayOG((char**)p1, p2));
+ if (!p1 || !p2) {
+ return(false);
+ }
+
+ if (!isOType(p2, "smallArray")) {
+ return(false);
+ }
+
+ cast(smallArrayt *, arr, p2);
+
+ if (!listLengthCS(p1) || !lenO(arr)) {
+ return(false);
+ }
+
+ // compare elements
+ // TODO compare any types of element, not only strings
+ enumerateSArray(arr->a, e, i) {
+ if (not e) {
+ return(false);
+ }
+ if (!icEqS(sStringGetTiny((sStringt*)e), p1[i])) {
+ return(false);
+ }
+ }
+
+ return(true);
}
bool icEqualArraySmallJsonG(char ** p1, smallJsont* p2) {
@@ -5158,6 +5236,26 @@ bool icEqualArraySmallJsonG(char ** p1, smallJsont* p2) {
return(p2->f->icEqualArray(p2, p1));
}
+bool icEqualCArraySmallJsonG(const char ** p1, smallJsont* p2) {
+
+ // sanity checks
+ if (!p2) {
+ return(false);
+ }
+
+ if (checkObjectTypes && !isOSmallJson(p2)) {
+ return(false);
+ }
+
+ const char *type = getTopTypeO(p2);
+
+ if (!eqS(type,"array")) {
+ return(false);
+ }
+
+ return(p2->f->icEqualCArray(p2, p1));
+}
+
bool icEqualArraySmallArrayG(char ** p1, smallArrayt* p2) {
if (!p2) {
@@ -5171,14 +5269,17 @@ bool icEqualArraySmallArrayG(char ** p1, smallArrayt* p2) {
return(p2->f->icEqualArray(p2, p1));
}
-bool icEqualCArraySmallJsonG(const char ** p1, smallJsont* p2) {
+bool icEqualCArraySmallArrayG(const char ** p1, smallArrayt* p2) {
- return(icEqualArraySmallJsonG((char**)p1, p2));
-}
+ if (!p2) {
+ return(false);
+ }
-bool icEqualCArraySmallArrayG(const char ** p1, smallArrayt* p2) {
+ if (checkObjectTypes && !isOSmallArray(p2)) {
+ return(false);
+ }
- return(icEqualArraySmallArrayG((char**)p1, p2));
+ return(p2->f->icEqualCArray(p2, p1));
}
bool icEqualOCharG(baset* p1, const char * p2) {
@@ -5198,7 +5299,7 @@ bool icEqualOArrayG(baset* p1, char ** p2) {
bool icEqualOCArrayG(baset* p1, const char ** p2) {
- return(icEqualArrayOG((char**)p2, p1));
+ return(icEqualCArrayOG(p2, p1));
}
bool icEqualOOG(baset* p1, baset* p2) {
@@ -5454,6 +5555,8 @@ baset *toBaset(smallt *obj) {
a->a = (sArrayt *)obj;
r = (baset *)a;
break;
+ default:;
+ // return NULL
}
return(r);
}
diff --git a/src/json/libsheepyObjectCuTest.c b/src/json/libsheepyObjectCuTest.c
@@ -116,7 +116,8 @@ void cSmallDictT(CuTest *tc UNUSED) {
ck_assert(obj2->f->has(obj2, "u"));
// keys
char **keys = obj2->f->keys(obj2);
- ck_assert_uint_eq(listLengthS(keys), 2);
+ size_t len = listLengthS(keys);
+ ck_assert_uint_eq(len, 2);
ck_assert_str_eq(keys[0], "u");
ck_assert_str_eq(keys[1], "str");
listFreeS(keys);
@@ -760,7 +761,7 @@ void cSmallJsonT(CuTest *tc UNUSED) {
char *ks = jpath.f->makeKey(&jpath, "\\\\\\\"\"");
ck_assert_str_eq(ks, "\"\\\\\\\\\\\\\\\"\\\"\"");
createSmallBool(b4);
- iPrependS(&ks, "[1]");
+ pErrorNULL(iPrependS(&ks, "[1]"));
o2 = jpath.f->set(&jpath, ks, (baset*)&b4);
ck_assert_ptr_ne(o2, NULL);
jBool = (smallBoolt*)jpath.f->get(&jpath,ks);
@@ -1266,7 +1267,8 @@ void cSmallArrayT(CuTest *tc UNUSED) {
smashO(in);
smallStringt *st;
st = (smallStringt *) o->f->getAt(o, 2);
- ck_assert(strEq(st->f->get(st), "sheepy"));
+ bool r = strEq(st->f->get(st), "sheepy");
+ ck_assert(r);
smashO(st);
terminateO(o);
// delete an element
@@ -1277,7 +1279,8 @@ void cSmallArrayT(CuTest *tc UNUSED) {
ck_assert(in->value->value == 123);
smashO(in);
st = (smallStringt *) o->f->getAt(o, 1);
- ck_assert(strEq(st->f->get(st), "sheepy"));
+ r = strEq(st->f->get(st), "sheepy");
+ ck_assert(r);
smashO(st);
terminateO(o);
terminateO(o2);
@@ -1801,8 +1804,8 @@ void cSmallArrayT(CuTest *tc UNUSED) {
// empty object
ck_assert(!o2->f->type(o2, 0));
// typeStrings
- char **l = o->f->typeStrings(o);
- s = join(l, ",");
+ const char **l = o->f->typeStrings(o);
+ s = joinCS(l, ",");
ck_assert_str_eq(s, "undefined,int,string");
free(s);
free(l);
@@ -1991,7 +1994,8 @@ void chDirOT(CuTest *tc UNUSED) {
v->f->set(v, "../dirTest.null");
ck_assert(chDirO(v));
char *s = getCwd();
- ck_assert((size_t)findS(s, "dirTest.null"));
+ bool r = (size_t)findS(s, "dirTest.null");
+ ck_assert(r);
chDirO(c);
free(s);
terminateO(c);
@@ -2090,7 +2094,7 @@ void fileSizeOT(CuTest *tc UNUSED) {
void mkdirParentsOT(CuTest *tc UNUSED) {
// directory
- rmAll("mkdirTest.null/null");
+ pError0(rmAll("mkdirTest.null/null"));
createAllocateSmallString(s);
s->f->set(s, "mkdirTest.null/null");
ck_assert_int_eq(mkdirParentsO(s),1);
@@ -2116,7 +2120,7 @@ void rmAllOT(CuTest *tc UNUSED) {
// directory
createAllocateSmallString(s);
s->f->set(s, "rmAllTest.null/null");
- mkdirParents("rmAllTest.null/null");
+ pError0(mkdirParents("rmAllTest.null/null"));
ck_assert_int_eq(rmAllO(s),1);
// empty path
createAllocateSmallString(e);
@@ -2144,12 +2148,13 @@ void copyOT(CuTest *tc UNUSED) {
s->f->set(s, "../chmodTest.null");
d->f->set(d, "../copyTest.null");
ck_assert_int_eq(copyO(s, d),1);
- ck_assert(fileExists("../copyTest.null"));
+ bool r = fileExists("../copyTest.null");
+ ck_assert(r);
// too little permissions
- fileChmod("../copyTest.null", 1);
+ pError0(fileChmod("../copyTest.null", 1));
ck_assert_int_eq(copyO(d, d),0);
- fileChmod("../copyTest.null", 777);
- rmAll("../copyTest.null");
+ pError0(fileChmod("../copyTest.null", 777));
+ pError0(rmAll("../copyTest.null"));
// empty path
createAllocateSmallString(e);
e->f->set(e, "");
@@ -2304,7 +2309,8 @@ void toBasetT(CuTest *tc UNUSED) {
// string
sStringt *ss = allocSStringTiny("sheepy");
smallStringt *s = (smallStringt *) toBaset((smallt *)ss);
- ck_assert_str_eq(sStringGetTiny(ss), "sheepy");
+ char *r = ssGet(s);
+ ck_assert_str_eq(r, "sheepy");
terminateO(s);
// undefined
sUndefinedt *su = allocSUndefined();
diff --git a/src/json/libsheepyObjectTest.c b/src/json/libsheepyObjectTest.c
@@ -105,7 +105,8 @@ START_TEST(cSmallDictT)
ck_assert(obj2->f->has(obj2, "u"));
// keys
char **keys = obj2->f->keys(obj2);
- ck_assert_uint_eq(listLengthS(keys), 2);
+ size_t len = listLengthS(keys);
+ ck_assert_uint_eq(len, 2);
ck_assert_str_eq(keys[0], "u");
ck_assert_str_eq(keys[1], "str");
listFreeS(keys);
@@ -749,7 +750,7 @@ START_TEST(cSmallJsonT)
char *ks = jpath.f->makeKey(&jpath, "\\\\\\\"\"");
ck_assert_str_eq(ks, "\"\\\\\\\\\\\\\\\"\\\"\"");
createSmallBool(b4);
- iPrependS(&ks, "[1]");
+ pErrorNULL(iPrependS(&ks, "[1]"));
o2 = jpath.f->set(&jpath, ks, (baset*)&b4);
ck_assert_ptr_ne(o2, NULL);
jBool = (smallBoolt*)jpath.f->get(&jpath,ks);
@@ -1255,7 +1256,8 @@ START_TEST(cSmallArrayT)
smashO(in);
smallStringt *st;
st = (smallStringt *) o->f->getAt(o, 2);
- ck_assert(strEq(st->f->get(st), "sheepy"));
+ bool r = strEq(st->f->get(st), "sheepy");
+ ck_assert(r);
smashO(st);
terminateO(o);
// delete an element
@@ -1266,7 +1268,8 @@ START_TEST(cSmallArrayT)
ck_assert(in->value->value == 123);
smashO(in);
st = (smallStringt *) o->f->getAt(o, 1);
- ck_assert(strEq(st->f->get(st), "sheepy"));
+ r = strEq(st->f->get(st), "sheepy");
+ ck_assert(r);
smashO(st);
terminateO(o);
terminateO(o2);
@@ -1790,8 +1793,8 @@ START_TEST(cSmallArrayT)
// empty object
ck_assert(!o2->f->type(o2, 0));
// typeStrings
- char **l = o->f->typeStrings(o);
- s = join(l, ",");
+ const char **l = o->f->typeStrings(o);
+ s = joinCS(l, ",");
ck_assert_str_eq(s, "undefined,int,string");
free(s);
free(l);
@@ -1980,7 +1983,8 @@ START_TEST(chDirOT)
v->f->set(v, "../dirTest.null");
ck_assert(chDirO(v));
char *s = getCwd();
- ck_assert((size_t)findS(s, "dirTest.null"));
+ bool r = (size_t)findS(s, "dirTest.null");
+ ck_assert(r);
chDirO(c);
free(s);
terminateO(c);
@@ -2079,7 +2083,7 @@ END_TEST
START_TEST(mkdirParentsOT)
// directory
- rmAll("mkdirTest.null/null");
+ pError0(rmAll("mkdirTest.null/null"));
createAllocateSmallString(s);
s->f->set(s, "mkdirTest.null/null");
ck_assert_int_eq(mkdirParentsO(s),1);
@@ -2105,7 +2109,7 @@ START_TEST(rmAllOT)
// directory
createAllocateSmallString(s);
s->f->set(s, "rmAllTest.null/null");
- mkdirParents("rmAllTest.null/null");
+ pError0(mkdirParents("rmAllTest.null/null"));
ck_assert_int_eq(rmAllO(s),1);
// empty path
createAllocateSmallString(e);
@@ -2133,12 +2137,13 @@ START_TEST(copyOT)
s->f->set(s, "../chmodTest.null");
d->f->set(d, "../copyTest.null");
ck_assert_int_eq(copyO(s, d),1);
- ck_assert(fileExists("../copyTest.null"));
+ bool r = fileExists("../copyTest.null");
+ ck_assert(r);
// too little permissions
- fileChmod("../copyTest.null", 1);
+ pError0(fileChmod("../copyTest.null", 1));
ck_assert_int_eq(copyO(d, d),0);
- fileChmod("../copyTest.null", 777);
- rmAll("../copyTest.null");
+ pError0(fileChmod("../copyTest.null", 777));
+ pError0(rmAll("../copyTest.null"));
// empty path
createAllocateSmallString(e);
e->f->set(e, "");
@@ -2293,7 +2298,8 @@ START_TEST(toBasetT)
// string
sStringt *ss = allocSStringTiny("sheepy");
smallStringt *s = (smallStringt *) toBaset((smallt *)ss);
- ck_assert_str_eq(sStringGetTiny(ss), "sheepy");
+ char *r = ssGet(s);
+ ck_assert_str_eq(r, "sheepy");
terminateO(s);
// undefined
sUndefinedt *su = allocSUndefined();
diff --git a/src/json/runCuTest.sh b/src/json/runCuTest.sh
@@ -1,2 +1,3 @@
-gcc -mrdrnd -g3 -std=gnu11 -o libsheepyObjectCuTest libsheepyObjectCuTest.c CuTest/CuTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -mrdrnd -Wall -Wextra -pthread -rdynamic -fprofile-arcs -ftest-coverage
+rm -f libsheepyObjectCuTest
+gcc -mrdrnd -g3 -std=gnu11 -o libsheepyObjectCuTest libsheepyObjectCuTest.c CuTest/CuTest.c ../libsheepySmall.c libsheepyObject.c libsheepyCSmallJson.c libsheepyCUndefined.c libsheepyCSmallBytes.c libsheepyCSmallDict.c libsheepyCSmallArray.c libsheepyCSmallBool.c libsheepyCSmallContainer.c libsheepyCSmallDouble.c libsheepyCSmallInt.c libsheepyCSmallString.c ../../release/libsheepy.c laxjson.c ymlParser.c ymlApi.c ymlScanner.c ymlReader.c ../tpool.c -Wall -Wextra -pthread -rdynamic -fprofile-arcs -ftest-coverage
./libsheepyObjectCuTest
diff --git a/src/libsheepy.c b/src/libsheepy.c
@@ -211,7 +211,7 @@ char **readDirDir(const char *dirPath);
char **walkDirAll(const char* dirPath);
internal void walkADirAll(const char *dirPath, char ***list);
char **readDirAll(const char *dirPath);
-mode_t getumask(void);
+mode_t getUmask(void);
mode_t getCurrentPermissions(void);
int mkdirParents(const char* path);
int rmAll(const char* path);
@@ -250,13 +250,13 @@ void loghex(const void *buf, size_t len);
char *toHexS(const void *buf, size_t len);
char *toHexSepS(const void *buf, size_t len, const char *separator);
char *toHexHeadSepS(const void *buf, size_t len, const char *head, const char *separator);
-char *strCpy(char *dst, const char *src);
-char *strNCpy(char *dst, const char *src, size_t srcSize);
-char *strLCpy(char *dst, size_t dstSize, const char *src);
-char *strCat(char *dst, const char *src);
-char *strNCat(char *dst, const char *src, size_t srcLen);
-char *strLCat(char *dst, size_t dstSize, const char *src);
-char *strLNCat(char *dst, size_t dstSize, const char *src, size_t srcLen);
+char *strCpy(char *restrict dst, const char *restrict src);
+char *strNCpy(char *restrict dst, const char *restrict src, size_t srcSize);
+char *strLCpy(char *restrict dst, size_t dstSize, const char *restrict src);
+char *strCat(char *restrict dst, const char *restrict src);
+char *strNCat(char *restrict dst, const char *restrict src, size_t srcLen);
+char *strLCat(char *restrict dst, size_t dstSize, const char *restrict src);
+char *strLNCat(char *restrict dst, size_t dstSize, const char *restrict src, size_t srcLen);
char *catSF(const char *paramType, ...);
char *iCatSF(char *dst, const char *paramType, ...);
char *bLCatSF(char *dst, size_t dstSize, const char *paramType, ...);
@@ -463,21 +463,23 @@ ssize_t icIndexOfS(const char *string, const char *needle);
ssize_t icIndexOfCharS(const char *string, char c);
bool icHasS(const char *string, const char *needle);
bool icHasCharS(const char *string, char c);
-char *tokS(const char *s, const char *delim, char **saveptr);
-char *icTokS(const char *s, const char *delim, char **saveptr);
+char *tokS(char *s, const char *delim, char **saveptr);
+char *icTokS(char *s, const char *delim, char **saveptr);
size_t lenUTF8(const char *s);
size_t bLLenUTF8(const char *s, size_t maxSize);
bool isUTF8(const char * string);
bool bLIsUTF8(const char * string, size_t stringSize);
bool isCodeUTF8(const char *code);
-char *nextUTF8(const char *utf8);
-char *bLNextUTF8(const char *string, size_t utf8Size, const char *utf8);
-char *findNextUTF8(const char *string, size_t utf8Size, const char *utf8);
-char *prevUTF8(const char *utf8);
-char *bPrevUTF8(const char *string, const char *utf8);
-local char *bPrevUTF8Tiny(const char *string, const char *utf8);
-char *idx2PtrUTF8(const char *utf8, int64_t index);
-char *bLIdx2PtrUTF8(const char *utf8, size_t utf8Size, int64_t index);
+const char *nextUTF8(const char *utf8);
+const char *bLNextUTF8(const char *string, size_t utf8Size, const char *utf8);
+const char *findNextUTF8(const char *string, size_t utf8Size, const char *utf8);
+const char *prevUTF8(const char *utf8);
+const char *bPrevUTF8(const char *string, const char *utf8);
+local const char *bPrevUTF8Tiny(const char *string, const char *utf8);
+local char *bPrevRWUTF8Tiny(const char *string, char *utf8);
+const char *idx2PtrUTF8(const char *utf8, int64_t index);
+local char *idx2PtrRWUTF8(char *utf8, int64_t index);
+const char *bLIdx2PtrUTF8(const char *utf8, size_t utf8Size, int64_t index);
int64_t ptr2IdxUTF8(const char *utf8, const char *pos);
int64_t bPtr2IdxUTF8(const char *start, const char *utf8, const char *pos);
int64_t bLPtr2IdxUTF8(const char *utf8, size_t utf8Size, const char *pos);
@@ -526,8 +528,8 @@ uint8_t runeLenUTF8(rune r);
internal size_t decompose_hangul(rune s, rune *r);
internal const char *find_decomposition (rune ch);
internal size_t runeFullyDecompose(rune ch, rune *result, size_t resultLen);
-internal int output_marks(const char **p_inout, char *dst, bool remove_dot);
-internal int output_special_case(char *dst, int offset, int type, int which);
+internal size_t output_marks(const char **p_inout, char *dst, bool remove_dot);
+internal size_t output_special_case(char *dst, int offset, int type, int which);
rune toupperUTF8(rune c);
internal size_t _upperUTF8(char *dst, const char *utf8, localeType lcl);
char *upperUTF8(const char *utf8);
@@ -591,6 +593,7 @@ bool listIsEmptyS(char **list);
bool listIsBlankS(char **list);
char **listCreateSF(const char *paramType, ...);
char **listFromArrayS(char **array, size_t size);
+char **listFromCArrayS(const char **array, size_t size);
char **listPushS(char ***list, const char *s);
char **listPushCharS(char ***list, char c);
char **iListPushS(char ***list, char *s);
@@ -602,22 +605,29 @@ char *listDequeueS(char ***list);
void listFreeS(char **list);
void listFreeManySF(char **paramType, ...);
size_t listLengthS(char **list);
+size_t listLengthCS(const char **list);
ssize_t listStrLengthS(char **list);
ssize_t listIntIndexS(char **list, int64_t index);
char **listAddrS(char **list, int64_t index);
char *listGetS(char **list, int64_t index);
char *iListGetS(char **list, int64_t index);
+char *listGetCS(const char **list, int64_t index);
+const char *iListGetCS(const char **list, int64_t index);
char **listSetS(char **list, int64_t index, const char *s);
char **listSetCharS(char **list, int64_t index, char c);
char **iListSetS(char **list, int64_t index, char *s);
char **listSwapS(char **list, int64_t index1, int64_t index2);
char **iListSwapS(char **list, int64_t index1, int64_t index2);
char **split(const char *string, const char* delim);
+char **splitS(const char *string, const char* delim);
char **splitChar(const char *string, char delim);
char **icSplit(const char *string, const char* delim);
+char **icSplitS(const char *string, const char* delim);
char **icSplitChar(const char *string, char delim);
ssize_t joinLength(char **list, const char* delim);
char *join(char **list, const char* delim);
+char *joinS(char **list, const char* delim);
+char *joinCS(const char **list, const char* delim);
char *joinChar(char **list, char delim);
char *bJoin(char *string, char **list, const char* delim);
char *bJoinChar(char *string, char **list, char delim);
@@ -632,6 +642,7 @@ char **icExtractCharSS(const char *string, char delim1, const char* delim2);
char **icExtractSCharS(const char *string, const char* delim1, char delim2);
char **icExtractCharCharS(const char *string, char delim1, char delim2);
char **listDupS(char **list);
+char **listDupCS(const char **list);
char **iListDupS(char **list);
char **listReverseS(char **list);
char **iListReverseS(char ***list);
@@ -643,6 +654,7 @@ char **listShiftS(char ***list1, char **list2);
char **iListShiftS(char ***list1, char **list2);
char **iListShiftNSmashS(char ***list1, char **list2);
char **listAddS(char **list1, char **list2);
+char **listAddCS(char **list1, const char **list2);
char **listSliceS(char **list, int64_t start, int64_t end);
char **iListCopyS(char **list, int64_t start, int64_t end);
char **iListSliceS(char ***list, int64_t start, int64_t end);
@@ -664,6 +676,7 @@ char **listDelElemS(char **list, int64_t index);
char **iListDelElemS(char ***list, int64_t index);
char **iListRemoveElemS(char ***list, int64_t index);
int listPrintS(char **list);
+int listPrintCS(const char **list);
internal int listSortSCmp(const void * a, const void * b);
char **listSortS(char **list);
char **iListSortS(char ***list);
@@ -675,8 +688,11 @@ char **iicListSortS(char ***list);
char **readText(const char *filePath);
char **readStream(FILE *fp);
bool writeText(const char *filePath, char **list);
+bool writeCText(const char *filePath, const char **list);
bool writeStream(FILE *fp, char **list);
+bool writeCStream(FILE *fp, const char **list);
bool appendText(const char *filePath, char **list);
+bool appendCText(const char *filePath, const char **list);
char **execOut(const char *cmd);
char **systemOutf(const char *fmt, ...);
int systemf(const char *fmt, ...);
@@ -684,19 +700,33 @@ int commandF(const char *cmd, int line, const char *thisFunc, const char *thisFi
int commandfF(int line, const char *thisFunc, const char *thisFileName, const char *fmt, ...);
int commandNFreeF(char *cmd, int line, const char *thisFunc, const char *thisFileName);
bool listEqS(char **list1, char **list2);
+bool listEqCS(char **list1, const char **list2);
+bool listEqC1S(const char **list1, char **list2);
+bool listEqCCS(const char **list1, const char **list2);
bool listHasS(char **list, const char *string);
+bool listHasCS(const char **list, const char *string);
bool listHasCharS(char **list, char c);
+bool listHasCharCS(const char **list, char c);
ssize_t listIndexOfS(char **list, const char *string);
+ssize_t listIndexOfCS(const char **list, const char *string);
ssize_t listIndexOfCharS(char **list, char c);
+ssize_t listIndexOfCharCS(const char **list, char c);
ssize_t listBinarySearchS(char **list, const char *string);
ssize_t listBinarySearchCharS(char **list, char c);
char **listUniqS(char **list);
char **iListUniqS(char ***list);
bool icListEqS(char **list1, char **list2);
+bool icListEqCS(char **list1, const char **list2);
+bool icListEqC1S(const char **list1, char **list2);
+bool icListEqCCS(const char **list1, const char **list2);
bool icListHasS(char **list, const char *string);
bool icListHasCharS(char **list, char c);
+bool icListHasCS(const char **list, const char *string);
+bool icListHasCharCS(const char **list, char c);
ssize_t icListIndexOfS(char **list, const char *string);
+ssize_t icListIndexOfCS(const char **list, const char *string);
ssize_t icListIndexOfCharS(char **list, char c);
+ssize_t icListIndexOfCharCS(const char **list, char c);
ssize_t icListBinarySearchS(char **list, const char *string);
ssize_t icListBinarySearchCharS(char **list, char c);
char **icListUniqS(char **list);
@@ -826,7 +856,7 @@ void *myMalloc(size_t l) {
l += 0;
r = malloc(l);
- randomUrandomOpen();
+ pError0(randomUrandomOpen());
void *w = r;
while (l-- > 0) {
@@ -849,7 +879,7 @@ void *myRealloc(void *buffer, size_t l) {
// NO creates bugs - over allocate to trigger bugs
r = realloc(buffer, l+0);
- randomUrandomOpen();
+ pError0(randomUrandomOpen());
int i = 0;
while (i-- > 0) {
@@ -1053,7 +1083,7 @@ FILE *setLogFile(char *filename) {
return(NULL);
}
- if (_current_log_file+1 > 16) {
+ if (_current_log_file >= 16) {
// we only support 16 different files
return(NULL);
}
@@ -1160,12 +1190,12 @@ void setLogStdout(bool state) {
*/
bool openProgLogFile(void) {
- if (!progName) {
+ if (!progName && !defaultProgName) {
logME(libsheepyErrorMask, "Program name is not set, call initLibsheepy or set prog name with setProgName");
return(false);
}
- char *s = formatS("%s.log", progName);;
+ char *s = formatS("%s.log", progName ? progName : defaultProgName);;
if (!setLogFile(s)) {
logME(libsheepyErrorMask, "Couldn't open log file: %s", s);
@@ -1263,6 +1293,7 @@ void _pLog(int loglevel, const char *file, const char *func, int line, const cha
printf(BLD CYN);
break;
case LOG_INVALID:
+ default:
printf(MGT);
break;
}
@@ -1301,12 +1332,7 @@ void _pLog(int loglevel, const char *file, const char *func, int line, const cha
}
}
- int tagSymbols = logSymbols;;
- switch(logSymbols) {
- case LOG_INVALID_MODE:
- tagSymbols = _log_current_mode;;
- break;
- }
+ int tagSymbols = logSymbols != LOG_INVALID_MODE ? logSymbols : _log_current_mode;
// print the log tag
int firstLogFile = _logToStdout ? 0 : 1;
@@ -1335,12 +1361,12 @@ void _pLog(int loglevel, const char *file, const char *func, int line, const cha
break;
case LOG_PROG:
for (i=firstLogFile; i < _current_log_file; i++) {
- fprintf(_logging_files[i], "%s: ", progName);
+ fprintf(_logging_files[i], "%s: ", progName ? progName : defaultProgName);
}
break;
case LOG_PROGNDATE:
for (i=firstLogFile; i < _current_log_file; i++) {
- fprintf(_logging_files[i], "%s %s: ", progName, clock);
+ fprintf(_logging_files[i], "%s %s: ", progName ? progName : defaultProgName, clock);
}
break;
case LOG_DATE:
@@ -1348,6 +1374,8 @@ void _pLog(int loglevel, const char *file, const char *func, int line, const cha
fprintf(_logging_files[i], "%s ", clock);
}
break;
+ default:;
+ // don't print anything
}
@@ -1374,7 +1402,7 @@ void _pLog(int loglevel, const char *file, const char *func, int line, const cha
}
}
- rangeFrom(i, 1, _current_log_file) {
+ for(i = 1; i <_current_log_file; i++) {;
// write log files immediately
fflush(_logging_files[i]);
}
@@ -1404,10 +1432,10 @@ void _pLog(int loglevel, const char *file, const char *func, int line, const cha
int print_k(FILE *stream, const struct printf_info *info, const void *const *args) {
u32 rgbColor;
char b[20];
- size_t len;
+ int len;
- rgbColor = *((u32*) args[0]);
- snprintf(b, sizeof(b), TERMRGB "%d;%d;%dm", rgbColor>>16, (rgbColor&0xFF00)>>8, rgbColor&0xFF);
+ rgbColor = *((const u32*) args[0]);
+ snprintf(b, sizeof(b), TERMRGB "%u;%u;%um", rgbColor>>16, (rgbColor&0xFF00)>>8, rgbColor&0xFF);
/* Pad to the minimum field width and print to the stream. */
//len = fprintf(stream, "%*s", (info->left ? -info->width : info->width), b)
@@ -1422,10 +1450,10 @@ int print_k(FILE *stream, const struct printf_info *info, const void *const *arg
int print_K(FILE *stream, const struct printf_info *info, const void *const *args) {
u32 rgbColor;
char b[20];
- size_t len;
+ int len;
- rgbColor = *((u32*) args[0]);
- snprintf(b, sizeof(b), BGTERMRGB "%d;%d;%dm", rgbColor>>16, (rgbColor&0xFF00)>>8, rgbColor&0xFF);
+ rgbColor = *((const u32*) args[0]);
+ snprintf(b, sizeof(b), BGTERMRGB "%u;%u;%um", rgbColor>>16, (rgbColor&0xFF00)>>8, rgbColor&0xFF);
/* Pad to the minimum field width and print to the stream. */
//len = fprintf(stream, "%*s", (info->left ? -info->width : info->width), b)
@@ -1450,9 +1478,9 @@ int print_k_arginfo(const struct printf_info *info UNUSED, size_t n, int *argtyp
*/
int print_b(FILE *stream, const struct printf_info *info, const void *const *args) {
bool value;
- size_t len;
+ int len;
- value = *((bool*) args[0]);
+ value = *((const bool*) args[0]);
/* Pad to the minimum field width and print to the stream. */
//len = fprintf(stream, "%*s", (info->left ? -info->width : info->width), boolS(value))
@@ -1508,18 +1536,17 @@ void initLibsheepyF(const char *progPath, initLibsheepyObjectP initF) {
libSheepyProgPath += sizeof(sheepyBuild)-1;
}
- // set progName as basename progPath
- // progName is the string after the last /
- rangeDown(i, strlen(libSheepyProgPath)) {
+ // set defaultProgName as basename progPath
+ // defaultProgName is the string after the last /
+ rangeDown(i, (ssize_t)strlen(libSheepyProgPath)) {
if (libSheepyProgPath[i] == '/') {
- progName = (char*)(libSheepyProgPath + i + 1);
+ defaultProgName = libSheepyProgPath + i + 1;
break;
}
}
- if (!progName) {
- progName = (char*)libSheepyProgPath;
+ if (!defaultProgName) {
+ defaultProgName = libSheepyProgPath;
}
- defaultProgName = progName;
// segfault signal
struct sigaction sa;
@@ -1569,18 +1596,17 @@ void initLibsheepyF(const char *progPath, initLibsheepyObjectP initF) {
libSheepyProgPath += sizeof(sheepyBuild)-1;
}
- // set progName as basename progPath
- // progName is the string after the last /
- rangeDown(i, strlen(libSheepyProgPath)) {
+ // set defaultProgName as basename progPath
+ // defaultProgName is the string after the last /
+ rangeDown(i, (ssize_t)strlen(libSheepyProgPath)) {
if (libSheepyProgPath[i] == '/') {
- progName = (char*)(libSheepyProgPath + i + 1);
+ defaultProgName = (libSheepyProgPath + i + 1);
break;
}
}
- if (!progName) {
- progName = (char*)libSheepyProgPath;
+ if (!defaultProgName) {
+ defaultProgName = libSheepyProgPath;
}
- defaultProgName = progName;
// segfault signal
struct sigaction sa;
@@ -1626,7 +1652,7 @@ void initLibsheepyF(const char *progPath, initLibsheepyObjectP initF) {
*/
void finalizeLibsheepyCharAtExit(void) {
- freeProgName();
+ free(progName);
freeRealProgPath();
randomUrandomClose();
}
@@ -1646,7 +1672,7 @@ int64_t getStackLimit(void) {
pFuncError
return(0);
}
- return(limit.rlim_cur);
+ return(limit.rlim_cur != RLIM_INFINITY ? (i64) limit.rlim_cur : -1);;
}
/**
@@ -1670,7 +1696,7 @@ int setStackLimit(int64_t stackSize) {
limit.rlim_cur = RLIM_INFINITY;
}
else {
- limit.rlim_cur = stackSize;
+ limit.rlim_cur = (u64)stackSize;
}
if (setrlimit(RLIMIT_STACK, &limit) == -1) {
@@ -1689,7 +1715,7 @@ int setStackLimit(int64_t stackSize) {
*/
const char *getProgName(void) {
- return(progName);
+ return(progName ? progName : defaultProgName);
}
/**
@@ -1704,7 +1730,7 @@ bool setProgName(const char *name) {
return(false);
}
- freeProgName();
+ free(progName);
progName = strdup(name);
return(true);
@@ -1717,12 +1743,8 @@ bool setProgName(const char *name) {
*/
void setDefaultProgName(void) {
- if (defaultProgName != progName) {
- // progName has been set by the user with setProgName, free it
- free(progName);
- progName = (char*)defaultProgName;
+ freen(progName);
}
- }
/**
* free ProgName
@@ -1730,11 +1752,8 @@ void setDefaultProgName(void) {
*/
void freeProgName(void) {
- if (defaultProgName != progName) {
- // progName has been set by the user with setProgName, free it
- freen(progName);
+ freen(progName);
}
- }
/**
* get program path
@@ -2212,7 +2231,7 @@ char *bDirname(char *path) {
if (isBlankS(path) || !strchr(path, '/')) {
// the path is blank or a filename
// set dir to pwd when dirname is empty
- strCpy(path, "./");
+ strcpy(path, "./");
return(path);
}
@@ -2334,13 +2353,13 @@ char *expandHome(const char* path) {
if (!slash) {
// no slash found, path is in the form: ~USER
// copy string after ~ to the end of the string
- strLCpy(user, sizeof(user)-1, path+1);
+ pErrorNULL(strLCpy(user, sizeof(user)-1, path+1));
pathStart = strlen(path);
}
else {
// copy string after ~ to first slash
pathStart = slash - path;
- strLNCat(user, sizeof(user)-1, path+1, pathStart-1);
+ pErrorNULL(strLNCat(user, sizeof(user)-1, path+1, pathStart-1));
}
}
@@ -2524,13 +2543,13 @@ char *iExpandHome(char **path) {
if (!slash) {
// no slash found, path is in the form: ~USER
// copy string after ~ to the end of the string
- strLCpy(user, sizeof(user)-1, (*path)+1);
+ pErrorNULL(strLCpy(user, sizeof(user)-1, (*path)+1));
pathStart = strlen(*path);
}
else {
// copy string after ~ to first slash
pathStart = slash - (*path);
- strLNCat(user, sizeof(user)-1, (*path)+1, pathStart-1);
+ pErrorNULL(strLNCat(user, sizeof(user)-1, (*path)+1, pathStart-1));
}
}
@@ -2708,13 +2727,13 @@ char *bExpandHome(char *path) {
if (!slash) {
// no slash found, path is in the form: ~USER
// copy string after ~ to the end of the string
- strLCpy(user, sizeof(user)-1, path+1);
+ pErrorNULL(strLCpy(user, sizeof(user)-1, path+1));
pathStart = strlen(path);
}
else {
// copy string after ~ to first slash
pathStart = slash - path;
- strLNCat(user, sizeof(user)-1, path+1, pathStart-1);
+ pErrorNULL(strLNCat(user, sizeof(user)-1, path+1, pathStart-1));
}
}
@@ -2885,7 +2904,7 @@ char *bLExpandHome(char *path, size_t pathSize) {
if (!slash) {
// no slash found, path is in the form: ~USER
// copy string after ~ to the end of the string
- strLCpy(user, sizeof(user)-1, path+1);
+ pErrorNULL(strLCpy(user, sizeof(user)-1, path+1));
pathStart = strlen(path);
}
else {
@@ -2932,7 +2951,7 @@ char *bLExpandHome(char *path, size_t pathSize) {
// append rest of the path to the result
iAppendS(&r, path + pathStart);
- strLCpy(path, pathSize, r);
+ pErrorNULL(strLCpy(path, pathSize, r));
free(r);
return(path);
}
@@ -2983,7 +3002,7 @@ char *bLExpandHome(char *path, size_t pathSize) {
default:
break;
}
- strLCpy(path, pathSize, exp_result.we_wordv[0]);
+ pErrorNULL(strLCpy(path, pathSize, exp_result.we_wordv[0]));
wordfree(&exp_result);
#else
bLReplaceS(path, pathSize, "~", "/data/data/com.termux/files/home", 1);
@@ -3023,7 +3042,7 @@ char *normalizePath(const char *path) {
char **pathL = split(path, "/");
// remove empty elements
- iListCompactS(&pathL);
+ pErrorNULL(iListCompactS(&pathL));
if (listIsEmptyS(pathL)) {
listFreeS(pathL);
@@ -3042,7 +3061,7 @@ char *normalizePath(const char *path) {
if (strEq(*level, "..")) {
if (onlyLeadingDoubleDots) {
// keep leading ..
- listPushS(&list, "..");
+ pErrorNULL(listPushS(&list, ".."));
}
else {
// remove .. in path
@@ -3052,7 +3071,7 @@ char *normalizePath(const char *path) {
}
else if (!strEq(*level, ".")) {
// remove . and add elements
- listPushS(&list, *level);
+ pErrorNULL(listPushS(&list, *level));
// an element is pushed, so this is the end of leading double dots
onlyLeadingDoubleDots = false;
}
@@ -3065,7 +3084,7 @@ char *normalizePath(const char *path) {
// handle /.: add empty string
if (strEq(path, "/.")) {
- listPushS(&list, "");
+ pErrorNULL(listPushS(&list, ""));
}
// keep leading /
@@ -3075,7 +3094,7 @@ char *normalizePath(const char *path) {
listFreeManyS(pathL, list);
return(strdup("/"));
}
- listPrependS(&list, "");
+ pErrorNULL(listPrependS(&list, ""));
}
// create new path
@@ -3114,7 +3133,7 @@ char *iNormalizePath(char **path) {
}
if (isEmptyS(*path)) {
- iEmptySF(path);
+ pErrorNULL(iEmptySF(path));
return(*path);
}
@@ -3122,7 +3141,7 @@ char *iNormalizePath(char **path) {
char **pathL = split(*path, "/");
// remove empty elements
- iListCompactS(&pathL);
+ pErrorNULL(iListCompactS(&pathL));
if (listIsEmptyS(pathL)) {
listFreeS(pathL);
@@ -3143,7 +3162,7 @@ char *iNormalizePath(char **path) {
if (strEq(*level, "..")) {
if (onlyLeadingDoubleDots) {
// keep leading ..
- listPushS(&list, "..");
+ pErrorNULL(listPushS(&list, ".."));
}
else {
// remove .. in path
@@ -3153,7 +3172,7 @@ char *iNormalizePath(char **path) {
}
else if (!strEq(*level, ".")) {
// remove . and add elements
- listPushS(&list, *level);
+ pErrorNULL(listPushS(&list, *level));
// an element is pushed, so this is the end of leading double dots
onlyLeadingDoubleDots = false;
}
@@ -3166,7 +3185,7 @@ char *iNormalizePath(char **path) {
// handle /.: add empty string
if (strEq(*path, "/.")) {
- listPushS(&list, "");
+ pErrorNULL(listPushS(&list, ""));
}
// keep leading /
@@ -3178,7 +3197,7 @@ char *iNormalizePath(char **path) {
*path = strdup("/");
return(*path);
}
- listPrependS(&list, "");
+ pErrorNULL(listPrependS(&list, ""));
}
// create new path
@@ -3227,7 +3246,7 @@ char *bNormalizePath(char *path) {
char **pathL = split(path, "/");
// remove empty elements
- iListCompactS(&pathL);
+ pErrorNULL(iListCompactS(&pathL));
if (listIsEmptyS(pathL)) {
listFreeS(pathL);
@@ -3247,7 +3266,7 @@ char *bNormalizePath(char *path) {
if (strEq(*level, "..")) {
if (onlyLeadingDoubleDots) {
// keep leading ..
- listPushS(&list, "..");
+ pErrorNULL(listPushS(&list, ".."));
}
else {
// remove .. in path
@@ -3257,7 +3276,7 @@ char *bNormalizePath(char *path) {
}
else if (!strEq(*level, ".")) {
// remove . and add elements
- listPushS(&list, *level);
+ pErrorNULL(listPushS(&list, *level));
// an element is pushed, so this is the end of leading double dots
onlyLeadingDoubleDots = false;
}
@@ -3270,7 +3289,7 @@ char *bNormalizePath(char *path) {
// handle /.: add empty string
if (strEq(path, "/.")) {
- listPushS(&list, "");
+ pErrorNULL(listPushS(&list, ""));
}
// keep leading /
@@ -3281,7 +3300,7 @@ char *bNormalizePath(char *path) {
strcpy(path, "/");
return(path);
}
- listPrependS(&list, "");
+ pErrorNULL(listPrependS(&list, ""));
}
// create new path
@@ -3338,7 +3357,7 @@ char *bLNormalizePath(char *path, size_t pathSize) {
char **pathL = split(path, "/");
// remove empty elements
- iListCompactS(&pathL);
+ pErrorNULL(iListCompactS(&pathL));
if (listIsEmptyS(pathL)) {
listFreeS(pathL);
@@ -3358,7 +3377,7 @@ char *bLNormalizePath(char *path, size_t pathSize) {
if (strEq(*level, "..")) {
if (onlyLeadingDoubleDots) {
// keep leading ..
- listPushS(&list, "..");
+ pErrorNULL(listPushS(&list, ".."));
}
else {
// remove .. in path
@@ -3368,7 +3387,7 @@ char *bLNormalizePath(char *path, size_t pathSize) {
}
else if (!strEq(*level, ".")) {
// remove . and add elements
- listPushS(&list, *level);
+ pErrorNULL(listPushS(&list, *level));
// an element is pushed, so this is the end of leading double dots
onlyLeadingDoubleDots = false;
}
@@ -3381,7 +3400,7 @@ char *bLNormalizePath(char *path, size_t pathSize) {
// handle /.: add empty string
if (strEq(path, "/.")) {
- listPushS(&list, "");
+ pErrorNULL(listPushS(&list, ""));
}
// keep leading /
@@ -3392,7 +3411,7 @@ char *bLNormalizePath(char *path, size_t pathSize) {
strcpy(path, "/");
return(path);
}
- listPrependS(&list, "");
+ pErrorNULL(listPrependS(&list, ""));
}
// create new path
@@ -3404,7 +3423,7 @@ char *bLNormalizePath(char *path, size_t pathSize) {
bEmptyS(path);
return(path);
}
- strLCpy(path, pathSize, r);
+ pErrorNULL(strLCpy(path, pathSize, r));
free(r);
return(path);
}
@@ -3448,7 +3467,7 @@ char *relPath(const char *path, const char *start) {
// normalize path and start
char *npath = expandHome(path);
- iNormalizePath(&npath);
+ pErrorNULL(iNormalizePath(&npath));
char *nstart;
char *cwd = getCwd();
@@ -3460,7 +3479,7 @@ char *relPath(const char *path, const char *start) {
else {
// use start in argument
nstart = expandHome(start);;
- iNormalizePath(&nstart);
+ pErrorNULL(iNormalizePath(&nstart));
}
// when path and start are equal, return "."
@@ -3472,29 +3491,29 @@ char *relPath(const char *path, const char *start) {
// if path is relative path and start is absolute path
// then path is relative to nstart
if (npath[0] != '/' and nstart[0] == '/') {
- iPrependS(&npath, "/");
- iPrependS(&npath, nstart);
- iNormalizePath(&npath);
+ pErrorNULL(iPrependS(&npath, "/"));
+ pErrorNULL(iPrependS(&npath, nstart));
+ pErrorNULL(iNormalizePath(&npath));
}
// if path is absolute path and start is relative path
// then start is relative to cwd
if (npath[0] == '/' and nstart[0] != '/') {
- iPrependS(&nstart, "/");
- iPrependS(&nstart, cwd);
- iNormalizePath(&nstart);
+ pErrorNULL(iPrependS(&nstart, "/"));
+ pErrorNULL(iPrependS(&nstart, cwd));
+ pErrorNULL(iNormalizePath(&nstart));
}
// when path starts with nstart, slice path to only keep the string
// after the end of nstart
if (startsWithS(npath, nstart)) {
if (npath[strlen(nstart)] == '/') {
- r = sliceS(npath, strlen(nstart)+1, 0);
+ r = sliceS(npath, (i64)strlen(nstart)+1, 0);
goto end;
}
// handle case when nstart is "/" after normalize
if (npath[strlen(nstart)-1] == '/') {
- r = sliceS(npath, strlen(nstart), 0);
+ r = sliceS(npath, (i64)strlen(nstart), 0);
goto end;
}
// fallthrough: npath starts with nstart but is a different path
@@ -3527,7 +3546,7 @@ char *relPath(const char *path, const char *start) {
// go up directories to last common directory between npath and nstart
r = repeatS("../", slash);;
- iAppendS(&r, npath+from);
+ pErrorNULL(iAppendS(&r, npath+from));
end:
free(npath);
@@ -3575,7 +3594,7 @@ char *iRelPath(char **path, const char *start) {
// normalize path and start
char *npath = expandHome(*path);
- iNormalizePath(&npath);
+ pErrorNULL(iNormalizePath(&npath));
char *nstart;
char *cwd = getCwd();
@@ -3587,7 +3606,7 @@ char *iRelPath(char **path, const char *start) {
else {
// use start in argument
nstart = expandHome(start);;
- iNormalizePath(&nstart);
+ pErrorNULL(iNormalizePath(&nstart));
}
// when path and start are equal, return "."
@@ -3599,29 +3618,29 @@ char *iRelPath(char **path, const char *start) {
// if path is relative path and start is absolute path
// then path is relative to nstart
if (npath[0] != '/' and nstart[0] == '/') {
- iPrependS(&npath, "/");
- iPrependS(&npath, nstart);
- iNormalizePath(&npath);
+ pErrorNULL(iPrependS(&npath, "/"));
+ pErrorNULL(iPrependS(&npath, nstart));
+ pErrorNULL(iNormalizePath(&npath));
}
// if path is absolute path and start is relative path
// then start is relative to cwd
if (npath[0] == '/' and nstart[0] != '/') {
- iPrependS(&nstart, "/");
- iPrependS(&nstart, cwd);
- iNormalizePath(&nstart);
+ pErrorNULL(iPrependS(&nstart, "/"));
+ pErrorNULL(iPrependS(&nstart, cwd));
+ pErrorNULL(iNormalizePath(&nstart));
}
// when path starts with nstart, slice path to only keep the string
// after the end of nstart
if (startsWithS(npath, nstart)) {
if (npath[strlen(nstart)] == '/') {
- r = sliceS(npath, strlen(nstart)+1, 0);
+ r = sliceS(npath, (i64)strlen(nstart)+1, 0);
goto end;
}
// handle case when nstart is "/" after normalize
if (npath[strlen(nstart)-1] == '/') {
- r = sliceS(npath, strlen(nstart), 0);
+ r = sliceS(npath, (i64)strlen(nstart), 0);
goto end;
}
// fallthrough: npath starts with nstart but is a different path
@@ -3655,7 +3674,7 @@ char *iRelPath(char **path, const char *start) {
// go up directories to last common directory between npath and nstart
r = repeatS("../", slash);;
- iAppendS(&r, npath+from);
+ pErrorNULL(iAppendS(&r, npath+from));
end:
free(npath);
@@ -3706,7 +3725,7 @@ char *bRelPath(char *dest, const char *path, const char *start) {
// normalize path and start
char *npath = expandHome(path);
- iNormalizePath(&npath);
+ pErrorNULL(iNormalizePath(&npath));
char *nstart;
char *cwd = getCwd();
@@ -3718,7 +3737,7 @@ char *bRelPath(char *dest, const char *path, const char *start) {
else {
// use start in argument
nstart = expandHome(start);;
- iNormalizePath(&nstart);
+ pErrorNULL(iNormalizePath(&nstart));
}
// when path and start are equal, return "."
@@ -3730,29 +3749,29 @@ char *bRelPath(char *dest, const char *path, const char *start) {
// if path is relative path and start is absolute path
// then path is relative to nstart
if (npath[0] != '/' and nstart[0] == '/') {
- iPrependS(&npath, "/");
- iPrependS(&npath, nstart);
- iNormalizePath(&npath);
+ pErrorNULL(iPrependS(&npath, "/"));
+ pErrorNULL(iPrependS(&npath, nstart));
+ pErrorNULL(iNormalizePath(&npath));
}
// if path is absolute path and start is relative path
// then start is relative to cwd
if (npath[0] == '/' and nstart[0] != '/') {
- iPrependS(&nstart, "/");
- iPrependS(&nstart, cwd);
- iNormalizePath(&nstart);
+ pErrorNULL(iPrependS(&nstart, "/"));
+ pErrorNULL(iPrependS(&nstart, cwd));
+ pErrorNULL(iNormalizePath(&nstart));
}
// when path starts with nstart, slice path to only keep the string
// after the end of nstart
if (startsWithS(npath, nstart)) {
if (npath[strlen(nstart)] == '/') {
- r = sliceS(npath, strlen(nstart)+1, 0);
+ r = sliceS(npath, (i64)strlen(nstart)+1, 0);
goto end;
}
// handle case when nstart is "/" after normalize
if (npath[strlen(nstart)-1] == '/') {
- r = sliceS(npath, strlen(nstart), 0);
+ r = sliceS(npath, (i64)strlen(nstart), 0);
goto end;
}
// fallthrough: npath starts with nstart but is a different path
@@ -3785,7 +3804,7 @@ char *bRelPath(char *dest, const char *path, const char *start) {
// go up directories to last common directory between npath and nstart
r = repeatS("../", slash);;
- iAppendS(&r, npath+from);
+ pErrorNULL(iAppendS(&r, npath+from));
end:
free(npath);
@@ -3836,7 +3855,7 @@ char *bLRelPath(char *dest, size_t destSize, char *path, const char *start) {
// normalize path and start
char *npath = expandHome(path);
- iNormalizePath(&npath);
+ pErrorNULL(iNormalizePath(&npath));
char *nstart;
char *cwd = getCwd();
@@ -3848,7 +3867,7 @@ char *bLRelPath(char *dest, size_t destSize, char *path, const char *start) {
else {
// use start in argument
nstart = expandHome(start);;
- iNormalizePath(&nstart);
+ pErrorNULL(iNormalizePath(&nstart));
}
// when path and start are equal, return "."
@@ -3860,29 +3879,29 @@ char *bLRelPath(char *dest, size_t destSize, char *path, const char *start) {
// if path is relative path and start is absolute path
// then path is relative to nstart
if (npath[0] != '/' and nstart[0] == '/') {
- iPrependS(&npath, "/");
- iPrependS(&npath, nstart);
- iNormalizePath(&npath);
+ pErrorNULL(iPrependS(&npath, "/"));
+ pErrorNULL(iPrependS(&npath, nstart));
+ pErrorNULL(iNormalizePath(&npath));
}
// if path is absolute path and start is relative path
// then start is relative to cwd
if (npath[0] == '/' and nstart[0] != '/') {
- iPrependS(&nstart, "/");
- iPrependS(&nstart, cwd);
- iNormalizePath(&nstart);
+ pErrorNULL(iPrependS(&nstart, "/"));
+ pErrorNULL(iPrependS(&nstart, cwd));
+ pErrorNULL(iNormalizePath(&nstart));
}
// when path starts with nstart, slice path to only keep the string
// after the end of nstart
if (startsWithS(npath, nstart)) {
if (npath[strlen(nstart)] == '/') {
- r = sliceS(npath, strlen(nstart)+1, 0);
+ r = sliceS(npath, (i64)strlen(nstart)+1, 0);
goto end;
}
// handle case when nstart is "/" after normalize
if (npath[strlen(nstart)-1] == '/') {
- r = sliceS(npath, strlen(nstart), 0);
+ r = sliceS(npath, (i64)strlen(nstart), 0);
goto end;
}
// fallthrough: npath starts with nstart but is a different path
@@ -3914,14 +3933,14 @@ char *bLRelPath(char *dest, size_t destSize, char *path, const char *start) {
// go up directories to last common directory between npath and nstart
r = repeatS("../", slash);;
- iAppendS(&r, npath+from);
+ pErrorNULL(iAppendS(&r, npath+from));
end:
free(npath);
free(nstart);
free(cwd);
- strLCpy(dest, destSize, r);
+ pErrorNULL(strLCpy(dest, destSize, r));
free(r);
return(dest);
}
@@ -3980,7 +3999,7 @@ char *bLGetHomePath(char *path, size_t pathSize) {
if (strlen(pw->pw_dir)+1 > pathSize) {
return(NULL);
}
- strLCpy(path, pathSize, pw->pw_dir);
+ pErrorNULL(strLCpy(path, pathSize, pw->pw_dir));
return(path);
}
@@ -4128,7 +4147,7 @@ char *shReadlink(const char *path) {
bufSize = PATH_MAX;
}
else {
- bufSize = st.st_size + 1;
+ bufSize = (size_t)st.st_size + 1;
}
linked = MALLOC(bufSize);
@@ -4192,10 +4211,10 @@ char *endlink(const char *path) {
bufSize = PATH_MAX;
}
else {
- bufSize = st.st_size + 1;
+ bufSize = (size_t)st.st_size + 1;
}
- strLCpy(from, sizeof from, path);
+ pErrorNULL(strLCpy(from, sizeof from, path));
while (S_ISLNK(st.st_mode)) {
r = readlink(from, to, bufSize);
@@ -4209,9 +4228,9 @@ char *endlink(const char *path) {
to[r] = 0;
if (to[0] != '/') {
- bDirname(from);
- bLAppendManyS(from, PATH_MAX, "/", to);
- bNormalizePath(from);
+ pErrorNULL(bDirname(from));
+ pErrorNULL(bLAppendManyS(from, PATH_MAX, "/", to));
+ pErrorNULL(bNormalizePath(from));
}
else {
// copy absolute path
@@ -4227,7 +4246,7 @@ char *endlink(const char *path) {
bufSize = PATH_MAX;
}
else {
- bufSize = st.st_size + 1;
+ bufSize = (size_t)st.st_size + 1;
}
}
@@ -4395,7 +4414,7 @@ void *readFileToS(const char *filePath) {
}
// +1 to add \0 at the end
- r = MALLOC(len+1);
+ r = MALLOC((size_t)len+1);
if (!r) {
return(NULL);
}
@@ -4407,7 +4426,7 @@ void *readFileToS(const char *filePath) {
shEPrintfS("The path was: \"%s\"\n", filePath);
return(NULL);
}
- readStatus = fread(r, 1, len , f);
+ readStatus = fread(r, 1, (size_t)len , f);
fclose(f);
if (readStatus != (size_t)len) {
@@ -4449,12 +4468,12 @@ void *readStreamToS(FILE *fp) {
}
// +1 to add \0 at the end
- r = MALLOC(len+1);
+ r = MALLOC((size_t)len+1);
if (!r) {
return(NULL);
}
- readStatus = fread(r, 1, len , fp);
+ readStatus = fread(r, 1, (size_t)len , fp);
if (readStatus != (size_t)len) {
free(r);
@@ -4503,7 +4522,7 @@ void *bReadFileToS(const char *filePath, void *dst) {
return(NULL);
}
- readStatus = fread(dst, 1, len , f);
+ readStatus = fread(dst, 1, (size_t)len , f);
fclose(f);
if (readStatus != (size_t)len) {
@@ -4544,7 +4563,7 @@ void *bReadStreamToS(FILE *fp, void *dst) {
return(NULL);
}
- readStatus = fread(dst, 1, len , fp);
+ readStatus = fread(dst, 1, (size_t)len , fp);
if (readStatus != (size_t)len) {
pFuncError
@@ -4593,7 +4612,7 @@ void *bLReadFileToS(const char *filePath, void *dst, size_t dstSize) {
}
// truncate if necessary
- len = ((size_t)len < dstSize) ? (size_t)len : dstSize-1;
+ len = ((size_t)len < dstSize) ? len : (ssize_t)dstSize-1;
f = fopen(filePath, "r");
if (!f) {
@@ -4602,7 +4621,7 @@ void *bLReadFileToS(const char *filePath, void *dst, size_t dstSize) {
return(NULL);
}
- readStatus = fread(dst, 1, len , f);
+ readStatus = fread(dst, 1, (size_t)len , f);
fclose(f);
if (readStatus != (size_t)len) {
@@ -4649,9 +4668,9 @@ void *bLReadStreamToS(FILE *fp, void *dst, size_t dstSize) {
}
// truncate if necessary
- len = ((size_t)len < dstSize) ? (size_t)len : dstSize-1;
+ len = ((size_t)len < dstSize) ? len : (ssize_t)dstSize-1;
- readStatus = fread(dst, 1, len , fp);
+ readStatus = fread(dst, 1, (size_t)len , fp);
if (readStatus != (size_t)len) {
pFuncError
@@ -4693,7 +4712,7 @@ ssize_t readFile(const char *filePath, void **buffer) {
}
// +1 to add \0 at the end
- *buffer = MALLOC(len);
+ *buffer = MALLOC((size_t)len);
if (!*buffer) {
return(-1);
}
@@ -4705,7 +4724,7 @@ ssize_t readFile(const char *filePath, void **buffer) {
shEPrintfS("The path was: \"%s\"\n", filePath);
return(-1);
}
- readStatus = fread(*buffer, 1, len , f);
+ readStatus = fread(*buffer, 1, (size_t)len , f);
fclose(f);
if (readStatus != (size_t)len) {
@@ -4754,7 +4773,7 @@ ssize_t bReadFile(const char *filePath, void *buffer) {
shEPrintfS("The path was: \"%s\"\n", filePath);
return(-1);
}
- readStatus = fread(buffer, 1, len , f);
+ readStatus = fread(buffer, 1, (size_t)len , f);
fclose(f);
if (readStatus != (size_t)len) {
@@ -4803,7 +4822,7 @@ ssize_t bLReadFile(const char *filePath, void *buffer, size_t dstSize) {
}
// truncate if necessary
- len = ((size_t)len < dstSize) ? (size_t)len : dstSize;
+ len = ((size_t)len < dstSize) ? len : (ssize_t)dstSize;
f = fopen(filePath, "r");
if (!f) {
@@ -4811,7 +4830,7 @@ ssize_t bLReadFile(const char *filePath, void *buffer, size_t dstSize) {
shEPrintfS("The path was: \"%s\"\n", filePath);
return(-1);
}
- readStatus = fread(buffer, 1, len , f);
+ readStatus = fread(buffer, 1, (size_t)len , f);
fclose(f);
if (readStatus != (size_t)len) {
@@ -5064,7 +5083,7 @@ char **walkDir(const char* dirPath) {
walkADir(dirPath, &list);
- iListSortS(&list);
+ pErrorNULL(iListSortS(&list));
return(list);
}
@@ -5096,7 +5115,7 @@ internal void walkADir(const char *dirPath, char ***list) {
}
}
else {
- listPushS(list, sPath);
+ pErrorNULL(listPushS(list, sPath));
}
free(sPath);
dp = readdir(d);
@@ -5127,7 +5146,7 @@ char **walkDirDir(const char* dirPath) {
walkADirDir(dirPath, &list);
- iListSortS(&list);
+ pErrorNULL(iListSortS(&list));
return(list);
}
@@ -5154,7 +5173,7 @@ internal void walkADirDir(const char *dirPath, char ***list) {
sPath = catS(dirPath, "/", dp->d_name);
if (isDir(sPath)) {
- listPushS(list, sPath);
+ pErrorNULL(listPushS(list, sPath));
if (!isLink(sPath)) {
walkADirDir(sPath, list);
}
@@ -5205,7 +5224,7 @@ char **readDir(const char *dirPath) {
char *sPath = catS(dirPath, "/", dp->d_name);
if (!isDir(sPath)) {
- listPushS(&list, dp->d_name);
+ pErrorNULL(listPushS(&list, dp->d_name));
}
free(sPath);
dp = readdir(d);
@@ -5213,7 +5232,7 @@ char **readDir(const char *dirPath) {
closedir(d);
- iListSortS(&list);
+ pErrorNULL(iListSortS(&list));
return(list);
}
@@ -5257,7 +5276,7 @@ char **readDirDir(const char *dirPath) {
char *sPath = catS(dirPath, "/", dp->d_name);
if (isDir(sPath)) {
- listPushS(&list, dp->d_name);
+ pErrorNULL(listPushS(&list, dp->d_name));
}
free(sPath);
dp = readdir(d);
@@ -5265,7 +5284,7 @@ char **readDirDir(const char *dirPath) {
closedir(d);
- iListSortS(&list);
+ pErrorNULL(iListSortS(&list));
return(list);
}
@@ -5292,7 +5311,7 @@ char **walkDirAll(const char* dirPath) {
walkADirAll(dirPath, &list);
- iListSortS(&list);
+ pErrorNULL(iListSortS(&list));
return(list);
}
@@ -5318,7 +5337,7 @@ internal void walkADirAll(const char *dirPath, char ***list) {
sPath = catS(dirPath, "/", dp->d_name);
- iListPushS(list, sPath);
+ pErrorNULL(iListPushS(list, sPath));
if (isDir(sPath)) {
if (!isLink(sPath)) {
@@ -5369,14 +5388,14 @@ char **readDirAll(const char *dirPath) {
char *sPath = catS(dirPath, "/", dp->d_name);
- listPushS(&list, dp->d_name);
+ pErrorNULL(listPushS(&list, dp->d_name));
free(sPath);
dp = readdir(d);
}
closedir(d);
- iListSortS(&list);
+ pErrorNULL(iListSortS(&list));
return(list);
}
@@ -5384,7 +5403,7 @@ char **readDirAll(const char *dirPath) {
/**
* get umask
*/
-mode_t getumask(void) {
+mode_t getUmask(void) {
mode_t mask = umask(0);
umask(mask);
@@ -5396,7 +5415,7 @@ mode_t getumask(void) {
*/
mode_t getCurrentPermissions(void) {
- return(0777 & ~getumask());
+ return(0777 & ~getUmask());
}
/**
@@ -5491,8 +5510,6 @@ int rmADir(const char *dirPath) {
return(0);
}
- size_t dirPathLen = strlen(dirPath);
-
dp = readdir(d);
while (dp) {
if (eqS(dp->d_name, ".") || eqS(dp->d_name, "..")) {
@@ -5500,23 +5517,30 @@ int rmADir(const char *dirPath) {
continue;
}
- sPath = alloca( dirPathLen + 1 + strlen(dp->d_name) + 1 );
- sprintf(sPath, "%s/%s", dirPath, dp->d_name);
+ int e = asprintf(&sPath, "%s/%s", dirPath, dp->d_name);
+ if (e == -1) {
+ pFuncError;
+ shEPrintfS("The path was: \"%s\"\n", dirPath);
+ closedir(d);
+ return(0);
+ }
+
if (isDir(sPath)) {
r = rmADir(sPath);;
}
else {
- pErrorResultCmd(r, remove(sPath), == -1, pFuncError; shEPrintfS("The path was: \"%s\"\n", sPath); r=0; break);
+ pErrorResultCmd(r, remove(sPath), == -1, pFuncError; shEPrintfS("The path was: \"%s\"\n", sPath); r=0; free(sPath); break);
r = 1;
}
dp = readdir(d);
+ free(sPath);
}
closedir(d);
int rd;
- pErrorResultCmd(rd, rmdir(dirPath), == -1, pFuncError; shEPrintfS("The path was: \"%s\"\n", sPath); return(0));;
+ pErrorResultCmd(rd, rmdir(dirPath), == -1, pFuncError; shEPrintfS("The path was: \"%s\"\n", dirPath); return(0));;
return(r);
}
@@ -5553,9 +5577,9 @@ int copy(const char* src, const char* dst) {
// dst name is a directory, add src basename to dst
char *csrc = strdup(src);
char *path = basename(csrc);
- free(csrc);
char *dPath = alloca(strlen(dst) + 1 + strlen(path) + 1);
sprintf(dPath, "%s/%s", dst, path);
+ free(csrc);
return(copyFile(src, dPath));
}
else {
@@ -5577,10 +5601,10 @@ int copy(const char* src, const char* dst) {
}
else {
char *csrc = strdup(src);
- char *path = basename((char*)src);
- free(csrc);
+ char *path = basename(csrc);
char *dPath = alloca(strlen(dst) + 1 + strlen(path) + 1);
sprintf(dPath, "%s/%s", dst, path);
+ free(csrc);
if (!mkdirParents(dPath)) {
if (errno != EEXIST) {
@@ -5667,22 +5691,16 @@ int copyADir(const char *src, const char *dst, const char *path) {
int r = 1;;
char *currentSrc = NULL;
char *currentDst = NULL;
- size_t cSrcLen;
- size_t cDstLen;
- cSrcLen = strlen(src) + 1 + strlen(path);
- cDstLen = strlen(dst) + 1 + strlen(path);
-
- currentSrc = alloca(cSrcLen + 1);
- currentDst = alloca(cDstLen + 1);
-
- sprintf(currentSrc, "%s/%s", src, path);
- sprintf(currentDst, "%s/%s", dst, path);
+ asprintf(¤tSrc, "%s/%s", src, path);
+ asprintf(¤tDst, "%s/%s", dst, path);
d = opendir(currentSrc);
if (!d) {
pFuncError
shEPrintfS("The path was: \"%s\"\n", currentSrc);
+ free(currentSrc);
+ free(currentDst);
return(0);
}
@@ -5693,15 +5711,14 @@ int copyADir(const char *src, const char *dst, const char *path) {
continue;
}
- sPath = alloca(cSrcLen + 1 + strlen(dp->d_name) + 1);
- dPath = alloca(cDstLen + 1 + strlen(dp->d_name) + 1);
-
- sprintf(sPath, "%s/%s", currentSrc, dp->d_name);
- sprintf(dPath, "%s/%s", currentDst, dp->d_name);
+ asprintf(&sPath, "%s/%s", currentSrc, dp->d_name);
+ asprintf(&dPath, "%s/%s", currentDst, dp->d_name);
if (isDir(sPath)) {
if (isLink(sPath)) {
dp = readdir(d);
+ free(sPath);
+ free(dPath);
continue;
}
mode_t mode = getCurrentPermissions();
@@ -5710,34 +5727,44 @@ int copyADir(const char *src, const char *dst, const char *path) {
pFuncError
shEPrintfS("The path was: \"%s\"\n", dPath);
r = 0;
+ free(sPath);
+ }
+ free(dPath);
break;
}
- }
- currentPath = alloca(strlen(path) + 1 + strlen(dp->d_name) + 1);
- sprintf(currentPath, "%s/%s", path, dp->d_name);
+ asprintf(¤tPath, "%s/%s", path, dp->d_name);
r = copyADir(src, dst, currentPath);;
+ free(currentPath);
// copy permissions
struct stat st;
if (stat(sPath, &st)) {
pFuncError
shEPrintfS("The path was: \"%s\"\n", sPath);
r = 0;
+ free(sPath);
+ free(dPath);
break;
}
if (chmod(dPath, st.st_mode & 07777)) {
pFuncError
shEPrintfS("The path was: \"%s\"\n", dPath);
r = 0;
+ free(sPath);
+ free(dPath);
break;
}
}
else {
- pErrorResultCmd(r, copyFile(sPath, dPath), == 0, pFuncError; shEPrintfS("The path was: \"%s\"\n", sPath); break);
+ pErrorResultCmd(r, copyFile(sPath, dPath), == 0, pFuncError; shEPrintfS("The path was: \"%s\"\n", sPath); free(sPath); free(dPath); break);
}
dp = readdir(d);
+ free(sPath);
+ free(dPath);
}
closedir(d);
+ free(currentSrc);
+ free(currentDst);
return(r);
}
@@ -5815,7 +5842,7 @@ static randomWordFt randomWordF = randomWord;
void setSoftwareRandom(void) {
randomWordF = randomWord;
- randomUrandomOpen();
+ pError0(randomUrandomOpen());
}
/**
@@ -6190,7 +6217,7 @@ char *bRandomAlphaNumS(char *dst, size_t dstSize) {
char *readS(void) {
int max = startMax;;
- char *s = MALLOC(max);
+ char *s = MALLOC((size_t)max);
if (!s) {
return(NULL);
}
@@ -6212,11 +6239,11 @@ char *readS(void) {
s[i] = 0;
break;
}
- s[i] = c;
+ s[i] = (char)c;
if (i == max-1) {
// buffer full
max += max;
- char *tmp = REALLOC(s, max);
+ char *tmp = REALLOC(s, (size_t)max);
if (!tmp) {
free(s);
return(NULL);
@@ -6263,7 +6290,7 @@ char *bLReadS(char *dst, size_t dstSize) {
dst[i] = 0;
break;
}
- dst[i] = c;
+ dst[i] = (char)c;
i++;
}
return(dst);
@@ -6295,7 +6322,7 @@ UNUSED local char *shGetpass(void) {
return(NULL);
}
new = old;
- new.c_lflag &= ~ECHO;
+ new.c_lflag &= ~(tcflag_t)ECHO;
if (tcsetattr (fileno (stream), TCSAFLUSH, &new) != 0) {
fclose(stream);
return(NULL);
@@ -6714,7 +6741,7 @@ char *toHexHeadSepS(const void *buf, size_t len, const char *head, const char *s
* dst string
* NULL error
*/
-char *strCpy(char *dst, const char *src) {
+char *strCpy(char *restrict dst, const char *restrict src) {
if (!dst || !src) {
return(NULL);
@@ -6739,7 +6766,7 @@ char *strCpy(char *dst, const char *src) {
* dst string
* NULL error
*/
-char *strNCpy(char *dst, const char *src, size_t srcSize) {
+char *strNCpy(char *restrict dst, const char *restrict src, size_t srcSize) {
if (!dst || !src) {
return(NULL);
@@ -6765,7 +6792,7 @@ char *strNCpy(char *dst, const char *src, size_t srcSize) {
* dst string
* NULL error
*/
-char *strLCpy(char *dst, size_t dstSize, const char *src) {
+char *strLCpy(char *restrict dst, size_t dstSize, const char *restrict src) {
if (!dst || !src) {
return(NULL);
@@ -6791,7 +6818,7 @@ char *strLCpy(char *dst, size_t dstSize, const char *src) {
* string with input strings concatenated
* NULL error
*/
-char *strCat(char *dst, const char *src) {
+char *strCat(char *restrict dst, const char *restrict src) {
if (!dst || !src) {
return(NULL);
@@ -6815,7 +6842,7 @@ char *strCat(char *dst, const char *src) {
* string with input strings concatenated
* NULL error
*/
-char *strNCat(char *dst, const char *src, size_t srcLen) {
+char *strNCat(char *restrict dst, const char *restrict src, size_t srcLen) {
if (!dst || !src) {
return(NULL);
@@ -6840,7 +6867,7 @@ char *strNCat(char *dst, const char *src, size_t srcLen) {
* NULL error
*/
/* same/slower than the other implementation with -O2 and kaby lake */
-char *strLCat(char *dst, size_t dstSize, const char *src) {
+char *strLCat(char *restrict dst, size_t dstSize, const char *restrict src) {
if (!dst || !src) {
return(NULL);
@@ -6909,7 +6936,7 @@ char *strLCat(char *dst, size_t dstSize, const char *src) {
* string with input strings concatenated
* NULL error
*/
-char *strLNCat(char *dst, size_t dstSize, const char *src, size_t srcLen) {
+char *strLNCat(char *restrict dst, size_t dstSize, const char *restrict src, size_t srcLen) {
if (!dst || !src) {
return(NULL);
@@ -6950,7 +6977,7 @@ char *catSF(const char *paramType, ...) {
va_start(pl, paramType);
paramType = va_arg(pl, char *);
while (paramType) {
- listPushS(&l, paramType);
+ pErrorNULL(listPushS(&l, paramType));
paramType = va_arg(pl, char *);
}
va_end(pl);
@@ -7018,7 +7045,7 @@ char *bLCatSF(char *dst, size_t dstSize, const char *paramType, ...) {
va_start(pl, paramType);
paramType = va_arg(pl, char *);
while (paramType) {
- strLCat(dst, dstSize, paramType);
+ pErrorNULL(strLCat(dst, dstSize, paramType));
paramType = va_arg(pl, char *);
}
va_end(pl);
@@ -7340,14 +7367,14 @@ char *iAppendManySF(char **string, const char *paramType, ...) {
return(NULL);
}
- iListPushS(&l, *string);
- listPushS(&l, paramType);
+ pErrorNULL(iListPushS(&l, *string));
+ pErrorNULL(listPushS(&l, paramType));
// add arguments to a list
va_start(pl, paramType);
paramType = va_arg(pl, char *);
while (paramType) {
- listPushS(&l, paramType);
+ pErrorNULL(listPushS(&l, paramType));
paramType = va_arg(pl, char *);
}
va_end(pl);
@@ -7379,14 +7406,14 @@ char *bAppendManySF(char *string, const char *paramType, ...) {
return(NULL);
}
- listPushS(&l, string);
- listPushS(&l, paramType);
+ pErrorNULL(listPushS(&l, string));
+ pErrorNULL(listPushS(&l, paramType));
// add arguments to a list
va_start(pl, paramType);
paramType = va_arg(pl, char *);
while (paramType) {
- listPushS(&l, paramType);
+ pErrorNULL(listPushS(&l, paramType));
paramType = va_arg(pl, char *);
}
va_end(pl);
@@ -7423,14 +7450,14 @@ char *bLAppendManySF(char *string, size_t stringSize, const char *paramType, ...
return(string);
}
- listPushS(&l, string);
- listPushS(&l, paramType);
+ pErrorNULL(listPushS(&l, string));
+ pErrorNULL(listPushS(&l, paramType));
// add arguments to a list
va_start(pl, paramType);
paramType = va_arg(pl, char *);
while (paramType) {
- listPushS(&l, paramType);
+ pErrorNULL(listPushS(&l, paramType));
paramType = va_arg(pl, char *);
}
va_end(pl);
@@ -7438,7 +7465,7 @@ char *bLAppendManySF(char *string, size_t stringSize, const char *paramType, ...
r = join(l, "");
listFreeS(l);
- strLCpy(string, stringSize, r);
+ pErrorNULL(strLCpy(string, stringSize, r));
free(r);
return(string);
}
@@ -7642,7 +7669,7 @@ char *bLPrependS(char *string1, size_t string1Size, const char *string2) {
}
if (!*string1) {
- strLCpy(string1, string1Size, string2);
+ pErrorNULL(strLCpy(string1, string1Size, string2));
return(string1);
}
@@ -7681,8 +7708,6 @@ char* replaceS(const char *s, const char *olds, const char *news, size_t max ) {
const char *ins = NULL;
size_t count;
size_t lfront;
- bool freeNewsStatus = false;;
- char *internalNews = NULL;
// sanity checks and initialization
// count the number of replacements needed
@@ -7709,11 +7734,7 @@ char* replaceS(const char *s, const char *olds, const char *news, size_t max ) {
}
if (!news) {
// empty string for NULL
- freeNewsStatus = true;
- emptyS(internalNews)
- }
- else {
- internalNews = (char *) news;
+ news = "";
}
// count the number of replacements needed
@@ -7728,14 +7749,11 @@ char* replaceS(const char *s, const char *olds, const char *news, size_t max ) {
size_t lnews;
- lnews = strlen(internalNews);
+ lnews = strlen(news);
// allocate result
tmp = r = MALLOC(strlen(s) + (lnews - lolds) * count + 1);
if (!r) {
- if (freeNewsStatus) {
- free(internalNews);
- }
return(NULL);//LCOV_EXCL_LINE
}
@@ -7746,17 +7764,14 @@ char* replaceS(const char *s, const char *olds, const char *news, size_t max ) {
// s is the remainder of s after end of olds
while (count--) {
ins = strstr(s, olds);
- lfront = ins - s;
+ lfront = (size_t)(ins - s);
tmp = strncpy(tmp, s, lfront) + lfront;
- tmp = strcpy(tmp, internalNews) + lnews;
+ tmp = strcpy(tmp, news) + lnews;
s += lfront + lolds;
}
// copy end of string
strcpy(tmp, s);
- if (freeNewsStatus) {
- free(internalNews);
- }
return(r);
}
@@ -7802,8 +7817,6 @@ char* iReplaceS(char **s, const char *olds, const char *news, size_t max ) {
char *ins = NULL;
size_t count;
size_t lfront;
- bool freeNewsStatus = false;;
- char *internalNews = NULL;
// sanity checks and initialization
// count the number of replacements needed
@@ -7830,11 +7843,7 @@ char* iReplaceS(char **s, const char *olds, const char *news, size_t max ) {
}
if (!news) {
// empty string for NULL
- freeNewsStatus = true;
- emptyS(internalNews)
- }
- else {
- internalNews = (char *) news;
+ news = "";
}
// count the number of replacements needed
@@ -7849,15 +7858,12 @@ char* iReplaceS(char **s, const char *olds, const char *news, size_t max ) {
size_t lnews;
- lnews = strlen(internalNews);
+ lnews = strlen(news);
// allocate result
size_t rLen = strlen(*s) + (lnews - lolds) * count + 1;;
tmp = r = MALLOC(rLen);
if (!r) {
- if (freeNewsStatus) {
- free(internalNews);
- }
return(NULL);
}
@@ -7868,17 +7874,14 @@ char* iReplaceS(char **s, const char *olds, const char *news, size_t max ) {
// s is the remainder of s after end of olds
while (count--) {
ins = strstr(workingS, olds);
- lfront = ins - workingS;
+ lfront = (size_t)(ins - workingS);
tmp = strncpy(tmp, workingS, lfront) + lfront;
- tmp = strcpy(tmp, internalNews) + lnews;
+ tmp = strcpy(tmp, news) + lnews;
workingS += lfront + lolds;
}
// copy end of string
strcpy(tmp, workingS);
- if (freeNewsStatus) {
- free(internalNews);
- }
free(*s);
*s = r;
@@ -7926,8 +7929,6 @@ char* bReplaceS(char *s, const char *olds, const char *news, size_t max ) {
char *ins = NULL;
size_t count;
size_t lfront;
- bool freeNewsStatus = false;;
- char *internalNews = NULL;
// sanity checks and initialization
// count the number of replacements needed
@@ -7954,11 +7955,7 @@ char* bReplaceS(char *s, const char *olds, const char *news, size_t max ) {
}
if (!news) {
// empty string for NULL
- freeNewsStatus = true;
- emptyS(internalNews)
- }
- else {
- internalNews = (char *) news;
+ news = "";
}
// count the number of replacements needed
@@ -7973,15 +7970,12 @@ char* bReplaceS(char *s, const char *olds, const char *news, size_t max ) {
size_t lnews;
- lnews = strlen(internalNews);
+ lnews = strlen(news);
// allocate result
size_t rLen = strlen(s) + (lnews - lolds) * count + 1;;
tmp = r = MALLOC(rLen);
if (!r) {
- if (freeNewsStatus) {
- free(internalNews);
- }
return(NULL);
}
@@ -7992,17 +7986,14 @@ char* bReplaceS(char *s, const char *olds, const char *news, size_t max ) {
// s is the remainder of s after end of olds
while (count--) {
ins = strstr(workingS, olds);
- lfront = ins - workingS;
+ lfront = (size_t)(ins - workingS);
tmp = strncpy(tmp, workingS, lfront) + lfront;
- tmp = strcpy(tmp, internalNews) + lnews;
+ tmp = strcpy(tmp, news) + lnews;
workingS += lfront + lolds;
}
// copy end of string
strcpy(tmp, workingS);
- if (freeNewsStatus) {
- free(internalNews);
- }
strcpy(s, r);
free(r);
@@ -8031,8 +8022,6 @@ char* bLReplaceS(char *s, size_t sSize, const char *olds, const char *news, size
char *ins = NULL;
size_t count;
size_t lfront;
- bool freeNewsStatus = false;;
- char *internalNews = NULL;
// sanity checks and initialization
// count the number of replacements needed
@@ -8063,11 +8052,7 @@ char* bLReplaceS(char *s, size_t sSize, const char *olds, const char *news, size
}
if (!news) {
// empty string for NULL
- freeNewsStatus = true;
- emptyS(internalNews)
- }
- else {
- internalNews = (char *) news;
+ news = "";
}
// count the number of replacements needed
@@ -8082,15 +8067,12 @@ char* bLReplaceS(char *s, size_t sSize, const char *olds, const char *news, size
size_t lnews;
- lnews = strlen(internalNews);
+ lnews = strlen(news);
// allocate result
size_t rLen = strlen(s) + (lnews - lolds) * count + 1;;
tmp = r = MALLOC(rLen);
if (!r) {
- if (freeNewsStatus) {
- free(internalNews);
- }
return(NULL);
}
@@ -8101,19 +8083,16 @@ char* bLReplaceS(char *s, size_t sSize, const char *olds, const char *news, size
// s is the remainder of s after end of olds
while (count--) {
ins = strstr(workingS, olds);
- lfront = ins - workingS;
+ lfront = (size_t)(ins - workingS);
tmp = strncpy(tmp, workingS, lfront) + lfront;
- tmp = strcpy(tmp, internalNews) + lnews;
+ tmp = strcpy(tmp, news) + lnews;
workingS += lfront + lolds;
}
// copy end of string
strcpy(tmp, workingS);
- if (freeNewsStatus) {
- free(internalNews);
- }
- strLCpy(s, sSize, r);
+ pErrorNULL(strLCpy(s, sSize, r));
free(r);
return(s);
}
@@ -8142,11 +8121,11 @@ char* bLReplaceS(char *s, size_t sSize, const char *olds, const char *news, size
*/
char *replaceManySF(const char *paramType, ...) {
va_list pl;
+ char *param = NULL;
char *r = NULL;
char *workingS = NULL;
char *olds = NULL;
char *news = NULL;
- bool freeWorkingS = false;;
// sanity checks
if (!paramType) {
@@ -8157,31 +8136,29 @@ char *replaceManySF(const char *paramType, ...) {
return(emptySF());
}
- workingS = (char *) paramType;
+ workingS = strdup(paramType);
// add arguments to a list
va_start(pl, paramType);
- paramType = va_arg(pl, char *);
- while (paramType) {
+ param = va_arg(pl, char *);
+ while (param) {
if (!olds) {
- olds = (char *) paramType;
+ olds = param;
}
else if (!news) {
- news = (char *) paramType;
- r = replaceS(workingS, olds, news, 0);
+ news = param;
+ r = replaceS(workingS, olds, news, 0);
+ free(workingS);
olds = NULL;
news = NULL;
- if (!freeWorkingS) {
- freeWorkingS = true;
- }
- else {
- free(workingS);
- }
workingS = r;
}
- paramType = va_arg(pl, char *);
+ param = va_arg(pl, char *);
}
va_end(pl);
+ if (!r) {
+ free(workingS);
+ }
return(r);
}
@@ -8228,7 +8205,7 @@ char *iReplaceManySF(char **s, char *paramType, ...) {
}
else if (!news) {
news = (char *) paramType;
- iReplaceS(s, olds, news, 0);
+ pErrorNULL(iReplaceS(s, olds, news, 0));
olds = NULL;
news = NULL;
}
@@ -8271,18 +8248,18 @@ char *bReplaceManySF(char *s, char *paramType, ...) {
return(NULL);
}
- olds = (char *) paramType;;
+ olds = paramType;;
// add arguments to a list
va_start(pl, paramType);
paramType = va_arg(pl, char *);
while (paramType) {
if (!olds) {
- olds = (char *) paramType;
+ olds = paramType;
}
else if (!news) {
- news = (char *) paramType;
- bReplaceS(s, olds, news, 0);
+ news = paramType;
+ pErrorNULL(bReplaceS(s, olds, news, 0));
olds = NULL;
news = NULL;
}
@@ -8329,18 +8306,18 @@ char *bLReplaceManySF(char *s, size_t sSize, char *paramType, ...) {
return(NULL);
}
- olds = (char *) paramType;;
+ olds = paramType;;
// add arguments to a list
va_start(pl, paramType);
paramType = va_arg(pl, char *);
while (paramType) {
if (!olds) {
- olds = (char *) paramType;
+ olds = paramType;
}
else if (!news) {
- news = (char *) paramType;
- bLReplaceS(s, sSize, olds, news, 0);
+ news = paramType;
+ pErrorNULL(bLReplaceS(s, sSize, olds, news, 0));
olds = NULL;
news = NULL;
}
@@ -8376,8 +8353,6 @@ char* icReplaceS(const char *s, const char *olds, const char *news, size_t max )
const char *ins = NULL;
size_t count;
size_t lfront;
- bool freeNewsStatus = false;;
- char *internalNews = NULL;
// sanity checks and initialization
// count the number of replacements needed
@@ -8404,11 +8379,7 @@ char* icReplaceS(const char *s, const char *olds, const char *news, size_t max )
}
if (!news) {
// empty string for NULL
- freeNewsStatus = true;
- emptyS(internalNews)
- }
- else {
- internalNews = (char *) news;
+ news = "";
}
// count the number of replacements needed
@@ -8423,14 +8394,11 @@ char* icReplaceS(const char *s, const char *olds, const char *news, size_t max )
size_t lnews;
- lnews = strlen(internalNews);
+ lnews = strlen(news);
// allocate result
tmp = r = MALLOC(strlen(s) + (lnews - lolds) * count + 1);
if (!r) {
- if (freeNewsStatus) {
- free(internalNews);
- }
return(NULL);//LCOV_EXCL_LINE
}
@@ -8441,17 +8409,14 @@ char* icReplaceS(const char *s, const char *olds, const char *news, size_t max )
// s is the remainder of s after end of olds
while (count--) {
ins = strcasestr(s, olds);
- lfront = ins - s;
+ lfront = (size_t)(ins - s);
tmp = strncpy(tmp, s, lfront) + lfront;
- tmp = strcpy(tmp, internalNews) + lnews;
+ tmp = strcpy(tmp, news) + lnews;
s += lfront + lolds;
}
// copy end of string
strcpy(tmp, s);
- if (freeNewsStatus) {
- free(internalNews);
- }
return(r);
}
@@ -8497,8 +8462,6 @@ char* iicReplaceS(char **s, const char *olds, const char *news, size_t max ) {
char *ins = NULL;
size_t count;
size_t lfront;
- bool freeNewsStatus = false;;
- char *internalNews = NULL;
// sanity checks and initialization
// count the number of replacements needed
@@ -8525,11 +8488,7 @@ char* iicReplaceS(char **s, const char *olds, const char *news, size_t max ) {
}
if (!news) {
// empty string for NULL
- freeNewsStatus = true;
- emptyS(internalNews)
- }
- else {
- internalNews = (char *) news;
+ news = "";
}
// count the number of replacements needed
@@ -8544,15 +8503,12 @@ char* iicReplaceS(char **s, const char *olds, const char *news, size_t max ) {
size_t lnews;
- lnews = strlen(internalNews);
+ lnews = strlen(news);
// allocate result
size_t rLen = strlen(*s) + (lnews - lolds) * count + 1;;
tmp = r = MALLOC(rLen);
if (!r) {
- if (freeNewsStatus) {
- free(internalNews);
- }
return(NULL);
}
@@ -8563,17 +8519,14 @@ char* iicReplaceS(char **s, const char *olds, const char *news, size_t max ) {
// s is the remainder of s after end of olds
while (count--) {
ins = strcasestr(workingS, olds);
- lfront = ins - workingS;
+ lfront = (size_t)(ins - workingS);
tmp = strncpy(tmp, workingS, lfront) + lfront;
- tmp = strcpy(tmp, internalNews) + lnews;
+ tmp = strcpy(tmp, news) + lnews;
workingS += lfront + lolds;
}
// copy end of string
strcpy(tmp, workingS);
- if (freeNewsStatus) {
- free(internalNews);
- }
free(*s);
*s = r;
@@ -8621,8 +8574,6 @@ char* bicReplaceS(char *s, const char *olds, const char *news, size_t max ) {
char *ins = NULL;
size_t count;
size_t lfront;
- bool freeNewsStatus = false;;
- char *internalNews = NULL;
// sanity checks and initialization
// count the number of replacements needed
@@ -8649,11 +8600,7 @@ char* bicReplaceS(char *s, const char *olds, const char *news, size_t max ) {
}
if (!news) {
// empty string for NULL
- freeNewsStatus = true;
- emptyS(internalNews)
- }
- else {
- internalNews = (char *) news;
+ news = "";
}
// count the number of replacements needed
@@ -8668,15 +8615,12 @@ char* bicReplaceS(char *s, const char *olds, const char *news, size_t max ) {
size_t lnews;
- lnews = strlen(internalNews);
+ lnews = strlen(news);
// allocate result
size_t rLen = strlen(s) + (lnews - lolds) * count + 1;;
tmp = r = MALLOC(rLen);
if (!r) {
- if (freeNewsStatus) {
- free(internalNews);
- }
return(NULL);
}
@@ -8687,17 +8631,14 @@ char* bicReplaceS(char *s, const char *olds, const char *news, size_t max ) {
// s is the remainder of s after end of olds
while (count--) {
ins = strcasestr(workingS, olds);
- lfront = ins - workingS;
+ lfront = (size_t)(ins - workingS);
tmp = strncpy(tmp, workingS, lfront) + lfront;
- tmp = strcpy(tmp, internalNews) + lnews;
+ tmp = strcpy(tmp, news) + lnews;
workingS += lfront + lolds;
}
// copy end of string
strcpy(tmp, workingS);
- if (freeNewsStatus) {
- free(internalNews);
- }
strcpy(s, r);
free(r);
@@ -8726,8 +8667,6 @@ char* bLicReplaceS(char *s, size_t sSize, const char *olds, const char *news, si
char *ins = NULL;
size_t count;
size_t lfront;
- bool freeNewsStatus = false;;
- char *internalNews = NULL;
// sanity checks and initialization
// count the number of replacements needed
@@ -8758,11 +8697,7 @@ char* bLicReplaceS(char *s, size_t sSize, const char *olds, const char *news, si
}
if (!news) {
// empty string for NULL
- freeNewsStatus = true;
- emptyS(internalNews)
- }
- else {
- internalNews = (char *) news;
+ news = "";
}
// count the number of replacements needed
@@ -8777,15 +8712,12 @@ char* bLicReplaceS(char *s, size_t sSize, const char *olds, const char *news, si
size_t lnews;
- lnews = strlen(internalNews);
+ lnews = strlen(news);
// allocate result
size_t rLen = strlen(s) + (lnews - lolds) * count + 1;;
tmp = r = MALLOC(rLen);
if (!r) {
- if (freeNewsStatus) {
- free(internalNews);
- }
return(NULL);
}
@@ -8796,19 +8728,16 @@ char* bLicReplaceS(char *s, size_t sSize, const char *olds, const char *news, si
// s is the remainder of s after end of olds
while (count--) {
ins = strcasestr(workingS, olds);
- lfront = ins - workingS;
+ lfront = (size_t)(ins - workingS);
tmp = strncpy(tmp, workingS, lfront) + lfront;
- tmp = strcpy(tmp, internalNews) + lnews;
+ tmp = strcpy(tmp, news) + lnews;
workingS += lfront + lolds;
}
// copy end of string
strcpy(tmp, workingS);
- if (freeNewsStatus) {
- free(internalNews);
- }
- strLCpy(s, sSize, r);
+ pErrorNULL(strLCpy(s, sSize, r));
free(r);
return(s);
}
@@ -8820,8 +8749,8 @@ char* bLicReplaceS(char *s, size_t sSize, const char *olds, const char *news, si
* the olds string is replaced with the news string max times in the result
*
* Example:
- * r = replaceManyS("asd", "s", "BNM", "a", "AAA")
- * ^olds ^news ^olds ^news
+ * r = icReplaceManyS("asd", "s", "BNM", "a", "AAA")
+ * ^olds ^news ^olds ^news
*
* \param
* s: string
@@ -8838,10 +8767,10 @@ char* bLicReplaceS(char *s, size_t sSize, const char *olds, const char *news, si
char *icReplaceManySF(const char *paramType, ...) {
va_list pl;
char *r = NULL;
+ char *param = NULL;
char *workingS = NULL;
char *olds = NULL;
char *news = NULL;
- bool freeWorkingS = false;;
// sanity checks
if (!paramType) {
@@ -8852,31 +8781,29 @@ char *icReplaceManySF(const char *paramType, ...) {
return(emptySF());
}
- workingS = (char *) paramType;
+ workingS = strdup(paramType);
// add arguments to a list
va_start(pl, paramType);
- paramType = va_arg(pl, char *);
- while (paramType) {
+ param = va_arg(pl, char *);
+ while (param) {
if (!olds) {
- olds = (char *) paramType;
+ olds = param;
}
else if (!news) {
- news = (char *) paramType;
- r = icReplaceS(workingS, olds, news, 0);
+ news = param;
+ r = icReplaceS(workingS, olds, news, 0);
+ free(workingS);
olds = NULL;
news = NULL;
- if (!freeWorkingS) {
- freeWorkingS = true;
- }
- else {
- free(workingS);
- }
workingS = r;
}
- paramType = va_arg(pl, char *);
+ param = va_arg(pl, char *);
}
va_end(pl);
+ if (!r) {
+ free(workingS);
+ }
return(r);
}
@@ -8912,18 +8839,18 @@ char *iicReplaceManySF(char **s, char *paramType, ...) {
return(NULL);
}
- olds = (char *) paramType;;
+ olds = paramType;;
// add arguments to a list
va_start(pl, paramType);
paramType = va_arg(pl, char *);
while (paramType) {
if (!olds) {
- olds = (char *) paramType;
+ olds = paramType;
}
else if (!news) {
- news = (char *) paramType;
- iicReplaceS(s, olds, news, 0);
+ news = paramType;
+ pErrorNULL(iicReplaceS(s, olds, news, 0));
olds = NULL;
news = NULL;
}
@@ -8966,18 +8893,18 @@ char *bicReplaceManySF(char *s, char *paramType, ...) {
return(NULL);
}
- olds = (char *) paramType;;
+ olds = paramType;;
// add arguments to a list
va_start(pl, paramType);
paramType = va_arg(pl, char *);
while (paramType) {
if (!olds) {
- olds = (char *) paramType;
+ olds = paramType;
}
else if (!news) {
- news = (char *) paramType;
- bicReplaceS(s, olds, news, 0);
+ news = paramType;
+ pErrorNULL(bicReplaceS(s, olds, news, 0));
olds = NULL;
news = NULL;
}
@@ -9024,18 +8951,18 @@ char *bLicReplaceManySF(char *s, size_t sSize, char *paramType, ...) {
return(NULL);
}
- olds = (char *) paramType;;
+ olds = paramType;;
// add arguments to a list
va_start(pl, paramType);
paramType = va_arg(pl, char *);
while (paramType) {
if (!olds) {
- olds = (char *) paramType;
+ olds = paramType;
}
else if (!news) {
- news = (char *) paramType;
- bLicReplaceS(s, sSize, olds, news, 0);
+ news = paramType;
+ pErrorNULL(bLicReplaceS(s, sSize, olds, news, 0));
olds = NULL;
news = NULL;
}
@@ -9104,7 +9031,7 @@ bool eqIS(const char *string1, const char *string2, int64_t index) {
return(false);
}
- int64_t len = strlen(string1);
+ int64_t len = (int64_t)strlen(string1);
if (index >= len && len) {
// && len: string1 is empty, check below if string2 is also empty
// when string1 and string2 are empty and index is 0, the result is true
@@ -9129,7 +9056,7 @@ bool eqIS(const char *string1, const char *string2, int64_t index) {
return(false);
}
- return(strncmp(string1 + index, string2, len2) == 0);;
+ return(strncmp(string1 + index, string2, (size_t)len2) == 0);;
}
bool eqICharS(const char *string1, char c, int64_t index) {
@@ -9320,7 +9247,7 @@ bool icEqIS(const char *string1, const char *string2, int64_t index) {
return(false);
}
- int64_t len = strlen(string1);
+ int64_t len = (int64_t)strlen(string1);
if (index >= len && len) {
// && len: string1 is empty, check below if string2 is also empty
// when string1 and string2 are empty and index is 0, the result is true
@@ -9345,7 +9272,7 @@ bool icEqIS(const char *string1, const char *string2, int64_t index) {
return(false);
}
- return(strncasecmp(string1 + index, string2, len2) == 0);;
+ return(strncasecmp(string1 + index, string2, (size_t)len2) == 0);;
}
bool icEqICharS(const char *string1, char c, int64_t index) {
@@ -9469,7 +9396,7 @@ ssize_t icCountCharS(const char *s, char c) {
ssize_t r = 0;
- c = tolower(c);
+ c = (char)tolower(c);
while (*s != 0) {
if (tolower(*s) == c) {
@@ -9952,7 +9879,7 @@ char *upperS(const char *string) {
// upper case
size_t i = 0;
while (r[i] != 0) {
- r[i] = toupper(r[i]);
+ r[i] = (char)toupper(r[i]);
i++;
}
return(r);
@@ -9977,7 +9904,7 @@ char *iUpperS(char **string) {
// upper case
size_t i = 0;
while ((*string)[i] != 0) {
- (*string)[i] = toupper((*string)[i]);
+ (*string)[i] = (char)toupper((*string)[i]);
i++;
}
return(*string);
@@ -10002,7 +9929,7 @@ char *bUpperS(char *string) {
// upper case
size_t i = 0;
while (string[i] != 0) {
- string[i] = toupper(string[i]);
+ string[i] = (char)toupper(string[i]);
i++;
}
return(string);
@@ -10033,7 +9960,7 @@ char *lowerS(const char *string) {
// lower case
size_t i = 0;
while (r[i] != 0) {
- r[i] = tolower(r[i]);
+ r[i] = (char)tolower(r[i]);
i++;
}
return(r);
@@ -10058,7 +9985,7 @@ char *iLowerS(char **string) {
// lower case
size_t i = 0;
while ((*string)[i] != 0) {
- (*string)[i] = tolower((*string)[i]);
+ (*string)[i] = (char)tolower((*string)[i]);
i++;
}
return(*string);
@@ -10083,7 +10010,7 @@ char *bLowerS(char *string) {
// lower case
size_t i = 0;
while (string[i] != 0) {
- string[i] = tolower(string[i]);
+ string[i] = (char)tolower(string[i]);
i++;
}
return(string);
@@ -10126,7 +10053,7 @@ char *trimS(const char *string) {
}
// copy range to new string
- len = end - string + 2;
+ len = (size_t)(end - string + 2);
r = MALLOC(len);
if (!r) {
return(NULL);
@@ -10177,7 +10104,7 @@ char *iTrimS(char **string) {
}
// copy range to new string
- len = end - workingS + 2;
+ len = (size_t)(end - workingS + 2);
r = MALLOC(len);
if (!r) {
return(NULL);
@@ -10229,7 +10156,7 @@ char *bTrimS(char *string) {
}
// copy range to new string
- len = end - workingS + 2;
+ len = (size_t)(end - workingS + 2);
r = MALLOC(len);
if (!r) {
return(NULL);
@@ -10332,10 +10259,7 @@ char *bLTrimS(char *string) {
workingS++;
}
- // valgrind warning - Source and destination overlap in strcpy
- // keep strcpy because string always < workingS
- strcpy(string, workingS);
- //memmove(string, workingS, strlen(workingS)+1);
+ memmove(string, workingS, strlen(workingS)+1);
return(string);
}
@@ -10365,7 +10289,7 @@ char *rTrimS(const char *string) {
}
// copy range to new string
- len = end - string + 2;
+ len = (size_t)(end - string + 2);
r = MALLOC(len);
if (!r) {
return(NULL);
@@ -10599,7 +10523,7 @@ char *icUniqS(const char *string, char c) {
return(r);
}
- c = tolower(c);
+ c = (char)tolower(c);
// index in r
size_t j = 1;;
@@ -10645,7 +10569,7 @@ char *iicUniqS(char **string, char c) {
return(*string);
}
- c = tolower(c);
+ c = (char)tolower(c);
// index in r
size_t j = 1;;
@@ -10691,7 +10615,7 @@ char *bicUniqS(char *string, char c) {
return(string);
}
- c = tolower(c);
+ c = (char)tolower(c);
// index in r
size_t j = 1;;
@@ -10959,7 +10883,7 @@ ssize_t repeatLenS(const char *string, size_t count) {
return(0);
}
- ssize_t r = strlen(string) * count;
+ ssize_t r = (ssize_t)(strlen(string) * count);
return(r);
}
@@ -11002,9 +10926,9 @@ char *ellipsisStartS(const char *string, size_t targetLength, const char *ellips
// truncate string
char *ellip = strdup(ellipsisString);
string += ((len - targetLength) + strlen(ellipsisString)) <= len ? (len - targetLength) + strlen(ellipsisString) : len;
- iAppendS(&ellip, string);
+ pErrorNULL(iAppendS(&ellip, string));
// make sure the result is target length
- iSliceS(&ellip, 0, targetLength);
+ pErrorNULL(iSliceS(&ellip, 0, (int64_t)targetLength));
return(ellip);
}
}
@@ -11046,9 +10970,9 @@ char *iEllipsisStartS(char **string, size_t targetLength, const char *ellipsisSt
// truncate string
char *ellip = strdup(ellipsisString);
char *str = *string + (((len - targetLength) + strlen(ellipsisString)) <= len ? (len - targetLength) + strlen(ellipsisString) : len);
- iAppendS(&ellip, str);
+ pErrorNULL(iAppendS(&ellip, str));
// make sure the result is target length
- iSliceS(&ellip, 0, targetLength);
+ pErrorNULL(iSliceS(&ellip, 0, (int64_t)targetLength));
free(*string);
*string = ellip;
}
@@ -11094,9 +11018,9 @@ char *bEllipsisStartS(char *dest, const char *string, size_t targetLength, const
// truncate string
char *ellip = strdup(ellipsisString);
string += ((len - targetLength) + strlen(ellipsisString)) <= len ? (len - targetLength) + strlen(ellipsisString) : len;
- iAppendS(&ellip, string);
+ pErrorNULL(iAppendS(&ellip, string));
// make sure the result is target length
- iSliceS(&ellip, 0, targetLength);
+ pErrorNULL(iSliceS(&ellip, 0, (int64_t)targetLength));
strncpy(dest, ellip, targetLength+1);
free(ellip);
}
@@ -11142,16 +11066,16 @@ char *bLEllipsisStartS(char *dest, size_t destSize, const char *string, size_t t
size_t len = strlen(string);
if (len <= targetLength) {
- strLCpy(dest, destSize, string);
+ pErrorNULL(strLCpy(dest, destSize, string));
}
else {
// truncate string
char *ellip = strdup(ellipsisString);
string += ((len - targetLength) + strlen(ellipsisString)) <= len ? (len - targetLength) + strlen(ellipsisString) : len;
- iAppendS(&ellip, string);
+ pErrorNULL(iAppendS(&ellip, string));
// make sure the result is target length
- iSliceS(&ellip, 0, targetLength);
- strLCpy(dest, destSize, ellip);
+ pErrorNULL(iSliceS(&ellip, 0, (int64_t)targetLength));
+ pErrorNULL(strLCpy(dest, destSize, ellip));
free(ellip);
}
return(dest);
@@ -11197,9 +11121,9 @@ char *ellipsisStartCharS(const char *string, size_t targetLength, char ellipsisC
// truncate string
char *ellip = strdup(ellipsisString);
string += ((len - targetLength) + strlen(ellipsisString)) <= len ? (len - targetLength) + strlen(ellipsisString) : len;
- iAppendS(&ellip, string);
+ pErrorNULL(iAppendS(&ellip, string));
// make sure the result is target length
- iSliceS(&ellip, 0, targetLength);
+ pErrorNULL(iSliceS(&ellip, 0, (int64_t)targetLength));
return(ellip);
}
}
@@ -11242,9 +11166,9 @@ char *iEllipsisStartCharS(char **string, size_t targetLength, char ellipsisChar)
// truncate string
char *ellip = strdup(ellipsisString);
char *str = *string + (((len - targetLength) + strlen(ellipsisString)) <= len ? (len - targetLength) + strlen(ellipsisString) : len);
- iAppendS(&ellip, str);
+ pErrorNULL(iAppendS(&ellip, str));
// make sure the result is target length
- iSliceS(&ellip, 0, targetLength);
+ pErrorNULL(iSliceS(&ellip, 0, (int64_t)targetLength));
free(*string);
*string = ellip;
}
@@ -11292,9 +11216,9 @@ char *bEllipsisStartCharS(char *dest, const char *string, size_t targetLength, c
// truncate string
char *ellip = strdup(ellipsisString);
string += ((len - targetLength) + strlen(ellipsisString)) <= len ? (len - targetLength) + strlen(ellipsisString) : len;
- iAppendS(&ellip, string);
+ pErrorNULL(iAppendS(&ellip, string));
// make sure the result is target length
- iSliceS(&ellip, 0, targetLength);
+ pErrorNULL(iSliceS(&ellip, 0, (int64_t)targetLength));
strncpy(dest, ellip, targetLength+1);
free(ellip);
}
@@ -11342,16 +11266,16 @@ char *bLEllipsisStartCharS(char *dest, size_t destSize, const char *string, size
size_t len = strlen(string);
if (len <= targetLength) {
- strLCpy(dest, destSize, string);
+ pErrorNULL(strLCpy(dest, destSize, string));
}
else {
// truncate string
char *ellip = strdup(ellipsisString);
string += ((len - targetLength) + strlen(ellipsisString)) <= len ? (len - targetLength) + strlen(ellipsisString) : len;
- iAppendS(&ellip, string);
+ pErrorNULL(iAppendS(&ellip, string));
// make sure the result is target length
- iSliceS(&ellip, 0, targetLength);
- strLCpy(dest, destSize, ellip);
+ pErrorNULL(iSliceS(&ellip, 0, (int64_t)targetLength));
+ pErrorNULL(strLCpy(dest, destSize, ellip));
free(ellip);
}
return(dest);
@@ -11377,10 +11301,10 @@ ssize_t ellipsisLenS(const char *string, size_t targetLength, const char *ellips
size_t len = strlen(string);
if (len <= targetLength) {
- return(len);
+ return((ssize_t)len);
}
else {
- return(targetLength);
+ return((ssize_t)targetLength);
}
}
@@ -11422,12 +11346,12 @@ char *ellipsisEndS(const char *string, size_t targetLength, const char *ellipsis
// truncate string
char *ellip;
if ( strlen(ellipsisString) < targetLength) {
- ellip = sliceS(string, 0, targetLength - strlen(ellipsisString));
- iAppendS(&ellip, ellipsisString);
+ ellip = sliceS(string, 0, (int64_t)(targetLength - strlen(ellipsisString)));
+ pErrorNULL(iAppendS(&ellip, ellipsisString));
}
else {
// ellipsisString is longer than targetLength
- ellip = sliceS(ellipsisString, 0, targetLength);
+ ellip = sliceS(ellipsisString, 0, (int64_t)targetLength);
}
return(ellip);
}
@@ -11469,12 +11393,12 @@ char *iEllipsisEndS(char **string, size_t targetLength, const char *ellipsisStri
// truncate string
char *ellip;
if ( strlen(ellipsisString) < targetLength) {
- ellip = sliceS(*string, 0, targetLength - strlen(ellipsisString));
- iAppendS(&ellip, ellipsisString);
+ ellip = sliceS(*string, 0, (int64_t)(targetLength - strlen(ellipsisString)));
+ pErrorNULL(iAppendS(&ellip, ellipsisString));
}
else {
// ellipsisString is longer than targetLength
- ellip = sliceS(ellipsisString, 0, targetLength);
+ ellip = sliceS(ellipsisString, 0, (int64_t)targetLength);
}
free(*string);
*string = ellip;
@@ -11521,12 +11445,12 @@ char *bEllipsisEndS(char *dest, const char *string, size_t targetLength, const c
// truncate string
char *ellip;
if ( strlen(ellipsisString) < targetLength) {
- ellip = sliceS(string, 0, targetLength - strlen(ellipsisString));
- iAppendS(&ellip, ellipsisString);
+ ellip = sliceS(string, 0, (int64_t)(targetLength - strlen(ellipsisString)));
+ pErrorNULL(iAppendS(&ellip, ellipsisString));
}
else {
// ellipsisString is longer than targetLength
- ellip = sliceS(ellipsisString, 0, targetLength);
+ ellip = sliceS(ellipsisString, 0, (int64_t)targetLength);
}
if (!ellip) {
return(NULL);
@@ -11576,20 +11500,20 @@ char *bLEllipsisEndS(char *dest, size_t destSize, const char *string, size_t tar
size_t len = strlen(string);
if (len <= targetLength) {
- strLCpy(dest, destSize, string);
+ pErrorNULL(strLCpy(dest, destSize, string));
}
else {
// truncate string
char *ellip;
if ( strlen(ellipsisString) < targetLength) {
- ellip = sliceS(string, 0, targetLength - strlen(ellipsisString));
- iAppendS(&ellip, ellipsisString);
+ ellip = sliceS(string, 0, (int64_t)(targetLength - strlen(ellipsisString)));
+ pErrorNULL(iAppendS(&ellip, ellipsisString));
}
else {
// ellipsisString is longer than targetLength
- ellip = sliceS(ellipsisString, 0, targetLength);
+ ellip = sliceS(ellipsisString, 0, (int64_t)targetLength);
}
- strLCpy(dest, destSize, ellip);
+ pErrorNULL(strLCpy(dest, destSize, ellip));
free(ellip);
}
return(dest);
@@ -11634,8 +11558,8 @@ char *ellipsisEndCharS(const char *string, size_t targetLength, char ellipsisCha
else {
// truncate string
char *ellip;
- ellip = sliceS(string, 0, targetLength - strlen(ellipsisString));
- iAppendS(&ellip, ellipsisString);
+ ellip = sliceS(string, 0, (int64_t)(targetLength - strlen(ellipsisString)));
+ pErrorNULL(iAppendS(&ellip, ellipsisString));
return(ellip);
}
}
@@ -11677,8 +11601,8 @@ char *iEllipsisEndCharS(char **string, size_t targetLength, char ellipsisChar) {
if (len > targetLength) {
// truncate string
char *ellip;
- ellip = sliceS(*string, 0, targetLength - strlen(ellipsisString));
- iAppendS(&ellip, ellipsisString);
+ ellip = sliceS(*string, 0, (int64_t)(targetLength - strlen(ellipsisString)));
+ pErrorNULL(iAppendS(&ellip, ellipsisString));
free(*string);
*string = ellip;
}
@@ -11725,11 +11649,11 @@ char *bEllipsisEndCharS(char *dest, const char *string, size_t targetLength, cha
else {
// truncate string
char *ellip;
- ellip = sliceS(string, 0, targetLength - strlen(ellipsisString));
+ ellip = sliceS(string, 0, (int64_t)(targetLength - strlen(ellipsisString)));
if (!ellip) {
return(NULL);
}
- iAppendS(&ellip, ellipsisString);
+ pErrorNULL(iAppendS(&ellip, ellipsisString));
strncpy(dest, ellip, targetLength+1);
free(ellip);
}
@@ -11777,14 +11701,14 @@ char *bLEllipsisEndCharS(char *dest, size_t destSize, const char *string, size_t
size_t len = strlen(string);
if (len <= targetLength) {
- strLCpy(dest, destSize, string);
+ pErrorNULL(strLCpy(dest, destSize, string));
}
else {
// truncate string
char *ellip;
- ellip = sliceS(string, 0, targetLength - strlen(ellipsisString));
- iAppendS(&ellip, ellipsisString);
- strLCpy(dest, destSize, ellip);
+ ellip = sliceS(string, 0, (int64_t)(targetLength - strlen(ellipsisString)));
+ pErrorNULL(iAppendS(&ellip, ellipsisString));
+ pErrorNULL(strLCpy(dest, destSize, ellip));
free(ellip);
}
return(dest);
@@ -11834,10 +11758,10 @@ char *padStartS(const char *string, size_t targetLength, const char *padString)
return(NULL);
}
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
char *r = appendS(pads, string);
free(pads);
@@ -11885,12 +11809,12 @@ char *iPadStartS(char **string, size_t targetLength, const char *padString) {
char *pads = strdup(padString);;
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
- iAppendS(&pads, *string);
+ pErrorNULL(iAppendS(&pads, *string));
free(*string);
*string = pads;
@@ -11942,10 +11866,10 @@ char *bPadStartS(char *dest, const char *string, size_t targetLength, const char
return(NULL);
}
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
char *r = appendS(pads, string);
free(pads);
@@ -11986,14 +11910,14 @@ char *bLPadStartS(char *dest, size_t destSize, const char *string, size_t target
return(NULL);
}
if (strlen(string) >= targetLength) {
- strLCpy(dest, destSize, string);
+ pErrorNULL(strLCpy(dest, destSize, string));
return(dest);
}
if (!padString) {
return(NULL);
}
if (!strlen(padString)) {
- strLCpy(dest, destSize, string);
+ pErrorNULL(strLCpy(dest, destSize, string));
return(dest);
}
@@ -12004,10 +11928,10 @@ char *bLPadStartS(char *dest, size_t destSize, const char *string, size_t target
return(NULL);
}
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
char *r = appendS(pads, string);
free(pads);
@@ -12015,7 +11939,7 @@ char *bLPadStartS(char *dest, size_t destSize, const char *string, size_t target
return(NULL);
}
- strLCpy(dest, destSize, r);
+ pErrorNULL(strLCpy(dest, destSize, r));
free(r);
return(dest);
@@ -12058,10 +11982,10 @@ char *padStartCharS(const char *string, size_t targetLength, char padChar) {
return(NULL);
}
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
char *r = appendS(pads, string);
free(pads);
@@ -12103,12 +12027,12 @@ char *iPadStartCharS(char **string, size_t targetLength, char padChar) {
char *pads = strdup(padString);;
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
- iAppendS(&pads, *string);
+ pErrorNULL(iAppendS(&pads, *string));
free(*string);
*string = pads;
@@ -12153,10 +12077,10 @@ char *bPadStartCharS(char *dest, const char *string, size_t targetLength, char p
return(NULL);
}
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
char *r = appendS(pads, string);
free(pads);
@@ -12195,7 +12119,7 @@ char *bLPadStartCharS(char *dest, size_t destSize, const char *string, size_t ta
return(NULL);
}
if (strlen(string) >= targetLength) {
- strLCpy(dest, destSize, string);
+ pErrorNULL(strLCpy(dest, destSize, string));
return(dest);
}
@@ -12208,10 +12132,10 @@ char *bLPadStartCharS(char *dest, size_t destSize, const char *string, size_t ta
return(NULL);
}
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
char *r = appendS(pads, string);
free(pads);
@@ -12219,7 +12143,7 @@ char *bLPadStartCharS(char *dest, size_t destSize, const char *string, size_t ta
return(NULL);
}
- strLCpy(dest, destSize, r);
+ pErrorNULL(strLCpy(dest, destSize, r));
free(r);
return(dest);
@@ -12241,16 +12165,16 @@ ssize_t padStartLenS(const char *string, size_t targetLength, const char *padStr
return(-1);
}
if (strlen(string) >= targetLength) {
- return(strlen(string));
+ return((ssize_t)strlen(string));
}
if (!padString) {
return(-1);
}
if (!strlen(padString)) {
- return(strlen(string));
+ return((ssize_t)strlen(string));
}
- return(targetLength);
+ return((ssize_t)targetLength);
}
/**
@@ -12296,10 +12220,10 @@ char *padEndS(const char *string, size_t targetLength, const char *padString) {
return(NULL);
}
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
char *r = appendS(string, pads);
free(pads);
@@ -12352,12 +12276,12 @@ char *iPadEndS(char **string, size_t targetLength, const char *padString) {
return(NULL);
}
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
- iAppendS(string, pads);
+ pErrorNULL(iAppendS(string, pads));
free(pads);
return(*string);
@@ -12408,10 +12332,10 @@ char *bPadEndS(char *dest, const char *string, size_t targetLength, const char *
return(NULL);
}
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
char *r = appendS(string, pads);
free(pads);
@@ -12452,14 +12376,14 @@ char *bLPadEndS(char *dest, size_t destSize, const char *string, size_t targetLe
return(NULL);
}
if (strlen(string) > targetLength) {
- strLCpy(dest, destSize, string);
+ pErrorNULL(strLCpy(dest, destSize, string));
return(dest);
}
if (!padString) {
return(NULL);
}
if (!strlen(padString)) {
- strLCpy(dest, destSize, string);
+ pErrorNULL(strLCpy(dest, destSize, string));
return(dest);
}
@@ -12470,10 +12394,10 @@ char *bLPadEndS(char *dest, size_t destSize, const char *string, size_t targetLe
return(NULL);
}
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
char *r = appendS(string, pads);
free(pads);
@@ -12481,7 +12405,7 @@ char *bLPadEndS(char *dest, size_t destSize, const char *string, size_t targetLe
return(NULL);
}
- strLCpy(dest, destSize, r);
+ pErrorNULL(strLCpy(dest, destSize, r));
free(r);
return(dest);
@@ -12524,10 +12448,10 @@ char *padEndCharS(const char *string, size_t targetLength, char padChar) {
return(NULL);
}
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
char *r = appendS(string, pads);
free(pads);
@@ -12572,12 +12496,12 @@ char *iPadEndCharS(char **string, size_t targetLength, char padChar) {
return(NULL);
}
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
- iAppendS(string, pads);
+ pErrorNULL(iAppendS(string, pads));
free(pads);
return(*string);
@@ -12621,10 +12545,10 @@ char *bPadEndCharS(char *dest, const char *string, size_t targetLength, char pad
return(NULL);
}
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
char *r = appendS(string, pads);
free(pads);
@@ -12663,7 +12587,7 @@ char *bLPadEndCharS(char *dest, size_t destSize, const char *string, size_t targ
return(NULL);
}
if (strlen(string) > targetLength) {
- strLCpy(dest, destSize, string);
+ pErrorNULL(strLCpy(dest, destSize, string));
return(dest);
}
@@ -12676,10 +12600,10 @@ char *bLPadEndCharS(char *dest, size_t destSize, const char *string, size_t targ
return(NULL);
}
if (targetLength > strlen(padString)) {
- iRepeatS(&pads, targetLength/strlen(padString)+1);
+ pErrorNULL(iRepeatS(&pads, targetLength/strlen(padString)+1));
}
- iSliceS(&pads, 0, targetLength);
+ pErrorNULL(iSliceS(&pads, 0, (int64_t)targetLength));
char *r = appendS(string, pads);
free(pads);
@@ -12687,7 +12611,7 @@ char *bLPadEndCharS(char *dest, size_t destSize, const char *string, size_t targ
return(NULL);
}
- strLCpy(dest, destSize, r);
+ pErrorNULL(strLCpy(dest, destSize, r));
free(r);
return(dest);
@@ -12710,16 +12634,16 @@ ssize_t padEndLenS(const char *string, size_t targetLength, const char *padStrin
return(-1);
}
if (strlen(string) > targetLength) {
- return(strlen(string));
+ return((ssize_t)strlen(string));
}
if (!padString) {
return(-1);
}
if (!strlen(padString)) {
- return(strlen(string));
+ return((ssize_t)strlen(string));
}
- return(targetLength);
+ return((ssize_t)targetLength);
}
/**
@@ -12735,7 +12659,7 @@ char getS(const char *string, int64_t index) {
return(0);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (index >= len) {
return(0);
}
@@ -12761,7 +12685,7 @@ char *setS(char *string, int64_t index, char c) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (index >= len) {
return(NULL);
}
@@ -12796,7 +12720,7 @@ char *swapS(char *string, int64_t index1, int64_t index2) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (index1 >= len) {
return(NULL);
}
@@ -12849,7 +12773,7 @@ char *iSwapS(char **string, int64_t index1, int64_t index2) {
return(NULL);
}
- len = strlen(*string);
+ len = (int64_t)strlen(*string);
if (index1 >= len) {
return(NULL);
}
@@ -12897,7 +12821,7 @@ char *bSwapS(char *string, int64_t index1, int64_t index2) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (index1 >= len) {
return(NULL);
}
@@ -12954,10 +12878,10 @@ char *bLSwapS(char *string, size_t size, int64_t index1, int64_t index2) {
return(string);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if ((size_t)len+1 > size) {
- len = size-1;
+ len = (int64_t)(size-1);
}
if (index1 >= len) {
@@ -13013,7 +12937,7 @@ char *sliceS(const char *string, int64_t start, int64_t end) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (start > len) {
return(NULL);
}
@@ -13044,11 +12968,11 @@ char *sliceS(const char *string, int64_t start, int64_t end) {
// copy range to a new string
int64_t n;
n = end - start;
- s = MALLOC(n+1);
+ s = MALLOC((size_t)(n+1));
if (!s) {
return(NULL);//LCOV_EXCL_LINE
}
- s = strncpy(s, string+start, n);
+ s = strncpy(s, string+start, (size_t)n);
s[n] = 0;
}
@@ -13078,7 +13002,7 @@ char *iSliceS(char **string, int64_t start, int64_t end) {
return(NULL);
}
- len = strlen(*string);
+ len = (int64_t)strlen(*string);
if (start > len) {
free(*string);
emptyS(*string);
@@ -13115,11 +13039,11 @@ char *iSliceS(char **string, int64_t start, int64_t end) {
// copy range to a new string
int64_t n;
n = end - start;
- s = MALLOC(n+1);
+ s = MALLOC((size_t)(n+1));
if (!s) {
return(NULL);
}
- s = strncpy(s, (*string)+start, n);
+ s = strncpy(s, (*string)+start, (size_t)n);
s[n] = 0;
}
@@ -13150,7 +13074,7 @@ char *bSliceS(char *string, int64_t start, int64_t end) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (start > len) {
bEmptyS(string);
return(NULL);
@@ -13185,7 +13109,7 @@ char *bSliceS(char *string, int64_t start, int64_t end) {
int64_t n;
n = end - start;
if (start) {
- strncpy(string, string+start, n);
+ memmove(string, string+start, (size_t)n);
}
string[n] = 0;
}
@@ -13219,9 +13143,9 @@ char *bLSliceS(char *string, size_t stringSize, int64_t start, int64_t end) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if ((size_t)len+1 > stringSize) {
- len = stringSize - 1;
+ len = (int64_t)(stringSize - 1);
}
// compute string length without NUL
@@ -13259,7 +13183,7 @@ char *bLSliceS(char *string, size_t stringSize, int64_t start, int64_t end) {
int64_t n;
n = end - start;
if (start) {
- strncpy(string, string+start, n);
+ memmove(string, string+start, (size_t)n);
}
string[n] = 0;
}
@@ -13295,7 +13219,7 @@ char *cropS(char *string, int64_t start, int64_t end) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (start > len) {
return(NULL);
@@ -13323,12 +13247,12 @@ char *cropS(char *string, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = MALLOC((n+1) * sizeof(char));
+ l = MALLOC((size_t)(n+1) * sizeof(char));
if (!l) {
return(NULL);
}
- strLCpy(l, (n+1) * sizeof(char), string+start);
- strLCpy(string+start, len-end+1, string+end);
+ pErrorNULL(strLCpy(l, (size_t)(n+1) * sizeof(char), string+start));
+ memmove(string+start, string+end, (size_t)(len-end+1));
}
else {
// start = end, return empty string
@@ -13366,7 +13290,7 @@ char *iCropS(char **string, int64_t start, int64_t end) {
return(NULL);
}
- len = strlen(*string);
+ len = (int64_t)strlen(*string);
if (start > len) {
return(NULL);
@@ -13394,12 +13318,12 @@ char *iCropS(char **string, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = MALLOC((n+1) * sizeof(char));
+ l = MALLOC((size_t)(n+1) * sizeof(char));
if (!l) {
return(NULL);
}
- strLCpy(l, (n+1) * sizeof(char), *string+start);
- strLCpy(*string+start, len-end+1, *string+end);
+ pErrorNULL(strLCpy(l, (size_t)(n+1) * sizeof(char), *string+start));
+ memmove(*string+start, *string+end, (size_t)(len-end+1));
}
else {
// start = end, return empty string
@@ -13416,7 +13340,7 @@ char cropElemS(char *string, int64_t index) {
return(0);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (index >= len) {
return(0);
}
@@ -13433,7 +13357,7 @@ char cropElemS(char *string, int64_t index) {
string[len-1] = 0;
}
else {
- strLCpy(string+index, len - index, string+index+1);
+ memmove(string+index, string+index+1, (size_t)(len - index));
}
return(r);
@@ -13480,7 +13404,7 @@ char *insertS(const char *string, int64_t index, const char *toInsert) {
return(strdup(string));
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
index = 0;
@@ -13551,7 +13475,7 @@ char *insertNFreeS(const char *string, int64_t index, char *toInsert) {
return(r);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
index = 0;
@@ -13629,7 +13553,7 @@ char *iInsertS(char **string, int64_t index, const char *toInsert) {
return(r);
}
- len = strlen(*string);
+ len = (int64_t)strlen(*string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -13709,7 +13633,7 @@ char *iInsertNFreeS(char **string, int64_t index, char *toInsert) {
return(r);
}
- len = strlen(*string);
+ len = (int64_t)strlen(*string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -13780,7 +13704,7 @@ char *bInsertS(char *string, int64_t index, const char *toInsert) {
if (!string) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -13811,16 +13735,16 @@ char *bInsertS(char *string, int64_t index, const char *toInsert) {
if (index == 0) {
// insert at beginning
- char *s = alloca(len+1);;
+ char *s = alloca((size_t)(len+1));;
strcpy(s, string);
- bCatS(string, toInsert, s);
+ pErrorNULL(bCatS(string, toInsert, s));
}
else {
- char *s1 = alloca(index+1);;
- strLCpy(s1, index+1, string);
- char *s2 = alloca(len-index+1);;
+ char *s1 = alloca((size_t)(index+1));;
+ pErrorNULL(strLCpy(s1, (size_t)(index+1), string));
+ char *s2 = alloca((size_t)(len-index+1));;
strcpy(s2, string+index);
- bCatS(string, s1, toInsert, s2);
+ pErrorNULL(bCatS(string, s1, toInsert, s2));
}
return(string);
}
@@ -13855,7 +13779,7 @@ char *bLInsertS(char *string, size_t stringSize, int64_t index, const char *toIn
return(string);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -13886,16 +13810,16 @@ char *bLInsertS(char *string, size_t stringSize, int64_t index, const char *toIn
if (index == 0) {
// insert at beginning
- char *s = alloca(len+1);;
+ char *s = alloca((size_t)(len+1));;
strcpy(s, string);
- bLCatS(string, stringSize, toInsert, s);
+ pErrorNULL(bLCatS(string, stringSize, toInsert, s));
}
else {
- char *s1 = alloca(index+1);;
- strLCpy(s1, index+1, string);
- char *s2 = alloca(len-index+1);;
+ char *s1 = alloca((size_t)(index+1));;
+ pErrorNULL(strLCpy(s1, (size_t)(index+1), string));
+ char *s2 = alloca((size_t)(len-index+1));;
strcpy(s2, string+index);
- bLCatS(string, stringSize, s1, toInsert, s2);
+ pErrorNULL(bLCatS(string, stringSize, s1, toInsert, s2));
}
return(string);
}
@@ -13930,7 +13854,7 @@ char *injectS(const char *string, int64_t index, char toInject) {
return(strdup(inject));
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -14004,7 +13928,7 @@ char *iInjectS(char **string, int64_t index, char toInject) {
return(*string);
}
- len = strlen(*string);
+ len = (int64_t)strlen(*string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -14072,7 +13996,7 @@ char *bInjectS(char *string, int64_t index, char toInject) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -14101,14 +14025,14 @@ char *bInjectS(char *string, int64_t index, char toInject) {
if (index == 0) {
// inject at beginning
- bPrependS(string, inject);
+ pErrorNULL(bPrependS(string, inject));
}
else {
- char *s1 = alloca(index+1);;
- strLCpy(s1, index+1, string);
- char *s2 = alloca(len-index+1);;
+ char *s1 = alloca((size_t)(index+1));;
+ pErrorNULL(strLCpy(s1, (size_t)(index+1), string));
+ char *s2 = alloca((size_t)(len-index+1));;
strcpy(s2, string+index);
- bCatS(string, s1, inject, s2);
+ pErrorNULL(bCatS(string, s1, inject, s2));
}
return(string);
}
@@ -14143,7 +14067,7 @@ char *bLInjectS(char *string, size_t stringSize, int64_t index, char toInject) {
return(string);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -14172,14 +14096,14 @@ char *bLInjectS(char *string, size_t stringSize, int64_t index, char toInject) {
if (index == 0) {
// inject at beginning
- bLPrependS(string, stringSize, inject);
+ pErrorNULL(bLPrependS(string, stringSize, inject));
}
else {
- char *s1 = alloca(index+1);;
- strLCpy(s1, index+1, string);
- char *s2 = alloca(len-index+1);;
+ char *s1 = alloca((size_t)(index+1));;
+ pErrorNULL(strLCpy(s1, (size_t)(index+1), string));
+ char *s2 = alloca((size_t)(len-index+1));;
strcpy(s2, string+index);
- bLCatS(string, stringSize, s1, inject, s2);
+ pErrorNULL(bLCatS(string, stringSize, s1, inject, s2));
}
return(string);
}
@@ -14210,7 +14134,7 @@ char *delS(const char *string, int64_t start, int64_t end) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (start >= len) {
start = len;
@@ -14242,12 +14166,12 @@ char *delS(const char *string, int64_t start, int64_t end) {
// copy range to a new string
int64_t n;
n = end - start;
- s = MALLOC(len-n+1);
+ s = MALLOC((size_t)(len-n+1));
if (!s) {
return(NULL);//LCOV_EXCL_LINE
}
- strncpy(s, string, start);
- strncpy(s+start, string+start+n, len-n-start);
+ strncpy(s, string, (size_t)start);
+ strncpy(s+start, string+start+n, (size_t)(len-n-start));
s[len-n] = 0;
return(s);
@@ -14280,7 +14204,7 @@ char *iDelS(char **string, int64_t start, int64_t end) {
return(NULL);
}
- len = strlen(*string);
+ len = (int64_t)strlen(*string);
if (start >= len) {
start = len;
@@ -14312,12 +14236,12 @@ char *iDelS(char **string, int64_t start, int64_t end) {
// copy range to a new string
int64_t n;
n = end - start;
- s = MALLOC(len-n+1);
+ s = MALLOC((size_t)(len-n+1));
if (!s) {
return(NULL);
}
- strncpy(s, *string, start);
- strncpy(s+start, (*string)+start+n, len-n-start);
+ strncpy(s, *string, (size_t)start);
+ strncpy(s+start, (*string)+start+n, (size_t)(len-n-start));
s[len-n] = 0;
free(*string);
@@ -14351,7 +14275,7 @@ char *bDelS(char *string, int64_t start, int64_t end) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (start >= len) {
start = len;
@@ -14383,7 +14307,7 @@ char *bDelS(char *string, int64_t start, int64_t end) {
// copy range to a new string
int64_t n;
n = end - start;
- strncpy(string+start, string+start+n, len-n-start);
+ memmove(string+start, string+start+n, (size_t)(len-n-start));
string[len-n] = 0;
return(string);
@@ -14417,9 +14341,9 @@ char *bLDelS(char *string, size_t stringSize, int64_t start, int64_t end) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if ((size_t)len+1 > stringSize) {
- len = stringSize - 1;
+ len = (int64_t)(stringSize - 1);
}
// compute string length without NUL
@@ -14453,7 +14377,7 @@ char *bLDelS(char *string, size_t stringSize, int64_t start, int64_t end) {
// copy range to a new string
int64_t n;
n = end - start;
- strncpy(string+start, string+start+n, len-n-start);
+ memmove(string+start, string+start+n, (size_t)(len-n-start));
string[len-n] = 0;
return(string);
@@ -14481,7 +14405,7 @@ char *delElemS(const char *string, int64_t index) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (index >= len) {
return(NULL);
}
@@ -14492,12 +14416,12 @@ char *delElemS(const char *string, int64_t index) {
index = len + index;
}
- s = MALLOC(len-1+1);
+ s = MALLOC((size_t)(len-1+1));
if (!s) {
return(NULL);//LCOV_EXCL_LINE
}
- strncpy(s, string, index);
- strncpy(s+index, string+index+1, len-1-index);
+ strncpy(s, string, (size_t)index);
+ strncpy(s+index, string+index+1, (size_t)(len-1-index));
s[len-1] = 0;
return(s);
}
@@ -14525,7 +14449,7 @@ char *iDelElemS(char **string, int64_t index) {
return(NULL);
}
- len = strlen(*string);
+ len = (int64_t)strlen(*string);
if (index >= len) {
return(NULL);
}
@@ -14536,12 +14460,12 @@ char *iDelElemS(char **string, int64_t index) {
index = len + index;
}
- s = MALLOC(len-1+1);
+ s = MALLOC((size_t)(len-1+1));
if (!s) {
return(NULL);//LCOV_EXCL_LINE
}
- strncpy(s, *string, index);
- strncpy(s+index, *string+index+1, len-1-index);
+ strncpy(s, *string, (size_t)index);
+ strncpy(s+index, *string+index+1, (size_t)(len-1-index));
s[len-1] = 0;
free(*string);
@@ -14571,7 +14495,7 @@ char *bDelElemS(char *string, int64_t index) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if (index >= len) {
return(NULL);
}
@@ -14582,7 +14506,7 @@ char *bDelElemS(char *string, int64_t index) {
index = len + index;
}
- strncpy(string+index, string+index+1, len-1-index);
+ memmove(string+index, string+index+1, (size_t)(len-1-index));
string[len-1] = 0;
return(string);
@@ -14612,9 +14536,9 @@ char *bLDelElemS(char *string, size_t stringSize, int64_t index) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if ((size_t)len+1 > stringSize) {
- len = stringSize - 1;
+ len = (int64_t)(stringSize - 1);
}
// compute string length without NUL
@@ -14628,7 +14552,7 @@ char *bLDelElemS(char *string, size_t stringSize, int64_t index) {
index = (int64_t)len + index;
}
- strncpy(string+index, string+index+1, len-1-index);
+ memmove(string+index, string+index+1, (size_t)(len-1-index));
string[len-1] = 0;
return(string);
@@ -14852,7 +14776,7 @@ bool icHasCharS(const char *string, char c) {
* token
* *saveptr is set to NULL when the last token is found
*/
-char *tokS(const char *s, const char *delim, char **saveptr) {
+char *tokS(char *s, const char *delim, char **saveptr) {
char *r = NULL;
// sanity checks
@@ -14860,7 +14784,7 @@ char *tokS(const char *s, const char *delim, char **saveptr) {
return(NULL);
}
if (s) {
- *saveptr = (char *) s;
+ *saveptr = s;
}
else if (!*saveptr) {
return(NULL);
@@ -14894,7 +14818,7 @@ char *tokS(const char *s, const char *delim, char **saveptr) {
* token
* *saveptr is set to NULL when the last token is found
*/
-char *icTokS(const char *s, const char *delim, char **saveptr) {
+char *icTokS(char *s, const char *delim, char **saveptr) {
char *r = NULL;
// sanity checks
@@ -14902,7 +14826,7 @@ char *icTokS(const char *s, const char *delim, char **saveptr) {
return(NULL);
}
if (s) {
- *saveptr = (char *) s;
+ *saveptr = s;
}
else if (!*saveptr) {
return(NULL);
@@ -44893,14 +44817,14 @@ static const int16_t type_table_part2[768] = {
* pointer to next UTF-8 code point
* NULL when the end string is reached or utf8 is NULL
*/
-char *nextUTF8(const char *utf8) {
+const char *nextUTF8(const char *utf8) {
if (!utf8 || !*utf8) {
return(NULL);
}
nxCodeUTF8(utf8);
- return((char *)utf8);
+ return(utf8);
}
/**
@@ -44923,7 +44847,7 @@ char *nextUTF8(const char *utf8) {
* pointer to next UTF-8 code point
* NULL when the end string is reached or utf8 is NULL or the start of the next code point is outside the string
*/
-char *bLNextUTF8(const char *string, size_t utf8Size, const char *utf8) {
+const char *bLNextUTF8(const char *string, size_t utf8Size, const char *utf8) {
if (!string || !utf8 || !utf8Size || !*utf8 || (size_t)(utf8 - string) >= utf8Size) {
return(NULL);
@@ -44934,7 +44858,7 @@ char *bLNextUTF8(const char *string, size_t utf8Size, const char *utf8) {
return(NULL);
}
- return((char *)utf8);
+ return(utf8);
}
/**
@@ -44955,7 +44879,7 @@ char *bLNextUTF8(const char *string, size_t utf8Size, const char *utf8) {
* pointer to next UTF-8 code point
* NULL when the end string is reached or utf8 is NULL or the start of the next code point is outside the string
*/
-char *findNextUTF8(const char *string, size_t utf8Size, const char *utf8) {
+const char *findNextUTF8(const char *string, size_t utf8Size, const char *utf8) {
if (!string || !utf8 || !utf8Size || !*utf8 || (size_t)(utf8 - string) >= utf8Size) {
return(NULL);
@@ -44970,7 +44894,7 @@ char *findNextUTF8(const char *string, size_t utf8Size, const char *utf8) {
return(NULL);
}
- return((char *)utf8);
+ return(utf8);
}
/**
@@ -44988,7 +44912,7 @@ char *findNextUTF8(const char *string, size_t utf8Size, const char *utf8) {
* pointer to previous UTF-8 code point
* NULL when utf8 is NULL
*/
-char *prevUTF8(const char *utf8) {
+const char *prevUTF8(const char *utf8) {
if (!utf8) {
return(NULL);
@@ -44997,7 +44921,7 @@ char *prevUTF8(const char *utf8) {
forever {
utf8--;
if ((*utf8 & 0xC0) != 0x80) {
- return((char *)utf8);
+ return(utf8);
}
}
}
@@ -45017,7 +44941,7 @@ char *prevUTF8(const char *utf8) {
* pointer to previous UTF-8 code point
* NULL when utf8 is NULL
*/
-char *bPrevUTF8(const char *string, const char *utf8) {
+const char *bPrevUTF8(const char *string, const char *utf8) {
if (!string || !utf8) {
return(NULL);
@@ -45026,12 +44950,24 @@ char *bPrevUTF8(const char *string, const char *utf8) {
return(bPrevUTF8Tiny(string, utf8));
}
-local char *bPrevUTF8Tiny(const char *string, const char *utf8) {
+local const char *bPrevUTF8Tiny(const char *string, const char *utf8) {
while (utf8 > string) {
utf8--;
if ((*utf8 & 0xC0) != 0x80) {
- return((char *)utf8);
+ return(utf8);
+ }
+ }
+
+ return(NULL);
+}
+
+local char *bPrevRWUTF8Tiny(const char *string, char *utf8) {
+
+ while (utf8 > string) {
+ utf8--;
+ if ((*utf8 & 0xC0) != 0x80) {
+ return(utf8);
}
}
@@ -45051,13 +44987,13 @@ local char *bPrevUTF8Tiny(const char *string, const char *utf8) {
* pointer to character at index
* NULL when index is outside the string
*/
-char *idx2PtrUTF8(const char *utf8, int64_t index) {
+const char *idx2PtrUTF8(const char *utf8, int64_t index) {
if (!utf8 || !*utf8 || !index) {
- return((char *)utf8);
+ return(utf8);
}
- int64_t len = strlen(utf8);
+ int64_t len = (int64_t)strlen(utf8);
if (index > 0) {
if (index > len) {
@@ -45066,7 +45002,7 @@ char *idx2PtrUTF8(const char *utf8, int64_t index) {
}
// go forward
- char *end = (char *)utf8 + len;;
+ const char *end = utf8 + len;;
int64_t i = 0;;
while (i != index) {
nxCodeUTF8(utf8);
@@ -45083,7 +45019,7 @@ char *idx2PtrUTF8(const char *utf8, int64_t index) {
}
// go from the end
- char *start = (char *)utf8;;
+ const char *start = utf8;;
utf8 += len;;
int64_t i = 0;;
while (i != index) {
@@ -45091,13 +45027,69 @@ char *idx2PtrUTF8(const char *utf8, int64_t index) {
i--;
}
}
- return((char *)utf8);
+ return(utf8);
+}
+
+/**
+ * index to pointer UTF8 encoded string - read write utf8 string (char*)
+ *
+ * Converts character index to pointer in utf8
+ *
+ * \param
+ * utf8 UTF8 encoded string
+ * \param
+ * index character index in utf8, positive or negative. -1 is the last character in the string
+ * \return
+ * pointer to character at index
+ * NULL when index is outside the string
+ */
+local char *idx2PtrRWUTF8(char *utf8, int64_t index) {
+
+ if (!utf8 || !*utf8 || !index) {
+ return(utf8);
+ }
+
+ int64_t len = (int64_t)strlen(utf8);
+
+ if (index > 0) {
+ if (index > len) {
+ // index is outside the string
+ return(NULL);
+ }
+
+ // go forward
+ char *end = utf8 + len;;
+ int64_t i = 0;;
+ while (i != index) {
+ nxCodeUTF8(utf8);
+ if (utf8 > end) {
+ return(NULL);
+ }
+ i++;
+ }
+ }
+ else {
+ if (index < -len) {
+ // index is outside the string
+ return(NULL);
+ }
+
+ // go from the end
+ char *start = utf8;;
+ utf8 += len;;
+ int64_t i = 0;;
+ while (i != index) {
+ utf8 = bPrevRWUTF8Tiny(start, utf8);;
+ i--;
+ }
+ }
+ return(utf8);
}
-char *bLIdx2PtrUTF8(const char *utf8, size_t utf8Size, int64_t index) {
+const char *bLIdx2PtrUTF8(const char *utf8, size_t utf8Size, int64_t index) {
if (!utf8 || !*utf8 || !utf8Size || !index) {
- return((char *)utf8);
+ return(utf8);
}
if (index > 0) {
@@ -45107,7 +45099,7 @@ char *bLIdx2PtrUTF8(const char *utf8, size_t utf8Size, int64_t index) {
}
// go forward
- char *end = (char *)utf8 + utf8Size;;
+ const char *end = utf8 + utf8Size;;
int64_t i = 0;;
while (i != index) {
nxCodeUTF8(utf8);
@@ -45131,7 +45123,7 @@ char *bLIdx2PtrUTF8(const char *utf8, size_t utf8Size, int64_t index) {
}
// go from the end
- char *start = (char *)utf8;;
+ const char *start = utf8;;
utf8 += len;;
int64_t i = 0;;
while (i != index) {
@@ -45139,7 +45131,7 @@ char *bLIdx2PtrUTF8(const char *utf8, size_t utf8Size, int64_t index) {
i--;
}
}
- return((char *)utf8);
+ return(utf8);
}
/**
@@ -45305,7 +45297,7 @@ int64_t bLPtr2IdxUTF8(const char *utf8, size_t utf8Size, const char *pos) {
if (pos > utf8) {
// there is at least one code point
// find next code point, works even when utf8 points inside a code point
- char *end = (char *)(utf8+utf8Size-1);;
+ const char *end = utf8+utf8Size-1;;
while ((utf8 < end) && *utf8) {
if ((*utf8++ & 0xC0) != 0x80) {
break;
@@ -45352,7 +45344,7 @@ int64_t bLPtr2NegIdxUTF8(const char *utf8, size_t utf8Size, const char *pos) {
int64_t r = 0;
- char *end = (char *)(utf8+utf8Size-1);
+ const char *end = utf8+utf8Size-1;
while ((end > pos) && (end > utf8)) {
// find previous code point
@@ -45710,7 +45702,7 @@ char *strLCpyUTF8(char *dst, size_t dstSize, const char *src) {
if (dstSize) {
r[dstSize-1] = 0;
}
- bMakeValidUTF8(r);
+ pErrorNULL(bMakeValidUTF8(r));
return(r);
}
@@ -45785,7 +45777,7 @@ char *strLCatUTF8(char *dst, size_t dstSize, const char *src) {
if (dL+sL > dstLen) {
// truncate
char *r = strncat(dst, src, dstLen - dL);
- bMakeValidUTF8(r);
+ pErrorNULL(bMakeValidUTF8(r));
return(r);
}
else {
@@ -45842,7 +45834,7 @@ char *strLNCatUTF8(char *dst, size_t dstSize, const char *src, size_t srcLen) {
if (dL+sL > dstLen) {
// truncate
char *r = strncat(dst, src, dstLen - dL);
- bMakeValidUTF8(r);
+ pErrorNULL(bMakeValidUTF8(r));
return(r);
}
else {
@@ -46106,7 +46098,7 @@ bool eqIUTF8(const char *string1, const char *string2, int64_t index) {
return(false);
}
- char *i = idx2PtrUTF8(string1, index);
+ const char *i = idx2PtrUTF8(string1, index);
return(eqIS(string1, string2, (int64_t)(i-string1)));
}
@@ -46116,7 +46108,7 @@ bool eqICharUTF8(const char *string1, char c, int64_t index) {
return(false);
}
- char *i = idx2PtrUTF8(string1, index);
+ const char *i = idx2PtrUTF8(string1, index);
return(eqICharS(string1, c, (int64_t)(i-string1)));
}
@@ -46152,7 +46144,7 @@ bool icEqCharUTF8(char c, const char *string2) {
return(false);
}
- charToS(s, tolower(c));
+ charToS(s, (char)tolower(c));
char *s2 = casefoldUTF8(string2);
bool r = (strcmp(s,s2) == 0);
free(s2);
@@ -46166,7 +46158,7 @@ bool icEqUTF8Char(const char *string1, char c) {
return(false);
}
- charToS(s, tolower(c));
+ charToS(s, (char)tolower(c));
char *s1 = casefoldUTF8(string1);
bool r = (strcmp(s1,s) == 0);
free(s1);
@@ -46322,6 +46314,8 @@ internal localeType getLocaleType(void) {
return(LOCALE_TURKIC);
}
break;
+ default:;
+ // return default value
}
return(LOCALE_NORMAL);
@@ -46437,11 +46431,11 @@ size_t bRune2CodeUTF8(char *dst, rune c) {
first = firstBytesUTF8[len-1];
if (dst) {
- rangeDownTo(i, len, 1) {
- dst[i] = (c & 0x3f) | 0x80;
+ rangeDownTo(i, (ssize_t)len, 1) {
+ dst[i] = (char)((c & 0x3f) | 0x80);
c >>= 6;
}
- dst[0] = c | first;
+ dst[0] = (char)(c | first);
}
return(len);
@@ -46582,9 +46576,9 @@ internal size_t runeFullyDecompose(rune ch, rune *result, size_t resultLen) {
return(1);
}
-internal int output_marks(const char **p_inout, char *dst, bool remove_dot) {
+internal size_t output_marks(const char **p_inout, char *dst, bool remove_dot) {
const char *p = NULL;
- int len = 0;;
+ size_t len = 0;;
p = *p_inout;
@@ -46607,9 +46601,9 @@ internal int output_marks(const char **p_inout, char *dst, bool remove_dot) {
return(len);
}
-internal int output_special_case(char *dst, int offset, int type, int which) {
+internal size_t output_special_case(char *dst, int offset, int type, int which) {
const char *p = NULL;
- int len;
+ size_t len;
p = special_case_table + offset;
@@ -46930,6 +46924,8 @@ internal size_t _lowerUTF8(char *dst, const char *utf8, localeType lcl) {
case 0x0128:
len += bRune2CodeUTF8(dst ? dst + len : NULL, 0x0303);
break;
+ default:;
+ // do nothing
}
}
else if (lcl == LOCALE_LITHUANIAN && (c == 'I' || c == 'J' || c == 0x012e) && has_more_above (utf8)) {
@@ -47097,7 +47093,7 @@ char *casefoldUTF8(const char *utf8) {
forever {
int half = (start + end) / 2;
if (ch == casefold_table[half].ch) {
- iAppendS(&r, casefold_table[half].data);
+ pErrorNULL(iAppendS(&r, casefold_table[half].data));
goto next;
}
else if (half == start) {
@@ -47113,8 +47109,8 @@ char *casefoldUTF8(const char *utf8) {
}
char code[8] = {0, 0, 0, 0, 0, 0, 0, 0};
- bRune2CodeUTF8(code, tolowerUTF8(ch));
- iAppendS(&r, code);
+ pError0(bRune2CodeUTF8(code, tolowerUTF8(ch)));
+ pErrorNULL(iAppendS(&r, code));
next:
nxCodeUTF8(utf8);
@@ -47358,7 +47354,7 @@ rune getUTF8(const char *string, int64_t index) {
return(0);
}
- len = lenUTF8(string);
+ len = (int64_t)lenUTF8(string);
if (index >= len) {
return(0);
}
@@ -47369,7 +47365,7 @@ rune getUTF8(const char *string, int64_t index) {
index = len + index;
}
- char *c = idx2PtrUTF8(string, index);
+ const char *c = idx2PtrUTF8(string, index);
return(code2RuneUTF8(c));
}
@@ -47389,7 +47385,7 @@ char *setUTF8(char *string, int64_t index, rune c) {
return(NULL);
}
- len = lenUTF8(string);
+ len = (int64_t)lenUTF8(string);
if (index >= len) {
return(NULL);
}
@@ -47400,8 +47396,8 @@ char *setUTF8(char *string, int64_t index, rune c) {
index = len + index;
}
- char *p = idx2PtrUTF8(string, index);
- bRune2CodeUTF8(p, c);
+ char *p = idx2PtrRWUTF8(string, index);
+ pError0(bRune2CodeUTF8(p, c));
// TODO check code point length and shift string end when necessary
return(string);
}
@@ -47434,7 +47430,7 @@ char *sliceUTF8(const char *string, int64_t start, int64_t end) {
return(NULL);
}
- len = lenUTF8(string);
+ len = (int64_t)lenUTF8(string);
if (start > len) {
return(NULL);
@@ -47466,9 +47462,9 @@ char *sliceUTF8(const char *string, int64_t start, int64_t end) {
// copy range to a new string
const char *startp = idx2PtrUTF8(string, start);
const char *endp = idx2PtrUTF8(string, end);
- int64_t n;
- n = endp - startp;
- s = MALLOC(n+1);
+ size_t n;
+ n = (size_t)(endp - startp);
+ s = MALLOC((n+1));
if (!s) {
return(NULL);//LCOV_EXCL_LINE
}
@@ -47505,7 +47501,7 @@ char *iSliceUTF8(char **string, int64_t start, int64_t end) {
return(NULL);
}
- len = lenUTF8(*string);
+ len = (int64_t)lenUTF8(*string);
if (start > len) {
free(*string);
@@ -47541,10 +47537,10 @@ char *iSliceUTF8(char **string, int64_t start, int64_t end) {
else {
// start < end < len
// copy range to a new string
- char *startp = idx2PtrUTF8(*string, start);
- char *endp = idx2PtrUTF8(*string, end);
- int64_t n;
- n = endp - startp;
+ const char *startp = idx2PtrUTF8(*string, start);
+ const char *endp = idx2PtrUTF8(*string, end);
+ size_t n;
+ n = (size_t)(endp - startp);
s = MALLOC(n+1);
if (!s) {
return(NULL);
@@ -47583,7 +47579,7 @@ char *bSliceUTF8(char *string, int64_t start, int64_t end) {
return(NULL);
}
- len = lenUTF8(string);
+ len = (int64_t)lenUTF8(string);
if (start > len) {
bEmptyS(string);
@@ -47616,11 +47612,11 @@ char *bSliceUTF8(char *string, int64_t start, int64_t end) {
else {
// start < end < len
// copy range to a new string
- char *startp = idx2PtrUTF8(string, start);
- char *endp = idx2PtrUTF8(string, end);
- int64_t n;
- n = endp - startp;
- strncpy(string, string+(size_t)(startp-string), n);
+ const char *startp = idx2PtrUTF8(string, start);
+ const char *endp = idx2PtrUTF8(string, end);
+ size_t n;
+ n = (size_t)(endp - startp);
+ memmove(string, string+(size_t)(startp-string), n);
string[n] = 0;
}
@@ -47654,9 +47650,9 @@ char *bLSliceUTF8(char *string, size_t stringSize, int64_t start, int64_t end) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if ((size_t)len+1 > stringSize) {
- len = stringSize - 1;
+ len = (int64_t)(stringSize - 1);
}
if (start > len) {
@@ -47684,8 +47680,8 @@ char *bLSliceUTF8(char *string, size_t stringSize, int64_t start, int64_t end) {
return(NULL);
}
- char *startp = bLIdx2PtrUTF8(string, stringSize, start);
- char *endp = bLIdx2PtrUTF8(string, stringSize, end);
+ const char *startp = bLIdx2PtrUTF8(string, stringSize, start);
+ const char *endp = bLIdx2PtrUTF8(string, stringSize, end);
size_t starto = (size_t)(startp-string);
size_t endo = (size_t)(endp-string);
@@ -47697,7 +47693,7 @@ char *bLSliceUTF8(char *string, size_t stringSize, int64_t start, int64_t end) {
return(NULL);
}
if (endo > stringSize) {
- end = stringSize;
+ end = (int64_t)stringSize;
}
if (start == 0) {
starto = 0;
@@ -47713,9 +47709,9 @@ char *bLSliceUTF8(char *string, size_t stringSize, int64_t start, int64_t end) {
else {
// start < end < stringSize
// copy range to a new string
- int64_t n;
- n = endp - startp;
- strncpy(string, string+starto, n);
+ size_t n;
+ n = (size_t)(endp - startp);
+ memmove(string, string+starto, n);
string[n] = 0;
}
@@ -47752,7 +47748,7 @@ char *insertUTF8(const char *string, int64_t index, const char *toInsert) {
return(strdup(toInsert));
}
- len = lenUTF8(string);
+ len = (int64_t)lenUTF8(string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -47786,10 +47782,10 @@ char *insertUTF8(const char *string, int64_t index, const char *toInsert) {
return(catS(toInsert, string));
}
- size_t offset = (size_t)(idx2PtrUTF8(string, index) - string);
- char *s1 = sliceS(string, 0, offset);
- char *s2 = sliceS(string, offset, 0);
- r = catS(s1, toInsert, s2);
+ int64_t offset = idx2PtrUTF8(string, index) - string;
+ char *s1 = sliceS(string, 0, offset);
+ char *s2 = sliceS(string, offset, 0);
+ r = catS(s1, toInsert, s2);
freeManyS(s1,s2);
return(r);
@@ -47830,7 +47826,7 @@ char *insertNFreeUTF8(const char *string, int64_t index, char *toInsert) {
return(r);
}
- len = lenUTF8(string);
+ len = (int64_t)lenUTF8(string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -47867,10 +47863,10 @@ char *insertNFreeUTF8(const char *string, int64_t index, char *toInsert) {
return(r);
}
- size_t offset = (size_t)(idx2PtrUTF8(string, index) - string);
- char *s1 = sliceS(string, 0, offset);
- char *s2 = sliceS(string, offset, 0);
- r = catS(s1, toInsert, s2);
+ int64_t offset = idx2PtrUTF8(string, index) - string;
+ char *s1 = sliceS(string, 0, offset);
+ char *s2 = sliceS(string, offset, 0);
+ r = catS(s1, toInsert, s2);
freeManyS(s1,s2, toInsert);
return(r);
@@ -47911,7 +47907,7 @@ char *iInsertUTF8(char **string, int64_t index, const char *toInsert) {
return(r);
}
- len = lenUTF8(*string);
+ len = (int64_t)lenUTF8(*string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -47945,10 +47941,10 @@ char *iInsertUTF8(char **string, int64_t index, const char *toInsert) {
r = catS(toInsert, *string);
}
else {
- size_t offset = (size_t)(idx2PtrUTF8(*string, index) - *string);
- char *s1 = sliceS(*string, 0, offset);
- char *s2 = sliceS(*string, offset, 0);
- r = catS(s1, toInsert, s2);
+ int64_t offset = idx2PtrUTF8(*string, index) - *string;
+ char *s1 = sliceS(*string, 0, offset);
+ char *s2 = sliceS(*string, offset, 0);
+ r = catS(s1, toInsert, s2);
freeManyS(s1,s2);
}
@@ -47993,7 +47989,7 @@ char *iInsertNFreeUTF8(char **string, int64_t index, char *toInsert) {
return(r);
}
- len = lenUTF8(*string);
+ len = (int64_t)lenUTF8(*string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -48028,10 +48024,10 @@ char *iInsertNFreeUTF8(char **string, int64_t index, char *toInsert) {
r = catS(toInsert, *string);
}
else {
- size_t offset = (size_t)(idx2PtrUTF8(*string, index) - *string);
- char *s1 = sliceS(*string, 0, offset);
- char *s2 = sliceS(*string, offset, 0);
- r = catS(s1, toInsert, s2);
+ int64_t offset = idx2PtrUTF8(*string, index) - *string;
+ char *s1 = sliceS(*string, 0, offset);
+ char *s2 = sliceS(*string, offset, 0);
+ r = catS(s1, toInsert, s2);
freeManyS(s1,s2);
}
free(toInsert);
@@ -48067,7 +48063,7 @@ char *bInsertUTF8(char *string, int64_t index, const char *toInsert) {
return(NULL);
}
- len = lenUTF8(string);
+ len = (int64_t)lenUTF8(string);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -48098,17 +48094,17 @@ char *bInsertUTF8(char *string, int64_t index, const char *toInsert) {
if (index == 0) {
// insert at beginning
- char *s = alloca(len+1);;
+ char *s = alloca((size_t)(len+1));
strcpy(s, string);
- bCatS(string, toInsert, s);
+ pErrorNULL(bCatS(string, toInsert, s));
}
else {
- size_t offset = (size_t)(idx2PtrUTF8(string, index) - string);
- char *s1 = alloca(offset+1);;
- strLCpy(s1, offset+1, string);
- char *s2 = alloca(len-offset+1);;
+ int64_t offset = idx2PtrUTF8(string, index) - string;
+ char *s1 = alloca((size_t)(offset+1));
+ pErrorNULL(strLCpy(s1, (size_t)(offset+1), string));
+ char *s2 = alloca((size_t)(len-offset+1));
strcpy(s2, string+offset);
- bCatS(string, s1, toInsert, s2);
+ pErrorNULL(bCatS(string, s1, toInsert, s2));
}
return(string);
}
@@ -48144,7 +48140,7 @@ char *bLInsertUTF8(char *string, size_t stringSize, int64_t index, const char *t
return(string);
}
- len = bLLenUTF8(string, stringSize);
+ len = (int64_t)bLLenUTF8(string, stringSize);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -48175,17 +48171,17 @@ char *bLInsertUTF8(char *string, size_t stringSize, int64_t index, const char *t
if (index == 0) {
// insert at beginning
- char *s = alloca(len+1);;
+ char *s = alloca((size_t)(len+1));;
strcpy(s, string);
- bLCatS(string, stringSize, toInsert, s);
+ pErrorNULL(bLCatS(string, stringSize, toInsert, s));
}
else {
- size_t offset = (size_t)(bLIdx2PtrUTF8(string, stringSize, index) - string);
- char *s1 = alloca(offset+1);;
- strLCpy(s1, offset+1, string);
- char *s2 = alloca(len-offset+1);;
+ int64_t offset = bLIdx2PtrUTF8(string, stringSize, index) - string;
+ char *s1 = alloca((size_t)(offset+1));
+ pErrorNULL(strLCpy(s1, (size_t)(offset+1), string));
+ char *s2 = alloca((size_t)(len-offset+1));
strcpy(s2, string+offset);
- bLCatS(string, stringSize, s1, toInsert, s2);
+ pErrorNULL(bLCatS(string, stringSize, s1, toInsert, s2));
}
return(string);
}
@@ -48217,7 +48213,7 @@ char *delUTF8(const char *string, int64_t start, int64_t end) {
return(NULL);
}
- len = lenUTF8(string);
+ len = (int64_t)lenUTF8(string);
if (start >= len) {
start = len;
@@ -48247,18 +48243,18 @@ char *delUTF8(const char *string, int64_t start, int64_t end) {
// start < end < len
// copy range to a new string
- len = strlen(string);
+ len = (int64_t)strlen(string);
const char *startp = idx2PtrUTF8(string, start);
const char *endp = idx2PtrUTF8(string, end);
size_t starto = (size_t)(startp-string);
int64_t n;
n = endp - startp;
- s = MALLOC(len-n+1);
+ s = MALLOC((size_t)(len-n+1));
if (!s) {
return(NULL);//LCOV_EXCL_LINE
}
strncpy(s, string, starto);
- strncpy(s+starto, string+starto+n, len-n-starto);
+ strncpy(s+starto, string+starto+n, (size_t)(len-n)-starto);
s[len-n] = 0;
return(s);
@@ -48292,7 +48288,7 @@ char *iDelUTF8(char **string, int64_t start, int64_t end) {
return(NULL);
}
- len = lenUTF8(*string);
+ len = (int64_t)lenUTF8(*string);
if (start >= len) {
start = len;
@@ -48322,18 +48318,18 @@ char *iDelUTF8(char **string, int64_t start, int64_t end) {
// start < end < len
// copy range to a new string
- len = strlen(*string);
- char *startp = idx2PtrUTF8(*string, start);
- char *endp = idx2PtrUTF8(*string, end);
- size_t starto = (size_t)(startp-*string);
+ len = (int64_t)strlen(*string);
+ const char *startp = idx2PtrUTF8(*string, start);
+ const char *endp = idx2PtrUTF8(*string, end);
+ size_t starto = (size_t)(startp-*string);
int64_t n;
n = endp - startp;
- s = MALLOC(len-n+1);
+ s = MALLOC((size_t)(len-n+1));
if (!s) {
return(NULL);
}
strncpy(s, *string, starto);
- strncpy(s+starto, (*string)+starto+n, len-n-starto);
+ strncpy(s+starto, (*string)+starto+n, (size_t)(len-n)-starto);
s[len-n] = 0;
free(*string);
@@ -48368,7 +48364,7 @@ char *bDelUTF8(char *string, int64_t start, int64_t end) {
return(NULL);
}
- len = lenUTF8(string);
+ len = (int64_t)lenUTF8(string);
if (start >= len) {
start = len;
@@ -48398,13 +48394,13 @@ char *bDelUTF8(char *string, int64_t start, int64_t end) {
// start < end < len
// copy range to a new string
- len = strlen(string);
+ len = (int64_t)strlen(string);
const char *startp = idx2PtrUTF8(string, start);
const char *endp = idx2PtrUTF8(string, end);
size_t starto = (size_t)(startp-string);
int64_t n;
n = endp - startp;
- strncpy(string+starto, string+starto+n, len-n-starto);
+ memmove(string+starto, string+starto+n, (size_t)(len-n)-starto);
string[len-n] = 0;
return(string);
@@ -48439,9 +48435,9 @@ char *bLDelUTF8(char *string, size_t stringSize, int64_t start, int64_t end) {
return(NULL);
}
- len = strlen(string);
+ len = (int64_t)strlen(string);
if ((size_t)len+1 > stringSize) {
- len = stringSize - 1;
+ len = (int64_t)(stringSize - 1);
}
// compute string length without NUL
@@ -48467,8 +48463,8 @@ char *bLDelUTF8(char *string, size_t stringSize, int64_t start, int64_t end) {
return(NULL);
}
- char *startp = bLIdx2PtrUTF8(string, stringSize, start);
- char *endp = bLIdx2PtrUTF8(string, stringSize, end);
+ const char *startp = bLIdx2PtrUTF8(string, stringSize, start);
+ const char *endp = bLIdx2PtrUTF8(string, stringSize, end);
size_t starto = (size_t)(startp-string);
@@ -48490,7 +48486,7 @@ char *bLDelUTF8(char *string, size_t stringSize, int64_t start, int64_t end) {
// copy range to a new string
int64_t n;
n = endp - startp;
- strncpy(string+starto, string+starto+n, len-n-starto);
+ memmove(string+starto, string+starto+n, (size_t)(len-n)-starto);
string[len-n] = 0;
return(string);
@@ -48667,8 +48663,8 @@ internal int icListSortUTF8Cmp(const void * a, const void * b) {
if (a && !b) {
return(1);
}
- char *A = casefoldUTF8(*(char **)a);
- char *B = casefoldUTF8(*(char **)b);
+ char *A = casefoldUTF8(*(char *const*)a);
+ char *B = casefoldUTF8(*(char *const*)b);
int r = strcmp(A,B);
free(A);
free(B);
@@ -48817,7 +48813,7 @@ ssize_t icListIndexOfUTF8(char **list, const char *string) {
}
}
if (found) {
- return(i);
+ return((ssize_t)i);
}
else {
return(-1);
@@ -48848,7 +48844,7 @@ ssize_t icListBinarySearchUTF8(char **list, const char *string) {
char *s = casefoldUTF8(string);
- last = listLengthS(list) - 1;
+ last = (ssize_t)(listLengthS(list) - 1);
while (first <= last) {
middle = (first+last)/2;
char *m = casefoldUTF8(list[middle]);
@@ -48896,7 +48892,7 @@ char **icListUniqUTF8(char **list) {
listEmptyS(r);
return(r);
}
- listPushS(&r, list[0]);
+ pErrorNULL(listPushS(&r, list[0]));
// one element list
if (len == 1) {
return(r);
@@ -48904,7 +48900,7 @@ char **icListUniqUTF8(char **list) {
// push element to new list if it is not already in new list
forEachCharP(list, e) {
if (icListIndexOfUTF8(r, *e) == -1) {
- listPushS(&r, *e);
+ pErrorNULL(listPushS(&r, *e));
}
}
return(r);
@@ -48938,13 +48934,13 @@ char **iicListUniqUTF8(char ***list) {
}
else if (len < 2) {
// one element list
- iListPushS(&r, (*list)[0]);
+ pErrorNULL(iListPushS(&r, (*list)[0]));
}
else {
// push element to new list if it is not already in new list
forEachCharP(*list, e) {
if (icListIndexOfUTF8(r, *e) == -1) {
- iListPushS(&r, *e);
+ pErrorNULL(iListPushS(&r, *e));
}
else {
free(*e);
@@ -49189,7 +49185,7 @@ char **listCreateSF(const char *paramType, ...) {
va_start(pl, paramType);
paramType = va_arg(pl, char *);
while (paramType) {
- listPushS(&l, paramType);
+ pErrorNULL(listPushS(&l, paramType));
paramType = va_arg(pl, char *);
}
va_end(pl);
@@ -49227,7 +49223,44 @@ char **listFromArrayS(char **array, size_t size) {
for (size_t i = 0 ; i < size ; i++) {
if (array[i]) {
// remove NULL strings
- listPushS(&r, array[i]);
+ pErrorNULL(listPushS(&r, array[i]));
+ }
+ }
+ return(r);
+}
+
+/**
+ * list From Const Array String
+ *
+ * copy array of 'size' strings to a new list
+ * NULL strings are not copied to the list
+ *
+ * \param
+ * array of strings
+ * \param
+ * size - number of strings in the array
+ * \return
+ * list
+ * empty list when size is 0
+ * NULL when array is NULL
+ */
+char **listFromCArrayS(const char **array, size_t size) {
+ char **r = NULL;
+
+ // sanity checks
+ if (!array) {
+ return(NULL);
+ }
+ if (!size) {
+ listEmptyS(r);
+ return(r);
+ }
+
+ // copy array content
+ for (size_t i = 0 ; i < size ; i++) {
+ if (array[i]) {
+ // remove NULL strings
+ pErrorNULL(listPushS(&r, array[i]));
}
}
return(r);
@@ -49350,7 +49383,7 @@ char **iListPushS(char ***list, char *s) {
*/
char *listPopS(char ***list) {
char *s = NULL;
- uint64_t len;
+ size_t len;
// sanity checks
if (!list) {
@@ -49404,7 +49437,7 @@ char **listPrependS(char ***list, const char *s) {
}
else {
// realloc list and copy s to first element
- uint64_t len;
+ size_t len;
len = listLengthS(*list);
char **tmp = REALLOC(*list, (len+2) * sizeof(char *));
if (!tmp) {
@@ -49463,7 +49496,7 @@ char **iListPrependS(char ***list, char *s) {
}
else {
// realloc list and copy s to first element
- uint64_t len;
+ size_t len;
len = listLengthS(*list);
char **tmp = REALLOC(*list, (len+2) * sizeof(char *));
if (!tmp) {
@@ -49494,7 +49527,7 @@ char **iListPrependS(char ***list, char *s) {
*/
char *listDequeueS(char ***list) {
char *s = NULL;
- uint64_t len;
+ size_t len;
// sanity checks
if (!list) {
@@ -49580,6 +49613,29 @@ size_t listLengthS(char **list) {
}
/**
+ * const list Length String
+ * return number of elements until the first NULL element
+ *
+ * \param
+ * list
+ * \return
+ * number of element until first NULL element
+ * 0 when list is NULL
+ */
+size_t listLengthCS(const char **list) {
+ size_t r = 0;;
+
+ // sanity checks
+ if (!list) {
+ return(0);
+ }
+ forEachCCharP(list, i) {
+ r++;
+ }
+ return(r);
+}
+
+/**
* list String Length String
*
* \param
@@ -49597,7 +49653,7 @@ ssize_t listStrLengthS(char **list) {
}
forEachS(list, i) {
- r += strlen(i);
+ r += (ssize_t)strlen(i);
}
return(r);
@@ -49624,7 +49680,7 @@ ssize_t listIntIndexS(char **list, int64_t index) {
return(-1);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (index >= len) {
return(-1);
}
@@ -49661,7 +49717,7 @@ char **listAddrS(char **list, int64_t index) {
return(NULL);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (index >= len) {
return(NULL);
}
@@ -49669,10 +49725,10 @@ char **listAddrS(char **list, int64_t index) {
return(NULL);
}
if (index < 0) {
- r = len + index;
+ r = (size_t)(len + index);
}
else {
- r = index;
+ r = (size_t)(index);
}
return((list+r));
}
@@ -49698,7 +49754,7 @@ char *listGetS(char **list, int64_t index) {
return(NULL);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (index >= len) {
return(NULL);
}
@@ -49732,7 +49788,76 @@ char *iListGetS(char **list, int64_t index) {
return(NULL);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
+ if (index >= len) {
+ return(NULL);
+ }
+ if (index < -len) {
+ return(NULL);
+ }
+ if (index < 0) {
+ index = len + index;
+ }
+
+ return(list[index]);
+}
+
+/**
+ * const list Get String
+ * duplicate string at given index
+ * index can be negative
+ *
+ * \param
+ * list
+ * \param
+ * index: index in list, must be inside the list
+ * \return
+ * duplicated string (you must free the pointer)
+ * NULL when list is NULL or index is not set correctly
+ */
+char *listGetCS(const char **list, int64_t index) {
+ int64_t len;
+
+ // sanity checks
+ if (!list) {
+ return(NULL);
+ }
+
+ len = (int64_t)listLengthCS(list);
+ if (index >= len) {
+ return(NULL);
+ }
+ if (index < -len) {
+ return(NULL);
+ }
+ if (index < 0) {
+ index = len + index;
+ }
+
+ return(strdup(list[index]));
+}
+
+/**
+ * const list Get String
+ * index can be negative
+ *
+ * \param
+ * list
+ * \param
+ * index: index in list, must be inside the list
+ * \return
+ * string
+ * NULL when list is NULL or index is not set correctly
+ */
+const char *iListGetCS(const char **list, int64_t index) {
+ int64_t len;
+
+ // sanity checks
+ if (!list) {
+ return(NULL);
+ }
+
+ len = (int64_t)listLengthCS(list);
if (index >= len) {
return(NULL);
}
@@ -49772,7 +49897,7 @@ char **listSetS(char **list, int64_t index, const char *s) {
return(NULL);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (index >= len) {
return(NULL);
}
@@ -49820,7 +49945,7 @@ char **iListSetS(char **list, int64_t index, char *s) {
return(NULL);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (index >= len) {
return(NULL);
}
@@ -49856,7 +49981,7 @@ char **listSwapS(char **list, int64_t index1, int64_t index2) {
return(NULL);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (index1 >= len) {
return(NULL);
}
@@ -49906,7 +50031,7 @@ char **iListSwapS(char **list, int64_t index1, int64_t index2) {
return(NULL);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (index1 >= len) {
return(NULL);
}
@@ -49937,6 +50062,7 @@ char **iListSwapS(char **list, int64_t index1, int64_t index2) {
/**
* split string with delim string
+ * when updating this function, also update splitS (identical to split)
* return list
*
* \param
@@ -49961,7 +50087,7 @@ char **split(const char *string, const char* delim) {
if (!*delim || !*string) {
// empty delimiter empty string, return string in a list
- listPushS(&r, string);
+ pErrorNULL(listPushS(&r, string));
return(r);
}
@@ -49971,7 +50097,7 @@ char **split(const char *string, const char* delim) {
line = workingString;
while (strlen(workingString) != 0) {
token = tokS(line, delim, &workingString);
- listPushS(&r, token);
+ pErrorNULL(listPushS(&r, token));
// mac os sets workingString to NULL at the end
if (!workingString) {
break; //LCOV_EXCL_LINE
@@ -49987,7 +50113,55 @@ char **split(const char *string, const char* delim) {
size_t len = strlen(string);
size_t lenD = strlen(delim);
if (strEq(string+(len-lenD), delim)) {
- listPushS(&r, "");
+ pErrorNULL(listPushS(&r, ""));
+ }
+
+ return(r);
+}
+
+// splitS is identical to split
+// to make the interface uniform
+char **splitS(const char *string, const char* delim) {
+ char *startString = NULL;
+ char *workingString = NULL;
+ char *line = NULL;
+ char *token = NULL;
+ char **r = NULL;
+
+ // sanity checks
+ if (!string || !delim) {
+ return(NULL);
+ }
+
+ if (!*delim || !*string) {
+ // empty delimiter empty string, return string in a list
+ pErrorNULL(listPushS(&r, string));
+ return(r);
+ }
+
+ // split using strtok_r
+ startString = strdup(string);
+ workingString = startString;
+ line = workingString;
+ while (strlen(workingString) != 0) {
+ token = tokS(line, delim, &workingString);
+ pErrorNULL(listPushS(&r, token));
+ // mac os sets workingString to NULL at the end
+ if (!workingString) {
+ break; //LCOV_EXCL_LINE
+ }
+ // first parameter should be NULL in next strtok_r calls
+ line = NULL;
+ }
+ free(startString);
+
+ // check if delim is at the end of string
+ // if yes, add an empty string in the result
+ // ["one",""] = split "one/" "/"
+ size_t len = strlen(string);
+ size_t lenD = strlen(delim);
+ if (strEq(string+(len-lenD), delim)) {
+ pErrorNULL(listPushS(&r, ""));
}
return(r);
@@ -50001,6 +50175,7 @@ char **splitChar(const char *string, char delim) {
/**
* ignore case split string with delim string
+ * when updating this function, also update icSplitS (identical to icSplit)
* return list
*
* \param
@@ -50025,7 +50200,7 @@ char **icSplit(const char *string, const char* delim) {
if (!*delim || !*string) {
// empty delimiter empty string, return string in a list
- listPushS(&r, string);
+ pErrorNULL(listPushS(&r, string));
return(r);
}
@@ -50035,7 +50210,7 @@ char **icSplit(const char *string, const char* delim) {
line = workingString;
while (strlen(workingString) != 0) {
token = icTokS(line, delim, &workingString);
- listPushS(&r, token);
+ pErrorNULL(listPushS(&r, token));
// mac os sets workingString to NULL at the end
if (!workingString) {
break; //LCOV_EXCL_LINE
@@ -50051,7 +50226,55 @@ char **icSplit(const char *string, const char* delim) {
size_t len = strlen(string);
size_t lenD = strlen(delim);
if (icEqS(string+(len-lenD), delim)) {
- listPushS(&r, "");
+ pErrorNULL(listPushS(&r, ""));
+ }
+
+ return(r);
+}
+
+// icSplitS is identical to icSplit
+// to make the interface uniform
+char **icSplitS(const char *string, const char* delim) {
+ char *startString = NULL;
+ char *workingString = NULL;
+ char *line = NULL;
+ char *token = NULL;
+ char **r = NULL;
+
+ // sanity checks
+ if (!string || !delim) {
+ return(NULL);
+ }
+
+ if (!*delim || !*string) {
+ // empty delimiter empty string, return string in a list
+ pErrorNULL(listPushS(&r, string));
+ return(r);
+ }
+
+ // split using strtok_r
+ startString = strdup(string);
+ workingString = startString;
+ line = workingString;
+ while (strlen(workingString) != 0) {
+ token = icTokS(line, delim, &workingString);
+ pErrorNULL(listPushS(&r, token));
+ // mac os sets workingString to NULL at the end
+ if (!workingString) {
+ break; //LCOV_EXCL_LINE
+ }
+ // first parameter should be NULL in next strtok_r calls
+ line = NULL;
+ }
+ free(startString);
+
+ // check if delim is at the end of string
+ // if yes, add an empty string in the result
+ // ["one",""] = split "one/" "/"
+ size_t len = strlen(string);
+ size_t lenD = strlen(delim);
+ if (icEqS(string+(len-lenD), delim)) {
+ pErrorNULL(listPushS(&r, ""));
}
return(r);
@@ -50087,11 +50310,11 @@ ssize_t joinLength(char **list, const char* delim) {
bool isFirstElem = true;
forEachS(list, i) {
if (isFirstElem) {
- r += strlen(i);
+ r += (ssize_t)strlen(i);
isFirstElem = no;
}
else {
- r += strlen(i) + delimLen;
+ r += (ssize_t)(strlen(i) + delimLen);
}
}
@@ -50100,6 +50323,7 @@ ssize_t joinLength(char **list, const char* delim) {
/**
* join list, the elements are seperated with delim in the resulting string
+ * when updating this function, also update joinS (identical to join)
*
* \param
* list
@@ -50142,6 +50366,85 @@ char *join(char **list, const char* delim) {
return(r);
}
+// joinS is identical to join
+// to make the interface uniform
+char *joinS(char **list, const char* delim) {
+ char *r = NULL;
+
+ // sanity checks
+ if (!list || !delim) {
+ return(NULL);
+ }
+
+ forEachCharP(list, e) {
+ if (!r) {
+ r = strdup(*e);
+ }
+ else {
+ char *tmp;
+ tmp = REALLOC(r, strlen(r) + strlen(delim) + 1);
+ if (!tmp) {
+ free(r);
+ return(NULL);//LCOV_EXCL_LINE
+ }
+ r = tmp;
+ strcat(r, delim);
+ tmp = REALLOC(r, strlen(r) + strlen(*e) + 1);
+ if (!tmp) {
+ free(r);
+ return(NULL);//LCOV_EXCL_LINE
+ }
+ r = tmp;
+ strcat(r, *e);
+ }
+ }
+ return(r);
+}
+
+/**
+ * join list, the elements are seperated with delim in the resulting string
+ *
+ * \param
+ * list
+ * \param
+ * delim: string seperator
+ * \return
+ * joined string (you must free the pointer)
+ * NULL when list or delim are NULL
+ */
+char *joinCS(const char **list, const char* delim) {
+ char *r = NULL;
+
+ // sanity checks
+ if (!list || !delim) {
+ return(NULL);
+ }
+
+ forEachCCharP(list, e) {
+ if (!r) {
+ r = strdup(*e);
+ }
+ else {
+ char *tmp;
+ tmp = REALLOC(r, strlen(r) + strlen(delim) + 1);
+ if (!tmp) {
+ free(r);
+ return(NULL);//LCOV_EXCL_LINE
+ }
+ r = tmp;
+ strcat(r, delim);
+ tmp = REALLOC(r, strlen(r) + strlen(*e) + 1);
+ if (!tmp) {
+ free(r);
+ return(NULL);//LCOV_EXCL_LINE
+ }
+ r = tmp;
+ strcat(r, *e);
+ }
+ }
+ return(r);
+}
+
char *joinChar(char **list, char delim) {
charToS(s, delim);
@@ -50173,7 +50476,7 @@ char *bJoin(char *string, char **list, const char* delim) {
strcpy(string, *e);
}
else {
- bAppendManyS(string, delim, *e);
+ pErrorNULL(bAppendManyS(string, delim, *e));
}
}
return(string);
@@ -50212,10 +50515,10 @@ char *bLJoin(char *string, size_t stringSize, char **list, const char* delim) {
enumerateCharP(list, e, i) {
if (!i) {
- strLCpy(string, stringSize, *e);
+ pErrorNULL(strLCpy(string, stringSize, *e));
}
else {
- bLAppendManyS(string, stringSize, delim, *e);
+ pErrorNULL(bLAppendManyS(string, stringSize, delim, *e));
}
}
return(string);
@@ -50267,12 +50570,12 @@ char **extractS(const char *string, const char* delim1, const char* delim2) {
}
// remove first element
- iListSliceS(&tmp, 1, 0);
+ pErrorNULL(iListSliceS(&tmp, 1, 0));
forEachCharP(tmp, e) {
char **tmp2 = split(*e, delim2);
if (listLengthS(tmp2) > 1) {
- listPushS(&r, tmp2[0]);
+ pErrorNULL(listPushS(&r, tmp2[0]));
}
listFreeS(tmp2);
}
@@ -50340,12 +50643,12 @@ char **icExtractS(const char *string, const char* delim1, const char* delim2) {
}
// remove first element
- iListSliceS(&tmp, 1, 0);
+ pErrorNULL(iListSliceS(&tmp, 1, 0));
forEachCharP(tmp, e) {
char **tmp2 = icSplit(*e, delim2);
if (listLengthS(tmp2) > 1) {
- listPushS(&r, tmp2[0]);
+ pErrorNULL(listPushS(&r, tmp2[0]));
}
listFreeS(tmp2);
}
@@ -50408,6 +50711,40 @@ char **listDupS(char **list) {
}
/**
+ * const list Duplicate String
+ *
+ * \param
+ * list
+ * \return
+ * duplicated list (you must free the pointer with listFreeS)
+ * NULL when list is NULL
+ */
+char **listDupCS(const char **list) {
+ char **l = NULL;
+ size_t len;
+
+ // sanity checks
+ if (!list) {
+ return(NULL);
+ }
+
+ len = listLengthCS(list);
+ l = MALLOC((len+1) * sizeof(char *));
+ if (!l) {
+ return(NULL);//LCOV_EXCL_LINE
+ }
+
+ // last element is NULL
+ l[len] = NULL;
+
+ // copy each element
+ enumerateCCharP(list, e, i) {
+ l[i] = strdup(*e);
+ }
+ return(l);
+}
+
+/**
* list Duplicate String
*
* copy pointers to new list
@@ -50536,7 +50873,7 @@ char **listCatSF(char **paramType, ...) {
va_start(pl, paramType);
paramType = va_arg(pl, char **);
while (paramType) {
- listAppendS(&r, paramType);
+ pErrorNULL(listAppendS(&r, paramType));
paramType = va_arg(pl, char **);
}
va_end(pl);
@@ -50854,6 +51191,57 @@ char **listAddS(char **list1, char **list2) {
/**
+ * const list Add String
+ * add list1 and list2 in a new list
+ *
+ * \param
+ * list1
+ * \param
+ * list2
+ * \return
+ * new list with list1 and list2 (you must free the pointer with listFreeS)
+ * NULL when list1 and list2 are NULL
+ */
+char **listAddCS(char **list1, const char **list2) {
+ char **l = NULL;
+ char **r = NULL;
+ size_t len1;
+ size_t len2;
+
+ // sanity checks
+ if (!list1 && !list2) {
+ return(NULL);
+ }
+ if (!list1) {
+ // copy list2
+ return(listDupCS(list2));
+ }
+ if (!list2) {
+ // copy list1
+ return(listDupS(list1));
+ }
+ // duplicate list1
+ l = listDupS(list1);
+ len1 = listLengthS(list1);
+ len2 = listLengthCS(list2);
+ r = REALLOC(l, (len1+len2+1) * sizeof(char *));
+ if (!r) {
+ // free l when realloc fails
+ listFreeS(l);
+ return(NULL);//LCOV_EXCL_LINE
+ }
+ // push list2 to new list
+ enumerateCCharP(list2, e, i) {
+ r[len1+i] = strdup(*e);
+ }
+
+ r[len1+len2] = NULL;
+
+ return(r);
+}
+
+
+/**
* list Slice String
* return new list with elements from start and end in list
* negative indexes are allowed
@@ -50879,7 +51267,7 @@ char **listSliceS(char **list, int64_t start, int64_t end) {
return(NULL);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (start > len) {
return(NULL);
@@ -50912,7 +51300,7 @@ char **listSliceS(char **list, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = MALLOC((n+1) * sizeof(char *));
+ l = MALLOC((size_t)(n+1) * sizeof(char *));
if (!l) {
return(NULL);//LCOV_EXCL_LINE
}
@@ -50952,7 +51340,7 @@ char **iListCopyS(char **list, int64_t start, int64_t end) {
return(NULL);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (start > len) {
return(NULL);
@@ -50985,7 +51373,7 @@ char **iListCopyS(char **list, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = MALLOC((n+1) * sizeof(char *));
+ l = MALLOC((size_t)(n+1) * sizeof(char *));
if (!l) {
return(NULL);//LCOV_EXCL_LINE
}
@@ -51023,7 +51411,7 @@ char **iListSliceS(char ***list, int64_t start, int64_t end) {
return(NULL);
}
- len = listLengthS(*list);
+ len = (int64_t)listLengthS(*list);
if (start > len) {
listFreeS(*list);
@@ -51063,7 +51451,7 @@ char **iListSliceS(char ***list, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = MALLOC((n+1) * sizeof(char *));
+ l = MALLOC((size_t)(n+1) * sizeof(char *));
if (!l) {
return(NULL);
}
@@ -51117,7 +51505,7 @@ char **listCropS(char **list, int64_t start, int64_t end) {
return(NULL);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (start > len) {
return(NULL);
@@ -51150,7 +51538,7 @@ char **listCropS(char **list, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = MALLOC((n+1) * sizeof(char *));
+ l = MALLOC((size_t)(n+1) * sizeof(char *));
if (!l) {
return(NULL);
}
@@ -51199,7 +51587,7 @@ char **iListCropS(char ***list, int64_t start, int64_t end) {
return(NULL);
}
- len = listLengthS(*list);
+ len = (int64_t)listLengthS(*list);
if (start > len) {
return(NULL);
@@ -51232,7 +51620,7 @@ char **iListCropS(char ***list, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = MALLOC((n+1) * sizeof(char *));
+ l = MALLOC((size_t)(n+1) * sizeof(char *));
if (!l) {
return(NULL);
}
@@ -51279,7 +51667,7 @@ char *listCropElemS(char **list, int64_t index) {
return(NULL);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (len == 0) {
return(NULL);
@@ -51333,7 +51721,7 @@ char *iListCropElemS(char ***list, int64_t index) {
return(NULL);
}
- len = listLengthS(*list);
+ len = (int64_t)listLengthS(*list);
if (len == 0) {
return(NULL);
@@ -51388,7 +51776,7 @@ char **listInsertS(char **list, int64_t index, char **toInsert) {
}
return(listDupS(toInsert));
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -51463,8 +51851,8 @@ char **iListInsertS(char ***list, int64_t index, char **toInsert) {
if (index) {
return(NULL);
}
- len = listLengthS(toInsert);
- r = MALLOC((len+1) * sizeof(char *));
+ len = (int64_t)listLengthS(toInsert);
+ r = MALLOC((size_t)(len+1) * sizeof(char *));
if (!r) {
return(NULL);//LCOV_EXCL_LINE
}
@@ -51478,7 +51866,7 @@ char **iListInsertS(char ***list, int64_t index, char **toInsert) {
return(r);
}
- len = listLengthS(*list);
+ len = (int64_t)listLengthS(*list);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -51515,15 +51903,15 @@ char **iListInsertS(char ***list, int64_t index, char **toInsert) {
if (index == 0) {
// insert at beginning
- iListAppendS(&r, toInsert);
- iListAppendS(&r, *list);
+ pErrorNULL(iListAppendS(&r, toInsert));
+ pErrorNULL(iListAppendS(&r, *list));
}
else {
r = iListCopyS(*list, 0, index);;
char **l2 = iListCopyS(*list, index, 0);
- iListAppendS(&r, toInsert);
- iListAppendS(&r, l2);
+ pErrorNULL(iListAppendS(&r, toInsert));
+ pErrorNULL(iListAppendS(&r, l2));
free(l2);
}
@@ -51570,7 +51958,7 @@ char **iListInsertNFreeS(char ***list, int64_t index, char **toInsert) {
return(r);
}
- len = listLengthS(*list);
+ len = (int64_t)listLengthS(*list);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -51608,15 +51996,15 @@ char **iListInsertNFreeS(char ***list, int64_t index, char **toInsert) {
if (index == 0) {
// insert at beginning
- iListAppendS(&r, toInsert);
- iListAppendS(&r, *list);
+ pErrorNULL(iListAppendS(&r, toInsert));
+ pErrorNULL(iListAppendS(&r, *list));
}
else {
r = iListCopyS(*list, 0, index);;
char **l2 = iListCopyS(*list, index, 0);
- iListAppendS(&r, toInsert);
- iListAppendS(&r, l2);
+ pErrorNULL(iListAppendS(&r, toInsert));
+ pErrorNULL(iListAppendS(&r, l2));
free(l2);
}
free(toInsert);
@@ -51654,7 +52042,7 @@ char **listInjectS(char **list, int64_t index, char *toInject) {
if (index || !toInject) {
return(NULL);
}
- listPushS(&r, toInject);
+ pErrorNULL(listPushS(&r, toInject));
return(r);
}
@@ -51662,7 +52050,7 @@ char **listInjectS(char **list, int64_t index, char *toInject) {
return(NULL);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -51742,11 +52130,11 @@ char **iListInjectS(char ***list, int64_t index, char *toInject) {
if (index) {
return(NULL);
}
- iListPushS(list, toInject);
+ pErrorNULL(iListPushS(list, toInject));
return(*list);
}
- len = listLengthS(*list);
+ len = (int64_t)listLengthS(*list);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -51777,15 +52165,15 @@ char **iListInjectS(char ***list, int64_t index, char *toInject) {
if (index == 0) {
// Inject at beginning
- iListAppendS(&r, inject);
- iListAppendS(&r, *list);
+ pErrorNULL(iListAppendS(&r, inject));
+ pErrorNULL(iListAppendS(&r, *list));
}
else {
r = iListCopyS(*list, 0, index);;
char **l2 = iListCopyS(*list, index, 0);
- iListAppendS(&r, inject);
- iListAppendS(&r, l2);
+ pErrorNULL(iListAppendS(&r, inject));
+ pErrorNULL(iListAppendS(&r, l2));
free(l2);
}
@@ -51835,7 +52223,7 @@ char **listDelS(char **list, int64_t start, int64_t end) {
return(NULL);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (len == 0) {
return(NULL);
@@ -51870,7 +52258,7 @@ char **listDelS(char **list, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = MALLOC((len-n+1) * sizeof(char *));
+ l = MALLOC((size_t)(len-n+1) * sizeof(char *));
if (!l) {
return(NULL);//LCOV_EXCL_LINE
}
@@ -51912,7 +52300,7 @@ char **iListDelS(char ***list, int64_t start, int64_t end) {
return(NULL);
}
- len = listLengthS(*list);
+ len = (int64_t)listLengthS(*list);
if (len == 0) {
return(NULL);
@@ -51947,7 +52335,7 @@ char **iListDelS(char ***list, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = MALLOC((len-n+1) * sizeof(char *));
+ l = MALLOC((size_t)(len-n+1) * sizeof(char *));
if (!l) {
return(NULL);
}
@@ -51995,7 +52383,7 @@ char **iListRemoveS(char ***list, int64_t start, int64_t end) {
return(NULL);
}
- len = listLengthS(*list);
+ len = (int64_t)listLengthS(*list);
if (len == 0) {
return(NULL);
@@ -52030,7 +52418,7 @@ char **iListRemoveS(char ***list, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = MALLOC((len-n+1) * sizeof(char *));
+ l = MALLOC((size_t)(len-n+1) * sizeof(char *));
if (!l) {
return(NULL);
}
@@ -52070,7 +52458,7 @@ char **listDelElemS(char **list, int64_t index) {
return(NULL);
}
- len = listLengthS(list);
+ len = (int64_t)listLengthS(list);
if (len == 0) {
return(NULL);
@@ -52086,7 +52474,7 @@ char **listDelElemS(char **list, int64_t index) {
index = len + index;
}
- l = MALLOC((len-1+1) * sizeof(char *));
+ l = MALLOC((size_t)(len-1+1) * sizeof(char *));
if (!l) {
return(NULL);//LCOV_EXCL_LINE
}
@@ -52125,7 +52513,7 @@ char **iListDelElemS(char ***list, int64_t index) {
return(NULL);
}
- len = listLengthS(*list);
+ len = (int64_t)listLengthS(*list);
if (len == 0) {
return(NULL);
@@ -52141,7 +52529,7 @@ char **iListDelElemS(char ***list, int64_t index) {
index = len + index;
}
- l = MALLOC((len-1+1) * sizeof(char *));
+ l = MALLOC((size_t)(len-1+1) * sizeof(char *));
if (!l) {
return(NULL);
}
@@ -52185,7 +52573,7 @@ char **iListRemoveElemS(char ***list, int64_t index) {
return(NULL);
}
- len = listLengthS(*list);
+ len = (int64_t)listLengthS(*list);
if (len == 0) {
return(NULL);
@@ -52201,7 +52589,7 @@ char **iListRemoveElemS(char ***list, int64_t index) {
index = len + index;
}
- l = MALLOC((len-1+1) * sizeof(char *));
+ l = MALLOC((size_t)(len-1+1) * sizeof(char *));
if (!l) {
return(NULL);
}
@@ -52229,18 +52617,29 @@ char **iListRemoveElemS(char ***list, int64_t index) {
* list
* \return
* nothing
- * 0 success
- * -1 error
+ * 1 success
+ * 0 error
*/
int listPrintS(char **list) {
if (!list) {
- return(-1);
+ return(0);
}
forEachCharP(list, e) {
printf("%s\n", *e);
}
- return(0);
+ return(1);
+}
+
+int listPrintCS(const char **list) {
+
+ if (!list) {
+ return(0);
+ }
+ forEachCCharP(list, e) {
+ printf("%s\n", *e);
+ }
+ return(1);
}
/**
@@ -52264,7 +52663,7 @@ internal int listSortSCmp(const void * a, const void * b) {
if (a && !b) {
return(1);
}
- return(strcmp(*(char **)a,*(char **)b));
+ return(strcmp(*(char *const*)a,*(char *const*)b));
}
/**
@@ -52405,7 +52804,7 @@ internal int icListSortSCmp(const void * a, const void * b) {
if (a && !b) {
return(1);
}
- return(strcasecmp(*(char **)a,*(char **)b));
+ return(strcasecmp(*(char *const*)a,*(char *const*)b));
}
/**
@@ -52528,7 +52927,7 @@ char **readText(const char *filePath) {
if (pos != NULL)
*pos = '\0';
}
- listPushS(&list, line);
+ pErrorNULL(listPushS(&list, line));
read = getline(&line, &len, fp);
}
fclose(fp);
@@ -52570,7 +52969,7 @@ char **readStream(FILE *fp) {
if (pos != NULL)
*pos = '\0';
}
- iListPushS(&list, line);
+ pErrorNULL(iListPushS(&list, line));
line = NULL;
len = 0;
read = getline(&line, &len, (FILE *) fp);
@@ -52621,6 +53020,43 @@ bool writeText(const char *filePath, char **list) {
}
/**
+ * write const list to filePath
+ *
+ * \param
+ * filePath
+ * \param
+ * list
+ * \return
+ * true success
+ * false failed, filePath or list are NULL
+ */
+bool writeCText(const char *filePath, const char **list) {
+ FILE *fp = NULL;
+
+ // sanity checks
+ if (!filePath || isBlankS(filePath)) {
+ return(false);
+ }
+
+ fp = fopen(filePath, "w");
+ if (!fp) {
+ pFuncError
+ shEPrintfS("The path was: \"%s\"\n", filePath);
+ return(false);
+ }
+ if (!list) {
+ fclose(fp);
+ return(false);
+ }
+ forEachCCharP(list, e) {
+ // add new line
+ fprintf(fp, "%s\n", *e);
+ }
+ fclose(fp);
+ return(true);
+}
+
+/**
* write list to stream
*
* \param
@@ -52645,6 +53081,30 @@ bool writeStream(FILE *fp, char **list) {
}
/**
+ * write const list to stream
+ *
+ * \param
+ * fp: file stream
+ * \param
+ * list
+ * \return
+ * true success
+ * false failed, fp or list are NULL
+ */
+bool writeCStream(FILE *fp, const char **list) {
+
+ // sanity checks
+ if (!fp || !list) {
+ return(false);
+ }
+ forEachCCharP(list, e) {
+ // add new line
+ fprintf((FILE*)fp, "%s\n", *e);
+ }
+ return(true);
+}
+
+/**
* append list to filePath
*
* \param
@@ -52682,6 +53142,43 @@ bool appendText(const char *filePath, char **list) {
}
/**
+ * append const list to filePath
+ *
+ * \param
+ * filePath
+ * \param
+ * list
+ * \return
+ * true success
+ * false failed, filePath or list are NULL
+ */
+bool appendCText(const char *filePath, const char **list) {
+ FILE *fp = NULL;
+
+ // sanity checks
+ if (!filePath || isBlankS(filePath)) {
+ return(false);
+ }
+
+ fp = fopen(filePath, "a");
+ if (!fp) {
+ pFuncError
+ shEPrintfS("The path was: \"%s\"\n", filePath);
+ return(false);
+ }
+ if (!list) {
+ fclose(fp);
+ return(false);
+ }
+ forEachCCharP(list, e) {
+ // add new line
+ fprintf(fp, "%s\n", *e);
+ }
+ fclose(fp);
+ return(true);
+}
+
+/**
* execute command
* return stdout from cmd
*
@@ -52886,6 +53383,96 @@ bool listEqS(char **list1, char **list2) {
}
/**
+ * const(list2) list Equal String
+ * compare each element of list1 and list2
+ *
+ * \param
+ * 2 lists
+ * \return
+ * true the lists have identical elements
+ * false they differ
+ */
+bool listEqCS(char **list1, const char **list2) {
+
+ // sanity checks
+ if (!list1 || !list2) {
+ return(false);
+ }
+ if (listLengthS(list1) != listLengthCS(list2)) {
+ return(false);
+ }
+
+ // compare elements
+ enumerateCharP(list1, e, i) {
+ if (!strEq(*e, list2[i])) {
+ return(false);
+ }
+ }
+
+ return(true);
+}
+
+/**
+ * const(list1) list Equal String
+ * compare each element of list1 and list2
+ *
+ * \param
+ * 2 lists
+ * \return
+ * true the lists have identical elements
+ * false they differ
+ */
+bool listEqC1S(const char **list1, char **list2) {
+
+ // sanity checks
+ if (!list1 || !list2) {
+ return(false);
+ }
+ if (listLengthCS(list1) != listLengthS(list2)) {
+ return(false);
+ }
+
+ // compare elements
+ enumerateCCharP(list1, e, i) {
+ if (!strEq(*e, list2[i])) {
+ return(false);
+ }
+ }
+
+ return(true);
+}
+
+/**
+ * const(list1 and 2) list Equal String
+ * compare each element of list1 and list2
+ *
+ * \param
+ * 2 lists
+ * \return
+ * true the lists have identical elements
+ * false they differ
+ */
+bool listEqCCS(const char **list1, const char **list2) {
+
+ // sanity checks
+ if (!list1 || !list2) {
+ return(false);
+ }
+ if (listLengthCS(list1) != listLengthCS(list2)) {
+ return(false);
+ }
+
+ // compare elements
+ enumerateCCharP(list1, e, i) {
+ if (!strEq(*e, list2[i])) {
+ return(false);
+ }
+ }
+
+ return(true);
+}
+
+/**
* return true when list has string
*
* \param
@@ -52908,12 +53495,41 @@ bool listHasS(char **list, const char *string) {
return(true);
}
+/**
+ * return true when const list has string
+ *
+ * \param
+ * list
+ * \param
+ * string
+ * \return
+ * true when list has string
+ * false when the string is not found
+ * false when list or string are NULL
+ */
+bool listHasCS(const char **list, const char *string) {
+
+ if (!list || !string) {
+ return(false);
+ }
+ if (listIndexOfCS(list, string) == -1) {
+ return(false);
+ }
+ return(true);
+}
+
bool listHasCharS(char **list, char c) {
charToS(s, c);
return(listHasS(list, s));
}
+bool listHasCharCS(const char **list, char c) {
+
+ charToS(s, c);
+ return(listHasCS(list, s));
+}
+
/**
* return index of string in list
*
@@ -52941,7 +53557,41 @@ ssize_t listIndexOfS(char **list, const char *string) {
}
}
if (found) {
- return(i);
+ return((ssize_t)i);
+ }
+ else {
+ return(-1);
+}
+ }
+
+/**
+ * return index of string in const list
+ *
+ * \param
+ * list
+ * \param
+ * string
+ * \return
+ * index
+ * -1 when the string is not found
+ * -1 when list or string are NULL
+ */
+ssize_t listIndexOfCS(const char **list, const char *string) {
+ bool found = false;;
+
+ // sanity checks
+ if (!list || !string) {
+ return(-1);
+ }
+ // search string in elements
+ enumerateCCharP(list, e, i) {
+ if (strEq(*e, string)) {
+ found = true;
+ break;
+ }
+ }
+ if (found) {
+ return((ssize_t)i);
}
else {
return(-1);
@@ -52954,6 +53604,12 @@ ssize_t listIndexOfCharS(char **list, char c) {
return(listIndexOfS(list, s));
}
+ssize_t listIndexOfCharCS(const char **list, char c) {
+
+ charToS(s, c);
+ return(listIndexOfCS(list, s));
+}
+
/**
* list binary search string
*
@@ -52975,7 +53631,7 @@ ssize_t listBinarySearchS(char **list, const char *string) {
return(-1);
}
- last = listLengthS(list) - 1;
+ last = (ssize_t)(listLengthS(list) - 1);
while (first <= last) {
middle = (first+last)/2;
if (strcmp(list[middle], string) < 0) {
@@ -53023,7 +53679,7 @@ char **listUniqS(char **list) {
listEmptyS(r);
return(r);
}
- listPushS(&r, list[0]);
+ pErrorNULL(listPushS(&r, list[0]));
// one element list
if (len == 1) {
return(r);
@@ -53031,7 +53687,7 @@ char **listUniqS(char **list) {
// push element to new list if it is not already in new list
forEachCharP(list, e) {
if (listIndexOfS(r, *e) == -1) {
- listPushS(&r, *e);
+ pErrorNULL(listPushS(&r, *e));
}
}
return(r);
@@ -53064,13 +53720,13 @@ char **iListUniqS(char ***list) {
}
else if (len == 1) {
// one element list
- iListPushS(&r, (*list)[0]);
+ pErrorNULL(iListPushS(&r, (*list)[0]));
}
else {
// push element to new list if it is not already in new list
forEachCharP(*list, e) {
if (listIndexOfS(r, *e) == -1) {
- iListPushS(&r, *e);
+ pErrorNULL(iListPushS(&r, *e));
}
else {
free(*e);
@@ -53114,6 +53770,96 @@ bool icListEqS(char **list1, char **list2) {
}
/**
+ * ignore case const(list2) list Equal String
+ * compare each element of list1 and list2
+ *
+ * \param
+ * 2 lists
+ * \return
+ * true the lists have identical elements
+ * false they differ
+ */
+bool icListEqCS(char **list1, const char **list2) {
+
+ // sanity checks
+ if (!list1 || !list2) {
+ return(false);
+ }
+ if (listLengthS(list1) != listLengthCS(list2)) {
+ return(false);
+ }
+
+ // compare elements
+ enumerateCharP(list1, e, i) {
+ if (!icEqS(*e, list2[i])) {
+ return(false);
+ }
+ }
+
+ return(true);
+}
+
+/**
+ * ignore case const(list1) list Equal String
+ * compare each element of list1 and list2
+ *
+ * \param
+ * 2 lists
+ * \return
+ * true the lists have identical elements
+ * false they differ
+ */
+bool icListEqC1S(const char **list1, char **list2) {
+
+ // sanity checks
+ if (!list1 || !list2) {
+ return(false);
+ }
+ if (listLengthCS(list1) != listLengthS(list2)) {
+ return(false);
+ }
+
+ // compare elements
+ enumerateCCharP(list1, e, i) {
+ if (!icEqS(*e, list2[i])) {
+ return(false);
+ }
+ }
+
+ return(true);
+}
+
+/**
+ * ignore case const(list1 and 2) list Equal String
+ * compare each element of list1 and list2
+ *
+ * \param
+ * 2 lists
+ * \return
+ * true the lists have identical elements
+ * false they differ
+ */
+bool icListEqCCS(const char **list1, const char **list2) {
+
+ // sanity checks
+ if (!list1 || !list2) {
+ return(false);
+ }
+ if (listLengthCS(list1) != listLengthCS(list2)) {
+ return(false);
+ }
+
+ // compare elements
+ enumerateCCharP(list1, e, i) {
+ if (!icEqS(*e, list2[i])) {
+ return(false);
+ }
+ }
+
+ return(true);
+}
+
+/**
* ignore case and return true when list has string
*
* \param
@@ -53143,6 +53889,35 @@ bool icListHasCharS(char **list, char c) {
}
/**
+ * ignore case and return true when const list has string
+ *
+ * \param
+ * list
+ * \param
+ * string
+ * \return
+ * true when list has string
+ * false when the string is not found
+ * false when list or string are NULL
+ */
+bool icListHasCS(const char **list, const char *string) {
+
+ if (!list || !string) {
+ return(false);
+ }
+ if (icListIndexOfCS(list, string) == -1) {
+ return(false);
+ }
+ return(true);
+}
+
+bool icListHasCharCS(const char **list, char c) {
+
+ charToS(s, c);
+ return(icListHasCS(list, s));
+}
+
+/**
* ignore case and return index of string in list
*
* \param
@@ -53169,7 +53944,41 @@ ssize_t icListIndexOfS(char **list, const char *string) {
}
}
if (found) {
- return(i);
+ return((ssize_t)i);
+ }
+ else {
+ return(-1);
+}
+ }
+
+/**
+ * ignore case and return index of string in const list
+ *
+ * \param
+ * list
+ * \param
+ * string
+ * \return
+ * index
+ * -1 when the string is not found
+ * -1 when list or string are NULL
+ */
+ssize_t icListIndexOfCS(const char **list, const char *string) {
+ bool found = false;;
+
+ // sanity checks
+ if (!list || !string) {
+ return(-1);
+ }
+ // search string in elements
+ enumerateCCharP(list, e, i) {
+ if (icEqS(*e, string)) {
+ found = true;
+ break;
+ }
+ }
+ if (found) {
+ return((ssize_t)i);
}
else {
return(-1);
@@ -53182,6 +53991,12 @@ ssize_t icListIndexOfCharS(char **list, char c) {
return(icListIndexOfS(list, s));
}
+ssize_t icListIndexOfCharCS(const char **list, char c) {
+
+ charToS(s, c);
+ return(icListIndexOfCS(list, s));
+}
+
/**
* ignore case list binary search string
*
@@ -53203,7 +54018,7 @@ ssize_t icListBinarySearchS(char **list, const char *string) {
return(-1);
}
- last = listLengthS(list) - 1;
+ last = (ssize_t)listLengthS(list) - 1;
while (first <= last) {
middle = (first+last)/2;
if (strcasecmp(list[middle], string) < 0) {
@@ -53251,7 +54066,7 @@ char **icListUniqS(char **list) {
listEmptyS(r);
return(r);
}
- listPushS(&r, list[0]);
+ pErrorNULL(listPushS(&r, list[0]));
// one element list
if (listLengthS(list) == 1) {
return(r);
@@ -53259,7 +54074,7 @@ char **icListUniqS(char **list) {
// push element to new list if it is not already in new list
forEachCharP(list, e) {
if (icListIndexOfS(r, *e) == -1) {
- listPushS(&r, *e);
+ pErrorNULL(listPushS(&r, *e));
}
}
return(r);
@@ -53292,13 +54107,13 @@ char **iicListUniqS(char ***list) {
}
else if (len == 1) {
// one element list
- iListPushS(&r, (*list)[0]);
+ pErrorNULL(iListPushS(&r, (*list)[0]));
}
else {
// push element to new list if it is not already in new list
forEachCharP(*list, e) {
if (icListIndexOfS(r, *e) == -1) {
- iListPushS(&r, *e);
+ pErrorNULL(iListPushS(&r, *e));
}
else {
free(*e);
@@ -53333,7 +54148,7 @@ char **listCompactS(char **list) {
forEachCharP(list, e) {
char *trim = trimS(*e);
if (*trim != 0) {
- listPushS(&r, *e);
+ pErrorNULL(listPushS(&r, *e));
}
free(trim);
}
@@ -53367,7 +54182,7 @@ char **iListCompactS(char ***list) {
forEachCharP(*list, e) {
char *trim = trimS(*e);
if (*trim != 0) {
- iListPushS(&r, *e);
+ pErrorNULL(iListPushS(&r, *e));
}
else {
free(*e);
@@ -53384,7 +54199,7 @@ char **iListCompactS(char ***list) {
*list = r;
}
else {
- iListEmptySF(list);
+ pErrorNULL(iListEmptySF(list));
}
return(*list);
}
@@ -53472,7 +54287,7 @@ char **btrace(void) {
char **symbols = NULL;;
forEachCharP(elf, s) {
// keep only one space between columns
- iUniqS(s, ' ');
+ pErrorNULL(iUniqS(s, ' '));
// s = " 530: 000000000000b7e5 65 FUNC GLOBAL DEFAULT 14 zeroS"
size_t len = strlen(*s);
// spaces is the column number
@@ -53503,7 +54318,7 @@ char **btrace(void) {
if (_ and startsWithS(_, "FUNC")) {
// this symbol is a function
// store function name and function address as a uint64_t
- iListPushS(&symbols, funcName);
+ pErrorNULL(iListPushS(&symbols, funcName));
dArrayAppend(&addresses, parseHex(addr));
}
}
@@ -53540,7 +54355,7 @@ char **btrace(void) {
free(bts);
return(NULL);
}
- size_t funcNameLen = (offset-1) - funcName;
+ size_t funcNameLen = (size_t)((offset-1) - funcName);
// search function in all funtions from the elf file
int symbolIndex = 0;;
@@ -53550,7 +54365,7 @@ char **btrace(void) {
}
if (!strncmp(funcName, *l, funcNameLen)) {
// found function
- symbolIndex = j;
+ symbolIndex = (int)j;
break;
}
}
@@ -53567,7 +54382,7 @@ char **btrace(void) {
continue;
}
- iListPushS(&r, formatS("%s: %s", symbols[symbolIndex], cres[0]));
+ pErrorNULL(iListPushS(&r, formatS("%s: %s", symbols[symbolIndex], cres[0])));
listFreeS(cres);
}
@@ -53674,7 +54489,7 @@ void **listCreateF(void *paramType, ...) {
va_start(pl, paramType);
paramType = va_arg(pl, void *);
while (paramType) {
- listPush(&l, paramType);
+ pErrorNULL(listPush(&l, paramType));
paramType = va_arg(pl, void *);
}
va_end(pl);
@@ -53712,7 +54527,7 @@ void **listFromArray(void **array, size_t size) {
for (size_t i = 0 ; i < size ; i++) {
if (array[i]) {
// remove NULL elements
- listPush(&r, array[i]);
+ pErrorNULL(listPush(&r, array[i]));
}
}
return(r);
@@ -53782,7 +54597,7 @@ void **listPush(void ***list, void *s) {
*/
void *listPop(void ***list) {
void *s = NULL;
- uint64_t len;
+ size_t len;
// sanity checks
if (!list) {
@@ -53839,7 +54654,7 @@ void **listPrepend(void ***list, void *s) {
}
else {
// realloc list and copy s to last element
- uint64_t len;
+ size_t len;
len = listLength(*list);
void **tmp = REALLOC(*list, (len+2) * sizeof(void *));
if (!tmp) {
@@ -53870,7 +54685,7 @@ void **listPrepend(void ***list, void *s) {
*/
void *listDequeue(void ***list) {
void *s = NULL;
- uint64_t len;
+ size_t len;
// sanity checks
if (!list) {
@@ -53978,7 +54793,7 @@ void *listGet(void **list, int64_t index) {
return(NULL);
}
- len = listLength(list);
+ len = (int64_t)listLength(list);
if (index >= len) {
return(NULL);
}
@@ -54022,7 +54837,7 @@ void **listSet(void **list, int64_t index, void *s) {
return(NULL);
}
- len = listLength(list);
+ len = (int64_t)listLength(list);
if (index >= len) {
return(NULL);
}
@@ -54159,7 +54974,7 @@ void **listCatF(void **paramType, ...) {
va_start(pl, paramType);
paramType = va_arg(pl, void **);
while (paramType) {
- listAppend(&r, paramType);
+ pErrorNULL(listAppend(&r, paramType));
paramType = va_arg(pl, void **);
}
va_end(pl);
@@ -54327,7 +55142,7 @@ void **listSlice(void **list, int64_t start, int64_t end) {
return(NULL);
}
- len = listLength(list);
+ len = (int64_t)listLength(list);
if (start > len) {
return(NULL);
@@ -54360,7 +55175,7 @@ void **listSlice(void **list, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = MALLOC((n+1) * sizeof(void *));
+ l = MALLOC((size_t)(n+1) * sizeof(void *));
if (!l) {
return(NULL);//LCOV_EXCL_LINE
}
@@ -54398,7 +55213,7 @@ void **iListSlice(void ***list, int64_t start, int64_t end) {
return(NULL);
}
- len = listLength(*list);
+ len = (int64_t)listLength(*list);
if (start > len) {
free(*list);
@@ -54436,7 +55251,7 @@ void **iListSlice(void ***list, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = MALLOC((n+1) * sizeof(void *));
+ l = MALLOC((size_t)(n+1) * sizeof(void *));
if (!l) {
return(NULL);
}
@@ -54486,7 +55301,7 @@ void **listInsert(void **list, int64_t index, void **toInsert) {
return(NULL);
}
- len = listLength(list);
+ len = (int64_t)listLength(list);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -54567,7 +55382,7 @@ void **iListInsert(void ***list, int64_t index, void **toInsert) {
return(r);
}
- len = listLength(*list);
+ len = (int64_t)listLength(*list);
if (!len && index == -1) {
// empty string, index -1 is equal to 0
@@ -54598,15 +55413,15 @@ void **iListInsert(void ***list, int64_t index, void **toInsert) {
if (index == 0) {
// insert at beginning
- listAppend(&r, toInsert);
- listAppend(&r, *list);
+ pErrorNULL(listAppend(&r, toInsert));
+ pErrorNULL(listAppend(&r, *list));
}
else {
r = listSlice(*list, 0, index);
void **l2 = listSlice(*list, index, 0);
- listAppend(&r, toInsert);
- listAppend(&r, l2);
+ pErrorNULL(listAppend(&r, toInsert));
+ pErrorNULL(listAppend(&r, l2));
free(l2);
}
@@ -54641,7 +55456,7 @@ void **listDel(void **list, int64_t start, int64_t end) {
return(NULL);
}
- len = listLength(list);
+ len = (int64_t)listLength(list);
if (len == 0) {
return(NULL);
@@ -54676,7 +55491,7 @@ void **listDel(void **list, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = MALLOC((len-n+1) * sizeof(void *));
+ l = MALLOC((size_t)(len-n+1) * sizeof(void *));
if (!l) {
return(NULL);//LCOV_EXCL_LINE
}
@@ -54718,7 +55533,7 @@ void **iListDel(void ***list, int64_t start, int64_t end) {
return(NULL);
}
- len = listLength(*list);
+ len = (int64_t)listLength(*list);
if (len == 0) {
return(NULL);
@@ -54753,7 +55568,7 @@ void **iListDel(void ***list, int64_t start, int64_t end) {
// start < end < len
int64_t n;
n = end - start;
- l = MALLOC((len-n+1) * sizeof(void *));
+ l = MALLOC((size_t)(len-n+1) * sizeof(void *));
if (!l) {
return(NULL);
}
@@ -55378,8 +56193,8 @@ uint64_t getMonotonicTime(void) {
int nanoSleepF(uint64_t time) {
struct timespec ts;
- ts.tv_sec = time / 1000000000;
- ts.tv_nsec = time % 1000000000;
+ ts.tv_sec = (time_t)(time / 1000000000);
+ ts.tv_nsec = (time_t)(time % 1000000000);
int r = nanosleep(&ts, NULL);;
if (r == -1) {
pFuncError
@@ -55634,9 +56449,9 @@ int MAIN(int ARGC, char** ARGV) {
char **lst = listCreateS("1","2","3","4","5");
char **lcrop = listCropS(lst, 1,3);
- listPrintS(lst);
+ pError0(listPrintS(lst));
AT
- listPrintS(lcrop);
+ pError0(listPrintS(lcrop));
setLogStdout(no);
@@ -55690,14 +56505,14 @@ int MAIN(int ARGC, char** ARGV) {
//char **li2;
// list negative index
- listPushS(&li, "1");
- listPushS(&li, "22");
- listPushS(&li, "333");
- listPushS(&li, "4444");
+ pErrorNULL(listPushS(&li, "1"));
+ pErrorNULL(listPushS(&li, "22"));
+ pErrorNULL(listPushS(&li, "333"));
+ pErrorNULL(listPushS(&li, "4444"));
//li2 = iListCropS(&li, 1,-1)
char *stri = iListCropElemS(&li, 1);
- listPrintS(li);
+ pError0(listPrintS(li));
put
puts(stri);
//listPrintS(li2);
@@ -55806,8 +56621,8 @@ int MAIN(int ARGC, char** ARGV) {
const char *AA[] = {"WER", "asd", NULL};
char **CA = listCreateS("zxc", "cvb");;
- listPrintS((char**)AA);
- listPrintS(CA);
+ pError0(listPrintS((char**)AA));
+ pError0(listPrintS(CA));
char *utf8 = "Футбол России и мира, новости футбола, видео голов...";;
char *utf8_l6 = "Футбол";;
@@ -55835,7 +56650,7 @@ int MAIN(int ARGC, char** ARGV) {
logPtr(utg8_l6+strlen(utg8_l6));
logVar(makeValidUTF8(utg8_l6), "s");
logVar(makeValidUTF8(aq), "s");
- strNCpyUTF8(aq, utg8_l6, 5);
+ pErrorNULL(strNCpyUTF8(aq, utg8_l6, 5));
logVar(aq, "s");
/* logVar(ptr2IdxUTF8(utg8_l6, utg8_l6+strlen(utg8_l6)+1),"d"); */
/* logVar(ptr2IdxUTF8(utg8_l6, utg8_l6),"d"); */
@@ -56054,7 +56869,7 @@ int MAIN(int ARGC, char** ARGV) {
XSUCCESS
char **bt = btrace();;
- listPrintS(bt);
+ pError0(listPrintS(bt));
listFreeS(bt);
logPtr(bt);
@@ -56265,7 +57080,7 @@ int MAIN(int ARGC, char** ARGV) {
puts(c);
XSUCCESS
- listPrintS(walkDirDir("dirTest.null"));
+ pError0(listPrintS(walkDirDir("dirTest.null")));
circular(i, 2, 4) {
printf("%d\n", (int)i);
@@ -56276,14 +57091,14 @@ int MAIN(int ARGC, char** ARGV) {
char **R = listInsertS(l, -1, l2);;
puts(R[0]);
- injectS("s", -2, 'D');
+ pErrorNULL(injectS("s", -2, 'D'));
c = strdup(" SHeePY");
- iLTrimS(&c);
+ pErrorNULL(iLTrimS(&c));
printf(">%s<\n",c);
free(c);
- copy("dirTest.null", "..");
+ pError0(copy("dirTest.null", ".."));
puts(getProgPath());
initLibsheepy("test");
@@ -56294,7 +57109,7 @@ int MAIN(int ARGC, char** ARGV) {
puts(__func__);
AT;
- iCatS(a, "qwee ", "wefwef", "--1`21`2123");
+ pErrorNULL(iCatS(a, "qwee ", "wefwef", "--1`21`2123"));
puts(a);
XSUCCESS
@@ -56322,15 +57137,15 @@ int MAIN(int ARGC, char** ARGV) {
puts("readDir");
put
- listPrintS(readDir("."));
+ pError0(listPrintS(readDir(".")));
puts("readDirDir");
put
- listPrintS(readDirDir("."));
+ pError0(listPrintS(readDirDir(".")));
puts("readDirAll");
put
- listPrintS(readDirAll("."));
+ pError0(listPrintS(readDirAll(".")));
- isNumber("-12.3");
+ pError0(isNumber("-12.3"));
XSUCCESS
/* int r = 0 */
@@ -56373,9 +57188,9 @@ int MAIN(int ARGC, char** ARGV) {
XSUCCESS
- copy("cov.info", "qwe");
- copy("dirTest.null/", "mkdirTest.null/null/");
- copy("dirTest.null", "mkdirTest.null/");
+ pError0(copy("cov.info", "qwe"));
+ pError0(copy("dirTest.null/", "mkdirTest.null/null/"));
+ pError0(copy("dirTest.null", "mkdirTest.null/"));
initLibsheepy(argv[0]);
@@ -56389,9 +57204,9 @@ int MAIN(int ARGC, char** ARGV) {
//pError(asprintf(&s, "%s/%s\n", "qwd","qw"));
puts(s);
- listPrintS(walkDirAll("."));
- printf("%o\n", 0777 & ~getumask());
- mkdirParents("mkdirTest.null/null");
+ pError0(listPrintS(walkDirAll(".")));
+ printf("%o\n", 0777 & ~getUmask());
+ pError0(mkdirParents("mkdirTest.null/null"));
/* pErrorCmd(isDir("json"), == false, pLog(LOG_WARNING, "json is NOT dir")) */
/* else */
@@ -56474,7 +57289,7 @@ int MAIN(int ARGC, char** ARGV) {
er = (int*)tt;
char *dum = strdup("ls dasd");;
- systemNFree(dum);
+ pErrorNot0(systemNFree(dum));
// no ~/
char *s;
@@ -56485,7 +57300,7 @@ int MAIN(int ARGC, char** ARGV) {
//ck_assert_ptr_eq(expandHome(NULL), NULL);
s = strdup(";//w//ef//");
- iUniqS(&s, '/');
+ pErrorNULL(iUniqS(&s, '/'));
puts(s);
puts(uniqS("wef", '/'));
puts(uniqS("//w//ef//", '/'));
diff --git a/src/libsheepy.h b/src/libsheepy.h
@@ -98,7 +98,7 @@
// version accoring to the version package: Release.Major.minor.patch
// https://noulin.net/version/file/README.md.html
-#define LIBSHEEPY_VERSION "2.2.5.5"
+#define LIBSHEEPY_VERSION "2.2.6"
#ifndef SH_PREFIX
#define SH_PREFIX(NAME) NAME
@@ -802,8 +802,8 @@ void cleanUpFileFree(FILE **val);
#define BGWHT "\x1B[47m"
// bug in cg_c.py
-#define sheepyRGBFP len = fprintf(stream, "%*s", (info->left ? -info->width : info->width), b)
-#define sheepyBOOLFP len = fprintf(stream, "%*s", (info->left ? -info->width : info->width), boolS(value))
+#define sheepyRGBFP len = fprintf(stream, "%*s", (int)(info->left ? -info->width : info->width), b)
+#define sheepyBOOLFP len = fprintf(stream, "%*s", (int)(info->left ? -info->width : info->width), boolS(value))
/**
* time a function in nanoseconds
@@ -970,14 +970,24 @@ uint64_t shStopwatch(uint8_t op);
// add a log file, maximum 15 files
FILE *SH_PREFIX(setLogFile)(char *filename);
+#ifdef __GNUC__
+/** force function callers to check return value
+ * The warning is disabled with -Wno-unused-result (default in sheepy config ~/.sheepy/config.yml
+ * Enable this warning to make all errors caught as early as possible and handled correctly.
+ */
+#define MUST_CHECK __attribute__ ((warn_unused_result))
+#else
+#define MUST_CHECK
+#endif
+
// current log symbols
-int getLogSymbols(void);
+int getLogSymbols(void) MUST_CHECK;
// set log symbols, LOG_VERBOSE for words, LOG_UTF8 for emojis, LOG_VOID for no symbols, LOG_INVALID_MODE (reset log symbols) for default log mode symbols, anything else (LOG_CONCISE,...) for symbols (!*+->~)
void setLogSymbols(int mode);
// current max log level
-int getMaxLogLevel(void);
+int getMaxLogLevel(void) MUST_CHECK;
// set max log level, logs above logMaxLevel are skipped
void setMaxLogLevel(int logLevel);
@@ -986,25 +996,25 @@ void setMaxLogLevel(int logLevel);
void closeLogFiles(void);
// get current log mode (LOG_VERBOSE, LOG_CONCISE, ...)
-int getLogMode(void);
+int getLogMode(void) MUST_CHECK;
// set log mode LOG_VERBOSE, LOG_CONCISE, ...
void setLogMode(int mode);
// get current log long/short path value, default is TRUE (short paths)
-bool getLogShortPath(void);
+bool getLogShortPath(void) MUST_CHECK;
// set log long/short file path value for VERBOSE mode
void setLogShortPath(bool shortPath);
// get stdout state, when TRUE (default) all logs are printed to stdout
-bool getLogStdout(void);
+bool getLogStdout(void) MUST_CHECK;
// enable/disable printing logs to stdout
void setLogStdout(bool state);
// log to a file named progName.log
-bool openProgLogFile(void);
+bool openProgLogFile(void) MUST_CHECK;
/**
* print logging levels
@@ -1548,16 +1558,16 @@ void initLibsheepyF(const char *progPath, initLibsheepyObjectP initF);
void finalizeLibsheepyCharAtExit(void);
// get current stack limit - returns 0 when error
-int64_t getStackLimit(void);
+int64_t getStackLimit(void) MUST_CHECK;
// set stack limit (-1 for unlimited) - returns 0 when error
-int setStackLimit(int64_t stackSize);
+int setStackLimit(int64_t stackSize) MUST_CHECK;
// get program name
-const char *getProgName(void);
+const char *getProgName(void) MUST_CHECK;
// set program name
-bool setProgName(const char *name);
+bool setProgName(const char *name) MUST_CHECK;
// set default program name
void setDefaultProgName(void);
@@ -1566,180 +1576,187 @@ void setDefaultProgName(void);
void freeProgName(void);
// get program path as given in the shell
-const char *getProgPath(void);
+const char *getProgPath(void) MUST_CHECK;
// get real program path, allocates path string internally
-const char *getRealProgPath(void);
+const char *getRealProgPath(void) MUST_CHECK;
// free real program path
void freeRealProgPath(void);
// run system command and free command buffer
#define systemNFree(command) systemNFreeF(command, __LINE__, __func__, __FILE__)
-int systemNFreeF(char *command, int line, const char *thisFunc, const char *thisFileName);
+int systemNFreeF(char *command, int line, const char *thisFunc, const char *thisFileName) MUST_CHECK;
// get modification time for path
-time_t getModificationTime(const char *path);
+time_t getModificationTime(const char *path) MUST_CHECK;
// set modification time for path
-int setModificationTime(const char *path, time_t mtime);
+int setModificationTime(const char *path, time_t mtime) MUST_CHECK;
// true when path is readable
-bool isReadable(const char *path);
+bool isReadable(const char *path) MUST_CHECK;
// true when path is writable
-bool isWritable(const char *path);
+bool isWritable(const char *path) MUST_CHECK;
// true when path is executable
-bool isExecutable(const char *path);
+bool isExecutable(const char *path) MUST_CHECK;
// compare modification times for path1 and path2
-bool equalModificationTimes(const char *path1, const char *path2);
+bool equalModificationTimes(const char *path1, const char *path2) MUST_CHECK;
// get current unix time
-time_t getCurrentUnixTime(void);
+time_t getCurrentUnixTime(void) MUST_CHECK;
// convert date string to unix time
-time_t strToUnixTime(const char *date, const char *format);
+time_t strToUnixTime(const char *date, const char *format) MUST_CHECK;
// convert unix time to string
-char *timeToS(const time_t t);
-char *bTimeToS(char *dst, const time_t t);
-char *bLTimeToS(char *dst, size_t dstSize, const time_t t);
+char *timeToS(const time_t t) MUST_CHECK;
+char *bTimeToS(char *dst, const time_t t) MUST_CHECK;
+char *bLTimeToS(char *dst, size_t dstSize, const time_t t) MUST_CHECK;
// convert unix time to Y-m-d H:M:S string
-char *timeToYMDS(const time_t t);
-char *bTimeToYMDS(char *dst, const time_t t);
-char *bLTimeToYMDS(char *dst, size_t dstSize, const time_t t);
+char *timeToYMDS(const time_t t) MUST_CHECK;
+char *bTimeToYMDS(char *dst, const time_t t) MUST_CHECK;
+char *bLTimeToYMDS(char *dst, size_t dstSize, const time_t t) MUST_CHECK;
// get current date in ctime format
-char *getCurrentDate(void);
-char *bGetCurrentDate(char *dst);
-char *bLGetCurrentDate(char *dst, size_t dstSize);
+char *getCurrentDate(void) MUST_CHECK;
+char *bGetCurrentDate(char *dst) MUST_CHECK;
+char *bLGetCurrentDate(char *dst, size_t dstSize) MUST_CHECK;
// get current date in Y-m-d H:M:S format
-char *getCurrentDateYMD(void);
-char *bGetCurrentDateYMD(char *dst);
-char *bLGetCurrentDateYMD(char *dst, size_t dstSize);
+char *getCurrentDateYMD(void) MUST_CHECK;
+char *bGetCurrentDateYMD(char *dst) MUST_CHECK;
+char *bLGetCurrentDateYMD(char *dst, size_t dstSize) MUST_CHECK;
// dirname
-char *shDirname(const char *path);
-char *bDirname(char *path);
-char *bLDirname(char *path, size_t pathSize);
+char *shDirname(const char *path) MUST_CHECK;
+char *bDirname(char *path) MUST_CHECK;
+char *bLDirname(char *path, size_t pathSize) MUST_CHECK;
// expand home ~/
-char *expandHome(const char *path);
-char *iExpandHome(char **path);
-char *bExpandHome(char *path);
-char *bLExpandHome(char *path, size_t pathSize);
+char *expandHome(const char *path) MUST_CHECK;
+char *iExpandHome(char **path) MUST_CHECK;
+char *bExpandHome(char *path) MUST_CHECK;
+char *bLExpandHome(char *path, size_t pathSize) MUST_CHECK;
// normalize path
-char *normalizePath(const char *path);
-char *iNormalizePath(char **path);
-char *bNormalizePath(char *path);
-char *bLNormalizePath(char *path, size_t pathSize);
+char *normalizePath(const char *path) MUST_CHECK;
+char *iNormalizePath(char **path) MUST_CHECK;
+char *bNormalizePath(char *path) MUST_CHECK;
+char *bLNormalizePath(char *path, size_t pathSize) MUST_CHECK;
// relative path
-char *relPath(const char *path, const char *start);
-char *iRelPath(char **path, const char *start);
-char *bRelPath(char *dest, const char *path, const char *start);
-char *bLRelPath(char *dest, size_t destSize, char *path, const char *start);
+char *relPath(const char *path, const char *start) MUST_CHECK;
+char *iRelPath(char **path, const char *start) MUST_CHECK;
+char *bRelPath(char *dest, const char *path, const char *start) MUST_CHECK;
+char *bLRelPath(char *dest, size_t destSize, char *path, const char *start) MUST_CHECK;
// get home path
-char *getHomePath(void);
-char *bGetHomePath(char *path);
-char *bLGetHomePath(char *path, size_t pathSize);
-const char *getCHomePath(void);
+char *getHomePath(void) MUST_CHECK;
+char *bGetHomePath(char *path) MUST_CHECK;
+char *bLGetHomePath(char *path, size_t pathSize) MUST_CHECK;
+const char *getCHomePath(void) MUST_CHECK;
// get current working directory
-char *getCwd(void);
-char *bLGetCwd(char *path, size_t pathSize);
+char *getCwd(void) MUST_CHECK;
+char *bLGetCwd(char *path, size_t pathSize) MUST_CHECK;
// change directory
-int chDir(const char *path);
+int chDir(const char *path) MUST_CHECK;
// true when path is directory
-bool isDir(const char *path);
+bool isDir(const char *path) MUST_CHECK;
// read link to a new string
-char *shReadlink(const char *path);
+char *shReadlink(const char *path) MUST_CHECK;
// read link chain to the end to a new string
-char *endlink(const char *path);
+char *endlink(const char *path) MUST_CHECK;
// true when path is symbolic link
-bool isLink(const char *path);
+bool isLink(const char *path) MUST_CHECK;
// file and dir exists
-bool fileExists(const char *filePath);
+bool fileExists(const char *filePath) MUST_CHECK;
#define isPath fileExists
// chmod "721"
-bool fileChmod(const char *filePath, mode_t mode);
+bool fileChmod(const char *filePath, mode_t mode) MUST_CHECK;
// file size
-ssize_t fileSize(const char *filePath);
-ssize_t fileSizeFP(FILE *fp);
+ssize_t fileSize(const char *filePath) MUST_CHECK;
+ssize_t fileSizeFP(FILE *fp) MUST_CHECK;
// read file
-void *readFileToS(const char *filePath);
-void *bReadFileToS(const char *filePath, void *dst);
-void *bLReadFileToS(const char *filePath, void *dst, size_t dstSize);
-ssize_t readFile(const char *filePath, void **buffer);
-ssize_t bReadFile(const char *filePath, void *buffer);
-ssize_t bLReadFile(const char *filePath, void *buffer, size_t dstSize);
-void *readStreamToS(FILE *fp);
-void *bReadStreamToS(FILE *fp, void *dst);
-void *bLReadStreamToS(FILE *fp, void *dst, size_t dstSize);
+void *readFileToS(const char *filePath) MUST_CHECK;
+void *bReadFileToS(const char *filePath, void *dst) MUST_CHECK;
+void *bLReadFileToS(const char *filePath, void *dst, size_t dstSize) MUST_CHECK;
+ssize_t readFile(const char *filePath, void **buffer) MUST_CHECK;
+ssize_t bReadFile(const char *filePath, void *buffer) MUST_CHECK;
+ssize_t bLReadFile(const char *filePath, void *buffer, size_t dstSize) MUST_CHECK;
+void *readStreamToS(FILE *fp) MUST_CHECK;
+void *bReadStreamToS(FILE *fp, void *dst) MUST_CHECK;
+void *bLReadStreamToS(FILE *fp, void *dst, size_t dstSize) MUST_CHECK;
+// defines without '...ToS'
+#define readFileS readFileToS
+#define bReadFileS bReadFileToS
+#define bLReadFileS bLReadFileToS
+#define readStreamS readStreamToS
+#define bReadStreamS bReadStreamToS
+#define bLReadStreamS bLReadStreamToS
// write file
-int writeFileS(const char *filePath, const char *string);
-int writeFile(const char *filePath, void *buffer, size_t len);
-int writeStreamS(FILE *fp, const char *string);
-int writeLStream(FILE *fp, void *buffer, size_t len);
+int writeFileS(const char *filePath, const char *string) MUST_CHECK;
+int writeFile(const char *filePath, void *buffer, size_t len) MUST_CHECK;
+int writeStreamS(FILE *fp, const char *string) MUST_CHECK;
+int writeLStream(FILE *fp, void *buffer, size_t len) MUST_CHECK;
// append string to file
-bool appendFileS(const char *filePath, const char *string);
-bool appendFile(const char *filePath, void *buffer, size_t len);
+bool appendFileS(const char *filePath, const char *string) MUST_CHECK;
+bool appendFile(const char *filePath, void *buffer, size_t len) MUST_CHECK;
// walkDir lists files only
-char **walkDir(const char* dirPath);
+char **walkDir(const char* dirPath) MUST_CHECK;
// walkDirDir lists directories
-char **walkDirDir(const char* dirPath);
+char **walkDirDir(const char* dirPath) MUST_CHECK;
// readDir lists files in a directory
-char **readDir(const char *dirPath);
+char **readDir(const char *dirPath) MUST_CHECK;
// readDirDir lists directories in a directory
-char **readDirDir(const char *dirPath);
+char **readDirDir(const char *dirPath) MUST_CHECK;
// walkDirAll lists files and directories
-char **walkDirAll(const char* dirPath);
+char **walkDirAll(const char* dirPath) MUST_CHECK;
// readDirAll lists files and directories in a directory
-char **readDirAll(const char *dirPath);
+char **readDirAll(const char *dirPath) MUST_CHECK;
// get umask
-mode_t getumask(void);
+mode_t getUmask(void) MUST_CHECK;
// get current permissions for creating directories
-mode_t getCurrentPermissions(void);
+mode_t getCurrentPermissions(void) MUST_CHECK;
// recursive mkdir
-int mkdirParents(const char* path);
+int mkdirParents(const char* path) MUST_CHECK;
// delete files and directories
-int rmAll(const char* path);
+int rmAll(const char* path) MUST_CHECK;
// copy files recursively
-int copy(const char* src, const char* dst);
+int copy(const char* src, const char* dst) MUST_CHECK;
// rename file
-int shRename(const char* src, const char* dst);
+int shRename(const char* src, const char* dst) MUST_CHECK;
// move files recursively
-int shMove(const char* src, const char* dst);
+int shMove(const char* src, const char* dst) MUST_CHECK;
// use /dev/urandom as a source of random numbers
void setSoftwareRandom(void);
@@ -1748,43 +1765,43 @@ void setSoftwareRandom(void);
void setHardwareRandom(void);
// open /dev/urandom in libsheepy
-int randomUrandomOpen(void);
+int randomUrandomOpen(void) MUST_CHECK;
// close /dev/urandom in libsheepy
void randomUrandomClose(void);
// return random 64 bit unsigned integer
-uint64_t randomWord(void);
+uint64_t randomWord(void) MUST_CHECK;
// return random 64 bit unsigned integer from the cpu
-uint64_t randomWordFromHW(void);
+uint64_t randomWordFromHW(void) MUST_CHECK;
// return a random value between 0 and range 0<=value<range
-uint64_t randomChoice(uint64_t range);
+uint64_t randomChoice(uint64_t range) MUST_CHECK;
// generate random string
-char *randomS(uint64_t length);
-char *bRandomS(char *dst, size_t length);
+char *randomS(uint64_t length) MUST_CHECK;
+char *bRandomS(char *dst, size_t length) MUST_CHECK;
// generate random alpha numerical string
-char *randomAlphaNumS(uint64_t length);
-char *bRandomAlphaNumS(char *dst, size_t dstSize);
+char *randomAlphaNumS(uint64_t length) MUST_CHECK;
+char *bRandomAlphaNumS(char *dst, size_t dstSize) MUST_CHECK;
// read user input (one line) as a string
-char *readS(void);
-char *bLReadS(char *dst, size_t dstSize);
+char *readS(void) MUST_CHECK;
+char *bLReadS(char *dst, size_t dstSize) MUST_CHECK;
// read hidden password as a string - like getpass
-char *readPasswordS(void);
+char *readPasswordS(void) MUST_CHECK;
// write zero to all bytes in string with memset, for clearing password buffers
-bool zeroS(char *string);
+bool zeroS(char *string) MUST_CHECK;
// write zero to all bytes in buffer with memset
-bool zeroBuf(void *buf, size_t len);
+bool zeroBuf(void *buf, size_t len) MUST_CHECK;
// allocate and copy buffer
-void *memdup(const void *buf, size_t size);
+void *memdup(const void *buf, size_t size) MUST_CHECK;
// wait until press the enter key
void readEnter(void);
@@ -1792,7 +1809,7 @@ void readEnter(void);
// TODO writeLine - copy cg_c code
// readLine
-char *readLine(FILE *fp);
+char *readLine(FILE *fp) MUST_CHECK;
// convert char to string by declaring string dst with c in it
#define charToS(dst, c) \
@@ -1803,7 +1820,7 @@ void freeManySF(char *paramType, ...);
#define freeManyS(...) freeManySF("", __VA_ARGS__, NULL)
// duplicate string
-char *dupS(const char *string);
+char *dupS(const char *string) MUST_CHECK;
// print like printf, the formating can be NULL
void shPrintfS(const char *fmt, ...);
@@ -1818,218 +1835,218 @@ void logNFree(char *s);
void loghex(const void *buf, size_t len);
// create a string with bytes in buf converted to hex strings: 0xff,
-char *toHexS(const void *buf, size_t len);
+char *toHexS(const void *buf, size_t len) MUST_CHECK;
// create a string with bytes in buf converted to hex strings separated by separator: 0xffSEP
-char *toHexSepS(const void *buf, size_t len, const char *separator);
+char *toHexSepS(const void *buf, size_t len, const char *separator) MUST_CHECK;
// create a string with bytes in buf converted to hex strings separated by separator and with head string in front of earch byte: HEADffSEP
-char *toHexHeadSepS(const void *buf, size_t len, const char *head, const char *separator);
+char *toHexHeadSepS(const void *buf, size_t len, const char *head, const char *separator) MUST_CHECK;
// print new line
#define put puts("");
// copy src to dst
-char *strCpy(char *dst, const char *src);
+char *strCpy(char *restrict dst, const char *restrict src) MUST_CHECK;
// copy string to buffer given string length: strNCpy(buffer, string, lenS(string));
// null safe version of strncpy
-char *strNCpy(char *dst, const char *src, size_t srcSize);
-char *strLCpy(char *dst, size_t dstSize, const char *src);
+char *strNCpy(char *restrict dst, const char *restrict src, size_t srcSize) MUST_CHECK;
+char *strLCpy(char *restrict dst, size_t dstSize, const char *restrict src) MUST_CHECK;
// concatenate src to dst
-char *strCat(char *dst, const char *src);
-char *strNCat(char *dst, const char *src, size_t srcLen);
-char *strLCat(char *dst, size_t dstSize, const char *src);
-char *strLNCat(char *dst, size_t dstSize, const char *src, size_t srcLen);
+char *strCat(char *restrict dst, const char *restrict src) MUST_CHECK;
+char *strNCat(char *restrict dst, const char *restrict src, size_t srcLen) MUST_CHECK;
+char *strLCat(char *restrict dst, size_t dstSize, const char *restrict src) MUST_CHECK;
+char *strLNCat(char *restrict dst, size_t dstSize, const char *restrict src, size_t srcLen) MUST_CHECK;
// cat: f("qwd ", str," werr ", str2)
-char *catSF(const char *paramType, ...);
+char *catSF(const char *paramType, ...) MUST_CHECK;
#define catS(...) catSF("", __VA_ARGS__, NULL)
// cat and copy result to dst buffer
-char *iCatSF(char *dst, const char *paramType, ...);
+char *iCatSF(char *dst, const char *paramType, ...) MUST_CHECK;
#define iCatS(dst, ...) iCatSF(dst, "", __VA_ARGS__, NULL)
#define bCatS iCatS
-char *bLCatSF(char *dst, size_t dstSize, const char *paramType, ...);
+char *bLCatSF(char *dst, size_t dstSize, const char *paramType, ...) MUST_CHECK;
#define bLCatS(dst, dstSize, ...) bLCatSF(dst, dstSize, "", __VA_ARGS__, NULL)
// allocate and format string using asprintf
-char *formatS(const char *fmt, ...);
+char *formatS(const char *fmt, ...) MUST_CHECK;
/** format and store in string: bFormatS(string, "Value %d", i); */
-char *bFormatS(char *string, const char *fmt, ...);
+char *bFormatS(char *string, const char *fmt, ...) MUST_CHECK;
/** format and store in string: bLFormatS(string, sizeof(string), "Value %d", i); */
-char *bLFormatS(char *string, size_t stringSize, const char *fmt, ...);
+char *bLFormatS(char *string, size_t stringSize, const char *fmt, ...) MUST_CHECK;
// append strings
-char *appendS(const char *string1, const char *string2);
-char *appendCharS(const char *string1, char c);
-char *appendSChar(char c, const char *string2);
-char *iAppendS(char **string1, const char *string2);
-char *iAppendCharS(char **string1, char c);
-char *iAppendNFreeS(char **string1, char *string2);
-char *iAppendManySF(char **string, const char *paramType, ...);
+char *appendS(const char *string1, const char *string2) MUST_CHECK;
+char *appendCharS(const char *string1, char c) MUST_CHECK;
+char *appendSChar(char c, const char *string2) MUST_CHECK;
+char *iAppendS(char **string1, const char *string2) MUST_CHECK;
+char *iAppendCharS(char **string1, char c) MUST_CHECK;
+char *iAppendNFreeS(char **string1, char *string2) MUST_CHECK;
+char *iAppendManySF(char **string, const char *paramType, ...) MUST_CHECK;
#define iAppendManyS(s, s1, ...) iAppendManySF(s, s1, __VA_ARGS__, NULL)
-char *bAppendManySF(char *string, const char *paramType, ...);
+char *bAppendManySF(char *string, const char *paramType, ...) MUST_CHECK;
#define bAppendManyS(s, s1, ...) bAppendManySF(s, s1, __VA_ARGS__, NULL)
-char *bLAppendManySF(char *string, size_t stringSize, const char *paramType, ...);
+char *bLAppendManySF(char *string, size_t stringSize, const char *paramType, ...) MUST_CHECK;
#define bLAppendManyS(s, sSize, s1, ...) bLAppendManySF(s, sSize, s1, __VA_ARGS__, NULL)
// prepend string
-char *prependS(const char *string1, const char *string2);
-char *prependCharS(const char *string1, char c);
-char *prependSChar(char c, const char *string2);
-char *iPrependS(char **string1, const char *string2);
-char *iPrependCharS(char **string1, char c);
-char *iPrependNFreeS(char **string1, char *string2);
-char *bPrependS(char *string1, const char *string2);
-char *bLPrependS(char *string1, size_t string1Size, const char *string2);
+char *prependS(const char *string1, const char *string2) MUST_CHECK;
+char *prependCharS(const char *string1, char c) MUST_CHECK;
+char *prependSChar(char c, const char *string2) MUST_CHECK;
+char *iPrependS(char **string1, const char *string2) MUST_CHECK;
+char *iPrependCharS(char **string1, char c) MUST_CHECK;
+char *iPrependNFreeS(char **string1, char *string2) MUST_CHECK;
+char *bPrependS(char *string1, const char *string2) MUST_CHECK;
+char *bLPrependS(char *string1, size_t string1Size, const char *string2) MUST_CHECK;
// string replace
-char *replaceS(const char *s, const char *olds, const char *news, size_t max);
-char *replaceCharSS(const char *s, char olds, const char *news, size_t max);
-char *replaceSCharS(const char *s, const char *olds, char news, size_t max);
-char *replaceCharCharS(const char *s, char olds, char news, size_t max);
+char *replaceS(const char *s, const char *olds, const char *news, size_t max) MUST_CHECK;
+char *replaceCharSS(const char *s, char olds, const char *news, size_t max) MUST_CHECK;
+char *replaceSCharS(const char *s, const char *olds, char news, size_t max) MUST_CHECK;
+char *replaceCharCharS(const char *s, char olds, char news, size_t max) MUST_CHECK;
#define replaceS_max(s,olds,news) replaceS(s,olds,news, 0)
#define replaceSMax replaceS_max
-char* iReplaceS(char **s, const char *olds, const char *news, size_t max);
-char* iReplaceCharSS(char **s, char olds, const char *news, size_t max);
-char* iReplaceSCharS(char **s, const char *olds, char news, size_t max);
-char* iReplaceCharCharS(char **s, char olds, char news, size_t max);
+char* iReplaceS(char **s, const char *olds, const char *news, size_t max) MUST_CHECK;
+char* iReplaceCharSS(char **s, char olds, const char *news, size_t max) MUST_CHECK;
+char* iReplaceSCharS(char **s, const char *olds, char news, size_t max) MUST_CHECK;
+char* iReplaceCharCharS(char **s, char olds, char news, size_t max) MUST_CHECK;
#define iReplaceS_max(s,olds,news) iReplaceS(s,olds,news, 0)
#define iReplaceSMax iReplaceS_max
-char* bReplaceS(char *s, const char *olds, const char *news, size_t max);
+char* bReplaceS(char *s, const char *olds, const char *news, size_t max) MUST_CHECK;
#define bReplaceS_max(s,olds,news) bReplaceS(s,olds,news, 0)
#define bReplaceSMax bReplaceS_max
-char* bLReplaceS(char *s, size_t sSize, const char *olds, const char *news, size_t max);
+char* bLReplaceS(char *s, size_t sSize, const char *olds, const char *news, size_t max) MUST_CHECK;
#define bLReplaceS_max(s,sSize,olds,news) bLReplaceS(s,sSize,olds,news, 0)
#define bLReplaceSMax bLReplaceS_max
// string replace many olds with news (s, olds1, news1, olds2, news2,...)
-char *replaceManySF(const char *paramType, ...);
+char *replaceManySF(const char *paramType, ...) MUST_CHECK;
#define replaceManyS(s, ...) replaceManySF(s, __VA_ARGS__, NULL)
-char *iReplaceManySF(char **string, char *paramType, ...);
+char *iReplaceManySF(char **string, char *paramType, ...) MUST_CHECK;
#define iReplaceManyS(s, olds, ...) iReplaceManySF(s, olds, __VA_ARGS__, NULL)
-char *bReplaceManySF(char *s, char *paramType, ...);
+char *bReplaceManySF(char *s, char *paramType, ...) MUST_CHECK;
#define bReplaceManyS(s, olds, ...) bReplaceManySF(s, olds, __VA_ARGS__, NULL)
-char *bLReplaceManySF(char *s, size_t sSize, char *paramType, ...);
+char *bLReplaceManySF(char *s, size_t sSize, char *paramType, ...) MUST_CHECK;
#define bLReplaceManyS(s, sSize, olds, ...) bLReplaceManySF(s, sSize, olds, __VA_ARGS__, NULL)
// ignore case string replace
-char *icReplaceS(const char *s, const char *olds, const char *news, size_t max);
-char *icReplaceCharSS(const char *s, char olds, const char *news, size_t max);
-char *icReplaceSCharS(const char *s, const char *olds, char news, size_t max);
-char *icReplaceCharCharS(const char *s, char olds, char news, size_t max);
+char *icReplaceS(const char *s, const char *olds, const char *news, size_t max) MUST_CHECK;
+char *icReplaceCharSS(const char *s, char olds, const char *news, size_t max) MUST_CHECK;
+char *icReplaceSCharS(const char *s, const char *olds, char news, size_t max) MUST_CHECK;
+char *icReplaceCharCharS(const char *s, char olds, char news, size_t max) MUST_CHECK;
#define icReplaceS_max(s,olds,news) icReplaceS(s,olds,news, 0)
#define icReplaceSMax icReplaceS_max
-char* iicReplaceS(char **s, const char *olds, const char *news, size_t max);
-char* iicReplaceCharSS(char **s, char olds, const char *news, size_t max);
-char* iicReplaceSCharS(char **s, const char *olds, char news, size_t max);
-char* iicReplaceCharCharS(char **s, char olds, char news, size_t max);
+char* iicReplaceS(char **s, const char *olds, const char *news, size_t max) MUST_CHECK;
+char* iicReplaceCharSS(char **s, char olds, const char *news, size_t max) MUST_CHECK;
+char* iicReplaceSCharS(char **s, const char *olds, char news, size_t max) MUST_CHECK;
+char* iicReplaceCharCharS(char **s, char olds, char news, size_t max) MUST_CHECK;
#define iicReplaceS_max(s,olds,news) iicReplaceS(s,olds,news, 0)
#define iicReplaceSMax iicReplaceS_max
-char* bicReplaceS(char *s, const char *olds, const char *news, size_t max);
+char* bicReplaceS(char *s, const char *olds, const char *news, size_t max) MUST_CHECK;
#define bicReplaceS_max(s,olds,news) bicReplaceS(s,olds,news, 0)
#define bicReplaceSMax bicReplaceS_max
-char* bLicReplaceS(char *s, size_t sSize, const char *olds, const char *news, size_t max);
+char* bLicReplaceS(char *s, size_t sSize, const char *olds, const char *news, size_t max) MUST_CHECK;
#define bLicReplaceS_max(s,sSize,olds,news) bLicReplaceS(s,sSize,olds,news, 0)
#define bLicReplaceSMax bLicReplaceS_max
// string replace many olds with news (s, olds1, news1, olds2, news2,...)
-char *icReplaceManySF(const char *paramType, ...);
+char *icReplaceManySF(const char *paramType, ...) MUST_CHECK;
#define icReplaceManyS(s, ...) icReplaceManySF(s, __VA_ARGS__, NULL)
-char *iicReplaceManySF(char **string, char *paramType, ...);
+char *iicReplaceManySF(char **string, char *paramType, ...) MUST_CHECK;
#define iicReplaceManyS(s, olds, ...) iicReplaceManySF(s, olds, __VA_ARGS__, NULL)
-char *bicReplaceManySF(char *s, char *paramType, ...);
+char *bicReplaceManySF(char *s, char *paramType, ...) MUST_CHECK;
#define bicReplaceManyS(s, olds, ...) bicReplaceManySF(s, olds, __VA_ARGS__, NULL)
-char *bLicReplaceManySF(char *s, size_t sSize, char *paramType, ...);
+char *bLicReplaceManySF(char *s, size_t sSize, char *paramType, ...) MUST_CHECK;
#define bLicReplaceManyS(s, sSize, olds, ...) bLicReplaceManySF(s, sSize, olds, __VA_ARGS__, NULL)
// string equal (compare content)
-bool eqS(const char *string1, const char *string2);
+bool eqS(const char *string1, const char *string2) MUST_CHECK;
#define strEq eqS
-bool eqCharS(char c, const char *string2);
-bool eqSChar(const char *string1, char c);
+bool eqCharS(char c, const char *string2) MUST_CHECK;
+bool eqSChar(const char *string1, char c) MUST_CHECK;
// string equal at index (compare content)
-bool eqIS(const char *string1, const char *string2, int64_t index);
+bool eqIS(const char *string1, const char *string2, int64_t index) MUST_CHECK;
#define strIEq eqIS
-bool eqICharS(const char *string1, char c, int64_t index);
+bool eqICharS(const char *string1, char c, int64_t index) MUST_CHECK;
// look for string2 at string1 start
-bool startsWithS(const char *string1, const char *string2);
-bool startsWithCharS(const char *string1, char c);
+bool startsWithS(const char *string1, const char *string2) MUST_CHECK;
+bool startsWithCharS(const char *string1, char c) MUST_CHECK;
// look for string2 at string1 end
-bool endsWithS(const char *string1, const char *string2);
-bool endsWithCharS(const char *string1, char c);
+bool endsWithS(const char *string1, const char *string2) MUST_CHECK;
+bool endsWithCharS(const char *string1, char c) MUST_CHECK;
// count number of (non-overlapping) occurrences of a substring
-ssize_t countS(const char *s, const char *needle);
-ssize_t countCharS(const char *s, char c);
+ssize_t countS(const char *s, const char *needle) MUST_CHECK;
+ssize_t countCharS(const char *s, char c) MUST_CHECK;
// ignore case string equal (compare content)
-bool icEqS(const char *string1, const char *string2);
-bool icEqCharS(char c, const char *string2);
-bool icEqSChar(const char *string1, char c);
+bool icEqS(const char *string1, const char *string2) MUST_CHECK;
+bool icEqCharS(char c, const char *string2) MUST_CHECK;
+bool icEqSChar(const char *string1, char c) MUST_CHECK;
// ignore case string equal at index (compare content)
-bool icEqIS(const char *string1, const char *string2, int64_t index);
-bool icEqICharS(const char *string1, char c, int64_t index);
+bool icEqIS(const char *string1, const char *string2, int64_t index) MUST_CHECK;
+bool icEqICharS(const char *string1, char c, int64_t index) MUST_CHECK;
// ignore case and look for string2 at string1 start
-bool icStartsWithS(const char *string1, const char *string2);
-bool icStartsWithCharS(const char *string1, char c);
+bool icStartsWithS(const char *string1, const char *string2) MUST_CHECK;
+bool icStartsWithCharS(const char *string1, char c) MUST_CHECK;
// ignore case look for string2 at string1 end
-bool icEndsWithS(const char *string1, const char *string2);
-bool icEndsWithCharS(const char *string1, char c);
+bool icEndsWithS(const char *string1, const char *string2) MUST_CHECK;
+bool icEndsWithCharS(const char *string1, char c) MUST_CHECK;
// ignore case and count number of (non-overlapping) occurrences of a substring
-ssize_t icCountS(const char *s, const char *needle);
-ssize_t icCountCharS(const char *s, char c);
+ssize_t icCountS(const char *s, const char *needle) MUST_CHECK;
+ssize_t icCountCharS(const char *s, char c) MUST_CHECK;
// has terminal control char (for example colors)
-bool hasCtrlChar(const char *string);
+bool hasCtrlChar(const char *string) MUST_CHECK;
// remove terminal control char from string
-char *stripCtrlS(const char *string);
-char *iStripCtrlS(char **string);
-char *bStripCtrlS(char *string);
+char *stripCtrlS(const char *string) MUST_CHECK;
+char *iStripCtrlS(char **string) MUST_CHECK;
+char *bStripCtrlS(char *string) MUST_CHECK;
// true when string is a number (integer or float)
-bool isNumber(const char *string);
+bool isNumber(const char *string) MUST_CHECK;
// true when string is an integer
-bool isInt(const char *string);
+bool isInt(const char *string) MUST_CHECK;
// parseInt
-int64_t parseInt(const char *string);
-int64_t parseIntChar(char c);
-int64_t parseI64(const char *string);
-int64_t parseI64Char(char c);
+int64_t parseInt(const char *string) MUST_CHECK;
+int64_t parseIntChar(char c) MUST_CHECK;
+int64_t parseI64(const char *string) MUST_CHECK;
+int64_t parseI64Char(char c) MUST_CHECK;
// parseDouble
-double parseDouble(const char *string);
-double parseDoubleChar(char c);
+double parseDouble(const char *string) MUST_CHECK;
+double parseDoubleChar(char c) MUST_CHECK;
// parse hexadecimal string: 0xff
-uint64_t parseHex(const char *string);
+uint64_t parseHex(const char *string) MUST_CHECK;
// TODO parseHexChar
// convert int to string
-char *intToS(int64_t n);
-char *bIntToS(char *s, int64_t n);
+char *intToS(int64_t n) MUST_CHECK;
+char *bIntToS(char *s, int64_t n) MUST_CHECK;
// convert double to string
-char *doubleToS(double n);
-char *bDoubleToS(char *s, double n);
+char *doubleToS(double n) MUST_CHECK;
+char *bDoubleToS(char *s, double n) MUST_CHECK;
// length
-size_t lenS(const char *string);
+size_t lenS(const char *string) MUST_CHECK;
// string buffer size: strlen+1
-size_t sizeS(const char *string);
+size_t sizeS(const char *string) MUST_CHECK;
/**
* upper case and store the result in c and return the result
@@ -2037,9 +2054,9 @@ size_t sizeS(const char *string);
#define toUpper(c) ((c) = toupper(c), c)
// duplicate and upper case
-char *upperS(const char *string);
-char *iUpperS(char **string);
-char *bUpperS(char *string);
+char *upperS(const char *string) MUST_CHECK;
+char *iUpperS(char **string) MUST_CHECK;
+char *bUpperS(char *string) MUST_CHECK;
/**
* lower case and store the result in c and return the result
@@ -2047,172 +2064,172 @@ char *bUpperS(char *string);
#define toLower(c) ((c) = tolower(c), c)
// duplicate and lower case
-char *lowerS(const char *string);
-char *iLowerS(char **string);
-char *bLowerS(char *string);
+char *lowerS(const char *string) MUST_CHECK;
+char *iLowerS(char **string) MUST_CHECK;
+char *bLowerS(char *string) MUST_CHECK;
// duplicate and trim
-char *trimS(const char *string);
-char *iTrimS(char **string);
-char *bTrimS(char *string);
-char *lTrimS(const char *string);
-char *iLTrimS(char **string);
-char *bLTrimS(char *string);
-char *rTrimS(const char *string);
-char *iRTrimS(char **string);
-char *bRTrimS(char *string);
+char *trimS(const char *string) MUST_CHECK;
+char *iTrimS(char **string) MUST_CHECK;
+char *bTrimS(char *string) MUST_CHECK;
+char *lTrimS(const char *string) MUST_CHECK;
+char *iLTrimS(char **string) MUST_CHECK;
+char *bLTrimS(char *string) MUST_CHECK;
+char *rTrimS(const char *string) MUST_CHECK;
+char *iRTrimS(char **string) MUST_CHECK;
+char *bRTrimS(char *string) MUST_CHECK;
// remove successive repetitions of char c
-char *uniqS(const char *string, char c);
-char *iUniqS(char **string, char c);
-char *bUniqS(char *string, char c);
+char *uniqS(const char *string, char c) MUST_CHECK;
+char *iUniqS(char **string, char c) MUST_CHECK;
+char *bUniqS(char *string, char c) MUST_CHECK;
#define uniqSlash(s) uniqS(s, '/')
#define iUniqSlash(s) iUniqS(&(s), '/')
#define bUniqSlash(s) bUniqS(s, '/')
// ignore case and remove successive repetitions of char c
-char *icUniqS(const char *string, char c);
-char *iicUniqS(char **string, char c);
-char *bicUniqS(char *string, char c);
+char *icUniqS(const char *string, char c) MUST_CHECK;
+char *iicUniqS(char **string, char c) MUST_CHECK;
+char *bicUniqS(char *string, char c) MUST_CHECK;
// repeat string count times
-char *repeatS(const char *string, size_t count);
-char *iRepeatS(char **string, size_t count);
-char *bRepeatS(char *dest, const char *string, size_t count);
-char *bLRepeatS(char *dest, size_t destSize, const char *string, size_t count);
-char *repeatCharS(char c, size_t count);
-char *bRepeatCharS(char *dest, char c, size_t count);
-char *bLRepeatCharS(char *dest, size_t destSize, char c, size_t count);
+char *repeatS(const char *string, size_t count) MUST_CHECK;
+char *iRepeatS(char **string, size_t count) MUST_CHECK;
+char *bRepeatS(char *dest, const char *string, size_t count) MUST_CHECK;
+char *bLRepeatS(char *dest, size_t destSize, const char *string, size_t count) MUST_CHECK;
+char *repeatCharS(char c, size_t count) MUST_CHECK;
+char *bRepeatCharS(char *dest, char c, size_t count) MUST_CHECK;
+char *bLRepeatCharS(char *dest, size_t destSize, char c, size_t count) MUST_CHECK;
// length of string repeated count times
-ssize_t repeatLenS(const char *string, size_t count);
+ssize_t repeatLenS(const char *string, size_t count) MUST_CHECK;
// ellipsisStart string
-char *ellipsisStartS(const char *string, size_t targetLength, const char *ellipsisString);
-char *iEllipsisStartS(char **string, size_t targetLength, const char *ellipsisString);
-char *bEllipsisStartS(char *dest, const char *string, size_t targetLength, const char *ellipsisString);
-char *bLEllipsisStartS(char *dest, size_t destSize, const char *string, size_t targetLength, const char *ellipsisString);
-char *ellipsisStartCharS(const char *string, size_t targetLength, char ellipsisChar);
-char *iEllipsisStartCharS(char **string, size_t targetLength, char ellipsisChar);
-char *bEllipsisStartCharS(char *dest, const char *string, size_t targetLength, char ellipsisChar);
-char *bLEllipsisStartCharS(char *dest, size_t destSize, const char *string, size_t targetLength, char ellipsisChar);
+char *ellipsisStartS(const char *string, size_t targetLength, const char *ellipsisString) MUST_CHECK;
+char *iEllipsisStartS(char **string, size_t targetLength, const char *ellipsisString) MUST_CHECK;
+char *bEllipsisStartS(char *dest, const char *string, size_t targetLength, const char *ellipsisString) MUST_CHECK;
+char *bLEllipsisStartS(char *dest, size_t destSize, const char *string, size_t targetLength, const char *ellipsisString) MUST_CHECK;
+char *ellipsisStartCharS(const char *string, size_t targetLength, char ellipsisChar) MUST_CHECK;
+char *iEllipsisStartCharS(char **string, size_t targetLength, char ellipsisChar) MUST_CHECK;
+char *bEllipsisStartCharS(char *dest, const char *string, size_t targetLength, char ellipsisChar) MUST_CHECK;
+char *bLEllipsisStartCharS(char *dest, size_t destSize, const char *string, size_t targetLength, char ellipsisChar) MUST_CHECK;
// length of string after ellipsis
-ssize_t ellipsisLenS(const char *string, size_t targetLength, const char *ellipsisString);
+ssize_t ellipsisLenS(const char *string, size_t targetLength, const char *ellipsisString) MUST_CHECK;
// ellipsisEnd string
-char *ellipsisEndS(const char *string, size_t targetLength, const char *ellipsisString);
-char *iEllipsisEndS(char **string, size_t targetLength, const char *ellipsisString);
-char *bEllipsisEndS(char *dest, const char *string, size_t targetLength, const char *ellipsisString);
-char *bLEllipsisEndS(char *dest, size_t destSize, const char *string, size_t targetLength, const char *ellipsisString);
-char *ellipsisEndCharS(const char *string, size_t targetLength, char ellipsisChar);
-char *iEllipsisEndCharS(char **string, size_t targetLength, char ellipsisChar);
-char *bEllipsisEndCharS(char *dest, const char *string, size_t targetLength, char ellipsisChar);
-char *bLEllipsisEndCharS(char *dest, size_t destSize, const char *string, size_t targetLength, char ellipsisChar);
+char *ellipsisEndS(const char *string, size_t targetLength, const char *ellipsisString) MUST_CHECK;
+char *iEllipsisEndS(char **string, size_t targetLength, const char *ellipsisString) MUST_CHECK;
+char *bEllipsisEndS(char *dest, const char *string, size_t targetLength, const char *ellipsisString) MUST_CHECK;
+char *bLEllipsisEndS(char *dest, size_t destSize, const char *string, size_t targetLength, const char *ellipsisString) MUST_CHECK;
+char *ellipsisEndCharS(const char *string, size_t targetLength, char ellipsisChar) MUST_CHECK;
+char *iEllipsisEndCharS(char **string, size_t targetLength, char ellipsisChar) MUST_CHECK;
+char *bEllipsisEndCharS(char *dest, const char *string, size_t targetLength, char ellipsisChar) MUST_CHECK;
+char *bLEllipsisEndCharS(char *dest, size_t destSize, const char *string, size_t targetLength, char ellipsisChar) MUST_CHECK;
// padStart string
-char *padStartS(const char *string, size_t targetLength, const char *padString);
-char *iPadStartS(char **string, size_t targetLength, const char *padString);
-char *bPadStartS(char *dest, const char *string, size_t targetLength, const char *padString);
-char *bLPadStartS(char *dest, size_t destSize, const char *string, size_t targetLength, const char *padString);
-char *padStartCharS(const char *string, size_t targetLength, char padChar);
-char *iPadStartCharS(char **string, size_t targetLength, char padChar);
-char *bPadStartCharS(char *dest, const char *string, size_t targetLength, char padChar);
-char *bLPadStartCharS(char *dest, size_t destSize, const char *string, size_t targetLength, char padChar);
+char *padStartS(const char *string, size_t targetLength, const char *padString) MUST_CHECK;
+char *iPadStartS(char **string, size_t targetLength, const char *padString) MUST_CHECK;
+char *bPadStartS(char *dest, const char *string, size_t targetLength, const char *padString) MUST_CHECK;
+char *bLPadStartS(char *dest, size_t destSize, const char *string, size_t targetLength, const char *padString) MUST_CHECK;
+char *padStartCharS(const char *string, size_t targetLength, char padChar) MUST_CHECK;
+char *iPadStartCharS(char **string, size_t targetLength, char padChar) MUST_CHECK;
+char *bPadStartCharS(char *dest, const char *string, size_t targetLength, char padChar) MUST_CHECK;
+char *bLPadStartCharS(char *dest, size_t destSize, const char *string, size_t targetLength, char padChar) MUST_CHECK;
// length of string after padStart
-ssize_t padStartLenS(const char *string, size_t targetLength, const char *padString);
+ssize_t padStartLenS(const char *string, size_t targetLength, const char *padString) MUST_CHECK;
// padEnd string
-char *padEndS(const char *string, size_t targetLength, const char *padString);
-char *iPadEndS(char **string, size_t targetLength, const char *padString);
-char *bPadEndS(char *dest, const char *string, size_t targetLength, const char *padString);
-char *bLPadEndS(char *dest, size_t destSize, const char *string, size_t targetLength, const char *padString);
-char *padEndCharS(const char *string, size_t targetLength, char padChar);
-char *iPadEndCharS(char **string, size_t targetLength, char padChar);
-char *bPadEndCharS(char *dest, const char *string, size_t targetLength, char padChar);
-char *bLPadEndCharS(char *dest, size_t destSize, const char *string, size_t targetLength, char padChar);
+char *padEndS(const char *string, size_t targetLength, const char *padString) MUST_CHECK;
+char *iPadEndS(char **string, size_t targetLength, const char *padString) MUST_CHECK;
+char *bPadEndS(char *dest, const char *string, size_t targetLength, const char *padString) MUST_CHECK;
+char *bLPadEndS(char *dest, size_t destSize, const char *string, size_t targetLength, const char *padString) MUST_CHECK;
+char *padEndCharS(const char *string, size_t targetLength, char padChar) MUST_CHECK;
+char *iPadEndCharS(char **string, size_t targetLength, char padChar) MUST_CHECK;
+char *bPadEndCharS(char *dest, const char *string, size_t targetLength, char padChar) MUST_CHECK;
+char *bLPadEndCharS(char *dest, size_t destSize, const char *string, size_t targetLength, char padChar) MUST_CHECK;
// length of string after padEnd
-ssize_t padEndLenS(const char *string, size_t targetLength, const char *padString);
+ssize_t padEndLenS(const char *string, size_t targetLength, const char *padString) MUST_CHECK;
// get char at python index
-char getS(const char *string, int64_t index);
+char getS(const char *string, int64_t index) MUST_CHECK;
// set char at python index
-char *setS(char *string, int64_t index, char c);
+char *setS(char *string, int64_t index, char c) MUST_CHECK;
// swap characters in a string
-char *swapS(char *string, int64_t index1, int64_t index2);
-char *iSwapS(char **string, int64_t index1, int64_t index2);
-char *bSwapS(char *string, int64_t index1, int64_t index2);
-char *bLSwapS(char *string, size_t size, int64_t index1, int64_t index2);
+char *swapS(char *string, int64_t index1, int64_t index2) MUST_CHECK;
+char *iSwapS(char **string, int64_t index1, int64_t index2) MUST_CHECK;
+char *bSwapS(char *string, int64_t index1, int64_t index2) MUST_CHECK;
+char *bLSwapS(char *string, size_t size, int64_t index1, int64_t index2) MUST_CHECK;
// slice string
// function to slice parts of a string [1:10] - python style indexes 0..len-1 -1..-len+1
-char *sliceS(const char *string, int64_t start, int64_t end);
-char *iSliceS(char **string, int64_t start, int64_t end);
-char *bSliceS(char *string, int64_t start, int64_t end);
-char *bLSliceS(char *string, size_t stringSize, int64_t start, int64_t end);
+char *sliceS(const char *string, int64_t start, int64_t end) MUST_CHECK;
+char *iSliceS(char **string, int64_t start, int64_t end) MUST_CHECK;
+char *bSliceS(char *string, int64_t start, int64_t end) MUST_CHECK;
+char *bLSliceS(char *string, size_t stringSize, int64_t start, int64_t end) MUST_CHECK;
// crop string (slice+del)
-char *cropS(char *string, int64_t start, int64_t end);
-char *iCropS(char **string, int64_t start, int64_t end);
-char cropElemS(char *string, int64_t index);
-char iCropElemS(char **string, int64_t index);
+char *cropS(char *string, int64_t start, int64_t end) MUST_CHECK;
+char *iCropS(char **string, int64_t start, int64_t end) MUST_CHECK;
+char cropElemS(char *string, int64_t index) MUST_CHECK;
+char iCropElemS(char **string, int64_t index) MUST_CHECK;
// insert string in string
-char *insertS(const char *string, int64_t index, const char *toInsert);
-char *insertNFreeS(const char *string, int64_t index, char *toInsert);
-char *iInsertS(char **string, int64_t index, const char *toInsert);
-char *iInsertNFreeS(char **string, int64_t index, char *toInsert);
-char *bInsertS(char *string, int64_t index, const char *toInsert);
-char *bLInsertS(char *string, size_t stringSize, int64_t index, const char *toInsert);
+char *insertS(const char *string, int64_t index, const char *toInsert) MUST_CHECK;
+char *insertNFreeS(const char *string, int64_t index, char *toInsert) MUST_CHECK;
+char *iInsertS(char **string, int64_t index, const char *toInsert) MUST_CHECK;
+char *iInsertNFreeS(char **string, int64_t index, char *toInsert) MUST_CHECK;
+char *bInsertS(char *string, int64_t index, const char *toInsert) MUST_CHECK;
+char *bLInsertS(char *string, size_t stringSize, int64_t index, const char *toInsert) MUST_CHECK;
// inject a char in string
-char *injectS(const char *string, int64_t index, char toInject);
-char *iInjectS(char **string, int64_t index, char toInject);
-char *bInjectS(char *string, int64_t index, char toInject);
-char *bLInjectS(char *string, size_t stringSize, int64_t index, char toInject);
+char *injectS(const char *string, int64_t index, char toInject) MUST_CHECK;
+char *iInjectS(char **string, int64_t index, char toInject) MUST_CHECK;
+char *bInjectS(char *string, int64_t index, char toInject) MUST_CHECK;
+char *bLInjectS(char *string, size_t stringSize, int64_t index, char toInject) MUST_CHECK;
// del string
// function to delete parts of a string [1:10] - python style indexes 0..len-1 -1..-len+1
-char *delS(const char *string, int64_t start, int64_t end);
-char *iDelS(char **string, int64_t start, int64_t end);
-char *bDelS(char *string, int64_t start, int64_t end);
-char *bLDelS(char *string, size_t stringSize, int64_t start, int64_t end);
+char *delS(const char *string, int64_t start, int64_t end) MUST_CHECK;
+char *iDelS(char **string, int64_t start, int64_t end) MUST_CHECK;
+char *bDelS(char *string, int64_t start, int64_t end) MUST_CHECK;
+char *bLDelS(char *string, size_t stringSize, int64_t start, int64_t end) MUST_CHECK;
// del a character in string
-char *delElemS(const char *string, int64_t index);
-char *iDelElemS(char **string, int64_t index);
-char *bDelElemS(char *string, int64_t index);
-char *bLDelElemS(char *string, size_t stringSize, int64_t index);
+char *delElemS(const char *string, int64_t index) MUST_CHECK;
+char *iDelElemS(char **string, int64_t index) MUST_CHECK;
+char *bDelElemS(char *string, int64_t index) MUST_CHECK;
+char *bLDelElemS(char *string, size_t stringSize, int64_t index) MUST_CHECK;
// find substring
-char *findS(const char *string, const char *needle);
-char *findCharS(const char *string, char c);
-ssize_t indexOfS(const char *string, const char *needle);
-ssize_t indexOfCharS(const char *string, char c);
+char *findS(const char *string, const char *needle) MUST_CHECK;
+char *findCharS(const char *string, char c) MUST_CHECK;
+ssize_t indexOfS(const char *string, const char *needle) MUST_CHECK;
+ssize_t indexOfCharS(const char *string, char c) MUST_CHECK;
// true when needle is found
-bool hasS(const char *string, const char *needle);
-bool hasCharS(const char *string, char c);
+bool hasS(const char *string, const char *needle) MUST_CHECK;
+bool hasCharS(const char *string, char c) MUST_CHECK;
// ignore case find substring
-char *icFindS(const char *string, const char *needle);
-char *icFindCharS(const char *string, char c);
-ssize_t icIndexOfS(const char *string, const char *needle);
-ssize_t icIndexOfCharS(const char *string, char c);
+char *icFindS(const char *string, const char *needle) MUST_CHECK;
+char *icFindCharS(const char *string, char c) MUST_CHECK;
+ssize_t icIndexOfS(const char *string, const char *needle) MUST_CHECK;
+ssize_t icIndexOfCharS(const char *string, char c) MUST_CHECK;
// ignore case, true when needle is found
-bool icHasS(const char *string, const char *needle);
-bool icHasCharS(const char *string, char c);
+bool icHasS(const char *string, const char *needle) MUST_CHECK;
+bool icHasCharS(const char *string, char c) MUST_CHECK;
// parse s string with delim - work like strtok_r from stdlib
-char *tokS(const char *s, const char *delim, char **saveptr);
+char *tokS(char *s, const char *delim, char **saveptr) MUST_CHECK;
// ignore case and parse s string with delim - work like strtok_r from stdlib
-char *icTokS(const char *s, const char *delim, char **saveptr);
+char *icTokS(char *s, const char *delim, char **saveptr) MUST_CHECK;
//
// UTF8 string functions
@@ -2222,15 +2239,15 @@ char *icTokS(const char *s, const char *delim, char **saveptr);
typedef int rune;
// character length of UTF-8 encoded string
-size_t lenUTF8(const char *s);
-size_t bLLenUTF8(const char *s, size_t maxSize);
+size_t lenUTF8(const char *s) MUST_CHECK;
+size_t bLLenUTF8(const char *s, size_t maxSize) MUST_CHECK;
// is string valid UTF-8 encoded string
-bool isUTF8(const char * string);
-bool bLIsUTF8(const char * string, size_t stringSize);
+bool isUTF8(const char * string) MUST_CHECK;
+bool bLIsUTF8(const char * string, size_t stringSize) MUST_CHECK;
// is string a valid UTF-8 code point
-bool isCodeUTF8(const char *code);
+bool isCodeUTF8(const char *code) MUST_CHECK;
extern const uint8_t codeSzUTF8[256];
@@ -2238,212 +2255,212 @@ extern const uint8_t codeSzUTF8[256];
#define codeSizeUTF8(utf8) codeSzUTF8[*(const uint8_t *)(utf8)]
/** move pointer to next UTF-8 code point, no checks are done, the utf8 pointer parameter is unchanged */
-#define nextCodeUTF8(utf8) (char *)((utf8) + codeSizeUTF8(utf8))
+#define nextCodeUTF8(utf8) ((utf8) + codeSizeUTF8(utf8))
/** change the utf8 pointer parameter to next UTF-8 code point, like char *s; s++; */
#define nxtCodeUTF8(utf8) EVA(utf8, nextCodeUTF8(utf8))
#define nxCodeUTF8(utf8) (utf8 = nextCodeUTF8(utf8))
// next code point, works only when utf8 points to a valid code point
-char *nextUTF8(const char *utf8);
-char *bLNextUTF8(const char *string, size_t utf8Size, const char *utf8);
+const char *nextUTF8(const char *utf8) MUST_CHECK;
+const char *bLNextUTF8(const char *string, size_t utf8Size, const char *utf8) MUST_CHECK;
// find next code point even when utf8 points inside a code point
-char *findNextUTF8(const char *string, size_t utf8Size, const char *utf8);
+const char *findNextUTF8(const char *string, size_t utf8Size, const char *utf8) MUST_CHECK;
// previous code point, undefined behavior when utf8 points to the start of the string
-char *prevUTF8(const char *utf8);
+const char *prevUTF8(const char *utf8) MUST_CHECK;
// previous code point
-char *bPrevUTF8(const char *string, const char *utf8);
+const char *bPrevUTF8(const char *string, const char *utf8) MUST_CHECK;
// character index to pointer
-char *idx2PtrUTF8(const char *utf8, int64_t index);
-char *bLIdx2PtrUTF8(const char *utf8, size_t utf8Size, int64_t index);
+const char *idx2PtrUTF8(const char *utf8, int64_t index) MUST_CHECK;
+const char *bLIdx2PtrUTF8(const char *utf8, size_t utf8Size, int64_t index) MUST_CHECK;
// pointer to character index
-int64_t ptr2IdxUTF8(const char *utf8, const char *pos);
-int64_t bPtr2IdxUTF8(const char *start, const char *utf8, const char *pos);
-int64_t bLPtr2IdxUTF8(const char *utf8, size_t utf8Size, const char *pos);
-int64_t bLPtr2NegIdxUTF8(const char *utf8, size_t utf8Size, const char *pos);
+int64_t ptr2IdxUTF8(const char *utf8, const char *pos) MUST_CHECK;
+int64_t bPtr2IdxUTF8(const char *start, const char *utf8, const char *pos) MUST_CHECK;
+int64_t bLPtr2IdxUTF8(const char *utf8, size_t utf8Size, const char *pos) MUST_CHECK;
+int64_t bLPtr2NegIdxUTF8(const char *utf8, size_t utf8Size, const char *pos) MUST_CHECK;
// make new valid UTF-8 encoded string
-char *makeValidUTF8(const char *utf8);
+char *makeValidUTF8(const char *utf8) MUST_CHECK;
// make utf8 a valid UTF-8 encoded string
-char *bMakeValidUTF8(char *utf8);
-char *nMakeValidUTF8(const char *utf8, size_t utf8Len);
-char *bNMakeValidUTF8(char *dst, const char *utf8, size_t utf8Len);
-char *bLMakeValidUTF8(char *dst, size_t dstSize, const char *utf8);
-char *bLNMakeValidUTF8(char *dst, size_t dstSize, const char *utf8, size_t utf8Len);
+char *bMakeValidUTF8(char *utf8) MUST_CHECK;
+char *nMakeValidUTF8(const char *utf8, size_t utf8Len) MUST_CHECK;
+char *bNMakeValidUTF8(char *dst, const char *utf8, size_t utf8Len) MUST_CHECK;
+char *bLMakeValidUTF8(char *dst, size_t dstSize, const char *utf8) MUST_CHECK;
+char *bLNMakeValidUTF8(char *dst, size_t dstSize, const char *utf8, size_t utf8Len) MUST_CHECK;
// strncpy where srcLen is number of characters
-char *strNCpyUTF8(char *dst, const char *src, size_t srcLen);
+char *strNCpyUTF8(char *dst, const char *src, size_t srcLen) MUST_CHECK;
// strLCpy for UTF-8 encoded strings
-char *strLCpyUTF8(char *dst, size_t dstSize, const char *src);
+char *strLCpyUTF8(char *dst, size_t dstSize, const char *src) MUST_CHECK;
// strncat where srcLen is number of characters
-char *strNCatUTF8(char *dst, const char *src, size_t srcLen);
+char *strNCatUTF8(char *dst, const char *src, size_t srcLen) MUST_CHECK;
// strLCat for UTF-8 encoded strings
-char *strLCatUTF8(char *dst, size_t dstSize, const char *src);
+char *strLCatUTF8(char *dst, size_t dstSize, const char *src) MUST_CHECK;
// strLNCat for UTF-8 encoded strings
-char *strLNCatUTF8(char *dst, size_t dstSize, const char *src, size_t srcLen);
+char *strLNCatUTF8(char *dst, size_t dstSize, const char *src, size_t srcLen) MUST_CHECK;
// TODO
-char* icReplaceUTF8(const char *s, const char *olds, const char *news, size_t max);
+char* icReplaceUTF8(const char *s, const char *olds, const char *news, size_t max) MUST_CHECK;
// TODO
-char *icReplaceCharSUTF8(const char *s, char olds, const char *news, size_t max);
+char *icReplaceCharSUTF8(const char *s, char olds, const char *news, size_t max) MUST_CHECK;
// TODO
-char *icReplaceSCharUTF8(const char *s, const char *olds, char news, size_t max);
+char *icReplaceSCharUTF8(const char *s, const char *olds, char news, size_t max) MUST_CHECK;
// TODO
-char* iicReplaceUTF8(char **s, const char *olds, const char *news, size_t max);
+char* iicReplaceUTF8(char **s, const char *olds, const char *news, size_t max) MUST_CHECK;
// TODO
-char *iicReplaceCharSUTF8(char **s, char olds, const char *news, size_t max);
+char *iicReplaceCharSUTF8(char **s, char olds, const char *news, size_t max) MUST_CHECK;
// TODO
-char *iicReplaceSCharUTF8(char **s, const char *olds, char news, size_t max);
+char *iicReplaceSCharUTF8(char **s, const char *olds, char news, size_t max) MUST_CHECK;
// TODO
-char* bicReplaceUTF8(char *s, const char *olds, const char *news, size_t max);
+char* bicReplaceUTF8(char *s, const char *olds, const char *news, size_t max) MUST_CHECK;
// TODO
-char* bLicReplaceUTF8(char *s, size_t sSize, const char *olds, const char *news, size_t max);
+char* bLicReplaceUTF8(char *s, size_t sSize, const char *olds, const char *news, size_t max) MUST_CHECK;
// TODO
-char *icReplaceManyUTF8F(const char *paramType, ...);
+char *icReplaceManyUTF8F(const char *paramType, ...) MUST_CHECK;
// TODO
-char *iicReplaceManyUTF8F(char **s, char *paramType, ...);
+char *iicReplaceManyUTF8F(char **s, char *paramType, ...) MUST_CHECK;
// TODO
-char *bicReplaceManyUTF8F(char *s, char *paramType, ...);
+char *bicReplaceManyUTF8F(char *s, char *paramType, ...) MUST_CHECK;
// TODO
-char *bLicReplaceManyUTF8F(char *s, size_t sSize, char *paramType, ...);
+char *bLicReplaceManyUTF8F(char *s, size_t sSize, char *paramType, ...) MUST_CHECK;
// UTF8 encoded string Index Equal
-bool eqIUTF8(const char *string1, const char *string2, int64_t index);
+bool eqIUTF8(const char *string1, const char *string2, int64_t index) MUST_CHECK;
// UTF8 encoded string Index Equal
-bool eqICharUTF8(const char *string1, char c, int64_t index);
+bool eqICharUTF8(const char *string1, char c, int64_t index) MUST_CHECK;
// ignore case UTF8 encoded string Equal
-bool icEqUTF8(const char *string1, const char *string2);
-bool icEqCharUTF8(char c, const char *string2);
-bool icEqUTF8Char(const char *string1, char c);
+bool icEqUTF8(const char *string1, const char *string2) MUST_CHECK;
+bool icEqCharUTF8(char c, const char *string2) MUST_CHECK;
+bool icEqUTF8Char(const char *string1, char c) MUST_CHECK;
// TODO
-bool icEqIUTF8(const char *string1, const char *string2, int64_t index);
+bool icEqIUTF8(const char *string1, const char *string2, int64_t index) MUST_CHECK;
// TODO
-bool icEqICharUTF8(const char *string1, char c, int64_t index);
+bool icEqICharUTF8(const char *string1, char c, int64_t index) MUST_CHECK;
// starts with for UTF-8 encoded string
-bool icStartsWithUTF8(const char *string1, const char *string2);
+bool icStartsWithUTF8(const char *string1, const char *string2) MUST_CHECK;
// ends with for UTF-8 encoded string
-bool icEndsWithUTF8(const char *string1, const char *string2);
+bool icEndsWithUTF8(const char *string1, const char *string2) MUST_CHECK;
// ignore case count UTF8 encoded String
-ssize_t icCountUTF8(const char *s, const char *needle);
+ssize_t icCountUTF8(const char *s, const char *needle) MUST_CHECK;
// UTF-8 code point to rune
-rune code2RuneUTF8(const char *code);
-rune code2RuneLUTF8(const char *code, uint8_t *n);
+rune code2RuneUTF8(const char *code) MUST_CHECK;
+rune code2RuneLUTF8(const char *code, uint8_t *n) MUST_CHECK;
// rune to UTF-8 code point
-size_t bRune2CodeUTF8(char *dst, rune c);
+size_t bRune2CodeUTF8(char *dst, rune c) MUST_CHECK;
// rune length as UTF-8 code point
-uint8_t runeLenUTF8(rune r);
+uint8_t runeLenUTF8(rune r) MUST_CHECK;
// rune toupper UTF8
-rune toupperUTF8(rune c);
+rune toupperUTF8(rune c) MUST_CHECK;
// upper case UTF-8 encoded string
-char *upperUTF8(const char *string);
-char *iUpperUTF8(char **string);
+char *upperUTF8(const char *string) MUST_CHECK;
+char *iUpperUTF8(char **string) MUST_CHECK;
// TODO
-char *bUpperUTF8(char *string);
+char *bUpperUTF8(char *string) MUST_CHECK;
// rune tolower UTF8
-rune tolowerUTF8(rune c);
+rune tolowerUTF8(rune c) MUST_CHECK;
// lower case UTF-8 String
-char *lowerUTF8(const char *string);
-char *iLowerUTF8(char **string);
+char *lowerUTF8(const char *string) MUST_CHECK;
+char *iLowerUTF8(char **string) MUST_CHECK;
// TODO
-char *bLowerUTF8(char *string);
+char *bLowerUTF8(char *string) MUST_CHECK;
// transform UTF-8 string to make it comparable regardless of case
-char *casefoldUTF8(const char *utf8);
+char *casefoldUTF8(const char *utf8) MUST_CHECK;
// uniquify code point in UTF-8 String
-char *uniqUTF8(const char *string, const char *code);
-char *iUniqUTF8(char **string, const char *code);
-char *bUniqUTF8(char *string, const char *code);
+char *uniqUTF8(const char *string, const char *code) MUST_CHECK;
+char *iUniqUTF8(char **string, const char *code) MUST_CHECK;
+char *bUniqUTF8(char *string, const char *code) MUST_CHECK;
// TODO
-char *icUniqUTF8(const char *string, const char *code);
+char *icUniqUTF8(const char *string, const char *code) MUST_CHECK;
// TODO
-char *iicUniqUTF8(char **string, const char *code);
+char *iicUniqUTF8(char **string, const char *code) MUST_CHECK;
// TODO
-char *bicUniqUTF8(char *string, char c);
+char *bicUniqUTF8(char *string, char c) MUST_CHECK;
// get rune in UTF8 encoded string
-rune getUTF8(const char *string, int64_t index);
+rune getUTF8(const char *string, int64_t index) MUST_CHECK;
// TODO
-char *setUTF8(char *string, int64_t index, rune c);
+char *setUTF8(char *string, int64_t index, rune c) MUST_CHECK;
// slice UTF8 encoded String
-char *sliceUTF8(const char *string, int64_t start, int64_t end);
-char *iSliceUTF8(char **string, int64_t start, int64_t end);
-char *bSliceUTF8(char *string, int64_t start, int64_t end);
-char *bLSliceUTF8(char *string, size_t stringSize, int64_t start, int64_t end);
+char *sliceUTF8(const char *string, int64_t start, int64_t end) MUST_CHECK;
+char *iSliceUTF8(char **string, int64_t start, int64_t end) MUST_CHECK;
+char *bSliceUTF8(char *string, int64_t start, int64_t end) MUST_CHECK;
+char *bLSliceUTF8(char *string, size_t stringSize, int64_t start, int64_t end) MUST_CHECK;
// insert string in UTF8 encoded string at index
-char *insertUTF8(const char *string, int64_t index, const char *toInsert);
-char *insertNFreeUTF8(const char *string, int64_t index, char *toInsert);
-char *iInsertUTF8(char **string, int64_t index, const char *toInsert);
-char *iInsertNFreeUTF8(char **string, int64_t index, char *toInsert);
-char *bInsertUTF8(char *string, int64_t index, const char *toInsert);
-char *bLInsertUTF8(char *string, size_t stringSize, int64_t index, const char *toInsert);
+char *insertUTF8(const char *string, int64_t index, const char *toInsert) MUST_CHECK;
+char *insertNFreeUTF8(const char *string, int64_t index, char *toInsert) MUST_CHECK;
+char *iInsertUTF8(char **string, int64_t index, const char *toInsert) MUST_CHECK;
+char *iInsertNFreeUTF8(char **string, int64_t index, char *toInsert) MUST_CHECK;
+char *bInsertUTF8(char *string, int64_t index, const char *toInsert) MUST_CHECK;
+char *bLInsertUTF8(char *string, size_t stringSize, int64_t index, const char *toInsert) MUST_CHECK;
// delete UTF8 encoded string
-char *delUTF8(const char *string, int64_t start, int64_t end);
-char *iDelUTF8(char **string, int64_t start, int64_t end);
-char *bDelUTF8(char *string, int64_t start, int64_t end);
-char *bLDelUTF8(char *string, size_t stringSize, int64_t start, int64_t end);
+char *delUTF8(const char *string, int64_t start, int64_t end) MUST_CHECK;
+char *iDelUTF8(char **string, int64_t start, int64_t end) MUST_CHECK;
+char *bDelUTF8(char *string, int64_t start, int64_t end) MUST_CHECK;
+char *bLDelUTF8(char *string, size_t stringSize, int64_t start, int64_t end) MUST_CHECK;
// indexOf UTF8 encoded String
-ssize_t indexOfUTF8(const char *string, const char *needle);
+ssize_t indexOfUTF8(const char *string, const char *needle) MUST_CHECK;
// TODO
-ssize_t icIndexOfUTF8(const char *string, const char *needle);
+ssize_t icIndexOfUTF8(const char *string, const char *needle) MUST_CHECK;
// ignore case has UTF8 encoded String
-bool icHasUTF8(const char *string, const char *needle);
+bool icHasUTF8(const char *string, const char *needle) MUST_CHECK;
// TODO
-char *icTokUTF8(const char *s, const char *delim, char **saveptr);
+char *icTokUTF8(const char *s, const char *delim, char **saveptr) MUST_CHECK;
// TODO
-char **icExtractUTF8(const char *string, const char* delim1, const char* delim2);
-char **icExtractCharSUTF8(const char *string, char delim1, const char* delim2);
-char **icExtractSCharUTF8(const char *string, const char* delim1, char delim2);
+char **icExtractUTF8(const char *string, const char* delim1, const char* delim2) MUST_CHECK;
+char **icExtractCharSUTF8(const char *string, char delim1, const char* delim2) MUST_CHECK;
+char **icExtractSCharUTF8(const char *string, const char* delim1, char delim2) MUST_CHECK;
// ignore case list Sort UTF8 encoded String
-char **icListSortUTF8(char **list);
-char **iicListSortUTF8(char ***list);
+char **icListSortUTF8(char **list) MUST_CHECK;
+char **iicListSortUTF8(char ***list) MUST_CHECK;
// ignore case list Equal UTF8 encoded String
-bool icListEqUTF8(char **list1, char **list2);
+bool icListEqUTF8(char **list1, char **list2) MUST_CHECK;
// ignore case and return true when list has UTF8 encoded string
-bool icListHasUTF8(char **list, const char *string);
+bool icListHasUTF8(char **list, const char *string) MUST_CHECK;
// ignore case and return index of UTF8 encoded string in list
-ssize_t icListIndexOfUTF8(char **list, const char *string);
+ssize_t icListIndexOfUTF8(char **list, const char *string) MUST_CHECK;
// ignore case list binary search UTF8 encoded string
-ssize_t icListBinarySearchUTF8(char **list, const char *string);
+ssize_t icListBinarySearchUTF8(char **list, const char *string) MUST_CHECK;
// ignore case and uniquify UTF8 encoded elements of list
-char **icListUniqUTF8(char **list);
-char **iicListUniqUTF8(char ***list);
+char **icListUniqUTF8(char **list) MUST_CHECK;
+char **iicListUniqUTF8(char ***list) MUST_CHECK;
//
// End UTF8 string functions
@@ -2453,35 +2470,41 @@ char **iicListUniqUTF8(char ***list);
// create empty string
#define emptyS(string) \
string = strdup("");
-char *emptySF(void);
-char *iEmptySF(char **string);
+char *emptySF(void) MUST_CHECK;
+char *iEmptySF(char **string) MUST_CHECK;
// string buffer empty - set 0 at index 0
#define bEmptyS(string) \
(string)[0] = 0
// is empty string
-bool isEmptyS(const char *string);
+bool isEmptyS(const char *string) MUST_CHECK;
/**
* orS - if string is empty, the value is alternative
*/
#define orS(string, alternative) \
- !isEmptyS(string) ? string : alternative
+ !isEmptyS(string) ? (string) : (alternative)
// true when string is empty or white spaces
-bool isBlankS(const char *string);
+bool isBlankS(const char *string) MUST_CHECK;
/**
* blankS - if string is blank(white spaces) or empty, the value is alternative
*/
#define orBlankS(string, alternative) \
- !isBlankS(string) ? string : alternative
+ !isBlankS(string) ? (string) : (alternative)
/**
* nS - null String - replace null string with "" string (empty string)
*/
#define nS(string) \
- string ? string : ""
+ (string) ? (string) : ""
+
+/**
+ * nAS - null Alternative String - replace null string with alternative string
+ */
+#define nAS(string, alternative) \
+ (string) ? (string) : (alternative)
// convert python index (int, positive and negative) to always positive index (uint), this function is more generic than listIntIndexS
@@ -2494,40 +2517,41 @@ ssize_t intIndex(int64_t index, int64_t length);
if (list) list[0] = NULL; \
} while(0);
-char **listEmptySF(void);
-char **iListEmptySF(char ***list);
+char **listEmptySF(void) MUST_CHECK;
+char **iListEmptySF(char ***list) MUST_CHECK;
// false when there are elements in the list
-bool listIsEmptyS(char **list);
+bool listIsEmptyS(char **list) MUST_CHECK;
// false when there are non blank elements in the list
-bool listIsBlankS(char **list);
+bool listIsBlankS(char **list) MUST_CHECK;
// String Lists
// createList(...)
-char **listCreateSF(const char *paramType, ...);
+char **listCreateSF(const char *paramType, ...) MUST_CHECK;
#define listCreateS(...) listCreateSF("", __VA_ARGS__, NULL)
// copy array to new list
-char **listFromArrayS(char **array, size_t size);
+char **listFromArrayS(char **array, size_t size) MUST_CHECK;
+char **listFromCArrayS(const char **array, size_t size) MUST_CHECK;
// push and pop (append) str
// modifies the list
-char **listPushS(char ***list, const char *s);
-char **listPushCharS(char ***list, char c);
-char **iListPushS(char ***list, char *s);
+char **listPushS(char ***list, const char *s) MUST_CHECK;
+char **listPushCharS(char ***list, char c) MUST_CHECK;
+char **iListPushS(char ***list, char *s) MUST_CHECK;
// copy last string and free it in the list
-char *listPopS(char ***list);
+char *listPopS(char ***list) MUST_CHECK;
// prepend and dequeue (append) str
// modifies the list
-char **listPrependS(char ***list, const char *s);
-char **listPrependCharS(char ***list, char c);
-char **iListPrependS(char ***list, char *s);
+char **listPrependS(char ***list, const char *s) MUST_CHECK;
+char **listPrependCharS(char ***list, char c) MUST_CHECK;
+char **iListPrependS(char ***list, char *s) MUST_CHECK;
// copy fist string and free it in the list
-char *listDequeueS(char ***list);
+char *listDequeueS(char ***list) MUST_CHECK;
// freeList
void listFreeS(char **list);
@@ -2537,120 +2561,130 @@ void listFreeManySF(char **paramType, ...);
#define listFreeManyS(...) listFreeManySF(NULL, __VA_ARGS__, NULL)
// length
-size_t listLengthS(char **list);
+size_t listLengthS(char **list) MUST_CHECK;
+size_t listLengthCS(const char **list) MUST_CHECK;
// list length as a single string
-ssize_t listStrLengthS(char **list);
+ssize_t listStrLengthS(char **list) MUST_CHECK;
// convert python index (int) to always positive index (uint)
-ssize_t listIntIndexS(char **list, int64_t index);
+ssize_t listIntIndexS(char **list, int64_t index) MUST_CHECK;
// pointer to the char* at python index
-char **listAddrS(char **list, int64_t index);
+char **listAddrS(char **list, int64_t index) MUST_CHECK;
// list get - get a string at python index
-char *listGetS(char **list, int64_t index);
-char *iListGetS(char **list, int64_t index);
+char *listGetS(char **list, int64_t index) MUST_CHECK;
+char *iListGetS(char **list, int64_t index) MUST_CHECK;
+char *listGetCS(const char **list, int64_t index) MUST_CHECK;
+const char *iListGetCS(const char **list, int64_t index) MUST_CHECK;
// list set - replace a string at python index
-char **listSetS(char **list, int64_t index, const char *s);
-char **listSetCharS(char **list, int64_t index, char c);
-char **iListSetS(char **list, int64_t index, char *s);
+char **listSetS(char **list, int64_t index, const char *s) MUST_CHECK;
+char **listSetCharS(char **list, int64_t index, char c) MUST_CHECK;
+char **iListSetS(char **list, int64_t index, char *s) MUST_CHECK;
// swap elements in a list
-char **listSwapS(char **list, int64_t index1, int64_t index2);
-char **iListSwapS(char **list, int64_t index1, int64_t index2);
+char **listSwapS(char **list, int64_t index1, int64_t index2) MUST_CHECK;
+char **iListSwapS(char **list, int64_t index1, int64_t index2) MUST_CHECK;
// split
-char **split(const char *string, const char* delim);
-char **splitChar(const char *string, char delim);
+char **split(const char *string, const char* delim) MUST_CHECK;
+char **splitS(const char *string, const char* delim) MUST_CHECK;
+char **splitChar(const char *string, char delim) MUST_CHECK;
// ignore case split
-char **icSplit(const char *string, const char* delim);
-char **icSplitChar(const char *string, char delim);
+char **icSplit(const char *string, const char* delim) MUST_CHECK;
+char **icSplitS(const char *string, const char* delim) MUST_CHECK;
+char **icSplitChar(const char *string, char delim) MUST_CHECK;
// list length after joined with delimiter
-ssize_t joinLength(char **list, const char* delim);
+ssize_t joinLength(char **list, const char* delim) MUST_CHECK;
// join
-char *join(char **list, const char* delim);
-char *joinChar(char **list, char delim);
-char *bJoin(char *string, char **list, const char* delim);
-char *bJoinChar(char *string, char **list, char delim);
-char *bLJoin(char *string, size_t stringSize, char **list, const char* delim);
-char *bLJoinChar(char *string, size_t stringSize, char **list, char delim);
+char *join(char **list, const char* delim) MUST_CHECK;
+char *joinS(char **list, const char* delim) MUST_CHECK;
+char *joinCS(const char **list, const char* delim) MUST_CHECK;
+char *joinChar(char **list, char delim) MUST_CHECK;
+char *bJoin(char *string, char **list, const char* delim) MUST_CHECK;
+char *bJoinChar(char *string, char **list, char delim) MUST_CHECK;
+char *bLJoin(char *string, size_t stringSize, char **list, const char* delim) MUST_CHECK;
+char *bLJoinChar(char *string, size_t stringSize, char **list, char delim) MUST_CHECK;
// extract string
-char **extractS(const char *string, const char* delim1, const char* delim2);
-char **extractCharSS(const char *string, char delim1, const char* delim2);
-char **extractSCharS(const char *string, const char* delim1, char delim2);
-char **extractCharCharS(const char *string, char delim1, char delim2);
+char **extractS(const char *string, const char* delim1, const char* delim2) MUST_CHECK;
+char **extractCharSS(const char *string, char delim1, const char* delim2) MUST_CHECK;
+char **extractSCharS(const char *string, const char* delim1, char delim2) MUST_CHECK;
+char **extractCharCharS(const char *string, char delim1, char delim2) MUST_CHECK;
// ignore case extract string
-char **icExtractS(const char *string, const char* delim1, const char* delim2);
-char **icExtractCharSS(const char *string, char delim1, const char* delim2);
-char **icExtractSCharS(const char *string, const char* delim1, char delim2);
-char **icExtractCharCharS(const char *string, char delim1, char delim2);
+char **icExtractS(const char *string, const char* delim1, const char* delim2) MUST_CHECK;
+char **icExtractCharSS(const char *string, char delim1, const char* delim2) MUST_CHECK;
+char **icExtractSCharS(const char *string, const char* delim1, char delim2) MUST_CHECK;
+char **icExtractCharCharS(const char *string, char delim1, char delim2) MUST_CHECK;
// duplicate list
-char **listDupS(char **list);
-char **iListDupS(char **list);
+char **listDupS(char **list) MUST_CHECK;
+char **listDupCS(const char **list) MUST_CHECK;
+char **iListDupS(char **list) MUST_CHECK;
// duplicate and reverse list
-char **listReverseS(char **list);
-char **iListReverseS(char ***list);
+char **listReverseS(char **list) MUST_CHECK;
+char **iListReverseS(char ***list) MUST_CHECK;
// listCatS: f(l1, l2, l3)
-char **listCatSF(char **paramType, ...);
+char **listCatSF(char **paramType, ...) MUST_CHECK;
#define listCatS(...) listCatSF(NULL, __VA_ARGS__, NULL)
// append lists
-char **listAppendS(char ***list1, char **list2);
-char **iListAppendS(char ***list1, char **list2);
-char **iListAppendNSmashS(char ***list1, char **list2);
+char **listAppendS(char ***list1, char **list2) MUST_CHECK;
+char **iListAppendS(char ***list1, char **list2) MUST_CHECK;
+char **iListAppendNSmashS(char ***list1, char **list2) MUST_CHECK;
// prepend list at the start and shift existing elements
-char **listShiftS(char ***list1, char **list2);
-char **iListShiftS(char ***list1, char **list2);
-char **iListShiftNSmashS(char ***list1, char **list2);
+char **listShiftS(char ***list1, char **list2) MUST_CHECK;
+char **iListShiftS(char ***list1, char **list2) MUST_CHECK;
+char **iListShiftNSmashS(char ***list1, char **list2) MUST_CHECK;
// add lists
char **listAddS(char **list1, char **list2);
+char **listAddCS(char **list1, const char **list2);
// slice - python style indexes 0..len-1 -1..-len+1
-char **listSliceS(char **list, int64_t start, int64_t end);
-char **iListCopyS(char **list, int64_t start, int64_t end);
-char **iListSliceS(char ***list, int64_t start, int64_t end);
+char **listSliceS(char **list, int64_t start, int64_t end) MUST_CHECK;
+char **iListCopyS(char **list, int64_t start, int64_t end) MUST_CHECK;
+char **iListSliceS(char ***list, int64_t start, int64_t end) MUST_CHECK;
// crop list (slice+del)
-char **listCropS(char **list, int64_t start, int64_t end);
-char **iListCropS(char ***list, int64_t start, int64_t end);
-char *listCropElemS(char **list, int64_t index);
-char *iListCropElemS(char ***list, int64_t index);
+char **listCropS(char **list, int64_t start, int64_t end) MUST_CHECK;
+char **iListCropS(char ***list, int64_t start, int64_t end) MUST_CHECK;
+char *listCropElemS(char **list, int64_t index) MUST_CHECK;
+char *iListCropElemS(char ***list, int64_t index) MUST_CHECK;
// insert list in list
-char **listInsertS(char **list, int64_t index, char **toInsert);
-char **iListInsertS(char ***list, int64_t index, char **toInsert);
-char **iListInsertNFreeS(char ***list, int64_t index, char **toInsert);
+char **listInsertS(char **list, int64_t index, char **toInsert) MUST_CHECK;
+char **iListInsertS(char ***list, int64_t index, char **toInsert) MUST_CHECK;
+char **iListInsertNFreeS(char ***list, int64_t index, char **toInsert) MUST_CHECK;
// inject string in list
-char **listInjectS(char **list, int64_t index, char *toInject);
-char **listInjectCharS(char **list, int64_t index, char toInject);
-char **iListInjectS(char ***list, int64_t index, char *toInject);
-char **iListInjectCharS(char ***list, int64_t index, char toInject);
+char **listInjectS(char **list, int64_t index, char *toInject) MUST_CHECK;
+char **listInjectCharS(char **list, int64_t index, char toInject) MUST_CHECK;
+char **iListInjectS(char ***list, int64_t index, char *toInject) MUST_CHECK;
+char **iListInjectCharS(char ***list, int64_t index, char toInject) MUST_CHECK;
// del - python style indexes 0..len-1 -1..-len+1
-char **listDelS(char **list, int64_t start, int64_t end);
-char **iListDelS(char ***list, int64_t start, int64_t end);
+char **listDelS(char **list, int64_t start, int64_t end) MUST_CHECK;
+char **iListDelS(char ***list, int64_t start, int64_t end) MUST_CHECK;
char **iListRemoveS(char ***list, int64_t start, int64_t end);
// del element in list
-char **listDelElemS(char **list, int64_t index);
-char **iListDelElemS(char ***list, int64_t index);
-char **iListRemoveElemS(char ***list, int64_t index);
+char **listDelElemS(char **list, int64_t index) MUST_CHECK;
+char **iListDelElemS(char ***list, int64_t index) MUST_CHECK;
+char **iListRemoveElemS(char ***list, int64_t index) MUST_CHECK;
// print list
-int listPrintS(char **list);
+int listPrintS(char **list) MUST_CHECK;
+int listPrintCS(const char **list) MUST_CHECK;
/**
* forever loop
@@ -2789,7 +2823,7 @@ int listPrintS(char **list);
*/
#define rangeFromStep(index, from, maxCount, step) \
;size_t UNIQVAR(maxCnt) = (size_t)(maxCount); \
- for (size_t index = from ; index < UNIQVAR(maxCnt) ; index+=step)
+ for (size_t index = from ; index < UNIQVAR(maxCnt) ; index+=(size_t)step)
/**
@@ -2868,11 +2902,17 @@ int listPrintS(char **list);
/**
* forEach - loop macro on list indexes
* to access the element in the loop, use *element
- */
+ */
#define forEachCharP(list, element) \
for (char **element=list ; *element != NULL ; element++)
/**
+ * forEach for const char** lists
+ */
+#define forEachCCharP(list, element) \
+ for (const char **element=list ; *element != NULL ; element++)
+
+/**
* forEach - loop macro on list indexes
* to access the element in the loop, use element
* ;size_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement
@@ -2883,6 +2923,13 @@ int listPrintS(char **list);
for (char *element = (list)[0]; (list)[UNIQVAR(libsheepyInternalIndex)]!= NULL ; UNIQVAR(libsheepyInternalIndex)++, element = (list)[UNIQVAR(libsheepyInternalIndex)])
/**
+ * forEach for const char** lists
+ */
+#define forEachCS(list, element) \
+ ;size_t UNIQVAR(libsheepyInternalIndex) = 0; \
+ for (const char *element = (list)[0]; (list)[UNIQVAR(libsheepyInternalIndex)]!= NULL ; UNIQVAR(libsheepyInternalIndex)++, element = (list)[UNIQVAR(libsheepyInternalIndex)])
+
+/**
* forEach - loop macro on list indexes
*/
#define forEachType(type, list, element) \
@@ -2891,7 +2938,7 @@ int listPrintS(char **list);
/**
* enumerateCharP list
* to access the element in the loop, use *element
- * ;size_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement
+ * ;size_t needed to avoid: error: a label can only be part of a statement and a declaration is not a statement
* on older compilers
*/
#define enumerateCharP(list, element, index) \
@@ -2899,9 +2946,19 @@ int listPrintS(char **list);
for (char **element=list; *element != NULL ; element++, index++)
/**
- * enumerateCharP list
+ * enumerateCCharP const list
+ * to access the element in the loop, use *element
+ * ;size_t needed to avoid: error: a label can only be part of a statement and a declaration is not a statement
+ * on older compilers
+ */
+#define enumerateCCharP(list, element, index) \
+ ;size_t index = 0; \
+ for (const char **element=list; *element != NULL ; element++, index++)
+
+/**
+ * enumerateS list
* to acess the element in the loop, use element
- * ;size_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement
+ * ;size_t needed to avoid: error: a label can only be part of a statement and a declaration is not a statement
* on older compilers
*/
#define enumerateS(list, element, index) \
@@ -2909,8 +2966,18 @@ int listPrintS(char **list);
for (char *element=(list)[0]; element != NULL ; index++, element = (list)[index])
/**
- * enumerateCharP list
- * ;size_t UNIQVAR needed to avoid: error: a label can only be part of a statement and a declaration is not a statement
+ * enumerateCS const list
+ * to acess the element in the loop, use element
+ * ;size_t needed to avoid: error: a label can only be part of a statement and a declaration is not a statement
+ * on older compilers
+ */
+#define enumerateCS(list, element, index) \
+ ;size_t index = 0; \
+ for (const char *element=(list)[0]; element != NULL ; index++, element = (list)[index])
+
+/**
+ * enumerateType list
+ * ;size_t needed to avoid: error: a label can only be part of a statement and a declaration is not a statement
* on older compilers
*/
#define enumerateType(type, list, element, index) \
@@ -2945,42 +3012,45 @@ int listPrintS(char **list);
typedef int (*shCmpt)(const void * a, const void * b);
// duplicate and sort
-char **listSortS(char **list);
-char **iListSortS(char ***list);
-char **listSortFS(char **list, shCmpt compareFunction);
-char **iListSortFS(char ***list, shCmpt compareFunction);
+char **listSortS(char **list) MUST_CHECK;
+char **iListSortS(char ***list) MUST_CHECK;
+char **listSortFS(char **list, shCmpt compareFunction) MUST_CHECK;
+char **iListSortFS(char ***list, shCmpt compareFunction) MUST_CHECK;
// ignore case, duplicate and sort
-char **icListSortS(char **list);
-char **iicListSortS(char ***list);
+char **icListSortS(char **list) MUST_CHECK;
+char **iicListSortS(char ***list) MUST_CHECK;
// open text file and return lines in list
-char **readText(const char *filePath);
+char **readText(const char *filePath) MUST_CHECK;
// read opened text file and return lines in list
// the file is left open
-char **readStream(FILE *fp);
+char **readStream(FILE *fp) MUST_CHECK;
// write text file
-bool writeText(const char *filePath, char **list);
+bool writeText(const char *filePath, char **list) MUST_CHECK;
+bool writeCText(const char *filePath, const char **list) MUST_CHECK;
// write buffer
-bool writeStream(FILE *fp, char **list);
+bool writeStream(FILE *fp, char **list) MUST_CHECK;
+bool writeCStream(FILE *fp, const char **list) MUST_CHECK;
// append text to file
-bool appendText(const char *filePath, char **list);
+bool appendText(const char *filePath, char **list) MUST_CHECK;
+bool appendCText(const char *filePath, const char **list) MUST_CHECK;
// execOut
-char **execOut(const char *cmd);
+char **execOut(const char *cmd) MUST_CHECK;
// convenience define
#define execOutf systemOutf
#define execf systemf
// system command with formatting
-char **systemOutf(const char *fmt, ...);
+char **systemOutf(const char *fmt, ...) MUST_CHECK;
// convenience define
#define systemOut execOut
-int systemf(const char *fmt, ...);
+int systemf(const char *fmt, ...) MUST_CHECK;
// system commands and log
#define logSystem(cmd) do{\
@@ -3006,11 +3076,11 @@ int systemf(const char *fmt, ...);
// run command and return exit code from command (not system return value like system, systemf and systemNFree)
#define command(cmd) commandF(cmd, __LINE__, __func__, __FILE__)
-int commandF(const char *cmd, int line, const char *thisFunc, const char *thisFileName);
+int commandF(const char *cmd, int line, const char *thisFunc, const char *thisFileName) MUST_CHECK;
#define commandf(...) commandfF(__LINE__, __func__, __FILE__, __VA_ARGS__)
-int commandfF(int line, const char *thisFunc, const char *thisFileName, const char *fmt, ...);
+int commandfF(int line, const char *thisFunc, const char *thisFileName, const char *fmt, ...) MUST_CHECK;
#define commandNFree(cmd) commandNFreeF(cmd, __LINE__, __func__, __FILE__)
-int commandNFreeF(char *cmd, int line, const char *thisFunc, const char *thisFileName);
+int commandNFreeF(char *cmd, int line, const char *thisFunc, const char *thisFileName) MUST_CHECK;
#define commandOut execOut
#define commandOutf systemOutf
@@ -3036,50 +3106,64 @@ int commandNFreeF(char *cmd, int line, const char *thisFunc, const char *thisFil
#define logCommandOutf logExecOutf
// compare lists
-bool listEqS(char **list1, char **list2);
+bool listEqS(char **list1, char **list2) MUST_CHECK;
+bool listEqCS(char **list1, const char **list2) MUST_CHECK;
+bool listEqC1S(const char **list1, char **list2) MUST_CHECK;
+bool listEqCCS(const char **list1, const char **list2) MUST_CHECK;
// has
-bool listHasS(char **list, const char *string);
-bool listHasCharS(char **list, char c);
+bool listHasS(char **list, const char *string) MUST_CHECK;
+bool listHasCS(const char **list, const char *string) MUST_CHECK;
+bool listHasCharS(char **list, char c) MUST_CHECK;
+bool listHasCharCS(const char **list, char c) MUST_CHECK;
// indexOf
-ssize_t listIndexOfS(char **list, const char *string);
-ssize_t listIndexOfCharS(char **list, char c);
+ssize_t listIndexOfS(char **list, const char *string) MUST_CHECK;
+ssize_t listIndexOfCS(const char **list, const char *string) MUST_CHECK;
+ssize_t listIndexOfCharS(char **list, char c) MUST_CHECK;
+ssize_t listIndexOfCharCS(const char **list, char c) MUST_CHECK;
// list binary search string
-ssize_t listBinarySearchS(char **list, const char *string);
-ssize_t listBinarySearchCharS(char **list, char c);
+ssize_t listBinarySearchS(char **list, const char *string) MUST_CHECK;
+ssize_t listBinarySearchCharS(char **list, char c) MUST_CHECK;
// duplicate and uniquify
-char **listUniqS(char **list);
-char **iListUniqS(char ***list);
+char **listUniqS(char **list) MUST_CHECK;
+char **iListUniqS(char ***list) MUST_CHECK;
// ignore case and compare lists
-bool icListEqS(char **list1, char **list2);
+bool icListEqS(char **list1, char **list2) MUST_CHECK;
+bool icListEqCS(char **list1, const char **list2) MUST_CHECK;
+bool icListEqC1S(const char **list1, char **list2) MUST_CHECK;
+bool icListEqCCS(const char **list1, const char **list2) MUST_CHECK;
// ignore case has
-bool icListHasS(char **list, const char *string);
-bool icListHasCharS(char **list, char c);
+bool icListHasS(char **list, const char *string) MUST_CHECK;
+bool icListHasCharS(char **list, char c) MUST_CHECK;
+bool icListHasCS(const char **list, const char *string) MUST_CHECK;
+bool icListHasCharCS(const char **list, char c) MUST_CHECK;
// ignore case indexOf
-ssize_t icListIndexOfS(char **list, const char *string);
-ssize_t icListIndexOfCharS(char **list, char c);
+ssize_t icListIndexOfS(char **list, const char *string) MUST_CHECK;
+ssize_t icListIndexOfCS(const char **list, const char *string) MUST_CHECK;
+ssize_t icListIndexOfCharS(char **list, char c) MUST_CHECK;
+ssize_t icListIndexOfCharCS(const char **list, char c) MUST_CHECK;
// ignore case list binary search string
-ssize_t icListBinarySearchS(char **list, const char *string);
-ssize_t icListBinarySearchCharS(char **list, char c);
+ssize_t icListBinarySearchS(char **list, const char *string) MUST_CHECK;
+ssize_t icListBinarySearchCharS(char **list, char c) MUST_CHECK;
// ignore case, duplicate and uniquify
-char **icListUniqS(char **list);
-char **iicListUniqS(char ***list);
+char **icListUniqS(char **list) MUST_CHECK;
+char **iicListUniqS(char ***list) MUST_CHECK;
// duplicate and compact
-char **listCompactS(char **list);
-char **iListCompactS(char ***list);
+char **listCompactS(char **list) MUST_CHECK;
+char **iListCompactS(char ***list) MUST_CHECK;
void btraceEnable(void);
void btraceDisable(void);
-bool btraceConfig(void);
+bool btraceConfig(void) MUST_CHECK;
// get backtrace
char **btrace(void);
@@ -3109,32 +3193,32 @@ extern bool btraceCfg;
if (list) list[0] = NULL; \
} while(0);
-void **listEmptyF(void);
-void **iListEmptyF(void ***list);
+void **listEmptyF(void) MUST_CHECK;
+void **iListEmptyF(void ***list) MUST_CHECK;
// false when there are elements in the list
-bool listIsEmpty(void **list);
+bool listIsEmpty(void **list) MUST_CHECK;
// createList(...)
-void **listCreateF(void *paramType, ...);
+void **listCreateF(void *paramType, ...) MUST_CHECK;
#define listCreate(...) listCreateF(NULL, __VA_ARGS__, NULL)
// copy array to new list
-void **listFromArray(void **array, size_t size);
+void **listFromArray(void **array, size_t size) MUST_CHECK;
// push and pop (append) element
// modifies the list
-void **listPush(void ***list, void *s);
+void **listPush(void ***list, void *s) MUST_CHECK;
// return last element and remove it from the list
-void *listPop(void ***list);
+void *listPop(void ***list) MUST_CHECK;
// prepend and dequeue (append) element
// modifies the list
-void **listPrepend(void ***list, void *s);
+void **listPrepend(void ***list, void *s) MUST_CHECK;
// return fist element and remove it from the list
-void *listDequeue(void ***list);
+void *listDequeue(void ***list) MUST_CHECK;
// freeList
void listFree(void **list);
@@ -3144,42 +3228,42 @@ void listFreeManyF(void **paramType, ...);
#define listFreeMany(...) listFreeManyF(NULL, __VA_ARGS__, NULL)
// length
-size_t listLength(void **list);
+size_t listLength(void **list) MUST_CHECK;
// list get - get an element at python index
-void *listGet(void **list, int64_t index);
+void *listGet(void **list, int64_t index) MUST_CHECK;
// list set - replace a string at python index
-void **listSet(void **list, int64_t index, void *s);
+void **listSet(void **list, int64_t index, void *s) MUST_CHECK;
// duplicate list
-void **listDup(void **list);
+void **listDup(void **list) MUST_CHECK;
// duplicate and reverse list
-void **listReverse(void **list);
-void **iListReverse(void ***list);
+void **listReverse(void **list) MUST_CHECK;
+void **iListReverse(void ***list) MUST_CHECK;
// listCatS: f(l1, l2, l3)
-void **listCatF(void **paramType, ...);
+void **listCatF(void **paramType, ...) MUST_CHECK;
#define listCat(...) listCatF(NULL, __VA_ARGS__, NULL)
// append lists
-void **listAppend(void ***list1, void **list2);
+void **listAppend(void ***list1, void **list2) MUST_CHECK;
// add lists
-void **listAdd(void **list1, void **list2);
+void **listAdd(void **list1, void **list2) MUST_CHECK;
// slice - python style indexes 0..len-1 -1..-len+1
-void **listSlice(void **list, int64_t start, int64_t end);
-void **iListSlice(void ***list, int64_t start, int64_t end);
+void **listSlice(void **list, int64_t start, int64_t end) MUST_CHECK;
+void **iListSlice(void ***list, int64_t start, int64_t end) MUST_CHECK;
// insert list in list
-void **listInsert(void **list, int64_t index, void **toInsert);
-void **iListInsert(void ***list, int64_t index, void **toInsert);
+void **listInsert(void **list, int64_t index, void **toInsert) MUST_CHECK;
+void **iListInsert(void ***list, int64_t index, void **toInsert) MUST_CHECK;
// del - python style indexes 0..len-1 -1..-len+1
-void **listDel(void **list, int64_t start, int64_t end);
-void **iListDel(void ***list, int64_t start, int64_t end);
+void **listDel(void **list, int64_t start, int64_t end) MUST_CHECK;
+void **iListDel(void ***list, int64_t start, int64_t end) MUST_CHECK;
//NOT NEEDED same as iListDel - void **iListRemove(void ***list, int64_t start, int64_t end);
// duplicate and sort
@@ -6913,7 +6997,7 @@ bool fiberPrepend(void *ctx, int thisSlot, fiberFT func);
#define dArrayAlloc(a) do{\
if ((a)->last == dArrayMaxCount(a)) {\
(a)->maxCount++;\
- (a)->buffers = realloc((a)->buffers, (a)->maxCount * sizeof(void*));\
+ (a)->buffers = realloc((a)->buffers, (size_t)(a)->maxCount * sizeof(void*));\
(a)->buffers[(a)->maxCount-1] = malloc(dArraySz * sizeof((a)->element));\
}\
}while(0)
@@ -7904,10 +7988,10 @@ bool fiberPrepend(void *ctx, int thisSlot, fiberFT func);
*/
// get monotonic time in ns
-uint64_t getMonotonicTime(void);
+uint64_t getMonotonicTime(void) MUST_CHECK;
// sleep nanoseconds
-int nanoSleepF(uint64_t time);
+int nanoSleepF(uint64_t time) MUST_CHECK;
#define nanoSleep(time) pError0(nanoSleepF(time))
/** sleep nanoseconds */
@@ -7989,9 +8073,6 @@ int nanoSleepF(uint64_t time);
/** function returning a pointer to a newly allocated buffer */
#define AMALLOC __attribute__ ((malloc))
-/** force function callers to check return value */
-#define MUST_CHECK __attribute__ ((warn_unused_result))
-
/** mark a function as used */
#define USED __attribute__ ((used))
diff --git a/src/libsheepyCuTest.c b/src/libsheepyCuTest.c
@@ -1909,6 +1909,7 @@ void readFileToST(CuTest *tc UNUSED) {
free(l);
// write only file
+ fileChmod("writeOnlyText.null", S_IWUSR | S_IWGRP | S_IWOTH);
ck_assert_ptr_eq(readFileToS("writeOnlyText.null"), NULL);
// blank path
@@ -2110,6 +2111,7 @@ void readFileT(CuTest *tc UNUSED) {
free(l);
// write only file
+ fileChmod("writeOnlyText.null", S_IWUSR | S_IWGRP | S_IWOTH);
ck_assert_int_eq(readFile("writeOnlyText.null", (void **) &l), -1);
// blank path
diff --git a/src/libsheepyObject.h b/src/libsheepyObject.h
@@ -7429,6 +7429,9 @@ void finishManyOF(void *paramType, ...);
#define mirrorO(self) (self)->f->mirror(self)
#define mirrorG mirrorO
+#define fromCArrayO(self, array, size) (self)->f->fromCArray(self, array, size)
+#define fromCArrayG fromCArrayO
+
#define fromArrayNFreeO(self, array, size) (self)->f->fromArrayNFree(self, array, size)
#define fromArrayNFreeG fromArrayNFreeO
@@ -7438,6 +7441,9 @@ void finishManyOF(void *paramType, ...);
#define pushArraycO(self, array) (self)->f->pushArrayc(self, array)
#define pushArraycG pushArraycO
+#define pushCArraycO(self, array) (self)->f->pushCArrayc(self, array)
+#define pushCArraycG pushCArraycO
+
#define pushNFreeArraycO(self, array) (self)->f->pushNFreeArrayc(self, array)
#define pushNFreeArraycG pushNFreeArraycO
@@ -7477,6 +7483,9 @@ void finishManyOF(void *paramType, ...);
#define prependArraycO(self, array) (self)->f->prependArrayc(self, array)
#define prependArraycG prependArraycO
+#define prependCArraycO(self, array) (self)->f->prependCArrayc(self, array)
+#define prependCArraycG prependCArraycO
+
#define prependSmallBoolO(self, value) (self)->f->prependSmallBool(self, value)
#define prependSmallBoolG prependSmallBoolO
@@ -7492,7 +7501,7 @@ void finishManyOF(void *paramType, ...);
#define prependSmallContainerO(self, container) (self)->f->prependSmallContainer(self, container)
#define prependSmallContainerG prependSmallContainerO
-#define prependNFreeUndefinedO(self, undefined) (self)->f->prependNFreeUndefined(self, undefined)
+#define prependNFreeUndefinedO(self, u) (self)->f->prependNFreeUndefined(self, u)
#define prependNFreeUndefinedG prependNFreeUndefinedO
#define prependNFreeSO(self, string) (self)->f->prependNFreeS(self, string)
@@ -7582,6 +7591,9 @@ void finishManyOF(void *paramType, ...);
#define appendArrayO(self, array) (self)->f->appendArray(self, array)
#define appendArrayG appendArrayO
+#define appendCArrayO(self, array) (self)->f->appendCArray(self, array)
+#define appendCArrayG appendCArrayO
+
#define appendNSmashArrayO(self, array) (self)->f->appendNSmashArray(self, array)
#define appendNSmashArrayG appendNSmashArrayO
@@ -7663,6 +7675,9 @@ void finishManyOF(void *paramType, ...);
#define injectArraycO(self, index, toInject) (self)->f->injectArrayc(self, index, toInject)
#define injectArraycG injectArraycO
+#define injectCArraycO(self, index, toInject) (self)->f->injectCArrayc(self, index, toInject)
+#define injectCArraycG injectCArraycO
+
#define injectSmallBoolO(self, index, toInject) (self)->f->injectSmallBool(self, index, toInject)
#define injectSmallBoolG injectSmallBoolO
@@ -7678,7 +7693,7 @@ void finishManyOF(void *paramType, ...);
#define injectSmallContainerO(self, index, toInject) (self)->f->injectSmallContainer(self, index, toInject)
#define injectSmallContainerG injectSmallContainerO
-#define injectNFreeUndefinedO(self, index, undefined) (self)->f->injectNFreeUndefined(self, index, undefined)
+#define injectNFreeUndefinedO(self, index, u) (self)->f->injectNFreeUndefined(self, index, u)
#define injectNFreeUndefinedG injectNFreeUndefinedO
#define injectNFreeSO(self, index, toInject) (self)->f->injectNFreeS(self, index, toInject)
@@ -7723,6 +7738,9 @@ void finishManyOF(void *paramType, ...);
#define equalArrayO(self, p2) (self)->f->equalArray(self, p2)
#define equalArrayG equalArrayO
+#define equalCArrayO(self, p2) (self)->f->equalCArray(self, p2)
+#define equalCArrayG equalCArrayO
+
#define equalBaseO(self, p2) (self)->f->equalBase(self, p2)
#define equalBaseG equalBaseO
@@ -7738,6 +7756,9 @@ void finishManyOF(void *paramType, ...);
#define setAtArraycO(self, index, array) (self)->f->setAtArrayc(self, index, array)
#define setAtArraycG setAtArraycO
+#define setAtCArraycO(self, index, array) (self)->f->setAtCArrayc(self, index, array)
+#define setAtCArraycG setAtCArraycO
+
#define setAtSmallBytesO(self, index, value) (self)->f->setAtSmallBytes(self, index, value)
#define setAtSmallBytesG setAtSmallBytesO
@@ -7753,7 +7774,7 @@ void finishManyOF(void *paramType, ...);
#define setPAtNFreeSmallJsonO(self, index, json) (self)->f->setPAtNFreeSmallJson(self, index, json)
#define setPAtNFreeSmallJsonG setPAtNFreeSmallJsonO
-#define hasUndefinedO(self, undefined) (self)->f->hasUndefined(self, undefined)
+#define hasUndefinedO(self, u) (self)->f->hasUndefined(self, u)
#define hasUndefinedG hasUndefinedO
#define hasBoolO(self, value) (self)->f->hasBool(self, value)
@@ -7780,6 +7801,9 @@ void finishManyOF(void *paramType, ...);
#define hasArraycO(self, array) (self)->f->hasArrayc(self, array)
#define hasArraycG hasArraycO
+#define hasCArraycO(self, array) (self)->f->hasCArrayc(self, array)
+#define hasCArraycG hasCArraycO
+
#define hasSmallBoolO(self, value) (self)->f->hasSmallBool(self, value)
#define hasSmallBoolG hasSmallBoolO
@@ -7795,7 +7819,7 @@ void finishManyOF(void *paramType, ...);
#define hasSmallContainerO(self, container) (self)->f->hasSmallContainer(self, container)
#define hasSmallContainerG hasSmallContainerO
-#define indexOfUndefinedO(self, undefined) (self)->f->indexOfUndefined(self, undefined)
+#define indexOfUndefinedO(self, u) (self)->f->indexOfUndefined(self, u)
#define indexOfUndefinedG indexOfUndefinedO
#define indexOfBoolO(self, value) (self)->f->indexOfBool(self, value)
@@ -7822,6 +7846,9 @@ void finishManyOF(void *paramType, ...);
#define indexOfArraycO(self, array) (self)->f->indexOfArrayc(self, array)
#define indexOfArraycG indexOfArraycO
+#define indexOfCArraycO(self, array) (self)->f->indexOfCArrayc(self, array)
+#define indexOfCArraycG indexOfCArraycO
+
#define indexOfSmallBoolO(self, value) (self)->f->indexOfSmallBool(self, value)
#define indexOfSmallBoolG indexOfSmallBoolO
@@ -7834,7 +7861,7 @@ void finishManyOF(void *paramType, ...);
#define indexOfSmallIntO(self, value) (self)->f->indexOfSmallInt(self, value)
#define indexOfSmallIntG indexOfSmallIntO
-#define binarySearchUndefinedO(self, undefined) (self)->f->binarySearchUndefined(self, undefined)
+#define binarySearchUndefinedO(self, u) (self)->f->binarySearchUndefined(self, u)
#define binarySearchUndefinedG binarySearchUndefinedO
#define binarySearchBoolO(self, value) (self)->f->binarySearchBool(self, value)
@@ -7861,6 +7888,9 @@ void finishManyOF(void *paramType, ...);
#define binarySearchArraycO(self, array) (self)->f->binarySearchArrayc(self, array)
#define binarySearchArraycG binarySearchArraycO
+#define binarySearchCArraycO(self, array) (self)->f->binarySearchCArrayc(self, array)
+#define binarySearchCArraycG binarySearchCArraycO
+
#define binarySearchSmallBoolO(self, value) (self)->f->binarySearchSmallBool(self, value)
#define binarySearchSmallBoolG binarySearchSmallBoolO
@@ -7891,6 +7921,9 @@ void finishManyOF(void *paramType, ...);
#define icHasArraycO(self, array) (self)->f->icHasArrayc(self, array)
#define icHasArraycG icHasArraycO
+#define icHasCArraycO(self, array) (self)->f->icHasCArrayc(self, array)
+#define icHasCArraycG icHasCArraycO
+
#define icIndexOfSO(self, string) (self)->f->icIndexOfS(self, string)
#define icIndexOfSG icIndexOfSO
@@ -7906,6 +7939,9 @@ void finishManyOF(void *paramType, ...);
#define icIndexOfArraycO(self, array) (self)->f->icIndexOfArrayc(self, array)
#define icIndexOfArraycG icIndexOfArraycO
+#define icIndexOfCArraycO(self, array) (self)->f->icIndexOfCArrayc(self, array)
+#define icIndexOfCArraycG icIndexOfCArraycO
+
#define icBinarySearchSO(self, string) (self)->f->icBinarySearchS(self, string)
#define icBinarySearchSG icBinarySearchSO
@@ -7921,6 +7957,9 @@ void finishManyOF(void *paramType, ...);
#define icBinarySearchArraycO(self, array) (self)->f->icBinarySearchArrayc(self, array)
#define icBinarySearchArraycG icBinarySearchArraycO
+#define icBinarySearchCArraycO(self, array) (self)->f->icBinarySearchCArrayc(self, array)
+#define icBinarySearchCArraycG icBinarySearchCArraycO
+
#define icBinarySearchSmallStringO(self, string) (self)->f->icBinarySearchSmallString(self, string)
#define icBinarySearchSmallStringG icBinarySearchSmallStringO
@@ -7981,25 +8020,25 @@ void finishManyOF(void *paramType, ...);
#define zipArrayO(self, array1, array2) (self)->f->zipArray(self, array1, array2)
#define zipArrayG zipArrayO
-#define zipCArrayO(self, a1, array2) (self)->f->zipCArray(self, a1, array2)
+#define zipCArrayO(self, array1, array2) (self)->f->zipCArray(self, array1, array2)
#define zipCArrayG zipCArrayO
#define zipCharO(self, array1, array2) (self)->f->zipChar(self, array1, array2)
#define zipCharG zipCharO
-#define zipCCharO(self, array1, a2) (self)->f->zipCChar(self, array1, a2)
+#define zipCCharO(self, array1, array2) (self)->f->zipCChar(self, array1, array2)
#define zipCCharG zipCCharO
#define zipArrayCharO(self, array1, array2) (self)->f->zipArrayChar(self, array1, array2)
#define zipArrayCharG zipArrayCharO
-#define zipCArrayCharO(self, a1, array2) (self)->f->zipCArrayChar(self, a1, array2)
+#define zipCArrayCharO(self, array1, array2) (self)->f->zipCArrayChar(self, array1, array2)
#define zipCArrayCharG zipCArrayCharO
-#define zipArrayCCharO(self, array1, a2) (self)->f->zipArrayCChar(self, array1, a2)
+#define zipArrayCCharO(self, array1, array2) (self)->f->zipArrayCChar(self, array1, array2)
#define zipArrayCCharG zipArrayCCharO
-#define zipCArrayCCharO(self, a1, a2) (self)->f->zipCArrayCChar(self, a1, a2)
+#define zipCArrayCCharO(self, array1, array2) (self)->f->zipCArrayCChar(self, array1, array2)
#define zipCArrayCCharG zipCArrayCCharO
#define readTextSmallStringO(self, filePath) (self)->f->readTextSmallString(self, filePath)
@@ -8176,6 +8215,9 @@ void finishManyOF(void *paramType, ...);
#define setArraycO(self, key, array) (self)->f->setArrayc(self, key, array)
#define setArraycG setArraycO
+#define setCArraycO(self, key, array) (self)->f->setCArrayc(self, key, array)
+#define setCArraycG setCArraycO
+
#define setSmallBytesO(self, key, value) (self)->f->setSmallBytes(self, key, value)
#define setSmallBytesG setSmallBytesO
@@ -8209,6 +8251,9 @@ void finishManyOF(void *paramType, ...);
#define setArraycKCharO(self, key, array) (self)->f->setArraycKChar(self, key, array)
#define setArraycKCharG setArraycKCharO
+#define setCArraycKCharO(self, key, array) (self)->f->setCArraycKChar(self, key, array)
+#define setCArraycKCharG setCArraycKCharO
+
#define setSmallBoolKCharO(self, key, value) (self)->f->setSmallBoolKChar(self, key, value)
#define setSmallBoolKCharG setSmallBoolKCharO
@@ -8239,7 +8284,7 @@ void finishManyOF(void *paramType, ...);
#define setNFreeKCharO(self, key, value) (self)->f->setNFreeKChar(self, key, value)
#define setNFreeKCharG setNFreeKCharO
-#define setNFreeUndefinedKCharO(self, key, undefined) (self)->f->setNFreeUndefinedKChar(self, key, undefined)
+#define setNFreeUndefinedKCharO(self, key, u) (self)->f->setNFreeUndefinedKChar(self, key, u)
#define setNFreeUndefinedKCharG setNFreeUndefinedKCharO
#define setNFreeSKCharO(self, key, string) (self)->f->setNFreeSKChar(self, key, string)
@@ -8452,7 +8497,7 @@ void finishManyOF(void *paramType, ...);
#define hasKCharO(self, key) (self)->f->hasKChar(self, key)
#define hasKCharG hasKCharO
-#define keyByUndefinedO(self, undefined) (self)->f->keyByUndefined(self, undefined)
+#define keyByUndefinedO(self, u) (self)->f->keyByUndefined(self, u)
#define keyByUndefinedG keyByUndefinedO
#define keyByBoolO(self, value) (self)->f->keyByBool(self, value)
@@ -8479,6 +8524,9 @@ void finishManyOF(void *paramType, ...);
#define keyByArraycO(self, array) (self)->f->keyByArrayc(self, array)
#define keyByArraycG keyByArraycO
+#define keyByCArraycO(self, array) (self)->f->keyByCArrayc(self, array)
+#define keyByCArraycG keyByCArraycO
+
#define keyBySmallBoolO(self, value) (self)->f->keyBySmallBool(self, value)
#define keyBySmallBoolG keyBySmallBoolO
@@ -8512,6 +8560,9 @@ void finishManyOF(void *paramType, ...);
#define icKeyByArraycO(self, array) (self)->f->icKeyByArrayc(self, array)
#define icKeyByArraycG icKeyByArraycO
+#define icKeyByCArraycO(self, array) (self)->f->icKeyByCArrayc(self, array)
+#define icKeyByCArraycG icKeyByCArraycO
+
#define icKeyBySmallStringO(self, string) (self)->f->icKeyBySmallString(self, string)
#define icKeyBySmallStringG icKeyBySmallStringO
@@ -8539,12 +8590,27 @@ void finishManyOF(void *paramType, ...);
#define zipSmallJsonVArrayO(self, keys, values) (self)->f->zipSmallJsonVArray(self, keys, values)
#define zipSmallJsonVArrayG zipSmallJsonVArrayO
+#define zipSmallJsonVCArrayO(self, keys, values) (self)->f->zipSmallJsonVCArray(self, keys, values)
+#define zipSmallJsonVCArrayG zipSmallJsonVCArrayO
+
#define zipArrayArrayO(self, keys, values) (self)->f->zipArrayArray(self, keys, values)
#define zipArrayArrayG zipArrayArrayO
+#define zipCArrayArrayO(self, keys, values) (self)->f->zipCArrayArray(self, keys, values)
+#define zipCArrayArrayG zipCArrayArrayO
+
+#define zipArrayCArrayO(self, keys, values) (self)->f->zipArrayCArray(self, keys, values)
+#define zipArrayCArrayG zipArrayCArrayO
+
+#define zipCArrayCArrayO(self, keys, values) (self)->f->zipCArrayCArray(self, keys, values)
+#define zipCArrayCArrayG zipCArrayCArrayO
+
#define zipVArrayO(self, keys, values) (self)->f->zipVArray(self, keys, values)
#define zipVArrayG zipVArrayO
+#define zipVCArrayO(self, keys, values) (self)->f->zipVCArray(self, keys, values)
+#define zipVCArrayG zipVCArrayO
+
#define toArrayO(self) (self)->f->toArray(self)
#define toArrayG toArrayO
@@ -8608,6 +8674,9 @@ void finishManyOF(void *paramType, ...);
#define setTopArraycO(self, value) (self)->f->setTopArrayc(self, value)
#define setTopArraycG setTopArraycO
+#define setTopCArraycO(self, value) (self)->f->setTopCArrayc(self, value)
+#define setTopCArraycG setTopCArraycO
+
#define setTopSmallBoolO(self, value) (self)->f->setTopSmallBool(self, value)
#define setTopSmallBoolG setTopSmallBoolO
@@ -10407,7 +10476,7 @@ char *listGetCG(const char **list, int retType UNUSED, int64_t index);
* call iListGetS for getG
*/
char *iListGetG(char **list, int retType UNUSED, int64_t index);
-char *iListGetCG(const char **list, int retType UNUSED, int64_t index);
+const char *iListGetCG(const char **list, int retType UNUSED, int64_t index);
/**
* call listPopS for popG
@@ -10458,7 +10527,7 @@ bool equalChaDoubleG(char c, double value);
bool equalChaInt64G(char c, int64_t value);
bool equalChaInt32G(char c, int32_t value);
bool equalChaUint32G(char c, uint32_t value);
-bool equalChaUint64G(char c, uint32_t value);
+bool equalChaUint64G(char c, uint64_t value);
bool equalChaSmallBytesG(char c, smallBytest* value);
bool equalChaSmallDoubleG(char c, smallDoublet* value);
bool equalChaSmallIntG(char c, smallIntt* value);
diff --git a/src/libsheepySmall.c b/src/libsheepySmall.c
@@ -66,11 +66,11 @@ char* sUndefinedToStringTiny(sUndefinedt* obj UNUSED);
char* sBytesToStringTiny(sBytest* obj);
char* sTypesTiny(smallt* obj);
sBytest* sTypesToBytesTiny(smallt *obj);
-char** sDictTypeStrings(sDictt* obj);
-char ** sTypesToStrings(sBytest *types);
+const char** sDictTypeStrings(sDictt* obj);
+const char ** sTypesToStrings(sBytest *types);
sBytest* sDictTypes(sDictt* obj);
sBytest* sDictTypesTiny(sDictt* obj);
-char** sArrayTypeStrings(sArrayt* obj);
+const char** sArrayTypeStrings(sArrayt* obj);
sBytest* sArrayTypes(sArrayt* obj);
sBytest* sArrayTypesTiny(sArrayt* obj);
smallt* sDictGet(sDictt *dict, const char *key);
@@ -199,6 +199,8 @@ size_t sSizeTiny(smallt *obj) {
r = sizeof(sBytest) + sizeof(char) * (((sBytest* )obj)->count - 1);
}
break;
+ default:;
+ // return 0
}
return(r);
}
@@ -535,6 +537,8 @@ smallt* sDuplicateTiny(smallt *obj) {
}
r = (smallt *) B;
break;
+ default:
+ logME(libsheepyErrorMask, "Unsupported object type.");
}
return(r);
}
@@ -625,6 +629,8 @@ char* sToStringTiny(smallt *obj) {
case BYTES:
r = sBytesToStringTiny((sBytest* )obj);
break;
+ default:
+ logME(libsheepyErrorMask, "Unsupported object type.");
}
return(r);
}
@@ -703,32 +709,32 @@ char* sDictToStringTiny(sDictt* obj) {
forEachSDict(obj, e) {
if (e->key) {
hasAtLeastOneElement = yes;
- iAppendS(&r, "\"");
- iAppendS(&r, e->key);
- iAppendS(&r, "\"");
+ pErrorNULL(iAppendS(&r, "\""));
+ pErrorNULL(iAppendS(&r, e->key));
+ pErrorNULL(iAppendS(&r, "\""));
if (isSType(e->data, STRING) || isSType(e->data, CONTAINER)) {
// add quotes for strings
- iAppendS(&r, ":\"");
+ pErrorNULL(iAppendS(&r, ":\""));
s = sToStringTiny(e->data);
- iAppendS(&r, s);
+ pErrorNULL(iAppendS(&r, s));
free(s);
- iAppendS(&r, "\",");
+ pErrorNULL(iAppendS(&r, "\","));
}
else {
- iAppendS(&r, ":");
+ pErrorNULL(iAppendS(&r, ":"));
s = sToStringTiny(e->data);
- iAppendS(&r, s);
+ pErrorNULL(iAppendS(&r, s));
free(s);
- iAppendS(&r, ",");
+ pErrorNULL(iAppendS(&r, ","));
}
}
}
if (hasAtLeastOneElement) {
- setS(r, -1, '}');
+ pErrorNULL(setS(r, -1, '}'));
}
else {
- iAppendS(&r, "}");
+ pErrorNULL(iAppendS(&r, "}"));
}
return(r);
}
@@ -816,24 +822,24 @@ char* sArrayToStringTiny(sArrayt* obj) {
cnt++;
if (isSType(o, STRING) || isSType(o, CONTAINER)) {
// add quotes for strings
- iAppendS(&r, "\"");
+ pErrorNULL(iAppendS(&r, "\""));
s = sToStringTiny(o);
- iAppendS(&r, s);
+ pErrorNULL(iAppendS(&r, s));
free(s);
- iAppendS(&r, "\"");
+ pErrorNULL(iAppendS(&r, "\""));
}
else {
s = sToStringTiny(o);
- iAppendS(&r, s);
+ pErrorNULL(iAppendS(&r, s));
free(s);
}
- iAppendS(&r, ",");
+ pErrorNULL(iAppendS(&r, ","));
}
if (!cnt && emptySlot) {
- iAppendS(&r, "]");
+ pErrorNULL(iAppendS(&r, "]"));
}
else {
- setS(r, -1, ']');
+ pErrorNULL(setS(r, -1, ']'));
}
return(r);
}
@@ -870,8 +876,8 @@ char* sBytesToStringTiny(sBytest* obj) {
}
char *r = toHexSepS(&(obj->data), obj->count, ",");
- iPrependS(&r, "[");
- iAppendS(&r, "]");
+ pErrorNULL(iPrependS(&r, "["));
+ pErrorNULL(iAppendS(&r, "]"));
return(r);
}
@@ -936,6 +942,7 @@ sBytest* sTypesToBytesTiny(smallt *obj) {
case ARRAY:
r = sArrayTypesTiny((sArrayt *) obj);;
break;
+ default:;
}
return(r);
}
@@ -950,7 +957,7 @@ sBytest* sTypesToBytesTiny(smallt *obj) {
* \return
* list of strings representing the types
*/
-char** sDictTypeStrings(sDictt* obj) {
+const char** sDictTypeStrings(sDictt* obj) {
sBytest *types = sDictTypes(obj);
@@ -966,8 +973,8 @@ char** sDictTypeStrings(sDictt* obj) {
* list of strings representing the object types, use free to free the list (not listFreeS)
* NULL error, types is not freed
*/
-char ** sTypesToStrings(sBytest *types) {
- char **r = NULL;
+const char ** sTypesToStrings(sBytest *types) {
+ const char **r = NULL;
if (!types) {
return(NULL);
@@ -982,7 +989,7 @@ char ** sTypesToStrings(sBytest *types) {
free(r);
return(NULL);
}
- r[i] = (char *)SMALL_TYPE_NAMES[(size_t) b];
+ r[i] = SMALL_TYPE_NAMES[(size_t) b];
}
free(types);
@@ -1037,7 +1044,7 @@ sBytest* sDictTypesTiny(sDictt* obj) {
* \return
* list of strings representing the types
*/
-char** sArrayTypeStrings(sArrayt* obj) {
+const char** sArrayTypeStrings(sArrayt* obj) {
sBytest *types = sArrayTypes(obj);
@@ -1817,7 +1824,7 @@ sBytest *sSerialTiny(smallt *obj) {
break;
case STRING:
sBytesPush(&r, obj->type);
- sBytesPushBuffer(&r, &((sStringt *)&(obj->type))->data, sizeof(sStringt) + strlen(&(((sStringt *)&(obj->type))->data)) -1);
+ sBytesPushBuffer(&r, &((sStringt *)&(obj->type))->data, (uint32_t)sizeof(sStringt) + (uint32_t)strlen(&(((sStringt *)&(obj->type))->data)) -1);
break;
case ARRAY:
sArraySerialElementsTiny(&r, (sArrayt *)&(obj->type));
@@ -1828,6 +1835,8 @@ sBytest *sSerialTiny(smallt *obj) {
sBytesPushBuffer(&r, &(B->count), sizeof(uint32_t));
sBytesPushBuffer(&r, &(B->data), B->count);
break;
+ default:
+ logME(libsheepyErrorMask, "Unsupported object type.");
}
return(r);
}
@@ -1852,7 +1861,7 @@ void sDictSerialElementsTiny(sBytest **r, sDictt *dict) {
forEachSDict(dict, e) {
if (e->key) {
- sBytesPushBuffer(r, e->key, strlen(e->key) + 1);
+ sBytesPushBuffer(r, e->key, (uint32_t)strlen(e->key) + 1);
sBytesPush(r, e->data->type);
switch(e->data->type) {
@@ -1876,7 +1885,7 @@ void sDictSerialElementsTiny(sBytest **r, sDictt *dict) {
sBytesPushBuffer(r, &((sIntt *)(e->data))->value, sizeof(int64_t));
break;
case STRING:
- sBytesPushBuffer(r, &((sStringt *)(e->data))->data, sizeof(sStringt) + strlen(&(((sStringt *)(e->data))->data)) -1);
+ sBytesPushBuffer(r, &((sStringt *)(e->data))->data, (uint32_t)sizeof(sStringt) + (uint32_t)strlen(&(((sStringt *)(e->data))->data)) -1);
break;
case ARRAY:
// decrease to overwrite the e->type since sDictSerialElementsTiny stores the type
@@ -1889,6 +1898,8 @@ void sDictSerialElementsTiny(sBytest **r, sDictt *dict) {
sBytesPushBuffer(r, &(B->count), sizeof(uint32_t));
sBytesPushBuffer(r, &(B->data), B->count);
break;
+ default:
+ logME(libsheepyErrorMask, "Unsupported object type.");
}
}
}
@@ -1942,7 +1953,7 @@ void sArraySerialElementsTiny(sBytest **r, sArrayt *array) {
sBytesPushBuffer(r, &((sIntt *)e)->value, sizeof(int64_t));
break;
case STRING:
- sBytesPushBuffer(r, &((sStringt *)e)->data, sizeof(sStringt) + strlen(&(((sStringt *)e)->data)) -1);
+ sBytesPushBuffer(r, &((sStringt *)e)->data, (uint32_t)sizeof(sStringt) + (uint32_t)strlen(&(((sStringt *)e)->data)) -1);
break;
case ARRAY:
// decrease to overwrite the e->type since sDictSerialElementsTiny stores the type
@@ -1955,6 +1966,8 @@ void sArraySerialElementsTiny(sBytest **r, sArrayt *array) {
sBytesPushBuffer(r, &(B->count), sizeof(uint32_t));
sBytesPushBuffer(r, &(B->data), B->count);
break;
+ default:
+ logME(libsheepyErrorMask, "Unsupported object type.");
}
}
}
@@ -2041,6 +2054,8 @@ smallt* sDeserialTiny(sBytest *obj) {
sBytesPushBuffer(&B, s, *count);
r = (smallt *)B;
break;
+ default:
+ logME(libsheepyErrorMask, "Unsupported object type.");
}
return(r);
@@ -2141,6 +2156,8 @@ void sDictDeserialElementsTiny(sDictt **dict, char **data) {
sBytesPushBuffer(&B, s, *count);
sDictPushTiny(dict, key, (smallt *) B);
break;
+ default:
+ logME(libsheepyErrorMask, "Unsupported object type.");
}
}
}
@@ -2237,6 +2254,8 @@ void sArrayDeserialElementsTiny(sArrayt **array, char **data) {
sBytesPushBuffer(&B, s, *count);
sArrayPushTiny(array, (smallt *) B);
break;
+ default:
+ logME(libsheepyErrorMask, "Unsupported object type.");
}
}
}
diff --git a/src/libsheepySmall.h b/src/libsheepySmall.h
@@ -209,51 +209,51 @@ bool isSTypeF(smallt *obj, char sType);
size_t sSizeTiny(smallt *obj);
-sBoolt* allocSBool(bool value);
-sContainert* allocSContainer(void *data);
-sDictt* allocSDict(void);
-sDoublet* allocSDouble(double value);
-sIntt* allocSInt(int64_t value);
-sStringt* allocSStringTiny(const char* data);
-sArrayt* allocSArray(void);
-sUndefinedt* allocSUndefined(void);
-sBytest* allocSBytes(void);
+sBoolt* allocSBool(bool value) MUST_CHECK;
+sContainert* allocSContainer(void *data) MUST_CHECK;
+sDictt* allocSDict(void) MUST_CHECK;
+sDoublet* allocSDouble(double value) MUST_CHECK;
+sIntt* allocSInt(int64_t value) MUST_CHECK;
+sStringt* allocSStringTiny(const char* data) MUST_CHECK;
+sArrayt* allocSArray(void) MUST_CHECK;
+sUndefinedt* allocSUndefined(void) MUST_CHECK;
+sBytest* allocSBytes(void) MUST_CHECK;
void sFree(smallt *obj);
void sFreeTiny(smallt *obj);
void sDictFreeTiny(sDictt *dict);
void sArrayFreeTiny(sArrayt *array);
-smallt* sDuplicate(smallt *o);
-smallt* sDuplicateTiny(smallt *obj);
-sDictt* sDictDuplicateTiny(sDictt *dict);
-sArrayt* sArrayDuplicateTiny(sArrayt *obj);
-
-char* sToStringTiny(smallt *obj);
-char* sToString(smallt *obj);
-char* sBoolToStringTiny(sBoolt* obj);
-char* sContainerToStringTiny(sContainert* obj);
-char* sDictToStringTiny(sDictt* obj);
-char* sDoubleToStringTiny(sDoublet* obj);
-char* sIntToStringTiny(sIntt* obj);
-char* sStringToStringTiny(sStringt* obj);
-char* sArrayToStringTiny(sArrayt* obj);
-char* sUndefinedToStringTiny(sUndefinedt* obj);
-char* sBytesToStringTiny(sBytest* obj);
-
-char* sTypesTiny(smallt* obj);
-sBytest* sTypesToBytesTiny(smallt *obj);
-char** sDictTypeStrings(sDictt* obj);
-sBytest* sDictTypes(sDictt* obj);
-sBytest* sDictTypesTiny(sDictt* obj);
-char** sArrayTypeStrings(sArrayt* obj);
-sBytest* sArrayTypes(sArrayt* obj);
-sBytest* sArrayTypesTiny(sArrayt* obj);
+smallt* sDuplicate(smallt *o) MUST_CHECK;
+smallt* sDuplicateTiny(smallt *obj) MUST_CHECK;
+sDictt* sDictDuplicateTiny(sDictt *dict) MUST_CHECK;
+sArrayt* sArrayDuplicateTiny(sArrayt *obj) MUST_CHECK;
+
+char* sToStringTiny(smallt *obj) MUST_CHECK;
+char* sToString(smallt *obj) MUST_CHECK;
+char* sBoolToStringTiny(sBoolt* obj) MUST_CHECK;
+char* sContainerToStringTiny(sContainert* obj) MUST_CHECK;
+char* sDictToStringTiny(sDictt* obj) MUST_CHECK;
+char* sDoubleToStringTiny(sDoublet* obj) MUST_CHECK;
+char* sIntToStringTiny(sIntt* obj) MUST_CHECK;
+char* sStringToStringTiny(sStringt* obj) MUST_CHECK;
+char* sArrayToStringTiny(sArrayt* obj) MUST_CHECK;
+char* sUndefinedToStringTiny(sUndefinedt* obj) MUST_CHECK;
+char* sBytesToStringTiny(sBytest* obj) MUST_CHECK;
+
+char* sTypesTiny(smallt* obj) MUST_CHECK;
+sBytest* sTypesToBytesTiny(smallt *obj) MUST_CHECK;
+const char** sDictTypeStrings(sDictt* obj) MUST_CHECK;
+sBytest* sDictTypes(sDictt* obj) MUST_CHECK;
+sBytest* sDictTypesTiny(sDictt* obj) MUST_CHECK;
+const char** sArrayTypeStrings(sArrayt* obj) MUST_CHECK;
+sBytest* sArrayTypes(sArrayt* obj) MUST_CHECK;
+sBytest* sArrayTypesTiny(sArrayt* obj) MUST_CHECK;
// forEach - loop macro on elements
#define forEachSDict(dict, element) \
sDictElemt *element = &((dict)->elements); \
- for (size_t libsheepyInternalIndex = 0; libsheepyInternalIndex < (dict)->count ; libsheepyInternalIndex++, element = libsheepyInternalIndex < (dict)->count ? &((dict)->elements) + libsheepyInternalIndex : NULL)
+ for (size_t UNIQVAR(libsheepyInternalIndex) = 0; UNIQVAR(libsheepyInternalIndex) < (dict)->count ; UNIQVAR(libsheepyInternalIndex)++, element = UNIQVAR(libsheepyInternalIndex) < (dict)->count ? &((dict)->elements) + UNIQVAR(libsheepyInternalIndex) : NULL)
#define enumerateSDict(dict, element, index) \
sDictElemt *element = &((dict)->elements); \
@@ -261,7 +261,7 @@ sBytest* sArrayTypesTiny(sArrayt* obj);
#define forEachSArray(array, element) \
smallt *element = ((smallt **) &((array)->data))[0]; \
- for (size_t libsheepyInternalIndex = 0; libsheepyInternalIndex < (array)->count ; libsheepyInternalIndex++, element = libsheepyInternalIndex < (array)->count ? ((smallt **) &((array)->data))[libsheepyInternalIndex] : NULL)
+ for (size_t UNIQVAR(libsheepyInternalIndex) = 0; UNIQVAR(libsheepyInternalIndex) < (array)->count ; UNIQVAR(libsheepyInternalIndex)++, element = UNIQVAR(libsheepyInternalIndex) < (array)->count ? ((smallt **) &((array)->data))[UNIQVAR(libsheepyInternalIndex)] : NULL)
#define enumerateSArray(array, element, index) \
smallt *element = ((smallt **) &((array)->data))[0]; \
@@ -269,45 +269,45 @@ sBytest* sArrayTypesTiny(sArrayt* obj);
// TODO forEachSBytes
-smallt* sDictGet(sDictt *dict, const char *key);
-smallt** sDictGetP(sDictt *dict, const char *key);
-smallt* sDictGetTiny(sDictt *dict, const char *key);
-smallt* sDictElemGet(sDictElemt *dictElement);
+smallt* sDictGet(sDictt *dict, const char *key) MUST_CHECK;
+smallt** sDictGetP(sDictt *dict, const char *key) MUST_CHECK;
+smallt* sDictGetTiny(sDictt *dict, const char *key) MUST_CHECK;
+smallt* sDictElemGet(sDictElemt *dictElement) MUST_CHECK;
void sDictSetP(sDictt **dict, const char *key, smallt *data);
void sDictSetTiny(sDictt **dict, const char *key, smallt *data);
void sDictPushTiny(sDictt **dict, const char *key, smallt *data);
void sDictDelTiny(sDictt *dict, const char *key);
-char* sStringGetTiny(sStringt *string);
+char* sStringGetTiny(sStringt *string) MUST_CHECK;
void sStringSetTiny(sStringt **string, const char *news);
void sArrayPushTiny(sArrayt **array, smallt* data);
void sArrayPrependTiny(sArrayt **array, smallt* data);
-smallt* sArrayPopTiny(sArrayt *array);
-smallt* sArrayDequeueTiny(sArrayt *array);
-smallt** sArrayGetP(sArrayt *array, uint32_t index);
-smallt* sArrayGetTiny(sArrayt *array, uint32_t index);
+smallt* sArrayPopTiny(sArrayt *array) MUST_CHECK;
+smallt* sArrayDequeueTiny(sArrayt *array) MUST_CHECK;
+smallt** sArrayGetP(sArrayt *array, uint32_t index) MUST_CHECK;
+smallt* sArrayGetTiny(sArrayt *array, uint32_t index) MUST_CHECK;
void sArraySetShortTiny(sArrayt *array, uint32_t index, smallt *value);
void sArraySetP(sArrayt *array, uint32_t index, smallt *value);
void sArraySetTiny(sArrayt *array, uint32_t index, smallt *value);
-int sArrayReverseTiny(sArrayt *array);
+int sArrayReverseTiny(sArrayt *array) MUST_CHECK;
void sArrayDelTiny(sArrayt *array, uint32_t index);
void sArrayDelRangeTiny(sArrayt *array, uint32_t start, uint32_t end);
// get void* from sBytes
-void* sBytesGet(sBytest *bytes);
-void* sBytesGetTiny(sBytest *bytes);
+void* sBytesGet(sBytest *bytes) MUST_CHECK;
+void* sBytesGetTiny(sBytest *bytes) MUST_CHECK;
void sBytesPush(sBytest **bytes, char data);
// function to copy data from void* to sBytes
void sBytesPushBuffer(sBytest **bytes, void* data, uint32_t size);
void sBytesPushBufferTiny(sBytest **bytes, void* data, uint32_t size);
// serialyzer/deserialyzer
-sBytest *sSerial(smallt *obj);
-sBytest *sSerialTiny(smallt *obj);
+sBytest *sSerial(smallt *obj) MUST_CHECK;
+sBytest *sSerialTiny(smallt *obj) MUST_CHECK;
void sDictSerialElementsTiny(sBytest **r, sDictt *dict);
void sArraySerialElementsTiny(sBytest **r, sArrayt *array);
-smallt* sDeserial(sBytest *obj);
-smallt* sDeserialTiny(sBytest *obj);
+smallt* sDeserial(sBytest *obj) MUST_CHECK;
+smallt* sDeserialTiny(sBytest *obj) MUST_CHECK;
void sDictDeserialElementsTiny(sDictt **dict, char **data);
void sArrayDeserialElementsTiny(sArrayt **array, char **data);
diff --git a/src/libsheepyTest.c b/src/libsheepyTest.c
@@ -1898,6 +1898,7 @@ START_TEST(readFileToST)
free(l);
// write only file
+ fileChmod("writeOnlyText.null", S_IWUSR | S_IWGRP | S_IWOTH);
ck_assert_ptr_eq(readFileToS("writeOnlyText.null"), NULL);
// blank path
@@ -2099,6 +2100,7 @@ START_TEST(readFileT)
free(l);
// write only file
+ fileChmod("writeOnlyText.null", S_IWUSR | S_IWGRP | S_IWOTH);
ck_assert_int_eq(readFile("writeOnlyText.null", (void **) &l), -1);
// blank path
diff --git a/src/runCuTest.sh b/src/runCuTest.sh
@@ -1,7 +1,7 @@
gcc -mrdrnd -DunitTest -g3 -std=gnu99 -Wall -Wextra -fprofile-arcs -ftest-coverage -pipe -c -o libsheepy.o libsheepy.c
gcc -mrdrnd -DunitTest -g3 -std=gnu99 -Wall -Wextra -fprofile-arcs -ftest-coverage -pipe -o libsheepyCuTest.o -c libsheepyCuTest.c
gcc -mrdrnd -DunitTest -g3 -std=gnu99 -Wall -Wextra -fprofile-arcs -ftest-coverage -pipe -c -o CuTest.o CuTest/CuTest.c
-gcc -o libsheepyCuTest libsheepyCuTest.o CuTest.o libsheepy.o -Wall -Wextra -pthread -rdynamic -fprofile-arcs -ftest-coverage
+gcc -o libsheepyCuTest libsheepyCuTest.o CuTest.o libsheepy.o -Wall -Wextra -pthread -rdynamic -fprofile-arcs -ftest-coverage
chmod 222 writeOnlyText.null
touch chmodTest.null
diff --git a/src/runSmallCuTest.sh b/src/runSmallCuTest.sh
@@ -1,3 +1,3 @@
-gcc -o libsheepySmallCuTest libsheepySmallCuTest.c CuTest/CuTest.c libsheepySmall.c ../release/libsheepy.c -mrdrnd -Wall -Wextra -pthread -rdynamic -fprofile-arcs -ftest-coverage
+rm -f libsheepySmallCuTest
+gcc -g3 -std=gnu99 -o libsheepySmallCuTest libsheepySmallCuTest.c CuTest/CuTest.c libsheepySmall.c ../release/libsheepy.c -mrdrnd -Wall -Wextra -pthread -rdynamic -fprofile-arcs -ftest-coverage
./libsheepySmallCuTest
-gcov -b libsheepySmall.c
diff --git a/src/tpool.c b/src/tpool.c
@@ -161,7 +161,7 @@ threadpool tpool_init(int num_threads){
}
/* Make threads in pool */
- tpool_p->threads = (struct thread**)malloc(num_threads * sizeof(struct thread *));
+ tpool_p->threads = (struct thread**)malloc((size_t)num_threads * sizeof(struct thread *));
if (tpool_p->threads == NULL){
err("tpool_init(): Could not allocate memory for threads\n");
jobqueue_destroy(&tpool_p->jobqueue);