ucx/cx/string.h

changeset 112
c3f2f16fa4b8
parent 109
c3dfcb8f0be7
child 113
dde28a806552
equal deleted inserted replaced
111:81c4f73236a4 112:c3f2f16fa4b8
110 /** 110 /**
111 * Position of the currently active token in the source string. 111 * Position of the currently active token in the source string.
112 */ 112 */
113 size_t pos; 113 size_t pos;
114 /** 114 /**
115 * Position of next delimiter in the source string. 115 * Position of the next delimiter in the source string.
116 * 116 *
117 * If the tokenizer has not yet returned a token, the content of this field 117 * If the tokenizer has not yet returned a token, the content of this field
118 * is undefined. If the tokenizer reached the end of the string, this field 118 * is undefined. If the tokenizer reaches the end of the string, this field
119 * contains the length of the source string. 119 * contains the length of the source string.
120 */ 120 */
121 size_t delim_pos; 121 size_t delim_pos;
122 /** 122 /**
123 * The position of the next token in the source string. 123 * The position of the next token in the source string.
165 /** 165 /**
166 * Wraps a mutable string that must be zero-terminated. 166 * Wraps a mutable string that must be zero-terminated.
167 * 167 *
168 * The length is implicitly inferred by using a call to @c strlen(). 168 * The length is implicitly inferred by using a call to @c strlen().
169 * 169 *
170 * When @c NULL is passed, the length will be set to zero.
171 *
170 * @note the wrapped string will share the specified pointer to the string. 172 * @note the wrapped string will share the specified pointer to the string.
171 * If you do want a copy, use cx_strdup() on the return value of this function. 173 * If you do want a copy, use cx_strdup() on the return value of this function.
172 * 174 *
173 * If you need to wrap a constant string, use cx_str(). 175 * If you need to wrap a constant string, use cx_str().
174 * 176 *
175 * @param cstring the string to wrap, must be zero-terminated 177 * @param cstring the string to wrap (must be zero-terminated)
176 * @return the wrapped string 178 * @return the wrapped string
177 * 179 *
178 * @see cx_mutstrn() 180 * @see cx_mutstrn()
179 */ 181 */
180 cx_attr_nonnull
181 cx_attr_nodiscard 182 cx_attr_nodiscard
182 cx_attr_cstr_arg(1) 183 cx_attr_cstr_arg(1)
183 cx_attr_export 184 cx_attr_export
184 cxmutstr cx_mutstr(char *cstring); 185 cxmutstr cx_mutstr(char *cstring);
185 186
210 /** 211 /**
211 * Wraps a string that must be zero-terminated. 212 * Wraps a string that must be zero-terminated.
212 * 213 *
213 * The length is implicitly inferred by using a call to @c strlen(). 214 * The length is implicitly inferred by using a call to @c strlen().
214 * 215 *
216 * When @c NULL is passed, the length will be set to zero.
217 *
215 * @note the wrapped string will share the specified pointer to the string. 218 * @note the wrapped string will share the specified pointer to the string.
216 * If you do want a copy, use cx_strdup() on the return value of this function. 219 * If you do want a copy, use cx_strdup() on the return value of this function.
217 * 220 *
218 * If you need to wrap a non-constant string, use cx_mutstr(). 221 * If you need to wrap a non-constant string, use cx_mutstr().
219 * 222 *
220 * @param cstring the string to wrap, must be zero-terminated 223 * @param cstring the string to wrap (must be zero-terminated)
221 * @return the wrapped string 224 * @return the wrapped string
222 * 225 *
223 * @see cx_strn() 226 * @see cx_strn()
224 */ 227 */
225 cx_attr_nonnull
226 cx_attr_nodiscard 228 cx_attr_nodiscard
227 cx_attr_cstr_arg(1) 229 cx_attr_cstr_arg(1)
228 cx_attr_export 230 cx_attr_export
229 cxstring cx_str(const char *cstring); 231 cxstring cx_str(const char *cstring);
230 232
300 static inline cxstring cx_strcast_z(const char *str) { 302 static inline cxstring cx_strcast_z(const char *str) {
301 return cx_str(str); 303 return cx_str(str);
302 } 304 }
303 305
304 /** 306 /**
305 * Casts a mutable string to an immutable string. 307 * Wraps any string into an UCX string.
306 * 308 *
307 * Does nothing for already immutable strings. 309 * @param str (any supported string type) the string to cast
308 * 310 * @return (@c cxstring) the string wrapped as UCX string
309 * @note This is not seriously a cast. Instead, you get a copy 311 */
310 * of the struct with the desired pointer type. Both structs still
311 * point to the same location, though!
312 *
313 * @param str (@c cxstring or @c cxmutstr) the string to cast
314 * @return (@c cxstring) an immutable copy of the string pointer
315 */
316 #define cx_strcast(str) _Generic((str), \ 312 #define cx_strcast(str) _Generic((str), \
317 cxmutstr: cx_strcast_m, \ 313 cxmutstr: cx_strcast_m, \
318 cxstring: cx_strcast_c, \ 314 cxstring: cx_strcast_c, \
315 const unsigned char*: cx_strcast_z, \
316 unsigned char *: cx_strcast_z, \
319 const char*: cx_strcast_z, \ 317 const char*: cx_strcast_z, \
320 char *: cx_strcast_z) (str) 318 char *: cx_strcast_z) (str)
321 #endif 319 #endif
322 320
323 /** 321 /**
324 * Passes the pointer in this string to the cxDefaultAllocator's @c free() function. 322 * Passes the pointer in this string to the cxDefaultAllocator's @c free() function.
325 * 323 *
326 * The pointer in the struct is set to @c NULL and the length is set to zero 324 * The pointer in the struct is set to @c NULL, and the length is set to zero,
327 * which means that this function protects you against double-free. 325 * which means that this function protects you against double-free.
328 * 326 *
329 * @note There is no implementation for cxstring, because it is unlikely that 327 * @note There is no implementation for cxstring, because it is unlikely that
330 * you ever have a <code>const char*</code> you are really supposed to free. 328 * you ever have a <code>const char*</code> you are really supposed to free.
331 * If you encounter such situation, you should double-check your code. 329 * If you encounter such a situation, you should double-check your code.
332 * 330 *
333 * @param str the string to free 331 * @param str the string to free
334 */ 332 */
335 cx_attr_export 333 cx_attr_export
336 void cx_strfree(cxmutstr *str); 334 void cx_strfree(cxmutstr *str);
337 335
338 /** 336 /**
339 * Passes the pointer in this string to the allocators free function. 337 * Passes the pointer in this string to the allocator's free function.
340 * 338 *
341 * The pointer in the struct is set to @c NULL and the length is set to zero 339 * The pointer in the struct is set to @c NULL, and the length is set to zero,
342 * which means that this function protects you against double-free. 340 * which means that this function protects you against double-free.
343 * 341 *
344 * @note There is no implementation for cxstring, because it is unlikely that 342 * @note There is no implementation for cxstring, because it is unlikely that
345 * you ever have a <code>const char*</code> you are really supposed to free. 343 * you ever have a <code>const char*</code> you are really supposed to free.
346 * If you encounter such situation, you should double-check your code. 344 * If you encounter such a situation, you should double-check your code.
347 * 345 *
348 * @param alloc the allocator 346 * @param alloc the allocator
349 * @param str the string to free 347 * @param str the string to free
350 */ 348 */
351 cx_attr_nonnull_arg(1) 349 cx_attr_nonnull_arg(1)
983 cx_attr_nodiscard 981 cx_attr_nodiscard
984 cx_attr_export 982 cx_attr_export
985 cxmutstr cx_strtrim_m(cxmutstr string); 983 cxmutstr cx_strtrim_m(cxmutstr string);
986 984
987 /** 985 /**
988 * Checks, if a string has a specific prefix. 986 * Checks if a string has a specific prefix.
989 * 987 *
990 * @param string the string to check 988 * @param string the string to check
991 * @param prefix the prefix the string should have 989 * @param prefix the prefix the string should have
992 * @return @c true, if and only if the string has the specified prefix, 990 * @return @c true, if and only if the string has the specified prefix,
993 * @c false otherwise 991 * @c false otherwise
998 cxstring string, 996 cxstring string,
999 cxstring prefix 997 cxstring prefix
1000 ); 998 );
1001 999
1002 /** 1000 /**
1003 * Checks, if a string has a specific suffix. 1001 * Checks if a string has a specific suffix.
1004 * 1002 *
1005 * @param string the string to check 1003 * @param string the string to check
1006 * @param suffix the suffix the string should have 1004 * @param suffix the suffix the string should have
1007 * @return @c true, if and only if the string has the specified suffix, 1005 * @return @c true, if and only if the string has the specified suffix,
1008 * @c false otherwise 1006 * @c false otherwise
1013 cxstring string, 1011 cxstring string,
1014 cxstring suffix 1012 cxstring suffix
1015 ); 1013 );
1016 1014
1017 /** 1015 /**
1018 * Checks, if a string has a specific prefix, ignoring the case. 1016 * Checks if a string has a specific prefix, ignoring the case.
1019 * 1017 *
1020 * @param string the string to check 1018 * @param string the string to check
1021 * @param prefix the prefix the string should have 1019 * @param prefix the prefix the string should have
1022 * @return @c true, if and only if the string has the specified prefix, 1020 * @return @c true, if and only if the string has the specified prefix,
1023 * @c false otherwise 1021 * @c false otherwise
1045 ); 1043 );
1046 1044
1047 /** 1045 /**
1048 * Replaces a string with another string. 1046 * Replaces a string with another string.
1049 * 1047 *
1050 * Replaces at most @p replmax occurrences. 1048 * The function replaces at most @p replmax occurrences.
1051 * 1049 *
1052 * The returned string will be allocated by @p allocator and is guaranteed 1050 * The returned string will be allocated by @p allocator and is guaranteed
1053 * to be zero-terminated. 1051 * to be zero-terminated.
1054 * 1052 *
1055 * If allocation fails, or the input string is empty, 1053 * If allocation fails, or the input string is empty,
1074 ); 1072 );
1075 1073
1076 /** 1074 /**
1077 * Replaces a string with another string. 1075 * Replaces a string with another string.
1078 * 1076 *
1079 * Replaces at most @p replmax occurrences. 1077 * The function replaces at most @p replmax occurrences.
1080 * 1078 *
1081 * The returned string will be allocated by the cxDefaultAllocator and is guaranteed 1079 * The returned string will be allocated by the cxDefaultAllocator and is guaranteed
1082 * to be zero-terminated. 1080 * to be zero-terminated.
1083 * 1081 *
1084 * If allocation fails, or the input string is empty, 1082 * If allocation fails, or the input string is empty,
1225 * It sets errno to ERANGE when the target datatype is too small. 1223 * It sets errno to ERANGE when the target datatype is too small.
1226 * 1224 *
1227 * @param str the string to convert 1225 * @param str the string to convert
1228 * @param output a pointer to the integer variable where the result shall be stored 1226 * @param output a pointer to the integer variable where the result shall be stored
1229 * @param base 2, 8, 10, or 16 1227 * @param base 2, 8, 10, or 16
1230 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1228 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1231 * @retval zero success 1229 * @retval zero success
1232 * @retval non-zero conversion was not possible 1230 * @retval non-zero conversion was not possible
1233 */ 1231 */
1234 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1232 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1235 int cx_strtos_lc_(cxstring str, short *output, int base, const char *groupsep); 1233 int cx_strtos_lc_(cxstring str, short *output, int base, const char *groupsep);
1242 * It sets errno to ERANGE when the target datatype is too small. 1240 * It sets errno to ERANGE when the target datatype is too small.
1243 * 1241 *
1244 * @param str the string to convert 1242 * @param str the string to convert
1245 * @param output a pointer to the integer variable where the result shall be stored 1243 * @param output a pointer to the integer variable where the result shall be stored
1246 * @param base 2, 8, 10, or 16 1244 * @param base 2, 8, 10, or 16
1247 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1245 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1248 * @retval zero success 1246 * @retval zero success
1249 * @retval non-zero conversion was not possible 1247 * @retval non-zero conversion was not possible
1250 */ 1248 */
1251 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1249 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1252 int cx_strtoi_lc_(cxstring str, int *output, int base, const char *groupsep); 1250 int cx_strtoi_lc_(cxstring str, int *output, int base, const char *groupsep);
1259 * It sets errno to ERANGE when the target datatype is too small. 1257 * It sets errno to ERANGE when the target datatype is too small.
1260 * 1258 *
1261 * @param str the string to convert 1259 * @param str the string to convert
1262 * @param output a pointer to the integer variable where the result shall be stored 1260 * @param output a pointer to the integer variable where the result shall be stored
1263 * @param base 2, 8, 10, or 16 1261 * @param base 2, 8, 10, or 16
1264 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1262 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1265 * @retval zero success 1263 * @retval zero success
1266 * @retval non-zero conversion was not possible 1264 * @retval non-zero conversion was not possible
1267 */ 1265 */
1268 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1266 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1269 int cx_strtol_lc_(cxstring str, long *output, int base, const char *groupsep); 1267 int cx_strtol_lc_(cxstring str, long *output, int base, const char *groupsep);
1276 * It sets errno to ERANGE when the target datatype is too small. 1274 * It sets errno to ERANGE when the target datatype is too small.
1277 * 1275 *
1278 * @param str the string to convert 1276 * @param str the string to convert
1279 * @param output a pointer to the integer variable where the result shall be stored 1277 * @param output a pointer to the integer variable where the result shall be stored
1280 * @param base 2, 8, 10, or 16 1278 * @param base 2, 8, 10, or 16
1281 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1279 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1282 * @retval zero success 1280 * @retval zero success
1283 * @retval non-zero conversion was not possible 1281 * @retval non-zero conversion was not possible
1284 */ 1282 */
1285 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1283 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1286 int cx_strtoll_lc_(cxstring str, long long *output, int base, const char *groupsep); 1284 int cx_strtoll_lc_(cxstring str, long long *output, int base, const char *groupsep);
1293 * It sets errno to ERANGE when the target datatype is too small. 1291 * It sets errno to ERANGE when the target datatype is too small.
1294 * 1292 *
1295 * @param str the string to convert 1293 * @param str the string to convert
1296 * @param output a pointer to the integer variable where the result shall be stored 1294 * @param output a pointer to the integer variable where the result shall be stored
1297 * @param base 2, 8, 10, or 16 1295 * @param base 2, 8, 10, or 16
1298 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1296 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1299 * @retval zero success 1297 * @retval zero success
1300 * @retval non-zero conversion was not possible 1298 * @retval non-zero conversion was not possible
1301 */ 1299 */
1302 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1300 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1303 int cx_strtoi8_lc_(cxstring str, int8_t *output, int base, const char *groupsep); 1301 int cx_strtoi8_lc_(cxstring str, int8_t *output, int base, const char *groupsep);
1310 * It sets errno to ERANGE when the target datatype is too small. 1308 * It sets errno to ERANGE when the target datatype is too small.
1311 * 1309 *
1312 * @param str the string to convert 1310 * @param str the string to convert
1313 * @param output a pointer to the integer variable where the result shall be stored 1311 * @param output a pointer to the integer variable where the result shall be stored
1314 * @param base 2, 8, 10, or 16 1312 * @param base 2, 8, 10, or 16
1315 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1313 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1316 * @retval zero success 1314 * @retval zero success
1317 * @retval non-zero conversion was not possible 1315 * @retval non-zero conversion was not possible
1318 */ 1316 */
1319 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1317 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1320 int cx_strtoi16_lc_(cxstring str, int16_t *output, int base, const char *groupsep); 1318 int cx_strtoi16_lc_(cxstring str, int16_t *output, int base, const char *groupsep);
1327 * It sets errno to ERANGE when the target datatype is too small. 1325 * It sets errno to ERANGE when the target datatype is too small.
1328 * 1326 *
1329 * @param str the string to convert 1327 * @param str the string to convert
1330 * @param output a pointer to the integer variable where the result shall be stored 1328 * @param output a pointer to the integer variable where the result shall be stored
1331 * @param base 2, 8, 10, or 16 1329 * @param base 2, 8, 10, or 16
1332 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1330 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1333 * @retval zero success 1331 * @retval zero success
1334 * @retval non-zero conversion was not possible 1332 * @retval non-zero conversion was not possible
1335 */ 1333 */
1336 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1334 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1337 int cx_strtoi32_lc_(cxstring str, int32_t *output, int base, const char *groupsep); 1335 int cx_strtoi32_lc_(cxstring str, int32_t *output, int base, const char *groupsep);
1344 * It sets errno to ERANGE when the target datatype is too small. 1342 * It sets errno to ERANGE when the target datatype is too small.
1345 * 1343 *
1346 * @param str the string to convert 1344 * @param str the string to convert
1347 * @param output a pointer to the integer variable where the result shall be stored 1345 * @param output a pointer to the integer variable where the result shall be stored
1348 * @param base 2, 8, 10, or 16 1346 * @param base 2, 8, 10, or 16
1349 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1347 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1350 * @retval zero success 1348 * @retval zero success
1351 * @retval non-zero conversion was not possible 1349 * @retval non-zero conversion was not possible
1352 */ 1350 */
1353 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1351 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1354 int cx_strtoi64_lc_(cxstring str, int64_t *output, int base, const char *groupsep); 1352 int cx_strtoi64_lc_(cxstring str, int64_t *output, int base, const char *groupsep);
1361 * It sets errno to ERANGE when the target datatype is too small. 1359 * It sets errno to ERANGE when the target datatype is too small.
1362 * 1360 *
1363 * @param str the string to convert 1361 * @param str the string to convert
1364 * @param output a pointer to the integer variable where the result shall be stored 1362 * @param output a pointer to the integer variable where the result shall be stored
1365 * @param base 2, 8, 10, or 16 1363 * @param base 2, 8, 10, or 16
1366 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1364 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1367 * @retval zero success 1365 * @retval zero success
1368 * @retval non-zero conversion was not possible 1366 * @retval non-zero conversion was not possible
1369 */ 1367 */
1370 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1368 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1371 int cx_strtous_lc_(cxstring str, unsigned short *output, int base, const char *groupsep); 1369 int cx_strtous_lc_(cxstring str, unsigned short *output, int base, const char *groupsep);
1378 * It sets errno to ERANGE when the target datatype is too small. 1376 * It sets errno to ERANGE when the target datatype is too small.
1379 * 1377 *
1380 * @param str the string to convert 1378 * @param str the string to convert
1381 * @param output a pointer to the integer variable where the result shall be stored 1379 * @param output a pointer to the integer variable where the result shall be stored
1382 * @param base 2, 8, 10, or 16 1380 * @param base 2, 8, 10, or 16
1383 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1381 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1384 * @retval zero success 1382 * @retval zero success
1385 * @retval non-zero conversion was not possible 1383 * @retval non-zero conversion was not possible
1386 */ 1384 */
1387 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1385 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1388 int cx_strtou_lc_(cxstring str, unsigned int *output, int base, const char *groupsep); 1386 int cx_strtou_lc_(cxstring str, unsigned int *output, int base, const char *groupsep);
1395 * It sets errno to ERANGE when the target datatype is too small. 1393 * It sets errno to ERANGE when the target datatype is too small.
1396 * 1394 *
1397 * @param str the string to convert 1395 * @param str the string to convert
1398 * @param output a pointer to the integer variable where the result shall be stored 1396 * @param output a pointer to the integer variable where the result shall be stored
1399 * @param base 2, 8, 10, or 16 1397 * @param base 2, 8, 10, or 16
1400 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1398 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1401 * @retval zero success 1399 * @retval zero success
1402 * @retval non-zero conversion was not possible 1400 * @retval non-zero conversion was not possible
1403 */ 1401 */
1404 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1402 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1405 int cx_strtoul_lc_(cxstring str, unsigned long *output, int base, const char *groupsep); 1403 int cx_strtoul_lc_(cxstring str, unsigned long *output, int base, const char *groupsep);
1412 * It sets errno to ERANGE when the target datatype is too small. 1410 * It sets errno to ERANGE when the target datatype is too small.
1413 * 1411 *
1414 * @param str the string to convert 1412 * @param str the string to convert
1415 * @param output a pointer to the integer variable where the result shall be stored 1413 * @param output a pointer to the integer variable where the result shall be stored
1416 * @param base 2, 8, 10, or 16 1414 * @param base 2, 8, 10, or 16
1417 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1415 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1418 * @retval zero success 1416 * @retval zero success
1419 * @retval non-zero conversion was not possible 1417 * @retval non-zero conversion was not possible
1420 */ 1418 */
1421 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1419 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1422 int cx_strtoull_lc_(cxstring str, unsigned long long *output, int base, const char *groupsep); 1420 int cx_strtoull_lc_(cxstring str, unsigned long long *output, int base, const char *groupsep);
1429 * It sets errno to ERANGE when the target datatype is too small. 1427 * It sets errno to ERANGE when the target datatype is too small.
1430 * 1428 *
1431 * @param str the string to convert 1429 * @param str the string to convert
1432 * @param output a pointer to the integer variable where the result shall be stored 1430 * @param output a pointer to the integer variable where the result shall be stored
1433 * @param base 2, 8, 10, or 16 1431 * @param base 2, 8, 10, or 16
1434 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1432 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1435 * @retval zero success 1433 * @retval zero success
1436 * @retval non-zero conversion was not possible 1434 * @retval non-zero conversion was not possible
1437 */ 1435 */
1438 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1436 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1439 int cx_strtou8_lc_(cxstring str, uint8_t *output, int base, const char *groupsep); 1437 int cx_strtou8_lc_(cxstring str, uint8_t *output, int base, const char *groupsep);
1446 * It sets errno to ERANGE when the target datatype is too small. 1444 * It sets errno to ERANGE when the target datatype is too small.
1447 * 1445 *
1448 * @param str the string to convert 1446 * @param str the string to convert
1449 * @param output a pointer to the integer variable where the result shall be stored 1447 * @param output a pointer to the integer variable where the result shall be stored
1450 * @param base 2, 8, 10, or 16 1448 * @param base 2, 8, 10, or 16
1451 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1449 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1452 * @retval zero success 1450 * @retval zero success
1453 * @retval non-zero conversion was not possible 1451 * @retval non-zero conversion was not possible
1454 */ 1452 */
1455 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1453 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1456 int cx_strtou16_lc_(cxstring str, uint16_t *output, int base, const char *groupsep); 1454 int cx_strtou16_lc_(cxstring str, uint16_t *output, int base, const char *groupsep);
1463 * It sets errno to ERANGE when the target datatype is too small. 1461 * It sets errno to ERANGE when the target datatype is too small.
1464 * 1462 *
1465 * @param str the string to convert 1463 * @param str the string to convert
1466 * @param output a pointer to the integer variable where the result shall be stored 1464 * @param output a pointer to the integer variable where the result shall be stored
1467 * @param base 2, 8, 10, or 16 1465 * @param base 2, 8, 10, or 16
1468 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1466 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1469 * @retval zero success 1467 * @retval zero success
1470 * @retval non-zero conversion was not possible 1468 * @retval non-zero conversion was not possible
1471 */ 1469 */
1472 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1470 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1473 int cx_strtou32_lc_(cxstring str, uint32_t *output, int base, const char *groupsep); 1471 int cx_strtou32_lc_(cxstring str, uint32_t *output, int base, const char *groupsep);
1480 * It sets errno to ERANGE when the target datatype is too small. 1478 * It sets errno to ERANGE when the target datatype is too small.
1481 * 1479 *
1482 * @param str the string to convert 1480 * @param str the string to convert
1483 * @param output a pointer to the integer variable where the result shall be stored 1481 * @param output a pointer to the integer variable where the result shall be stored
1484 * @param base 2, 8, 10, or 16 1482 * @param base 2, 8, 10, or 16
1485 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1483 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1486 * @retval zero success 1484 * @retval zero success
1487 * @retval non-zero conversion was not possible 1485 * @retval non-zero conversion was not possible
1488 */ 1486 */
1489 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1487 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1490 int cx_strtou64_lc_(cxstring str, uint64_t *output, int base, const char *groupsep); 1488 int cx_strtou64_lc_(cxstring str, uint64_t *output, int base, const char *groupsep);
1497 * It sets errno to ERANGE when the target datatype is too small. 1495 * It sets errno to ERANGE when the target datatype is too small.
1498 * 1496 *
1499 * @param str the string to convert 1497 * @param str the string to convert
1500 * @param output a pointer to the integer variable where the result shall be stored 1498 * @param output a pointer to the integer variable where the result shall be stored
1501 * @param base 2, 8, 10, or 16 1499 * @param base 2, 8, 10, or 16
1502 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1500 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1503 * @retval zero success 1501 * @retval zero success
1504 * @retval non-zero conversion was not possible 1502 * @retval non-zero conversion was not possible
1505 */ 1503 */
1506 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1504 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1507 int cx_strtoz_lc_(cxstring str, size_t *output, int base, const char *groupsep); 1505 int cx_strtoz_lc_(cxstring str, size_t *output, int base, const char *groupsep);
1508 1506
1509 /** 1507 /**
1510 * Converts a string to a single precision floating point number. 1508 * Converts a string to a single precision floating-point number.
1511 * 1509 *
1512 * The function returns non-zero when conversion is not possible. 1510 * The function returns non-zero when conversion is not possible.
1513 * In that case the function sets errno to EINVAL when the reason is an invalid character. 1511 * In that case the function sets errno to EINVAL when the reason is an invalid character.
1514 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h. 1512 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h.
1515 * 1513 *
1516 * @param str the string to convert 1514 * @param str the string to convert
1517 * @param output a pointer to the float variable where the result shall be stored 1515 * @param output a pointer to the float variable where the result shall be stored
1518 * @param decsep the decimal separator 1516 * @param decsep the decimal separator
1519 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1517 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1520 * @retval zero success 1518 * @retval zero success
1521 * @retval non-zero conversion was not possible 1519 * @retval non-zero conversion was not possible
1522 */ 1520 */
1523 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1521 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1524 int cx_strtof_lc_(cxstring str, float *output, char decsep, const char *groupsep); 1522 int cx_strtof_lc_(cxstring str, float *output, char decsep, const char *groupsep);
1525 1523
1526 /** 1524 /**
1527 * Converts a string to a double precision floating point number. 1525 * Converts a string to a double precision floating-point number.
1528 * 1526 *
1529 * The function returns non-zero when conversion is not possible. 1527 * The function returns non-zero when conversion is not possible.
1530 * In that case the function sets errno to EINVAL when the reason is an invalid character. 1528 * In that case the function sets errno to EINVAL when the reason is an invalid character.
1531 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h. 1529 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h.
1532 * 1530 *
1533 * @param str the string to convert 1531 * @param str the string to convert
1534 * @param output a pointer to the float variable where the result shall be stored 1532 * @param output a pointer to the float variable where the result shall be stored
1535 * @param decsep the decimal separator 1533 * @param decsep the decimal separator
1536 * @param groupsep each character in this string is treated as group separator and ignored during conversion 1534 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
1537 * @retval zero success 1535 * @retval zero success
1538 * @retval non-zero conversion was not possible 1536 * @retval non-zero conversion was not possible
1539 */ 1537 */
1540 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export 1538 cx_attr_access_w(2) cx_attr_nonnull_arg(2) cx_attr_export
1541 int cx_strtod_lc_(cxstring str, double *output, char decsep, const char *groupsep); 1539 int cx_strtod_lc_(cxstring str, double *output, char decsep, const char *groupsep);
1548 * It sets errno to ERANGE when the target datatype is too small. 1546 * It sets errno to ERANGE when the target datatype is too small.
1549 * 1547 *
1550 * @param str the string to convert 1548 * @param str the string to convert
1551 * @param output a pointer to the integer variable where the result shall be stored 1549 * @param output a pointer to the integer variable where the result shall be stored
1552 * @param base 2, 8, 10, or 16 1550 * @param base 2, 8, 10, or 16
1553 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1551 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1554 * @retval zero success 1552 * @retval zero success
1555 * @retval non-zero conversion was not possible 1553 * @retval non-zero conversion was not possible
1556 */ 1554 */
1557 #define cx_strtos_lc(str, output, base, groupsep) cx_strtos_lc_(cx_strcast(str), output, base, groupsep) 1555 #define cx_strtos_lc(str, output, base, groupsep) cx_strtos_lc_(cx_strcast(str), output, base, groupsep)
1558 1556
1564 * It sets errno to ERANGE when the target datatype is too small. 1562 * It sets errno to ERANGE when the target datatype is too small.
1565 * 1563 *
1566 * @param str the string to convert 1564 * @param str the string to convert
1567 * @param output a pointer to the integer variable where the result shall be stored 1565 * @param output a pointer to the integer variable where the result shall be stored
1568 * @param base 2, 8, 10, or 16 1566 * @param base 2, 8, 10, or 16
1569 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1567 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1570 * @retval zero success 1568 * @retval zero success
1571 * @retval non-zero conversion was not possible 1569 * @retval non-zero conversion was not possible
1572 */ 1570 */
1573 #define cx_strtoi_lc(str, output, base, groupsep) cx_strtoi_lc_(cx_strcast(str), output, base, groupsep) 1571 #define cx_strtoi_lc(str, output, base, groupsep) cx_strtoi_lc_(cx_strcast(str), output, base, groupsep)
1574 1572
1580 * It sets errno to ERANGE when the target datatype is too small. 1578 * It sets errno to ERANGE when the target datatype is too small.
1581 * 1579 *
1582 * @param str the string to convert 1580 * @param str the string to convert
1583 * @param output a pointer to the integer variable where the result shall be stored 1581 * @param output a pointer to the integer variable where the result shall be stored
1584 * @param base 2, 8, 10, or 16 1582 * @param base 2, 8, 10, or 16
1585 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1583 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1586 * @retval zero success 1584 * @retval zero success
1587 * @retval non-zero conversion was not possible 1585 * @retval non-zero conversion was not possible
1588 */ 1586 */
1589 #define cx_strtol_lc(str, output, base, groupsep) cx_strtol_lc_(cx_strcast(str), output, base, groupsep) 1587 #define cx_strtol_lc(str, output, base, groupsep) cx_strtol_lc_(cx_strcast(str), output, base, groupsep)
1590 1588
1596 * It sets errno to ERANGE when the target datatype is too small. 1594 * It sets errno to ERANGE when the target datatype is too small.
1597 * 1595 *
1598 * @param str the string to convert 1596 * @param str the string to convert
1599 * @param output a pointer to the integer variable where the result shall be stored 1597 * @param output a pointer to the integer variable where the result shall be stored
1600 * @param base 2, 8, 10, or 16 1598 * @param base 2, 8, 10, or 16
1601 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1599 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1602 * @retval zero success 1600 * @retval zero success
1603 * @retval non-zero conversion was not possible 1601 * @retval non-zero conversion was not possible
1604 */ 1602 */
1605 #define cx_strtoll_lc(str, output, base, groupsep) cx_strtoll_lc_(cx_strcast(str), output, base, groupsep) 1603 #define cx_strtoll_lc(str, output, base, groupsep) cx_strtoll_lc_(cx_strcast(str), output, base, groupsep)
1606 1604
1612 * It sets errno to ERANGE when the target datatype is too small. 1610 * It sets errno to ERANGE when the target datatype is too small.
1613 * 1611 *
1614 * @param str the string to convert 1612 * @param str the string to convert
1615 * @param output a pointer to the integer variable where the result shall be stored 1613 * @param output a pointer to the integer variable where the result shall be stored
1616 * @param base 2, 8, 10, or 16 1614 * @param base 2, 8, 10, or 16
1617 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1615 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1618 * @retval zero success 1616 * @retval zero success
1619 * @retval non-zero conversion was not possible 1617 * @retval non-zero conversion was not possible
1620 */ 1618 */
1621 #define cx_strtoi8_lc(str, output, base, groupsep) cx_strtoi8_lc_(cx_strcast(str), output, base, groupsep) 1619 #define cx_strtoi8_lc(str, output, base, groupsep) cx_strtoi8_lc_(cx_strcast(str), output, base, groupsep)
1622 1620
1628 * It sets errno to ERANGE when the target datatype is too small. 1626 * It sets errno to ERANGE when the target datatype is too small.
1629 * 1627 *
1630 * @param str the string to convert 1628 * @param str the string to convert
1631 * @param output a pointer to the integer variable where the result shall be stored 1629 * @param output a pointer to the integer variable where the result shall be stored
1632 * @param base 2, 8, 10, or 16 1630 * @param base 2, 8, 10, or 16
1633 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1631 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1634 * @retval zero success 1632 * @retval zero success
1635 * @retval non-zero conversion was not possible 1633 * @retval non-zero conversion was not possible
1636 */ 1634 */
1637 #define cx_strtoi16_lc(str, output, base, groupsep) cx_strtoi16_lc_(cx_strcast(str), output, base, groupsep) 1635 #define cx_strtoi16_lc(str, output, base, groupsep) cx_strtoi16_lc_(cx_strcast(str), output, base, groupsep)
1638 1636
1644 * It sets errno to ERANGE when the target datatype is too small. 1642 * It sets errno to ERANGE when the target datatype is too small.
1645 * 1643 *
1646 * @param str the string to convert 1644 * @param str the string to convert
1647 * @param output a pointer to the integer variable where the result shall be stored 1645 * @param output a pointer to the integer variable where the result shall be stored
1648 * @param base 2, 8, 10, or 16 1646 * @param base 2, 8, 10, or 16
1649 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1647 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1650 * @retval zero success 1648 * @retval zero success
1651 * @retval non-zero conversion was not possible 1649 * @retval non-zero conversion was not possible
1652 */ 1650 */
1653 #define cx_strtoi32_lc(str, output, base, groupsep) cx_strtoi32_lc_(cx_strcast(str), output, base, groupsep) 1651 #define cx_strtoi32_lc(str, output, base, groupsep) cx_strtoi32_lc_(cx_strcast(str), output, base, groupsep)
1654 1652
1660 * It sets errno to ERANGE when the target datatype is too small. 1658 * It sets errno to ERANGE when the target datatype is too small.
1661 * 1659 *
1662 * @param str the string to convert 1660 * @param str the string to convert
1663 * @param output a pointer to the integer variable where the result shall be stored 1661 * @param output a pointer to the integer variable where the result shall be stored
1664 * @param base 2, 8, 10, or 16 1662 * @param base 2, 8, 10, or 16
1665 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1663 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1666 * @retval zero success 1664 * @retval zero success
1667 * @retval non-zero conversion was not possible 1665 * @retval non-zero conversion was not possible
1668 */ 1666 */
1669 #define cx_strtoi64_lc(str, output, base, groupsep) cx_strtoi64_lc_(cx_strcast(str), output, base, groupsep) 1667 #define cx_strtoi64_lc(str, output, base, groupsep) cx_strtoi64_lc_(cx_strcast(str), output, base, groupsep)
1670 1668
1676 * It sets errno to ERANGE when the target datatype is too small. 1674 * It sets errno to ERANGE when the target datatype is too small.
1677 * 1675 *
1678 * @param str the string to convert 1676 * @param str the string to convert
1679 * @param output a pointer to the integer variable where the result shall be stored 1677 * @param output a pointer to the integer variable where the result shall be stored
1680 * @param base 2, 8, 10, or 16 1678 * @param base 2, 8, 10, or 16
1681 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1679 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1682 * @retval zero success 1680 * @retval zero success
1683 * @retval non-zero conversion was not possible 1681 * @retval non-zero conversion was not possible
1684 */ 1682 */
1685 #define cx_strtous_lc(str, output, base, groupsep) cx_strtous_lc_(cx_strcast(str), output, base, groupsep) 1683 #define cx_strtous_lc(str, output, base, groupsep) cx_strtous_lc_(cx_strcast(str), output, base, groupsep)
1686 1684
1692 * It sets errno to ERANGE when the target datatype is too small. 1690 * It sets errno to ERANGE when the target datatype is too small.
1693 * 1691 *
1694 * @param str the string to convert 1692 * @param str the string to convert
1695 * @param output a pointer to the integer variable where the result shall be stored 1693 * @param output a pointer to the integer variable where the result shall be stored
1696 * @param base 2, 8, 10, or 16 1694 * @param base 2, 8, 10, or 16
1697 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1695 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1698 * @retval zero success 1696 * @retval zero success
1699 * @retval non-zero conversion was not possible 1697 * @retval non-zero conversion was not possible
1700 */ 1698 */
1701 #define cx_strtou_lc(str, output, base, groupsep) cx_strtou_lc_(cx_strcast(str), output, base, groupsep) 1699 #define cx_strtou_lc(str, output, base, groupsep) cx_strtou_lc_(cx_strcast(str), output, base, groupsep)
1702 1700
1708 * It sets errno to ERANGE when the target datatype is too small. 1706 * It sets errno to ERANGE when the target datatype is too small.
1709 * 1707 *
1710 * @param str the string to convert 1708 * @param str the string to convert
1711 * @param output a pointer to the integer variable where the result shall be stored 1709 * @param output a pointer to the integer variable where the result shall be stored
1712 * @param base 2, 8, 10, or 16 1710 * @param base 2, 8, 10, or 16
1713 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1711 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1714 * @retval zero success 1712 * @retval zero success
1715 * @retval non-zero conversion was not possible 1713 * @retval non-zero conversion was not possible
1716 */ 1714 */
1717 #define cx_strtoul_lc(str, output, base, groupsep) cx_strtoul_lc_(cx_strcast(str), output, base, groupsep) 1715 #define cx_strtoul_lc(str, output, base, groupsep) cx_strtoul_lc_(cx_strcast(str), output, base, groupsep)
1718 1716
1724 * It sets errno to ERANGE when the target datatype is too small. 1722 * It sets errno to ERANGE when the target datatype is too small.
1725 * 1723 *
1726 * @param str the string to convert 1724 * @param str the string to convert
1727 * @param output a pointer to the integer variable where the result shall be stored 1725 * @param output a pointer to the integer variable where the result shall be stored
1728 * @param base 2, 8, 10, or 16 1726 * @param base 2, 8, 10, or 16
1729 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1727 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1730 * @retval zero success 1728 * @retval zero success
1731 * @retval non-zero conversion was not possible 1729 * @retval non-zero conversion was not possible
1732 */ 1730 */
1733 #define cx_strtoull_lc(str, output, base, groupsep) cx_strtoull_lc_(cx_strcast(str), output, base, groupsep) 1731 #define cx_strtoull_lc(str, output, base, groupsep) cx_strtoull_lc_(cx_strcast(str), output, base, groupsep)
1734 1732
1740 * It sets errno to ERANGE when the target datatype is too small. 1738 * It sets errno to ERANGE when the target datatype is too small.
1741 * 1739 *
1742 * @param str the string to convert 1740 * @param str the string to convert
1743 * @param output a pointer to the integer variable where the result shall be stored 1741 * @param output a pointer to the integer variable where the result shall be stored
1744 * @param base 2, 8, 10, or 16 1742 * @param base 2, 8, 10, or 16
1745 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1743 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1746 * @retval zero success 1744 * @retval zero success
1747 * @retval non-zero conversion was not possible 1745 * @retval non-zero conversion was not possible
1748 */ 1746 */
1749 #define cx_strtou8_lc(str, output, base, groupsep) cx_strtou8_lc_(cx_strcast(str), output, base, groupsep) 1747 #define cx_strtou8_lc(str, output, base, groupsep) cx_strtou8_lc_(cx_strcast(str), output, base, groupsep)
1750 1748
1756 * It sets errno to ERANGE when the target datatype is too small. 1754 * It sets errno to ERANGE when the target datatype is too small.
1757 * 1755 *
1758 * @param str the string to convert 1756 * @param str the string to convert
1759 * @param output a pointer to the integer variable where the result shall be stored 1757 * @param output a pointer to the integer variable where the result shall be stored
1760 * @param base 2, 8, 10, or 16 1758 * @param base 2, 8, 10, or 16
1761 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1759 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1762 * @retval zero success 1760 * @retval zero success
1763 * @retval non-zero conversion was not possible 1761 * @retval non-zero conversion was not possible
1764 */ 1762 */
1765 #define cx_strtou16_lc(str, output, base, groupsep) cx_strtou16_lc_(cx_strcast(str), output, base, groupsep) 1763 #define cx_strtou16_lc(str, output, base, groupsep) cx_strtou16_lc_(cx_strcast(str), output, base, groupsep)
1766 1764
1772 * It sets errno to ERANGE when the target datatype is too small. 1770 * It sets errno to ERANGE when the target datatype is too small.
1773 * 1771 *
1774 * @param str the string to convert 1772 * @param str the string to convert
1775 * @param output a pointer to the integer variable where the result shall be stored 1773 * @param output a pointer to the integer variable where the result shall be stored
1776 * @param base 2, 8, 10, or 16 1774 * @param base 2, 8, 10, or 16
1777 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1775 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1778 * @retval zero success 1776 * @retval zero success
1779 * @retval non-zero conversion was not possible 1777 * @retval non-zero conversion was not possible
1780 */ 1778 */
1781 #define cx_strtou32_lc(str, output, base, groupsep) cx_strtou32_lc_(cx_strcast(str), output, base, groupsep) 1779 #define cx_strtou32_lc(str, output, base, groupsep) cx_strtou32_lc_(cx_strcast(str), output, base, groupsep)
1782 1780
1788 * It sets errno to ERANGE when the target datatype is too small. 1786 * It sets errno to ERANGE when the target datatype is too small.
1789 * 1787 *
1790 * @param str the string to convert 1788 * @param str the string to convert
1791 * @param output a pointer to the integer variable where the result shall be stored 1789 * @param output a pointer to the integer variable where the result shall be stored
1792 * @param base 2, 8, 10, or 16 1790 * @param base 2, 8, 10, or 16
1793 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1791 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1794 * @retval zero success 1792 * @retval zero success
1795 * @retval non-zero conversion was not possible 1793 * @retval non-zero conversion was not possible
1796 */ 1794 */
1797 #define cx_strtou64_lc(str, output, base, groupsep) cx_strtou64_lc_(cx_strcast(str), output, base, groupsep) 1795 #define cx_strtou64_lc(str, output, base, groupsep) cx_strtou64_lc_(cx_strcast(str), output, base, groupsep)
1798 1796
1804 * It sets errno to ERANGE when the target datatype is too small. 1802 * It sets errno to ERANGE when the target datatype is too small.
1805 * 1803 *
1806 * @param str the string to convert 1804 * @param str the string to convert
1807 * @param output a pointer to the integer variable where the result shall be stored 1805 * @param output a pointer to the integer variable where the result shall be stored
1808 * @param base 2, 8, 10, or 16 1806 * @param base 2, 8, 10, or 16
1809 * @param groupsep (@c const @c char*) each character in this string is treated as group separator and ignored during conversion 1807 * @param groupsep (@c const @c char*) each character in this string is treated as a group separator and ignored during conversion
1810 * @retval zero success 1808 * @retval zero success
1811 * @retval non-zero conversion was not possible 1809 * @retval non-zero conversion was not possible
1812 */ 1810 */
1813 #define cx_strtoz_lc(str, output, base, groupsep) cx_strtoz_lc_(cx_strcast(str), output, base, groupsep) 1811 #define cx_strtoz_lc(str, output, base, groupsep) cx_strtoz_lc_(cx_strcast(str), output, base, groupsep)
1814 1812
1817 * 1815 *
1818 * The function returns non-zero when conversion is not possible. 1816 * The function returns non-zero when conversion is not possible.
1819 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 1817 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
1820 * It sets errno to ERANGE when the target datatype is too small. 1818 * It sets errno to ERANGE when the target datatype is too small.
1821 * 1819 *
1822 * The comma character is treated as group separator and ignored during parsing. 1820 * The comma character is treated as a group separator and ignored during parsing.
1823 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 1821 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
1824 * 1822 *
1825 * @param str the string to convert 1823 * @param str the string to convert
1826 * @param output a pointer to the integer variable where the result shall be stored 1824 * @param output a pointer to the integer variable where the result shall be stored
1827 * @param base 2, 8, 10, or 16 1825 * @param base 2, 8, 10, or 16
1835 * 1833 *
1836 * The function returns non-zero when conversion is not possible. 1834 * The function returns non-zero when conversion is not possible.
1837 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 1835 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
1838 * It sets errno to ERANGE when the target datatype is too small. 1836 * It sets errno to ERANGE when the target datatype is too small.
1839 * 1837 *
1840 * The comma character is treated as group separator and ignored during parsing. 1838 * The comma character is treated as a group separator and ignored during parsing.
1841 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 1839 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
1842 * 1840 *
1843 * @param str the string to convert 1841 * @param str the string to convert
1844 * @param output a pointer to the integer variable where the result shall be stored 1842 * @param output a pointer to the integer variable where the result shall be stored
1845 * @param base 2, 8, 10, or 16 1843 * @param base 2, 8, 10, or 16
1853 * 1851 *
1854 * The function returns non-zero when conversion is not possible. 1852 * The function returns non-zero when conversion is not possible.
1855 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 1853 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
1856 * It sets errno to ERANGE when the target datatype is too small. 1854 * It sets errno to ERANGE when the target datatype is too small.
1857 * 1855 *
1858 * The comma character is treated as group separator and ignored during parsing. 1856 * The comma character is treated as a group separator and ignored during parsing.
1859 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 1857 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
1860 * 1858 *
1861 * @param str the string to convert 1859 * @param str the string to convert
1862 * @param output a pointer to the integer variable where the result shall be stored 1860 * @param output a pointer to the integer variable where the result shall be stored
1863 * @param base 2, 8, 10, or 16 1861 * @param base 2, 8, 10, or 16
1871 * 1869 *
1872 * The function returns non-zero when conversion is not possible. 1870 * The function returns non-zero when conversion is not possible.
1873 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 1871 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
1874 * It sets errno to ERANGE when the target datatype is too small. 1872 * It sets errno to ERANGE when the target datatype is too small.
1875 * 1873 *
1876 * The comma character is treated as group separator and ignored during parsing. 1874 * The comma character is treated as a group separator and ignored during parsing.
1877 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 1875 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
1878 * 1876 *
1879 * @param str the string to convert 1877 * @param str the string to convert
1880 * @param output a pointer to the integer variable where the result shall be stored 1878 * @param output a pointer to the integer variable where the result shall be stored
1881 * @param base 2, 8, 10, or 16 1879 * @param base 2, 8, 10, or 16
1889 * 1887 *
1890 * The function returns non-zero when conversion is not possible. 1888 * The function returns non-zero when conversion is not possible.
1891 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 1889 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
1892 * It sets errno to ERANGE when the target datatype is too small. 1890 * It sets errno to ERANGE when the target datatype is too small.
1893 * 1891 *
1894 * The comma character is treated as group separator and ignored during parsing. 1892 * The comma character is treated as a group separator and ignored during parsing.
1895 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 1893 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
1896 * 1894 *
1897 * @param str the string to convert 1895 * @param str the string to convert
1898 * @param output a pointer to the integer variable where the result shall be stored 1896 * @param output a pointer to the integer variable where the result shall be stored
1899 * @param base 2, 8, 10, or 16 1897 * @param base 2, 8, 10, or 16
1907 * 1905 *
1908 * The function returns non-zero when conversion is not possible. 1906 * The function returns non-zero when conversion is not possible.
1909 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 1907 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
1910 * It sets errno to ERANGE when the target datatype is too small. 1908 * It sets errno to ERANGE when the target datatype is too small.
1911 * 1909 *
1912 * The comma character is treated as group separator and ignored during parsing. 1910 * The comma character is treated as a group separator and ignored during parsing.
1913 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 1911 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
1914 * 1912 *
1915 * @param str the string to convert 1913 * @param str the string to convert
1916 * @param output a pointer to the integer variable where the result shall be stored 1914 * @param output a pointer to the integer variable where the result shall be stored
1917 * @param base 2, 8, 10, or 16 1915 * @param base 2, 8, 10, or 16
1925 * 1923 *
1926 * The function returns non-zero when conversion is not possible. 1924 * The function returns non-zero when conversion is not possible.
1927 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 1925 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
1928 * It sets errno to ERANGE when the target datatype is too small. 1926 * It sets errno to ERANGE when the target datatype is too small.
1929 * 1927 *
1930 * The comma character is treated as group separator and ignored during parsing. 1928 * The comma character is treated as a group separator and ignored during parsing.
1931 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 1929 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
1932 * 1930 *
1933 * @param str the string to convert 1931 * @param str the string to convert
1934 * @param output a pointer to the integer variable where the result shall be stored 1932 * @param output a pointer to the integer variable where the result shall be stored
1935 * @param base 2, 8, 10, or 16 1933 * @param base 2, 8, 10, or 16
1943 * 1941 *
1944 * The function returns non-zero when conversion is not possible. 1942 * The function returns non-zero when conversion is not possible.
1945 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 1943 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
1946 * It sets errno to ERANGE when the target datatype is too small. 1944 * It sets errno to ERANGE when the target datatype is too small.
1947 * 1945 *
1948 * The comma character is treated as group separator and ignored during parsing. 1946 * The comma character is treated as a group separator and ignored during parsing.
1949 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 1947 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
1950 * 1948 *
1951 * @param str the string to convert 1949 * @param str the string to convert
1952 * @param output a pointer to the integer variable where the result shall be stored 1950 * @param output a pointer to the integer variable where the result shall be stored
1953 * @param base 2, 8, 10, or 16 1951 * @param base 2, 8, 10, or 16
1961 * 1959 *
1962 * The function returns non-zero when conversion is not possible. 1960 * The function returns non-zero when conversion is not possible.
1963 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 1961 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
1964 * It sets errno to ERANGE when the target datatype is too small. 1962 * It sets errno to ERANGE when the target datatype is too small.
1965 * 1963 *
1966 * The comma character is treated as group separator and ignored during parsing. 1964 * The comma character is treated as a group separator and ignored during parsing.
1967 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 1965 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
1968 * 1966 *
1969 * @param str the string to convert 1967 * @param str the string to convert
1970 * @param output a pointer to the integer variable where the result shall be stored 1968 * @param output a pointer to the integer variable where the result shall be stored
1971 * @param base 2, 8, 10, or 16 1969 * @param base 2, 8, 10, or 16
1979 * 1977 *
1980 * The function returns non-zero when conversion is not possible. 1978 * The function returns non-zero when conversion is not possible.
1981 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 1979 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
1982 * It sets errno to ERANGE when the target datatype is too small. 1980 * It sets errno to ERANGE when the target datatype is too small.
1983 * 1981 *
1984 * The comma character is treated as group separator and ignored during parsing. 1982 * The comma character is treated as a group separator and ignored during parsing.
1985 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 1983 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
1986 * 1984 *
1987 * @param str the string to convert 1985 * @param str the string to convert
1988 * @param output a pointer to the integer variable where the result shall be stored 1986 * @param output a pointer to the integer variable where the result shall be stored
1989 * @param base 2, 8, 10, or 16 1987 * @param base 2, 8, 10, or 16
1997 * 1995 *
1998 * The function returns non-zero when conversion is not possible. 1996 * The function returns non-zero when conversion is not possible.
1999 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 1997 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
2000 * It sets errno to ERANGE when the target datatype is too small. 1998 * It sets errno to ERANGE when the target datatype is too small.
2001 * 1999 *
2002 * The comma character is treated as group separator and ignored during parsing. 2000 * The comma character is treated as a group separator and ignored during parsing.
2003 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 2001 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
2004 * 2002 *
2005 * @param str the string to convert 2003 * @param str the string to convert
2006 * @param output a pointer to the integer variable where the result shall be stored 2004 * @param output a pointer to the integer variable where the result shall be stored
2007 * @param base 2, 8, 10, or 16 2005 * @param base 2, 8, 10, or 16
2015 * 2013 *
2016 * The function returns non-zero when conversion is not possible. 2014 * The function returns non-zero when conversion is not possible.
2017 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 2015 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
2018 * It sets errno to ERANGE when the target datatype is too small. 2016 * It sets errno to ERANGE when the target datatype is too small.
2019 * 2017 *
2020 * The comma character is treated as group separator and ignored during parsing. 2018 * The comma character is treated as a group separator and ignored during parsing.
2021 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 2019 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
2022 * 2020 *
2023 * @param str the string to convert 2021 * @param str the string to convert
2024 * @param output a pointer to the integer variable where the result shall be stored 2022 * @param output a pointer to the integer variable where the result shall be stored
2025 * @param base 2, 8, 10, or 16 2023 * @param base 2, 8, 10, or 16
2033 * 2031 *
2034 * The function returns non-zero when conversion is not possible. 2032 * The function returns non-zero when conversion is not possible.
2035 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 2033 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
2036 * It sets errno to ERANGE when the target datatype is too small. 2034 * It sets errno to ERANGE when the target datatype is too small.
2037 * 2035 *
2038 * The comma character is treated as group separator and ignored during parsing. 2036 * The comma character is treated as a group separator and ignored during parsing.
2039 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 2037 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
2040 * 2038 *
2041 * @param str the string to convert 2039 * @param str the string to convert
2042 * @param output a pointer to the integer variable where the result shall be stored 2040 * @param output a pointer to the integer variable where the result shall be stored
2043 * @param base 2, 8, 10, or 16 2041 * @param base 2, 8, 10, or 16
2051 * 2049 *
2052 * The function returns non-zero when conversion is not possible. 2050 * The function returns non-zero when conversion is not possible.
2053 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 2051 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
2054 * It sets errno to ERANGE when the target datatype is too small. 2052 * It sets errno to ERANGE when the target datatype is too small.
2055 * 2053 *
2056 * The comma character is treated as group separator and ignored during parsing. 2054 * The comma character is treated as a group separator and ignored during parsing.
2057 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 2055 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
2058 * 2056 *
2059 * @param str the string to convert 2057 * @param str the string to convert
2060 * @param output a pointer to the integer variable where the result shall be stored 2058 * @param output a pointer to the integer variable where the result shall be stored
2061 * @param base 2, 8, 10, or 16 2059 * @param base 2, 8, 10, or 16
2069 * 2067 *
2070 * The function returns non-zero when conversion is not possible. 2068 * The function returns non-zero when conversion is not possible.
2071 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 2069 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
2072 * It sets errno to ERANGE when the target datatype is too small. 2070 * It sets errno to ERANGE when the target datatype is too small.
2073 * 2071 *
2074 * The comma character is treated as group separator and ignored during parsing. 2072 * The comma character is treated as a group separator and ignored during parsing.
2075 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 2073 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
2076 * 2074 *
2077 * @param str the string to convert 2075 * @param str the string to convert
2078 * @param output a pointer to the integer variable where the result shall be stored 2076 * @param output a pointer to the integer variable where the result shall be stored
2079 * @param base 2, 8, 10, or 16 2077 * @param base 2, 8, 10, or 16
2087 * 2085 *
2088 * The function returns non-zero when conversion is not possible. 2086 * The function returns non-zero when conversion is not possible.
2089 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 2087 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
2090 * It sets errno to ERANGE when the target datatype is too small. 2088 * It sets errno to ERANGE when the target datatype is too small.
2091 * 2089 *
2092 * The comma character is treated as group separator and ignored during parsing. 2090 * The comma character is treated as a group separator and ignored during parsing.
2093 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 2091 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
2094 * 2092 *
2095 * @param str the string to convert 2093 * @param str the string to convert
2096 * @param output a pointer to the integer variable where the result shall be stored 2094 * @param output a pointer to the integer variable where the result shall be stored
2097 * @param base 2, 8, 10, or 16 2095 * @param base 2, 8, 10, or 16
2105 * 2103 *
2106 * The function returns non-zero when conversion is not possible. 2104 * The function returns non-zero when conversion is not possible.
2107 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. 2105 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base.
2108 * It sets errno to ERANGE when the target datatype is too small. 2106 * It sets errno to ERANGE when the target datatype is too small.
2109 * 2107 *
2110 * The comma character is treated as group separator and ignored during parsing. 2108 * The comma character is treated as a group separator and ignored during parsing.
2111 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()). 2109 * If you want to choose the set of group separators, use the @c _lc variant of this function (e.g. cx_strtoz_lc()).
2112 * 2110 *
2113 * @param str the string to convert 2111 * @param str the string to convert
2114 * @param output a pointer to the integer variable where the result shall be stored 2112 * @param output a pointer to the integer variable where the result shall be stored
2115 * @param base 2, 8, 10, or 16 2113 * @param base 2, 8, 10, or 16
2117 * @retval non-zero conversion was not possible 2115 * @retval non-zero conversion was not possible
2118 */ 2116 */
2119 #define cx_strtou64(str, output, base) cx_strtou64_lc_(cx_strcast(str), output, base, ",") 2117 #define cx_strtou64(str, output, base) cx_strtou64_lc_(cx_strcast(str), output, base, ",")
2120 2118
2121 /** 2119 /**
2122 * Converts a string to a single precision floating point number. 2120 * Converts a string to a single precision floating-point number.
2123 * 2121 *
2124 * The function returns non-zero when conversion is not possible. 2122 * The function returns non-zero when conversion is not possible.
2125 * In that case the function sets errno to EINVAL when the reason is an invalid character. 2123 * In that case the function sets errno to EINVAL when the reason is an invalid character.
2126 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h. 2124 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h.
2127 * 2125 *
2128 * @param str the string to convert 2126 * @param str the string to convert
2129 * @param output a pointer to the float variable where the result shall be stored 2127 * @param output a pointer to the float variable where the result shall be stored
2130 * @param decsep the decimal separator 2128 * @param decsep the decimal separator
2131 * @param groupsep each character in this string is treated as group separator and ignored during conversion 2129 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
2132 * @retval zero success 2130 * @retval zero success
2133 * @retval non-zero conversion was not possible 2131 * @retval non-zero conversion was not possible
2134 */ 2132 */
2135 #define cx_strtof_lc(str, output, decsep, groupsep) cx_strtof_lc_(cx_strcast(str), output, decsep, groupsep) 2133 #define cx_strtof_lc(str, output, decsep, groupsep) cx_strtof_lc_(cx_strcast(str), output, decsep, groupsep)
2136 2134
2137 /** 2135 /**
2138 * Converts a string to a double precision floating point number. 2136 * Converts a string to a double precision floating-point number.
2139 * 2137 *
2140 * The function returns non-zero when conversion is not possible. 2138 * The function returns non-zero when conversion is not possible.
2141 * In that case the function sets errno to EINVAL when the reason is an invalid character. 2139 * In that case the function sets errno to EINVAL when the reason is an invalid character.
2142 * 2140 *
2143 * @param str the string to convert 2141 * @param str the string to convert
2144 * @param output a pointer to the double variable where the result shall be stored 2142 * @param output a pointer to the double variable where the result shall be stored
2145 * @param decsep the decimal separator 2143 * @param decsep the decimal separator
2146 * @param groupsep each character in this string is treated as group separator and ignored during conversion 2144 * @param groupsep each character in this string is treated as a group separator and ignored during conversion
2147 * @retval zero success 2145 * @retval zero success
2148 * @retval non-zero conversion was not possible 2146 * @retval non-zero conversion was not possible
2149 */ 2147 */
2150 #define cx_strtod_lc(str, output, decsep, groupsep) cx_strtod_lc_(cx_strcast(str), output, decsep, groupsep) 2148 #define cx_strtod_lc(str, output, decsep, groupsep) cx_strtod_lc_(cx_strcast(str), output, decsep, groupsep)
2151 2149
2152 /** 2150 /**
2153 * Converts a string to a single precision floating point number. 2151 * Converts a string to a single precision floating-point number.
2154 * 2152 *
2155 * The function returns non-zero when conversion is not possible. 2153 * The function returns non-zero when conversion is not possible.
2156 * In that case the function sets errno to EINVAL when the reason is an invalid character. 2154 * In that case the function sets errno to EINVAL when the reason is an invalid character.
2157 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h. 2155 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h.
2158 * 2156 *
2159 * The decimal separator is assumed to be a dot character. 2157 * The decimal separator is assumed to be a dot character.
2160 * The comma character is treated as group separator and ignored during parsing. 2158 * The comma character is treated as a group separator and ignored during parsing.
2161 * If you want to choose a different format, use cx_strtof_lc(). 2159 * If you want to choose a different format, use cx_strtof_lc().
2162 * 2160 *
2163 * @param str the string to convert 2161 * @param str the string to convert
2164 * @param output a pointer to the float variable where the result shall be stored 2162 * @param output a pointer to the float variable where the result shall be stored
2165 * @retval zero success 2163 * @retval zero success
2166 * @retval non-zero conversion was not possible 2164 * @retval non-zero conversion was not possible
2167 */ 2165 */
2168 #define cx_strtof(str, output) cx_strtof_lc_(cx_strcast(str), output, '.', ",") 2166 #define cx_strtof(str, output) cx_strtof_lc_(cx_strcast(str), output, '.', ",")
2169 2167
2170 /** 2168 /**
2171 * Converts a string to a double precision floating point number. 2169 * Converts a string to a double precision floating-point number.
2172 * 2170 *
2173 * The function returns non-zero when conversion is not possible. 2171 * The function returns non-zero when conversion is not possible.
2174 * In that case the function sets errno to EINVAL when the reason is an invalid character. 2172 * In that case the function sets errno to EINVAL when the reason is an invalid character.
2175 * 2173 *
2176 * The decimal separator is assumed to be a dot character. 2174 * The decimal separator is assumed to be a dot character.
2177 * The comma character is treated as group separator and ignored during parsing. 2175 * The comma character is treated as a group separator and ignored during parsing.
2178 * If you want to choose a different format, use cx_strtof_lc(). 2176 * If you want to choose a different format, use cx_strtof_lc().
2179 * 2177 *
2180 * @param str the string to convert 2178 * @param str the string to convert
2181 * @param output a pointer to the double variable where the result shall be stored 2179 * @param output a pointer to the double variable where the result shall be stored
2182 * @retval zero success 2180 * @retval zero success

mercurial