ucx/cx/string.h

changeset 854
1c8401ece69e
parent 852
83fdf679df99
child 855
6740836b7a1e
--- a/ucx/cx/string.h	Mon Jan 06 21:18:56 2025 +0100
+++ b/ucx/cx/string.h	Sun Feb 23 13:11:32 2025 +0100
@@ -42,6 +42,7 @@
 /**
  * The maximum length of the "needle" in cx_strstr() that can use SBO.
  */
+cx_attr_export
 extern const unsigned cx_strstr_sbo_size;
 
 /**
@@ -51,7 +52,6 @@
     /**
      * A pointer to the string.
      * @note The string is not necessarily @c NULL terminated.
-     * Always use the length.
      */
     char *ptr;
     /** The length of the string */
@@ -70,7 +70,6 @@
     /**
      * A pointer to the immutable string.
      * @note The string is not necessarily @c NULL terminated.
-     * Always use the length.
      */
     const char *ptr;
     /** The length of the string */
@@ -175,6 +174,7 @@
 cx_attr_nonnull
 cx_attr_nodiscard
 cx_attr_cstr_arg(1)
+cx_attr_export
 cxmutstr cx_mutstr(char *cstring);
 
 /**
@@ -195,6 +195,7 @@
  */
 cx_attr_nodiscard
 cx_attr_access_rw(1, 2)
+cx_attr_export
 cxmutstr cx_mutstrn(
         char *cstring,
         size_t length
@@ -218,6 +219,7 @@
 cx_attr_nonnull
 cx_attr_nodiscard
 cx_attr_cstr_arg(1)
+cx_attr_export
 cxstring cx_str(const char *cstring);
 
 
@@ -239,6 +241,7 @@
  */
 cx_attr_nodiscard
 cx_attr_access_r(1, 2)
+cx_attr_export
 cxstring cx_strn(
         const char *cstring,
         size_t length
@@ -298,7 +301,8 @@
 /**
  * Passes the pointer in this string to @c free().
  *
- * The pointer in the struct is set to @c NULL and the length is set to zero.
+ * The pointer in the struct is set to @c NULL and the length is set to zero
+ * which means that this function protects you against double-free.
  *
  * @note There is no implementation for cxstring, because it is unlikely that
  * you ever have a <code>const char*</code> you are really supposed to free.
@@ -306,12 +310,14 @@
  *
  * @param str the string to free
  */
+cx_attr_export
 void cx_strfree(cxmutstr *str);
 
 /**
  * Passes the pointer in this string to the allocators free function.
  *
- * The pointer in the struct is set to @c NULL and the length is set to zero.
+ * The pointer in the struct is set to @c NULL and the length is set to zero
+ * which means that this function protects you against double-free.
  *
  * @note There is no implementation for cxstring, because it is unlikely that
  * you ever have a <code>const char*</code> you are really supposed to free.
@@ -321,6 +327,7 @@
  * @param str the string to free
  */
 cx_attr_nonnull_arg(1)
+cx_attr_export
 void cx_strfree_a(
         const CxAllocator *alloc,
         cxmutstr *str
@@ -339,6 +346,7 @@
  * @return the accumulated length of all strings
  */
 cx_attr_nodiscard
+cx_attr_export
 size_t cx_strlen(
         size_t count,
         ...
@@ -368,6 +376,7 @@
  */
 cx_attr_nodiscard
 cx_attr_nonnull
+cx_attr_export
 cxmutstr cx_strcat_ma(
         const CxAllocator *alloc,
         cxmutstr str,
@@ -456,6 +465,7 @@
  * @see cx_strsubsl_m()
  */
 cx_attr_nodiscard
+cx_attr_export
 cxstring cx_strsubs(
         cxstring string,
         size_t start
@@ -481,6 +491,7 @@
  * @see cx_strsubsl_m()
  */
 cx_attr_nodiscard
+cx_attr_export
 cxstring cx_strsubsl(
         cxstring string,
         size_t start,
@@ -503,6 +514,7 @@
  * @see cx_strsubsl()
  */
 cx_attr_nodiscard
+cx_attr_export
 cxmutstr cx_strsubs_m(
         cxmutstr string,
         size_t start
@@ -528,6 +540,7 @@
  * @see cx_strsubsl()
  */
 cx_attr_nodiscard
+cx_attr_export
 cxmutstr cx_strsubsl_m(
         cxmutstr string,
         size_t start,
@@ -547,6 +560,7 @@
  * @see cx_strchr_m()
  */
 cx_attr_nodiscard
+cx_attr_export
 cxstring cx_strchr(
         cxstring string,
         int chr
@@ -565,6 +579,7 @@
  * @see cx_strchr()
  */
 cx_attr_nodiscard
+cx_attr_export
 cxmutstr cx_strchr_m(
         cxmutstr string,
         int chr
@@ -583,6 +598,7 @@
  * @see cx_strrchr_m()
  */
 cx_attr_nodiscard
+cx_attr_export
 cxstring cx_strrchr(
         cxstring string,
         int chr
@@ -601,6 +617,7 @@
  * @see cx_strrchr()
  */
 cx_attr_nodiscard
+cx_attr_export
 cxmutstr cx_strrchr_m(
         cxmutstr string,
         int chr
@@ -623,6 +640,7 @@
  * @see cx_strstr_m()
  */
 cx_attr_nodiscard
+cx_attr_export
 cxstring cx_strstr(
         cxstring haystack,
         cxstring needle
@@ -645,6 +663,7 @@
  * @see cx_strstr()
  */
 cx_attr_nodiscard
+cx_attr_export
 cxmutstr cx_strstr_m(
         cxmutstr haystack,
         cxstring needle
@@ -659,12 +678,13 @@
  * @param string the string to split
  * @param delim  the delimiter
  * @param limit the maximum number of split items
- * @param output a pre-allocated array of at least @p limit length
+ * @param output 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_attr_export
 size_t cx_strsplit(
         cxstring string,
         cxstring delim,
@@ -694,6 +714,7 @@
 cx_attr_nodiscard
 cx_attr_nonnull
 cx_attr_access_w(5)
+cx_attr_export
 size_t cx_strsplit_a(
         const CxAllocator *allocator,
         cxstring string,
@@ -712,12 +733,13 @@
  * @param string the string to split
  * @param delim  the delimiter
  * @param limit the maximum number of split items
- * @param output a pre-allocated array of at least @p limit length
+ * @param output 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_attr_export
 size_t cx_strsplit_m(
         cxmutstr string,
         cxstring delim,
@@ -747,6 +769,7 @@
 cx_attr_nodiscard
 cx_attr_nonnull
 cx_attr_access_w(5)
+cx_attr_export
 size_t cx_strsplit_ma(
         const CxAllocator *allocator,
         cxmutstr string,
@@ -764,6 +787,7 @@
  * than @p s2, zero if both strings equal
  */
 cx_attr_nodiscard
+cx_attr_export
 int cx_strcmp(
         cxstring s1,
         cxstring s2
@@ -778,6 +802,7 @@
  * than @p s2, zero if both strings equal ignoring case
  */
 cx_attr_nodiscard
+cx_attr_export
 int cx_strcasecmp(
         cxstring s1,
         cxstring s2
@@ -795,6 +820,7 @@
  */
 cx_attr_nodiscard
 cx_attr_nonnull
+cx_attr_export
 int cx_strcmp_p(
         const void *s1,
         const void *s2
@@ -812,6 +838,7 @@
  */
 cx_attr_nodiscard
 cx_attr_nonnull
+cx_attr_export
 int cx_strcasecmp_p(
         const void *s1,
         const void *s2
@@ -832,7 +859,8 @@
  */
 cx_attr_nodiscard
 cx_attr_nonnull
-cxmutstr cx_strdup_a(
+cx_attr_export
+cxmutstr cx_strdup_a_(
         const CxAllocator *allocator,
         cxstring string
 );
@@ -840,45 +868,33 @@
 /**
  * Creates a duplicate of the specified string.
  *
+ * The new string will contain a copy allocated by @p allocator.
+ *
+ * @note The returned string is guaranteed to be zero-terminated.
+ *
+ * @param allocator (@c CxAllocator*) the allocator to use
+ * @param string the string to duplicate
+ * @return (@c cxmutstr) a duplicate of the string
+ * @see cx_strdup()
+ * @see cx_strfree_a()
+ */
+#define cx_strdup_a(allocator, string) \
+    cx_strdup_a_((allocator), cx_strcast((string)))
+
+/**
+ * Creates a duplicate of the specified string.
+ *
  * The new string will contain a copy allocated by standard
  * @c malloc(). So developers @em must pass the return value to cx_strfree().
  *
  * @note The returned string is guaranteed to be zero-terminated.
  *
- * @param string (@c cxstring) the string to duplicate
+ * @param string the string to duplicate
  * @return (@c cxmutstr) a duplicate of the string
  * @see cx_strdup_a()
- */
-#define cx_strdup(string) cx_strdup_a(cxDefaultAllocator, string)
-
-
-/**
- * Creates a duplicate of the specified string.
- *
- * The new string will contain a copy allocated by @p allocator.
- *
- * @note The returned string is guaranteed to be zero-terminated.
- *
- * @param allocator (@c CxAllocator*) the allocator to use
- * @param string (@c cxmutstr) the string to duplicate
- * @return (@c cxmutstr) a duplicate of the string
- * @see cx_strdup_m()
+ * @see cx_strfree()
  */
-#define cx_strdup_ma(allocator, string) cx_strdup_a(allocator, cx_strcast(string))
-
-/**
- * Creates a duplicate of the specified string.
- *
- * The new string will contain a copy allocated by standard
- * @c malloc(). So developers @em must pass the return value to cx_strfree().
- *
- * @note The returned string is guaranteed to be zero-terminated.
- *
- * @param string (@c cxmutstr) the string to duplicate
- * @return (@c cxmutstr) a duplicate of the string
- * @see cx_strdup_ma()
- */
-#define cx_strdup_m(string) cx_strdup_a(cxDefaultAllocator, cx_strcast(string))
+#define cx_strdup(string) cx_strdup_a_(cxDefaultAllocator, string)
 
 /**
  * Omits leading and trailing spaces.
@@ -890,6 +906,7 @@
  * @return the trimmed string
  */
 cx_attr_nodiscard
+cx_attr_export
 cxstring cx_strtrim(cxstring string);
 
 /**
@@ -902,6 +919,7 @@
  * @return the trimmed string
  */
 cx_attr_nodiscard
+cx_attr_export
 cxmutstr cx_strtrim_m(cxmutstr string);
 
 /**
@@ -913,6 +931,7 @@
  * @c false otherwise
  */
 cx_attr_nodiscard
+cx_attr_export
 bool cx_strprefix(
         cxstring string,
         cxstring prefix
@@ -927,6 +946,7 @@
  * @c false otherwise
  */
 cx_attr_nodiscard
+cx_attr_export
 bool cx_strsuffix(
         cxstring string,
         cxstring suffix
@@ -941,6 +961,7 @@
  * @c false otherwise
  */
 cx_attr_nodiscard
+cx_attr_export
 bool cx_strcaseprefix(
         cxstring string,
         cxstring prefix
@@ -955,35 +976,15 @@
  * @c false otherwise
  */
 cx_attr_nodiscard
+cx_attr_export
 bool cx_strcasesuffix(
         cxstring string,
         cxstring suffix
 );
 
 /**
- * Converts the string to lower case.
- *
- * The change is made in-place. If you want a copy, use cx_strdup(), first.
- *
- * @param string the string to modify
- * @see cx_strdup()
- */
-void cx_strlower(cxmutstr string);
-
-/**
- * Converts the string to upper case.
+ * Replaces a string with another string.
  *
- * The change is made in-place. If you want a copy, use cx_strdup(), first.
- *
- * @param string the string to modify
- * @see cx_strdup()
- */
-void cx_strupper(cxmutstr string);
-
-/**
- * Replaces a pattern in a string with another string.
- *
- * The pattern is taken literally and is no regular expression.
  * Replaces at most @p replmax occurrences.
  *
  * The returned string will be allocated by @p allocator and is guaranteed
@@ -994,25 +995,25 @@
  *
  * @param allocator the allocator to use
  * @param str the string where replacements should be applied
- * @param pattern the pattern to search for
+ * @param search the string to search for
  * @param replacement the replacement string
  * @param replmax maximum number of replacements
  * @return the resulting string after applying the replacements
  */
 cx_attr_nodiscard
 cx_attr_nonnull
+cx_attr_export
 cxmutstr cx_strreplacen_a(
         const CxAllocator *allocator,
         cxstring str,
-        cxstring pattern,
+        cxstring search,
         cxstring replacement,
         size_t replmax
 );
 
 /**
- * Replaces a pattern in a string with another string.
+ * Replaces a string with another string.
  *
- * The pattern is taken literally and is no regular expression.
  * Replaces at most @p replmax occurrences.
  *
  * The returned string will be allocated by @c malloc() and is guaranteed
@@ -1022,18 +1023,16 @@
  * the returned string will be empty.
  *
  * @param str (@c cxstring) the string where replacements should be applied
- * @param pattern (@c cxstring) the pattern to search for
+ * @param search (@c cxstring) the string to search for
  * @param replacement (@c cxstring) the replacement string
  * @param replmax (@c size_t) maximum number of replacements
  * @return (@c cxmutstr) the resulting string after applying the replacements
  */
-#define cx_strreplacen(str, pattern, replacement, replmax) \
-cx_strreplacen_a(cxDefaultAllocator, str, pattern, replacement, replmax)
+#define cx_strreplacen(str, search, replacement, replmax) \
+cx_strreplacen_a(cxDefaultAllocator, str, search, replacement, replmax)
 
 /**
- * Replaces a pattern in a string with another string.
- *
- * The pattern is taken literally and is no regular expression.
+ * Replaces a string with another string.
  *
  * The returned string will be allocated by @p allocator and is guaranteed
  * to be zero-terminated.
@@ -1043,18 +1042,15 @@
  *
  * @param allocator (@c CxAllocator*) the allocator to use
  * @param str (@c cxstring) the string where replacements should be applied
- * @param pattern (@c cxstring) the pattern to search for
+ * @param search (@c cxstring) the string to search for
  * @param replacement (@c cxstring) the replacement string
  * @return (@c cxmutstr) the resulting string after applying the replacements
  */
-#define cx_strreplace_a(allocator, str, pattern, replacement) \
-cx_strreplacen_a(allocator, str, pattern, replacement, SIZE_MAX)
+#define cx_strreplace_a(allocator, str, search, replacement) \
+cx_strreplacen_a(allocator, str, search, replacement, SIZE_MAX)
 
 /**
- * Replaces a pattern in a string with another string.
- *
- * The pattern is taken literally and is no regular expression.
- * Replaces at most @p replmax occurrences.
+ * Replaces a string with another string.
  *
  * The returned string will be allocated by @c malloc() and is guaranteed
  * to be zero-terminated.
@@ -1063,12 +1059,12 @@
  * the returned string will be empty.
  *
  * @param str (@c cxstring) the string where replacements should be applied
- * @param pattern (@c cxstring) the pattern to search for
+ * @param search (@c cxstring) the string to search for
  * @param replacement (@c cxstring) the replacement string
  * @return (@c cxmutstr) the resulting string after applying the replacements
  */
-#define cx_strreplace(str, pattern, replacement) \
-cx_strreplacen_a(cxDefaultAllocator, str, pattern, replacement, SIZE_MAX)
+#define cx_strreplace(str, search, replacement) \
+cx_strreplacen_a(cxDefaultAllocator, str, search, replacement, SIZE_MAX)
 
 /**
  * Creates a string tokenization context.
@@ -1079,26 +1075,23 @@
  * @return a new string tokenization context
  */
 cx_attr_nodiscard
-CxStrtokCtx cx_strtok(
+cx_attr_export
+CxStrtokCtx cx_strtok_(
         cxstring str,
         cxstring delim,
         size_t limit
 );
 
 /**
-* Creates a string tokenization context for a mutable string.
-*
-* @param str the string to tokenize
-* @param delim the delimiter (must not be empty)
-* @param limit the maximum number of tokens that shall be returned
-* @return a new string tokenization context
-*/
-cx_attr_nodiscard
-CxStrtokCtx cx_strtok_m(
-        cxmutstr str,
-        cxstring delim,
-        size_t limit
-);
+ * Creates a string tokenization context.
+ *
+ * @param str the string to tokenize
+ * @param delim the delimiter string (must not be empty)
+ * @param limit (@c size_t) the maximum number of tokens that shall be returned
+ * @return (@c CxStrtokCtx) a new string tokenization context
+ */
+#define cx_strtok(str, delim, limit) \
+    cx_strtok_(cx_strcast((str)), cx_strcast((delim)), (limit))
 
 /**
  * Returns the next token.
@@ -1113,6 +1106,7 @@
 cx_attr_nonnull
 cx_attr_nodiscard
 cx_attr_access_w(2)
+cx_attr_export
 bool cx_strtok_next(
         CxStrtokCtx *ctx,
         cxstring *token
@@ -1122,6 +1116,8 @@
  * Returns the next token of a mutable string.
  *
  * The token will point to the source string.
+ *
+ * @attention
  * If the context was not initialized over a mutable string, modifying
  * the data of the returned token is undefined behavior.
  *
@@ -1133,6 +1129,7 @@
 cx_attr_nonnull
 cx_attr_nodiscard
 cx_attr_access_w(2)
+cx_attr_export
 bool cx_strtok_next_m(
         CxStrtokCtx *ctx,
         cxmutstr *token
@@ -1147,6 +1144,7 @@
  */
 cx_attr_nonnull
 cx_attr_access_r(2, 3)
+cx_attr_export
 void cx_strtok_delim(
         CxStrtokCtx *ctx,
         const cxstring *delim,
@@ -1158,90 +1156,276 @@
  * ------------------------------------------------------------------------- */
 
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-cx_attr_access_w(2) cx_attr_nonnull_arg(2)
-int cx_strtos_lc(cxstring str, short *output, int base, const char *groupsep);
-/**
- * @copydoc cx_strtouz_lc()
- */
-cx_attr_access_w(2) cx_attr_nonnull_arg(2)
-int cx_strtoi_lc(cxstring str, int *output, int base, const char *groupsep);
+cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
+int cx_strtos_lc_(cxstring str, short *output, int base, const char *groupsep);
+
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-cx_attr_access_w(2) cx_attr_nonnull_arg(2)
-int cx_strtol_lc(cxstring str, long *output, int base, const char *groupsep);
+cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
+int cx_strtoi_lc_(cxstring str, int *output, int base, const char *groupsep);
+
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-cx_attr_access_w(2) cx_attr_nonnull_arg(2)
-int cx_strtoll_lc(cxstring str, long long *output, int base, const char *groupsep);
+cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
+int cx_strtol_lc_(cxstring str, long *output, int base, const char *groupsep);
+
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-cx_attr_access_w(2) cx_attr_nonnull_arg(2)
-int cx_strtoi8_lc(cxstring str, int8_t *output, int base, const char *groupsep);
+cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
+int cx_strtoll_lc_(cxstring str, long long *output, int base, const char *groupsep);
+
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-cx_attr_access_w(2) cx_attr_nonnull_arg(2)
-int cx_strtoi16_lc(cxstring str, int16_t *output, int base, const char *groupsep);
+cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
+int cx_strtoi8_lc_(cxstring str, int8_t *output, int base, const char *groupsep);
+
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-cx_attr_access_w(2) cx_attr_nonnull_arg(2)
-int cx_strtoi32_lc(cxstring str, int32_t *output, int base, const char *groupsep);
+cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
+int cx_strtoi16_lc_(cxstring str, int16_t *output, int base, const char *groupsep);
+
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-cx_attr_access_w(2) cx_attr_nonnull_arg(2)
-int cx_strtoi64_lc(cxstring str, int64_t *output, int base, const char *groupsep);
+cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
+int cx_strtoi32_lc_(cxstring str, int32_t *output, int base, const char *groupsep);
+
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-cx_attr_access_w(2) cx_attr_nonnull_arg(2)
-int cx_strtoz_lc(cxstring str, ssize_t *output, int base, const char *groupsep);
+cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
+int cx_strtoi64_lc_(cxstring str, int64_t *output, int base, const char *groupsep);
+
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-cx_attr_access_w(2) cx_attr_nonnull_arg(2)
-int cx_strtous_lc(cxstring str, unsigned short *output, int base, const char *groupsep);
+cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
+int cx_strtous_lc_(cxstring str, unsigned short *output, int base, const char *groupsep);
+
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-cx_attr_access_w(2) cx_attr_nonnull_arg(2)
-int cx_strtou_lc(cxstring str, unsigned int *output, int base, const char *groupsep);
+cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
+int cx_strtou_lc_(cxstring str, unsigned int *output, int base, const char *groupsep);
+
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-cx_attr_access_w(2) cx_attr_nonnull_arg(2)
-int cx_strtoul_lc(cxstring str, unsigned long *output, int base, const char *groupsep);
+cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
+int cx_strtoul_lc_(cxstring str, unsigned long *output, int base, const char *groupsep);
+
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-cx_attr_access_w(2) cx_attr_nonnull_arg(2)
-int cx_strtoull_lc(cxstring str, unsigned long long *output, int base, const char *groupsep);
+cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
+int cx_strtoull_lc_(cxstring str, unsigned long long *output, int base, const char *groupsep);
+
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-cx_attr_access_w(2) cx_attr_nonnull_arg(2)
-int cx_strtou8_lc(cxstring str, uint8_t *output, int base, const char *groupsep);
+cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
+int cx_strtou8_lc_(cxstring str, uint8_t *output, int base, const char *groupsep);
+
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-cx_attr_access_w(2) cx_attr_nonnull_arg(2)
-int cx_strtou16_lc(cxstring str, uint16_t *output, int base, const char *groupsep);
+cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
+int cx_strtou16_lc_(cxstring str, uint16_t *output, int base, const char *groupsep);
+
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-cx_attr_access_w(2) cx_attr_nonnull_arg(2)
-int cx_strtou32_lc(cxstring str, uint32_t *output, int base, const char *groupsep);
+cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
+int cx_strtou32_lc_(cxstring str, uint32_t *output, int base, const char *groupsep);
+
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-cx_attr_access_w(2) cx_attr_nonnull_arg(2)
-int cx_strtou64_lc(cxstring str, uint64_t *output, int base, const char *groupsep);
+cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
+int cx_strtou64_lc_(cxstring str, uint64_t *output, int base, const char *groupsep);
 
 /**
  * Converts a string to a number.
@@ -1257,8 +1441,8 @@
  * @retval zero success
  * @retval non-zero conversion was not possible
  */
-cx_attr_access_w(2) cx_attr_nonnull_arg(2)
-int cx_strtouz_lc(cxstring str, size_t *output, int base, const char *groupsep);
+cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
+int cx_strtoz_lc_(cxstring str, size_t *output, int base, const char *groupsep);
 
 /**
  * Converts a string to a single precision floating point number.
@@ -1267,10 +1451,6 @@
  * In that case the function sets errno to EINVAL when the reason is an invalid character.
  * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h.
  *
- * The decimal separator is assumed to be a dot character.
- * The comma character is treated as group separator and ignored during parsing.
- * If you want to choose a different format, use cx_strtof_lc().
- *
  * @param str the string to convert
  * @param output a pointer to the float variable where the result shall be stored
  * @param decsep the decimal separator
@@ -1278,8 +1458,8 @@
  * @retval zero success
  * @retval non-zero conversion was not possible
  */
-cx_attr_access_w(2) cx_attr_nonnull_arg(2)
-int cx_strtof_lc(cxstring str, float *output, char decsep, const char *groupsep);
+cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
+int cx_strtof_lc_(cxstring str, float *output, char decsep, const char *groupsep);
 
 /**
  * Converts a string to a double precision floating point number.
@@ -1288,10 +1468,6 @@
  * In that case the function sets errno to EINVAL when the reason is an invalid character.
  * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h.
  *
- * The decimal separator is assumed to be a dot character.
- * The comma character is treated as group separator and ignored during parsing.
- * If you want to choose a different format, use cx_strtof_lc().
- *
  * @param str the string to convert
  * @param output a pointer to the float variable where the result shall be stored
  * @param decsep the decimal separator
@@ -1299,78 +1475,265 @@
  * @retval zero success
  * @retval non-zero conversion was not possible
  */
-cx_attr_access_w(2) cx_attr_nonnull_arg(2)
-int cx_strtod_lc(cxstring str, double *output, char decsep, const char *groupsep);
+cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
+int cx_strtod_lc_(cxstring str, double *output, char decsep, const char *groupsep);
 
-#ifndef CX_STR_IMPLEMENTATION
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-#define cx_strtos_lc(str, output, base, groupsep) cx_strtos_lc(cx_strcast(str), output, base, groupsep)
+#define cx_strtos_lc(str, output, base, groupsep) cx_strtos_lc_(cx_strcast(str), output, base, groupsep)
+
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-#define cx_strtoi_lc(str, output, base, groupsep) cx_strtoi_lc(cx_strcast(str), output, base, groupsep)
+#define cx_strtoi_lc(str, output, base, groupsep) cx_strtoi_lc_(cx_strcast(str), output, base, groupsep)
+
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-#define cx_strtol_lc(str, output, base, groupsep) cx_strtol_lc(cx_strcast(str), output, base, groupsep)
+#define cx_strtol_lc(str, output, base, groupsep) cx_strtol_lc_(cx_strcast(str), output, base, groupsep)
+
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-#define cx_strtoll_lc(str, output, base, groupsep) cx_strtoll_lc(cx_strcast(str), output, base, groupsep)
+#define cx_strtoll_lc(str, output, base, groupsep) cx_strtoll_lc_(cx_strcast(str), output, base, groupsep)
+
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-#define cx_strtoi8_lc(str, output, base, groupsep) cx_strtoi8_lc(cx_strcast(str), output, base, groupsep)
+#define cx_strtoi8_lc(str, output, base, groupsep) cx_strtoi8_lc_(cx_strcast(str), output, base, groupsep)
+
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-#define cx_strtoi16_lc(str, output, base, groupsep) cx_strtoi16_lc(cx_strcast(str), output, base, groupsep)
+#define cx_strtoi16_lc(str, output, base, groupsep) cx_strtoi16_lc_(cx_strcast(str), output, base, groupsep)
+
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-#define cx_strtoi32_lc(str, output, base, groupsep) cx_strtoi32_lc(cx_strcast(str), output, base, groupsep)
+#define cx_strtoi32_lc(str, output, base, groupsep) cx_strtoi32_lc_(cx_strcast(str), output, base, groupsep)
+
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-#define cx_strtoi64_lc(str, output, base, groupsep) cx_strtoi64_lc(cx_strcast(str), output, base, groupsep)
+#define cx_strtoi64_lc(str, output, base, groupsep) cx_strtoi64_lc_(cx_strcast(str), output, base, groupsep)
+
 /**
- * @copydoc cx_strtouz_lc()
- */
-#define cx_strtoz_lc(str, output, base, groupsep) cx_strtoz_lc(cx_strcast(str), output, base, groupsep)
-/**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-#define cx_strtous_lc(str, output, base, groupsep) cx_strtous_lc(cx_strcast(str), output, base, groupsep)
+#define cx_strtous_lc(str, output, base, groupsep) cx_strtous_lc_(cx_strcast(str), output, base, groupsep)
+
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-#define cx_strtou_lc(str, output, base, groupsep) cx_strtou_lc(cx_strcast(str), output, base, groupsep)
+#define cx_strtou_lc(str, output, base, groupsep) cx_strtou_lc_(cx_strcast(str), output, base, groupsep)
+
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-#define cx_strtoul_lc(str, output, base, groupsep) cx_strtoul_lc(cx_strcast(str), output, base, groupsep)
+#define cx_strtoul_lc(str, output, base, groupsep) cx_strtoul_lc_(cx_strcast(str), output, base, groupsep)
+
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-#define cx_strtoull_lc(str, output, base, groupsep) cx_strtoull_lc(cx_strcast(str), output, base, groupsep)
+#define cx_strtoull_lc(str, output, base, groupsep) cx_strtoull_lc_(cx_strcast(str), output, base, groupsep)
+
 /**
- * @copydoc cx_strtouz_lc()
- */
-#define cx_strtou8_lc(str, output, base, groupsep) cx_strtou8_lc(cx_strcast(str), output, base, groupsep)
-/**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-#define cx_strtou16_lc(str, output, base, groupsep) cx_strtou16_lc(cx_strcast(str), output, base, groupsep)
+#define cx_strtou8_lc(str, output, base, groupsep) cx_strtou8_lc_(cx_strcast(str), output, base, groupsep)
+
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-#define cx_strtou32_lc(str, output, base, groupsep) cx_strtou32_lc(cx_strcast(str), output, base, groupsep)
+#define cx_strtou16_lc(str, output, base, groupsep) cx_strtou16_lc_(cx_strcast(str), output, base, groupsep)
+
 /**
- * @copydoc cx_strtouz_lc()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-#define cx_strtou64_lc(str, output, base, groupsep) cx_strtou64_lc(cx_strcast(str), output, base, groupsep)
+#define cx_strtou32_lc(str, output, base, groupsep) cx_strtou32_lc_(cx_strcast(str), output, base, groupsep)
+
+/**
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
+ */
+#define cx_strtou64_lc(str, output, base, groupsep) cx_strtou64_lc_(cx_strcast(str), output, base, groupsep)
+
 /**
  * Converts a string to a number.
  *
@@ -1381,80 +1744,156 @@
  * @param str the string to convert
  * @param output a pointer to the integer variable where the result shall be stored
  * @param base 2, 8, 10, or 16
- * @param groupsep each character in this string is treated as group separator and ignored during conversion
+ * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion
+ * @retval zero success
+ * @retval non-zero conversion was not possible
+ */
+#define cx_strtoz_lc(str, output, base, groupsep) cx_strtoz_lc_(cx_strcast(str), output, base, groupsep)
+
+/**
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * The comma character is treated as group separator and ignored during parsing.
+ * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @retval zero success
+ * @retval non-zero conversion was not possible
+ */
+#define cx_strtos(str, output, base) cx_strtos_lc_(cx_strcast(str), output, base, ",")
+
+/**
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * The comma character is treated as group separator and ignored during parsing.
+ * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @retval zero success
+ * @retval non-zero conversion was not possible
+ */
+#define cx_strtoi(str, output, base) cx_strtoi_lc_(cx_strcast(str), output, base, ",")
+
+/**
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * The comma character is treated as group separator and ignored during parsing.
+ * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
  * @retval zero success
  * @retval non-zero conversion was not possible
  */
-#define cx_strtouz_lc(str, output, base, groupsep) cx_strtouz_lc(cx_strcast(str), output, base, groupsep)
+#define cx_strtol(str, output, base) cx_strtol_lc_(cx_strcast(str), output, base, ",")
+
+/**
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * The comma character is treated as group separator and ignored during parsing.
+ * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @retval zero success
+ * @retval non-zero conversion was not possible
+ */
+#define cx_strtoll(str, output, base) cx_strtoll_lc_(cx_strcast(str), output, base, ",")
+
+/**
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * The comma character is treated as group separator and ignored during parsing.
+ * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @retval zero success
+ * @retval non-zero conversion was not possible
+ */
+#define cx_strtoi8(str, output, base) cx_strtoi8_lc_(cx_strcast(str), output, base, ",")
 
 /**
- * @copydoc cx_strtouz()
- */
-#define cx_strtos(str, output, base) cx_strtos_lc(str, output, base, ",")
-/**
- * @copydoc cx_strtouz()
- */
-#define cx_strtoi(str, output, base) cx_strtoi_lc(str, output, base, ",")
-/**
- * @copydoc cx_strtouz()
- */
-#define cx_strtol(str, output, base) cx_strtol_lc(str, output, base, ",")
-/**
- * @copydoc cx_strtouz()
- */
-#define cx_strtoll(str, output, base) cx_strtoll_lc(str, output, base, ",")
-/**
- * @copydoc cx_strtouz()
- */
-#define cx_strtoi8(str, output, base) cx_strtoi8_lc(str, output, base, ",")
-/**
- * @copydoc cx_strtouz()
- */
-#define cx_strtoi16(str, output, base) cx_strtoi16_lc(str, output, base, ",")
-/**
- * @copydoc cx_strtouz()
- */
-#define cx_strtoi32(str, output, base) cx_strtoi32_lc(str, output, base, ",")
-/**
- * @copydoc cx_strtouz()
- */
-#define cx_strtoi64(str, output, base) cx_strtoi64_lc(str, output, base, ",")
-/**
- * @copydoc cx_strtouz()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * The comma character is treated as group separator and ignored during parsing.
+ * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-#define cx_strtoz(str, output, base) cx_strtoz_lc(str, output, base, ",")
-/**
- * @copydoc cx_strtouz()
- */
-#define cx_strtous(str, output, base) cx_strtous_lc(str, output, base, ",")
+#define cx_strtoi16(str, output, base) cx_strtoi16_lc_(cx_strcast(str), output, base, ",")
+
 /**
- * @copydoc cx_strtouz()
- */
-#define cx_strtou(str, output, base) cx_strtou_lc(str, output, base, ",")
-/**
- * @copydoc cx_strtouz()
- */
-#define cx_strtoul(str, output, base) cx_strtoul_lc(str, output, base, ",")
-/**
- * @copydoc cx_strtouz()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * The comma character is treated as group separator and ignored during parsing.
+ * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-#define cx_strtoull(str, output, base) cx_strtoull_lc(str, output, base, ",")
+#define cx_strtoi32(str, output, base) cx_strtoi32_lc_(cx_strcast(str), output, base, ",")
+
 /**
- * @copydoc cx_strtouz()
- */
-#define cx_strtou8(str, output, base) cx_strtou8_lc(str, output, base, ",")
-/**
- * @copydoc cx_strtouz()
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * The comma character is treated as group separator and ignored during parsing.
+ * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @retval zero success
+ * @retval non-zero conversion was not possible
  */
-#define cx_strtou16(str, output, base) cx_strtou16_lc(str, output, base, ",")
-/**
- * @copydoc cx_strtouz()
- */
-#define cx_strtou32(str, output, base) cx_strtou32_lc(str, output, base, ",")
-/**
- * @copydoc cx_strtouz()
- */
-#define cx_strtou64(str, output, base) cx_strtou64_lc(str, output, base, ",")
+#define cx_strtoi64(str, output, base) cx_strtoi64_lc_(cx_strcast(str), output, base, ",")
+
 /**
  * Converts a string to a number.
  *
@@ -1463,7 +1902,61 @@
  * It sets errno to ERANGE when the target datatype is too small.
  *
  * The comma character is treated as group separator and ignored during parsing.
- * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtouz_lc()).
+ * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @retval zero success
+ * @retval non-zero conversion was not possible
+ */
+#define cx_strtoz(str, output, base) cx_strtoz_lc_(cx_strcast(str), output, base, ",")
+
+/**
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * The comma character is treated as group separator and ignored during parsing.
+ * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @retval zero success
+ * @retval non-zero conversion was not possible
+ */
+#define cx_strtous(str, output, base) cx_strtous_lc_(cx_strcast(str), output, base, ",")
+
+/**
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * The comma character is treated as group separator and ignored during parsing.
+ * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @retval zero success
+ * @retval non-zero conversion was not possible
+ */
+#define cx_strtou(str, output, base) cx_strtou_lc_(cx_strcast(str), output, base, ",")
+
+/**
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * The comma character is treated as group separator and ignored during parsing.
+ * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
  *
  * @param str the string to convert
  * @param output a pointer to the integer variable where the result shall be stored
@@ -1471,7 +1964,97 @@
  * @retval zero success
  * @retval non-zero conversion was not possible
  */
-#define cx_strtouz(str, output, base) cx_strtouz_lc(str, output, base, ",")
+#define cx_strtoul(str, output, base) cx_strtoul_lc_(cx_strcast(str), output, base, ",")
+
+/**
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * The comma character is treated as group separator and ignored during parsing.
+ * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @retval zero success
+ * @retval non-zero conversion was not possible
+ */
+#define cx_strtoull(str, output, base) cx_strtoull_lc_(cx_strcast(str), output, base, ",")
+
+/**
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * The comma character is treated as group separator and ignored during parsing.
+ * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @retval zero success
+ * @retval non-zero conversion was not possible
+ */
+#define cx_strtou8(str, output, base) cx_strtou8_lc_(cx_strcast(str), output, base, ",")
+
+/**
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * The comma character is treated as group separator and ignored during parsing.
+ * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @retval zero success
+ * @retval non-zero conversion was not possible
+ */
+#define cx_strtou16(str, output, base) cx_strtou16_lc_(cx_strcast(str), output, base, ",")
+
+/**
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * The comma character is treated as group separator and ignored during parsing.
+ * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @retval zero success
+ * @retval non-zero conversion was not possible
+ */
+#define cx_strtou32(str, output, base) cx_strtou32_lc_(cx_strcast(str), output, base, ",")
+
+/**
+ * Converts a string to a number.
+ *
+ * The function returns non-zero when conversion is not possible.
+ * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
+ * It sets errno to ERANGE when the target datatype is too small.
+ *
+ * The comma character is treated as group separator and ignored during parsing.
+ * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
+ *
+ * @param str the string to convert
+ * @param output a pointer to the integer variable where the result shall be stored
+ * @param base 2, 8, 10, or 16
+ * @retval zero success
+ * @retval non-zero conversion was not possible
+ */
+#define cx_strtou64(str, output, base) cx_strtou64_lc_(cx_strcast(str), output, base, ",")
 
 /**
  * Converts a string to a single precision floating point number.
@@ -1480,10 +2063,6 @@
  * In that case the function sets errno to EINVAL when the reason is an invalid character.
  * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h.
  *
- * The decimal separator is assumed to be a dot character.
- * The comma character is treated as group separator and ignored during parsing.
- * If you want to choose a different format, use cx_strtof_lc().
- *
  * @param str the string to convert
  * @param output a pointer to the float variable where the result shall be stored
  * @param decsep the decimal separator
@@ -1491,17 +2070,14 @@
  * @retval zero success
  * @retval non-zero conversion was not possible
  */
-#define cx_strtof_lc(str, output, decsep, groupsep) cx_strtof_lc(cx_strcast(str), output, decsep, groupsep)
+#define cx_strtof_lc(str, output, decsep, groupsep) cx_strtof_lc_(cx_strcast(str), output, decsep, groupsep)
+
 /**
  * Converts a string to a double precision floating point number.
  *
  * The function returns non-zero when conversion is not possible.
  * In that case the function sets errno to EINVAL when the reason is an invalid character.
  *
- * The decimal separator is assumed to be a dot character.
- * The comma character is treated as group separator and ignored during parsing.
- * If you want to choose a different format, use cx_strtof_lc().
- *
  * @param str the string to convert
  * @param output a pointer to the double variable where the result shall be stored
  * @param decsep the decimal separator
@@ -1509,7 +2085,7 @@
  * @retval zero success
  * @retval non-zero conversion was not possible
  */
-#define cx_strtod_lc(str, output, decsep, groupsep) cx_strtod_lc(cx_strcast(str), output, decsep, groupsep)
+#define cx_strtod_lc(str, output, decsep, groupsep) cx_strtod_lc_(cx_strcast(str), output, decsep, groupsep)
 
 /**
  * Converts a string to a single precision floating point number.
@@ -1527,7 +2103,8 @@
  * @retval zero success
  * @retval non-zero conversion was not possible
  */
-#define cx_strtof(str, output) cx_strtof_lc(str, output, '.', ",")
+#define cx_strtof(str, output) cx_strtof_lc_(cx_strcast(str), output, '.', ",")
+
 /**
  * Converts a string to a double precision floating point number.
  *
@@ -1543,9 +2120,7 @@
  * @retval zero success
  * @retval non-zero conversion was not possible
  */
-#define cx_strtod(str, output) cx_strtod_lc(str, output, '.', ",")
-
-#endif
+#define cx_strtod(str, output) cx_strtod_lc_(cx_strcast(str), output, '.', ",")
 
 #ifdef __cplusplus
 } // extern "C"

mercurial