diff -r 38b051dea6b1 -r db8299984bfe src/cx/string.h --- a/src/cx/string.h Mon Dec 22 15:28:07 2025 +0100 +++ b/src/cx/string.h Mon Dec 22 15:47:59 2025 +0100 @@ -703,18 +703,86 @@ /** * Splits a given string using a delimiter string. * - * @note The resulting array contains strings that point to the source - * @p string. Use cx_strdup() to get copies. + * Internal function - do not use. + * + * @param string the string to split + * @param delim the delimiter + * @param limit the maximum number of split items + * @param output the output array + * @return the actual number of split items + * @see cx_strsplit() + */ +cx_attr_nodiscard cx_attr_nonnull cx_attr_access_w(4, 3) +CX_EXPORT size_t cx_strsplit_(cxstring string, cxstring delim, + size_t limit, cxstring *output); + +/** + * Splits a given string using a delimiter string. + * + * Internal function - do not use. + * + * @param allocator the allocator to use for allocating the resulting array + * @param string the string to split + * @param delim the delimiter + * @param limit the maximum number of split items + * @param output the output array + * @return the actual number of split items + * @see cx_strsplit_a() + */ +cx_attr_nodiscard cx_attr_nonnull cx_attr_access_w(5) +CX_EXPORT size_t cx_strsplit_a_(const CxAllocator *allocator, + cxstring string, cxstring delim, + size_t limit, cxstring **output); + + +/** + * Splits a given string using a delimiter string. + * + * Internal function - do not use. * * @param string the string to split * @param delim the delimiter * @param limit the maximum number of split items - * @param output a preallocated array of at least @p limit length + * @param output the output array + * @return the actual number of split items + * @see cx_strsplit_m() + */ +cx_attr_nodiscard cx_attr_nonnull cx_attr_access_w(4, 3) +CX_EXPORT size_t cx_strsplit_m_(cxmutstr string, cxstring delim, + size_t limit, cxmutstr *output); + +/** + * Splits a given string using a delimiter string. + * + * Internal function - do not use. + * + * @param allocator the allocator to use for allocating the resulting array + * @param string the string to split + * @param delim the delimiter + * @param limit the maximum number of split items + * @param output the output array + * @return the actual number of split items + * @see cx_strsplit_ma() + */ +cx_attr_nodiscard cx_attr_nonnull cx_attr_access_w(5) +CX_EXPORT size_t cx_strsplit_ma_(const CxAllocator *allocator, + cxmutstr string, cxstring delim, size_t limit, + cxmutstr **output); + +/** + * Splits a given string using a delimiter string. + * + * @note The resulting array contains strings that point to the source + * @p string. Use cx_strdup() to get copies. + * + * @param string (@c cxstring) the string to split + * @param delim the delimiter + * @param limit (@c size_t) the maximum number of split items + * @param output (@c cxstring*) a preallocated array of at least @p limit length * @return the actual number of split items */ -cx_attr_nodiscard cx_attr_nonnull cx_attr_access_w(4, 3) -CX_EXPORT size_t cx_strsplit(cxstring string, cxstring delim, - size_t limit, cxstring *output); +#define cx_strsplit(string, delim, limit, output) \ + cx_strsplit_(string, cx_strcast(delim), limit, output) /** * Splits a given string using a delimiter string. @@ -727,18 +795,16 @@ * @attention If allocation fails, the @c NULL pointer will be written to * @p output and the number returned will be zero. * - * @param allocator the allocator to use for allocating the resulting array - * @param string the string to split + * @param allocator (@c CxAllocator*) the allocator to use for allocating the resulting array + * @param string (@c cxstring) the string to split * @param delim the delimiter - * @param limit the maximum number of split items - * @param output a pointer where the address of the allocated array shall be - * written to + * @param limit (@c size_t) the maximum number of split items + * @param output (@c cxstring**) a pointer where the address of the allocated + * array shall be written to * @return the actual number of split items */ -cx_attr_nodiscard cx_attr_nonnull cx_attr_access_w(5) -CX_EXPORT size_t cx_strsplit_a(const CxAllocator *allocator, - cxstring string, cxstring delim, - size_t limit, cxstring **output); +#define cx_strsplit_a(allocator, string, delim, limit, output) \ + cx_strsplit_a_(allocator, string, cx_strcast(delim), limit, output) /** @@ -747,15 +813,14 @@ * @note The resulting array contains strings that point to the source * @p string. Use cx_strdup() to get copies. * - * @param string the string to split + * @param string (@c cxmutstr) the string to split * @param delim the delimiter - * @param limit the maximum number of split items - * @param output a preallocated array of at least @p limit length + * @param limit (@c size_t) the maximum number of split items + * @param output (@c cxmutstr*) a preallocated array of at least @p limit length * @return the actual number of split items */ -cx_attr_nodiscard cx_attr_nonnull cx_attr_access_w(4, 3) -CX_EXPORT size_t cx_strsplit_m(cxmutstr string, cxstring delim, - size_t limit, cxmutstr *output); +#define cx_strsplit_m(string, delim, limit, output) \ + cx_strsplit_m_(string, cx_strcast(delim), limit, output) /** * Splits a given string using a delimiter string. @@ -768,18 +833,16 @@ * @attention If allocation fails, the @c NULL pointer will be written to * @p output and the number returned will be zero. * - * @param allocator the allocator to use for allocating the resulting array - * @param string the string to split + * @param allocator (@c CxAllocator*) the allocator to use for allocating the resulting array + * @param string (@c cxmutstr) the string to split * @param delim the delimiter - * @param limit the maximum number of split items - * @param output a pointer where the address of the allocated array shall be - * written to + * @param limit (@c size_t) the maximum number of split items + * @param output (@c cxmutstr**) a pointer where the address of the allocated + * array shall be written to * @return the actual number of split items */ -cx_attr_nodiscard cx_attr_nonnull cx_attr_access_w(5) -CX_EXPORT size_t cx_strsplit_ma(const CxAllocator *allocator, - cxmutstr string, cxstring delim, size_t limit, - cxmutstr **output); +#define cx_strsplit_ma(allocator, string, delim, limit, output) \ + cx_strsplit_ma_(allocator, string, cx_strcast(delim), limit, output) /** * Compares two strings.