diff options
| author | tylov <[email protected]> | 2023-08-13 23:15:45 +0200 |
|---|---|---|
| committer | tylov <[email protected]> | 2023-08-13 23:15:45 +0200 |
| commit | 25dc58db206714dc02c1ae0548f6ba7dd3519d29 (patch) | |
| tree | dcf65b08300d82c4d6752284d5c0a5a00507f07f /misc/examples/strings/cstr_match.c | |
| parent | 8bb2f5618e4cefe668a663936354cf53191f2129 (diff) | |
| download | STC-modified-25dc58db206714dc02c1ae0548f6ba7dd3519d29.tar.gz STC-modified-25dc58db206714dc02c1ae0548f6ba7dd3519d29.zip | |
API CHANGES:
Changed csview: becomes a null-terminated string view.
Added csubview: a null-terminated string view/span, like previous csview.
Note that csview works like a csubview, so not much compability issues should arise.
However, some functions have changed from _sv suffix to _ss.
Diffstat (limited to 'misc/examples/strings/cstr_match.c')
| -rw-r--r-- | misc/examples/strings/cstr_match.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/misc/examples/strings/cstr_match.c b/misc/examples/strings/cstr_match.c index be03e981..3c41bd43 100644 --- a/misc/examples/strings/cstr_match.c +++ b/misc/examples/strings/cstr_match.c @@ -1,11 +1,11 @@ #define i_implement #include <stc/cstr.h> -#include <stc/csview.h> +#include <stc/csubstr.h> #include <stdio.h> int main(void) { - cstr ss = cstr_lit("The quick brown fox jumps over the lazy dog.JPG"); + cstr ss = cstr_from("The quick brown fox jumps over the lazy dog.JPG"); intptr_t pos = cstr_find_at(&ss, 0, "brown"); printf("%" c_ZI " [%s]\n", pos, pos == c_NPOS ? "<NULL>" : cstr_str(&ss) + pos); @@ -16,11 +16,11 @@ int main(void) printf("ends_with: %d\n", cstr_ends_with(&ss, ".JPG")); cstr s1 = cstr_lit("hell😀 w😀rl🐨"); - csview ch1 = cstr_u8_chr(&s1, 7); - csview ch2 = cstr_u8_chr(&s1, 10); + csubstr ch1 = cstr_u8_chr(&s1, 7); + csubstr ch2 = cstr_u8_chr(&s1, 10); printf("%s\nsize: %" c_ZI ", %" c_ZI "\n", cstr_str(&s1), cstr_u8_size(&s1), cstr_size(&s1)); - printf("ch1: %.*s\n", c_SV(ch1)); - printf("ch2: %.*s\n", c_SV(ch2)); + printf("ch1: %.*s\n", c_SS(ch1)); + printf("ch2: %.*s\n", c_SS(ch2)); c_drop(cstr, &ss, &s1); } |
