summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/astar.c2
-rw-r--r--examples/books.c4
-rw-r--r--examples/city.c8
-rw-r--r--examples/csmap_erase.c10
-rw-r--r--examples/csmap_insert.c2
-rw-r--r--examples/cstr_match.c4
-rw-r--r--examples/demos.c2
-rw-r--r--examples/inits.c2
-rw-r--r--examples/sso_substr.c2
-rw-r--r--examples/utf8replace_c.c2
10 files changed, 19 insertions, 19 deletions
diff --git a/examples/astar.c b/examples/astar.c
index 4d9f2469..d4a821f9 100644
--- a/examples/astar.c
+++ b/examples/astar.c
@@ -131,7 +131,7 @@ astar(cstr* maze, int width)
int
main(void)
{
- c_with (cstr maze = cstr_new(
+ c_with (cstr maze = cstr_lit(
"#########################################################################\n"
"# # # # # # #\n"
"# # ######### # ##### ######### ##### ##### ##### # ! #\n"
diff --git a/examples/books.c b/examples/books.c
index bfced28f..b6067d81 100644
--- a/examples/books.c
+++ b/examples/books.c
@@ -24,8 +24,8 @@ int main()
"Very enjoyable"
);
cmap_str_insert(&book_reviews,
- cstr_new("The Adventures of Sherlock Holmes"),
- cstr_new("Eye lyked it alot.")
+ cstr_lit("The Adventures of Sherlock Holmes"),
+ cstr_lit("Eye lyked it alot.")
);
// Check for a specific one.
diff --git a/examples/city.c b/examples/city.c
index 0996fe9b..8557c6cf 100644
--- a/examples/city.c
+++ b/examples/city.c
@@ -54,10 +54,10 @@ int main(void)
c_auto (CityMap, map)
{
c_forlist (i, City, {
- {cstr_new("New York"), cstr_new("US"), 4.3f, 23.2f, 9000000},
- {cstr_new("Paris"), cstr_new("France"), 4.3f, 23.2f, 9000000},
- {cstr_new("Berlin"), cstr_new("Germany"), 4.3f, 23.2f, 9000000},
- {cstr_new("London"), cstr_new("UK"), 4.3f, 23.2f, 9000000},
+ {cstr_lit("New York"), cstr_lit("US"), 4.3f, 23.2f, 9000000},
+ {cstr_lit("Paris"), cstr_lit("France"), 4.3f, 23.2f, 9000000},
+ {cstr_lit("Berlin"), cstr_lit("Germany"), 4.3f, 23.2f, 9000000},
+ {cstr_lit("London"), cstr_lit("UK"), 4.3f, 23.2f, 9000000},
}) Cities_emplace(&cities, *i.ref); // NB. creates smart pointers!
Cities_sort(&cities);
diff --git a/examples/csmap_erase.c b/examples/csmap_erase.c
index 97f45779..48d8ceef 100644
--- a/examples/csmap_erase.c
+++ b/examples/csmap_erase.c
@@ -20,11 +20,11 @@ int main()
c_auto (mymap, m1)
{
// Fill in some data to test with, one at a time
- mymap_insert(&m1, 1, cstr_new("A"));
- mymap_insert(&m1, 2, cstr_new("B"));
- mymap_insert(&m1, 3, cstr_new("C"));
- mymap_insert(&m1, 4, cstr_new("D"));
- mymap_insert(&m1, 5, cstr_new("E"));
+ mymap_insert(&m1, 1, cstr_lit("A"));
+ mymap_insert(&m1, 2, cstr_lit("B"));
+ mymap_insert(&m1, 3, cstr_lit("C"));
+ mymap_insert(&m1, 4, cstr_lit("D"));
+ mymap_insert(&m1, 5, cstr_lit("E"));
puts("Starting data of map m1 is:");
printmap(m1);
diff --git a/examples/csmap_insert.c b/examples/csmap_insert.c
index 5b18d691..8f777fc6 100644
--- a/examples/csmap_insert.c
+++ b/examples/csmap_insert.c
@@ -85,7 +85,7 @@ int main()
// The templatized versions move-constructing elements
c_auto (csmap_istr, m3) {
- csmap_istr_value ip1 = {475, cstr_new("blue")}, ip2 = {510, cstr_new("green")};
+ csmap_istr_value ip1 = {475, cstr_lit("blue")}, ip2 = {510, cstr_lit("green")};
// single element
csmap_istr_insert(&m3, ip1.first, cstr_move(&ip1.second));
diff --git a/examples/cstr_match.c b/examples/cstr_match.c
index 5ba09ed9..286ba505 100644
--- a/examples/cstr_match.c
+++ b/examples/cstr_match.c
@@ -4,7 +4,7 @@
int main()
{
- c_with (cstr ss = cstr_new("The quick brown fox jumps over the lazy dog.JPG"), cstr_drop(&ss)) {
+ c_with (cstr ss = cstr_lit("The quick brown fox jumps over the lazy dog.JPG"), cstr_drop(&ss)) {
size_t pos = cstr_find_at(&ss, 0, "brown");
printf("%" c_ZU " [%s]\n", pos, pos == c_NPOS ? "<NULL>" : cstr_str(&ss) + pos);
printf("equals: %d\n", cstr_equals(&ss, "The quick brown fox jumps over the lazy dog.JPG"));
@@ -13,7 +13,7 @@ int main()
printf("ends_with: %d\n", cstr_ends_with(&ss, ".jpg"));
printf("ends_with: %d\n", cstr_ends_with(&ss, ".JPG"));
- cstr s1 = cstr_new("hell😀 w😀rl🐨");
+ cstr s1 = cstr_lit("hell😀 w😀rl🐨");
csview ch1 = cstr_u8_chr(&s1, 7);
csview ch2 = cstr_u8_chr(&s1, 10);
printf("%s\nsize: %" c_ZU ", %" c_ZU "\n", cstr_str(&s1), cstr_u8_size(&s1), cstr_size(&s1));
diff --git a/examples/demos.c b/examples/demos.c
index 2795b478..fc3771cb 100644
--- a/examples/demos.c
+++ b/examples/demos.c
@@ -3,7 +3,7 @@
void stringdemo1()
{
printf("\nSTRINGDEMO1\n");
- c_with (cstr cs = cstr_new("one-nine-three-seven-five"), cstr_drop(&cs))
+ c_with (cstr cs = cstr_lit("one-nine-three-seven-five"), cstr_drop(&cs))
{
printf("%s.\n", cstr_str(&cs));
diff --git a/examples/inits.c b/examples/inits.c
index 324168cf..021a3e0a 100644
--- a/examples/inits.c
+++ b/examples/inits.c
@@ -56,7 +56,7 @@ int main(void)
int year = 2020;
c_auto (cmap_id, idnames) {
cmap_id_emplace(&idnames, 100, "Hello");
- cmap_id_insert(&idnames, 110, cstr_new("World"));
+ cmap_id_insert(&idnames, 110, cstr_lit("World"));
cmap_id_insert(&idnames, 120, cstr_from_fmt("Howdy, -%d-", year));
c_foreach (i, cmap_id, idnames)
diff --git a/examples/sso_substr.c b/examples/sso_substr.c
index ea10c411..be372a8d 100644
--- a/examples/sso_substr.c
+++ b/examples/sso_substr.c
@@ -4,7 +4,7 @@
int main ()
{
- cstr str = cstr_new("We think in generalities, but we live in details.");
+ cstr str = cstr_lit("We think in generalities, but we live in details.");
csview sv1 = cstr_substr_ex(&str, 3, 5); // "think"
size_t pos = cstr_find(&str, "live"); // position of "live"
csview sv2 = cstr_substr_ex(&str, pos, 4); // "live"
diff --git a/examples/utf8replace_c.c b/examples/utf8replace_c.c
index 35e6b8ef..22a5c990 100644
--- a/examples/utf8replace_c.c
+++ b/examples/utf8replace_c.c
@@ -4,7 +4,7 @@
int main() {
c_auto (cstr, hello, upper) {
- hello = cstr_new("hell😀 w😀rld");
+ hello = cstr_lit("hell😀 w😀rld");
printf("%s\n", cstr_str(&hello));
/* replace second smiley at utf8 codepoint pos 7 */