diff options
-rw-r--r-- | .github/workflows/build.yml | 2 | ||||
-rw-r--r-- | .github/workflows/codeql-analysis.yml | 6 | ||||
-rw-r--r-- | NEWS | 14 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | cython/plist.pyx | 8 | ||||
-rw-r--r-- | include/plist/Data.h | 6 | ||||
-rw-r--r-- | include/plist/plist.h | 10 | ||||
-rw-r--r-- | src/Data.cpp | 12 | ||||
-rw-r--r-- | src/jplist.c | 6 | ||||
-rw-r--r-- | src/plist.c | 10 |
10 files changed, 46 insertions, 30 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 68948af..e2caf04 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,7 +50,7 @@ jobs: else brew install libtool autoconf automake fi - pip3 install cython + pip3 install --break-system-packages cython shell: bash - uses: actions/checkout@v4 with: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 9e02074..8f2384a 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -28,7 +28,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: # We must fetch at least the immediate parents so that if this is # a pull request then we can checkout the head. @@ -36,7 +36,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -50,4 +50,4 @@ jobs: make - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 @@ -1,3 +1,17 @@ +Version 2.6.0 +~~~~~~~~~~~~~ + +- Changes: + * Revert back API change around PLIST_DATA to use char* again + +Version 2.5.0 +~~~~~~~~~~~~~ + +- Changes: + * Change API around PLIST_DATA to use uint8_t* instead of char* + * Add PLIST_DICT helper functions for different operations + * Require Cython 3.0 for python bindings + Version 2.4.0 ~~~~~~~~~~~~~ diff --git a/configure.ac b/configure.ac index fe6592b..67a05bb 100644 --- a/configure.ac +++ b/configure.ac @@ -15,7 +15,7 @@ dnl libtool versioning # changes to the signature and the semantic) # ? :+1 : ? == just internal changes # CURRENT : REVISION : AGE -LIBPLIST_SO_VERSION=8:0:4 +LIBPLIST_SO_VERSION=10:0:6 AC_SUBST(LIBPLIST_SO_VERSION) diff --git a/cython/plist.pyx b/cython/plist.pyx index a16e7be..b5f4ef6 100644 --- a/cython/plist.pyx +++ b/cython/plist.pyx @@ -48,9 +48,9 @@ cdef extern from *: void plist_get_string_val(plist_t node, char **val) void plist_set_string_val(plist_t node, char *val) - plist_t plist_new_data(uint8_t *val, uint64_t length) - void plist_get_data_val(plist_t node, uint8_t **val, uint64_t * length) - void plist_set_data_val(plist_t node, uint8_t *val, uint64_t length) + plist_t plist_new_data(char *val, uint64_t length) + void plist_get_data_val(plist_t node, char **val, uint64_t * length) + void plist_set_data_val(plist_t node, char *val, uint64_t length) plist_t plist_new_null(); @@ -579,7 +579,7 @@ cdef class Data(Node): cpdef bytes get_value(self): cdef: - uint8_t* val = NULL + char* val = NULL uint64_t length = 0 plist_get_data_val(self._c_node, &val, &length) diff --git a/include/plist/Data.h b/include/plist/Data.h index 3f1c329..b566a6c 100644 --- a/include/plist/Data.h +++ b/include/plist/Data.h @@ -35,13 +35,13 @@ public : Data(plist_t node, Node* parent = NULL); Data(const Data& d); Data& operator=(const Data& b); - Data(const std::vector<uint8_t>& buff); + Data(const std::vector<char>& buff); virtual ~Data(); Node* Clone() const; - void SetValue(const std::vector<uint8_t>& buff); - std::vector<uint8_t> GetValue() const; + void SetValue(const std::vector<char>& buff); + std::vector<char> GetValue() const; }; }; diff --git a/include/plist/plist.h b/include/plist/plist.h index 7d5b4cb..aff81e9 100644 --- a/include/plist/plist.h +++ b/include/plist/plist.h @@ -258,7 +258,7 @@ extern "C" * @return the created item * @sa #plist_type */ - PLIST_API plist_t plist_new_data(const uint8_t *val, uint64_t length); + PLIST_API plist_t plist_new_data(const char *val, uint64_t length); /** * Create a new plist_t type #PLIST_DATE @@ -445,7 +445,7 @@ extern "C" PLIST_API void plist_dict_get_item_key(plist_t node, char **key); /** - * Get the item for given key in a #PLIST_DICT node. + * Get the nth item in a #PLIST_DICT node. * * @param node the node of type #PLIST_DICT * @param key the identifier of the item to get. @@ -755,7 +755,7 @@ extern "C" * @param length the length of the buffer * @note Use plist_mem_free() to free the allocated memory. */ - PLIST_API void plist_get_data_val(plist_t node, uint8_t **val, uint64_t * length); + PLIST_API void plist_get_data_val(plist_t node, char **val, uint64_t * length); /** * Get a pointer to the data buffer of a #PLIST_DATA node. @@ -768,7 +768,7 @@ extern "C" * * @return Pointer to the buffer */ - PLIST_API const uint8_t* plist_get_data_ptr(plist_t node, uint64_t* length); + PLIST_API const char* plist_get_data_ptr(plist_t node, uint64_t* length); /** * Get the value of a #PLIST_DATE node. @@ -860,7 +860,7 @@ extern "C" * be freed by the node. * @param length the length of the buffer */ - PLIST_API void plist_set_data_val(plist_t node, const uint8_t *val, uint64_t length); + PLIST_API void plist_set_data_val(plist_t node, const char *val, uint64_t length); /** * Set the value of a node. diff --git a/src/Data.cpp b/src/Data.cpp index c4709f7..a96fc50 100644 --- a/src/Data.cpp +++ b/src/Data.cpp @@ -34,7 +34,7 @@ Data::Data(plist_t node, Node* parent) : Node(node, parent) Data::Data(const PList::Data& d) : Node(PLIST_DATA) { - std::vector<uint8_t> b = d.GetValue(); + std::vector<char> b = d.GetValue(); plist_set_data_val(_node, &b[0], b.size()); } @@ -45,7 +45,7 @@ Data& Data::operator=(const PList::Data& b) return *this; } -Data::Data(const std::vector<uint8_t>& buff) : Node(PLIST_DATA) +Data::Data(const std::vector<char>& buff) : Node(PLIST_DATA) { plist_set_data_val(_node, &buff[0], buff.size()); } @@ -59,17 +59,17 @@ Node* Data::Clone() const return new Data(*this); } -void Data::SetValue(const std::vector<uint8_t>& buff) +void Data::SetValue(const std::vector<char>& buff) { plist_set_data_val(_node, &buff[0], buff.size()); } -std::vector<uint8_t> Data::GetValue() const +std::vector<char> Data::GetValue() const { - uint8_t* buff = NULL; + char* buff = NULL; uint64_t length = 0; plist_get_data_val(_node, &buff, &length); - std::vector<uint8_t> ret(buff, buff + length); + std::vector<char> ret(buff, buff + length); delete buff; return ret; } diff --git a/src/jplist.c b/src/jplist.c index 782d2b3..4f30cd0 100644 --- a/src/jplist.c +++ b/src/jplist.c @@ -460,6 +460,8 @@ static int64_t parse_decimal(const char* str, const char* str_end, char** endp) if (str[0] == '-') { is_neg = 1; (*endp)++; + } else if (str[0] == '+') { + (*endp)++; } if (is_neg) { MAX++; @@ -522,7 +524,7 @@ static plist_t parse_primitive(const char* js, jsmntok_info_t* ti, int* index) } else { val = plist_new_uint((uint64_t)intpart); } - } else if ((*endp == '.' && endp+1 < str_end && isdigit(*(endp+1))) || ((*endp == 'e' || *endp == 'E') && endp+1 < str_end && (isdigit(*(endp+1)) || ((*(endp+1) == '-') && endp+2 < str_end && isdigit(*(endp+2)))))) { + } else if ((*endp == '.' && endp+1 < str_end && isdigit(*(endp+1))) || ((*endp == 'e' || *endp == 'E') && endp+1 < str_end && (isdigit(*(endp+1)) || (((*(endp+1) == '-') || (*(endp+1) == '+')) && endp+2 < str_end && isdigit(*(endp+2)))))) { /* floating point */ double dval = (double)intpart; char* fendp = endp; @@ -546,7 +548,7 @@ static plist_t parse_primitive(const char* js, jsmntok_info_t* ti, int* index) if (fendp >= str_end) { break; } - if (fendp+1 < str_end && (*fendp == 'e' || *fendp == 'E') && (isdigit(*(fendp+1)) || ((*(fendp+1) == '-') && fendp+2 < str_end && isdigit(*(fendp+2))))) { + if (fendp+1 < str_end && (*fendp == 'e' || *fendp == 'E') && (isdigit(*(fendp+1)) || (((*(fendp+1) == '-') || (*(fendp+1) == '+')) && fendp+2 < str_end && isdigit(*(fendp+2))))) { int64_t exp = parse_decimal(fendp+1, str_end, &fendp); dval = dval * pow(10, (double)exp); } else { diff --git a/src/plist.c b/src/plist.c index d1b0b5a..a425466 100644 --- a/src/plist.c +++ b/src/plist.c @@ -544,7 +544,7 @@ plist_t plist_new_real(double val) return plist_new_node(data); } -plist_t plist_new_data(const uint8_t *val, uint64_t length) +plist_t plist_new_data(const char *val, uint64_t length) { plist_data_t data = plist_new_plist_data(); data->type = PLIST_DATA; @@ -1385,7 +1385,7 @@ void plist_get_real_val(plist_t node, double *val) assert(length == sizeof(double)); } -void plist_get_data_val(plist_t node, uint8_t **val, uint64_t * length) +void plist_get_data_val(plist_t node, char **val, uint64_t * length) { if (!node || !val || !length) return; @@ -1395,7 +1395,7 @@ void plist_get_data_val(plist_t node, uint8_t **val, uint64_t * length) plist_get_type_and_value(node, &type, (void *) val, length); } -const uint8_t* plist_get_data_ptr(plist_t node, uint64_t* length) +const char* plist_get_data_ptr(plist_t node, uint64_t* length) { if (!node || !length) return NULL; @@ -1404,7 +1404,7 @@ const uint8_t* plist_get_data_ptr(plist_t node, uint64_t* length) return NULL; plist_data_t data = plist_get_data(node); *length = data->length; - return data->buff; + return (const char*)data->buff; } void plist_get_date_val(plist_t node, int32_t * sec, int32_t * usec) @@ -1575,7 +1575,7 @@ void plist_set_real_val(plist_t node, double val) plist_set_element_val(node, PLIST_REAL, &val, sizeof(double)); } -void plist_set_data_val(plist_t node, const uint8_t *val, uint64_t length) +void plist_set_data_val(plist_t node, const char *val, uint64_t length) { plist_set_element_val(node, PLIST_DATA, val, length); } |