add unsigned char strings to cx_strcast() and changes documentation

Wed, 08 Oct 2025 20:09:32 +0200

author
Mike Becker <universe@uap-core.de>
date
Wed, 08 Oct 2025 20:09:32 +0200
changeset 1416
e67caa21d5a7
parent 1415
40074e643663
child 1417
b97faf8b7ab7

add unsigned char strings to cx_strcast() and changes documentation

also relates to #700

src/cx/string.h file | annotate | diff | comparison | revisions
--- a/src/cx/string.h	Fri Oct 03 18:58:44 2025 +0200
+++ b/src/cx/string.h	Wed Oct 08 20:09:32 2025 +0200
@@ -304,20 +304,16 @@
 }
 
 /**
-* Casts a mutable string to an immutable string.
-*
-* Does nothing for already immutable strings.
-*
-* @note This is not seriously a cast. Instead, you get a copy
-* of the struct with the desired pointer type. Both structs still
-* point to the same location, though!
-*
-* @param str (@c cxstring or @c cxmutstr) the string to cast
-* @return (@c cxstring) an immutable copy of the string pointer
-*/
+ * Wraps any string into an UCX string.
+ *
+ * @param str (any supported string type) the string to cast
+ * @return (@c cxstring) the string wrapped as UCX string
+ */
 #define cx_strcast(str) _Generic((str), \
         cxmutstr: cx_strcast_m, \
         cxstring: cx_strcast_c, \
+        const unsigned char*: cx_strcast_z, \
+        unsigned char *: cx_strcast_z, \
         const char*: cx_strcast_z, \
         char *: cx_strcast_z) (str)
 #endif

mercurial