diff options
| author | Tyge Løvset <[email protected]> | 2022-04-18 00:44:51 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-04-18 00:44:51 +0200 |
| commit | 00804d9ff488f63468a0bb528c7b807aea7c3ea3 (patch) | |
| tree | 51b47787adc853bd1a10ec820a6ef5c184fa2498 /examples/replace.c | |
| parent | 4436a1c0ac37dc2e73a2134d5ad85c010340b35d (diff) | |
| download | STC-modified-00804d9ff488f63468a0bb528c7b807aea7c3ea3.tar.gz STC-modified-00804d9ff488f63468a0bb528c7b807aea7c3ea3.zip | |
Converted all example to use cstr_str(&s) instead of s.str to allow SSO string. Fixed misc warnings.
Diffstat (limited to 'examples/replace.c')
| -rw-r--r-- | examples/replace.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/examples/replace.c b/examples/replace.c index c425e4f8..a5bcf4d3 100644 --- a/examples/replace.c +++ b/examples/replace.c @@ -10,23 +10,23 @@ int main () // replace signatures used in the same order as described above:
- // Ustring positions: 0123456789*123456789*12345
- cstr s = cstr_from(base); // "this is a test string."
+ // Ustring positions: 0123456789*123456789*12345
+ cstr s = cstr_from(base); // "this is a test string."
cstr m = cstr_clone(s);
c_autodefer (cstr_drop(&s), cstr_drop(&m)) {
- cstr_append(&m, m.str);
- cstr_append(&m, m.str);
- printf("%s\n", m.str);
+ cstr_append(&m, cstr_str(&m));
+ cstr_append(&m, cstr_str(&m));
+ printf("%s\n", cstr_str(&m));
cstr_replace(&s, 9, 5, s2); // "this is an example string." (1)
- printf("(1) %s\n", s.str);
+ printf("(1) %s\n", cstr_str(&s));
cstr_replace_n(&s, 19, 6, s3+7, 6); // "this is an example phrase." (2)
- printf("(2) %s\n", s.str);
+ printf("(2) %s\n", cstr_str(&s));
cstr_replace(&s, 8, 10, "just a"); // "this is just a phrase." (3)
- printf("(3) %s\n", s.str);
+ printf("(3) %s\n", cstr_str(&s));
cstr_replace_n(&s, 8, 6,"a shorty", 7); // "this is a short phrase." (4)
- printf("(4) %s\n", s.str);
+ printf("(4) %s\n", cstr_str(&s));
cstr_replace(&s, 22, 1, "!!!"); // "this is a short phrase!!!" (5)
- printf("(5) %s\n", s.str);
+ printf("(5) %s\n", cstr_str(&s));
}
}
|
