diff options
| author | Tyge Løvset <[email protected]> | 2021-06-11 16:38:06 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-06-11 16:38:06 +0200 |
| commit | b8f24b90481d83d06ae89e2594c249c9741dae21 (patch) | |
| tree | 84e8c3807f97221435ec5191e17fb0e8b78e483e /examples | |
| parent | c7944e2ddb51819dfaee9dd8d3708df54bd5a5d1 (diff) | |
| download | STC-modified-b8f24b90481d83d06ae89e2594c249c9741dae21.tar.gz STC-modified-b8f24b90481d83d06ae89e2594c249c9741dae21.zip | |
Improve naming of c_sv() and c_lit() in csview.h: Rename c_sv(cstr) => cstr_sv(cstr), and c_lit(string literal) => c_sv(string literal). Hopefully not too much used yet, as they are fairly new.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/splitstr.c | 6 | ||||
| -rw-r--r-- | examples/svmap.c | 8 |
2 files changed, 7 insertions, 7 deletions
diff --git a/examples/splitstr.c b/examples/splitstr.c index b6c703b4..54bbe92d 100644 --- a/examples/splitstr.c +++ b/examples/splitstr.c @@ -29,12 +29,12 @@ cvec_str string_split(csview str, csview sep) int main()
{
puts("Output from print_split():");
- print_split(c_lit("//This is a//double-slash//separated//string"), c_lit("//")); puts("");
- print_split(c_lit("This has no matching separator"), c_lit("xx")); puts("");
+ print_split(c_sv("//This is a//double-slash//separated//string"), c_sv("//")); puts("");
+ print_split(c_sv("This has no matching separator"), c_sv("xx")); puts("");
puts("Output from string_split():");
cstr string = cstr_lit("Split,this,,string,now,");
- cvec_str vec = string_split(c_sv(string), c_lit(","));
+ cvec_str vec = string_split(cstr_sv(string), c_sv(","));
c_fordefer (cvec_str_del(&vec), cstr_del(&string))
c_foreach (i, cvec_str, vec)
diff --git a/examples/svmap.c b/examples/svmap.c index 769913df..d0f84ce4 100644 --- a/examples/svmap.c +++ b/examples/svmap.c @@ -6,7 +6,7 @@ using_cmap_strvkey(si, int);
int main() {
- csview fox = c_lit("The quick brown fox jumps over the lazy dog.");
+ csview fox = c_sv("The quick brown fox jumps over the lazy dog.");
printf("\"%s\", length=%zu\n", fox.str, fox.size);
c_forvar_initdel (cmap_si, frequencies)
@@ -18,13 +18,13 @@ int main() { // Emplace: csview element API
const char* key = "hundred";
- cmap_si_emplace(&frequencies, c_lit("hundred"), 300); // c_lit() shorthand for csview_lit()
+ cmap_si_emplace(&frequencies, c_sv("hundred"), 300); // c_sv() shorthand for csview_lit()
cmap_si_emplace(&frequencies, csview_from_n(key, 4), 400); // insert "hund"
cmap_si_emplace_or_assign(&frequencies, csview_from(key), 500); // update
- cmap_si_emplace(&frequencies, c_lit("hundred"), 600); // ignored, already inserted
+ cmap_si_emplace(&frequencies, c_sv("hundred"), 600); // ignored, already inserted
// Lookup always uses "raw" type API, i.e. csview here.
- printf("at(\"hundred\"): %d\n", *cmap_si_at(&frequencies, c_lit("hundred")));
+ printf("at(\"hundred\"): %d\n", *cmap_si_at(&frequencies, c_sv("hundred")));
c_foreach (i, cmap_si, frequencies)
printf("%s: %d\n", i.ref->first.str, i.ref->second);
|
