summaryrefslogtreecommitdiffhomepage
path: root/misc/examples/strings/sso_substr.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-08-14 16:46:24 +0200
committerTyge Løvset <[email protected]>2023-08-14 16:46:24 +0200
commit78d8668e6d527070568a405408ed906e51055bf4 (patch)
tree60f963a36826acce264c7ecd0af3eb80502a4335 /misc/examples/strings/sso_substr.c
parent2b6b4785c5c26bc47d800c1a7c7a48784df2d57b (diff)
downloadSTC-modified-78d8668e6d527070568a405408ed906e51055bf4.tar.gz
STC-modified-78d8668e6d527070568a405408ed906e51055bf4.zip
Reverted csubstr => csview. Sorry about that!
Added crawstr to become the null-terminated string view.
Diffstat (limited to 'misc/examples/strings/sso_substr.c')
-rw-r--r--misc/examples/strings/sso_substr.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/misc/examples/strings/sso_substr.c b/misc/examples/strings/sso_substr.c
index 2262e349..70d34440 100644
--- a/misc/examples/strings/sso_substr.c
+++ b/misc/examples/strings/sso_substr.c
@@ -1,20 +1,20 @@
#define i_implement
#include <stc/cstr.h>
#define i_implement
-#include <stc/csubstr.h>
+#include <stc/csview.h>
int main(void)
{
cstr str = cstr_from("We think in generalities, but we live in details.");
- csubstr sv1 = cstr_substr_ex(&str, 3, 5); // "think"
+ csview sv1 = cstr_substr_ex(&str, 3, 5); // "think"
intptr_t pos = cstr_find(&str, "live"); // position of "live"
- csubstr sv2 = cstr_substr_ex(&str, pos, 4); // "live"
- csubstr sv3 = cstr_slice_ex(&str, -8, -1); // "details"
- printf("%.*s, %.*s, %.*s\n", c_SS(sv1), c_SS(sv2), c_SS(sv3));
+ csview sv2 = cstr_substr_ex(&str, pos, 4); // "live"
+ csview sv3 = cstr_slice_ex(&str, -8, -1); // "details"
+ printf("%.*s, %.*s, %.*s\n", c_SV(sv1), c_SV(sv2), c_SV(sv3));
cstr_assign(&str, "apples are green or red");
- cstr s2 = cstr_from_ss(cstr_substr_ex(&str, -3, 3)); // "red"
- cstr s3 = cstr_from_ss(cstr_substr_ex(&str, 0, 6)); // "apples"
+ cstr s2 = cstr_from_sv(cstr_substr_ex(&str, -3, 3)); // "red"
+ cstr s3 = cstr_from_sv(cstr_substr_ex(&str, 0, 6)); // "apples"
printf("%s %s: %d, %d\n", cstr_str(&s2), cstr_str(&s3),
cstr_is_long(&str), cstr_is_long(&s2));
c_drop (cstr, &str, &s2, &s3);