document substring family of functions default tip

Fri, 21 Feb 2025 21:06:07 +0100

author
Mike Becker <universe@uap-core.de>
date
Fri, 21 Feb 2025 21:06:07 +0100
changeset 1220
e9dfb1e92481
parent 1219
9c1c33ac077a

document substring family of functions

relates to #451

docs/Writerside/topics/string.h.md file | annotate | diff | comparison | revisions
--- a/docs/Writerside/topics/string.h.md	Thu Feb 20 21:21:25 2025 +0100
+++ b/docs/Writerside/topics/string.h.md	Fri Feb 21 21:06:07 2025 +0100
@@ -137,31 +137,41 @@
 
 cxstring cx_strchr(cxstring string, int chr);
 
-cxmutstr cx_strchr_m(cxmutstr string, int chr);
-
-cxstring cx_strrchr(cxstring string,int chr);
+cxstring cx_strrchr(cxstring string, int chr);
 
-cxmutstr cx_strrchr_m(cxmutstr string, int chr);
-
-cxstring cx_strstr(cxstring haystack, cxstring needle);
-
-cxmutstr cx_strstr_m(cxmutstr haystack, cxstring needle);
+cxstring cx_strstr(cxstring string, cxstring search);
 
 cxstring cx_strsubs(cxstring string, size_t start);
 
 cxstring cx_strsubsl(cxstring string, size_t start, size_t length);
 
+cxstring cx_strtrim(cxstring string);
+
+cxmutstr cx_strchr_m(cxmutstr string, int chr);
+
+cxmutstr cx_strrchr_m(cxmutstr string, int chr);
+
+cxmutstr cx_strstr_m(cxmutstr string, cxstring search);
+
 cxmutstr cx_strsubs_m(cxmutstr string, size_t start);
 
 cxmutstr cx_strsubsl_m(cxmutstr string, size_t start, size_t length);
 
-cxstring cx_strtrim(cxstring string);
-
 cxmutstr cx_strtrim_m(cxmutstr string);
 ```
 
-> Documentation work in progress.
->{style="warning"}
+The functions `cx_strchr()`, `cx_strrchr()`, and `cx_strstr()`, behave like their stdlib counterparts.
+
+The function `cx_strsubs()` returns the substring starting at the specified `start` index,
+and `cx_strsubsl()` returns a substring with at most `length` bytes.
+
+The function `cx_strtrim()` returns the substring that results when removing all leading and trailing
+whitespace characters (a space character is one of the following string: `" \t\r\n\v\f"`).
+
+All functions with the `_m` suffix behave exactly the same as their counterparts without `_m` suffix,
+except that they operate on a `cxmustr`.
+In _both_ variants the functions return a view into the given `string`
+and thus the returned strings must never be passed to `cx_strfree()`.
 
 ## Replace Substrings
 

mercurial