From 0761c13f316cc98ae7756f3527931aa86bed5016 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Thu, 29 Dec 2022 00:28:50 +0100 Subject: Restructuring of some headers into include/algo folder. Some API changes *_replace*() functions have been renamed, and a few minor API changes. --- misc/examples/cpque.c | 2 +- misc/examples/demos.c | 2 +- misc/examples/forfilter.c | 8 +++++--- misc/examples/forloops.c | 2 +- misc/examples/prime.c | 6 ++++-- misc/examples/regex_replace.c | 4 ++-- misc/examples/utf8replace_c.c | 4 ++-- 7 files changed, 16 insertions(+), 12 deletions(-) (limited to 'misc/examples') diff --git a/misc/examples/cpque.c b/misc/examples/cpque.c index 47080038..2ec841ae 100644 --- a/misc/examples/cpque.c +++ b/misc/examples/cpque.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include // predeclare diff --git a/misc/examples/demos.c b/misc/examples/demos.c index b077aa73..4a9fac89 100644 --- a/misc/examples/demos.c +++ b/misc/examples/demos.c @@ -13,7 +13,7 @@ void stringdemo1() cstr_erase(&cs, 7, 5); // -nine printf("%s.\n", cstr_str(&cs)); - cstr_replace(&cs, "seven", "four", 1); + cstr_replace_ex(&cs, "seven", "four", 1); printf("%s.\n", cstr_str(&cs)); cstr_take(&cs, cstr_from_fmt("%s *** %s", cstr_str(&cs), cstr_str(&cs))); diff --git a/misc/examples/forfilter.c b/misc/examples/forfilter.c index 32154904..c0a4ccad 100644 --- a/misc/examples/forfilter.c +++ b/misc/examples/forfilter.c @@ -2,7 +2,8 @@ #define i_extern #include #include -#include +#include +#include #define i_type IVec #define i_val int @@ -63,12 +64,13 @@ void demo2(void) c_AUTO (IVec, vector) { puts("demo2:"); - c_FORFILTER (x, crange, crange_literal(INT64_MAX) + c_FORFILTER (x, crange, crange_LITERAL(INT64_MAX) , c_FLT_SKIPWHILE(x, *x.ref != 11) && *x.ref % 2 != 0 , c_FLT_TAKE(x, 5)) IVec_push(&vector, *x.ref * *x.ref); - c_FOREACH (x, IVec, vector) printf(" %d", *x.ref); + c_FOREACH (x, IVec, vector) + printf(" %d", *x.ref); puts(""); } } diff --git a/misc/examples/forloops.c b/misc/examples/forloops.c index 95a955a3..69c1c193 100644 --- a/misc/examples/forloops.c +++ b/misc/examples/forloops.c @@ -1,5 +1,5 @@ #include -#include +#include #define i_type IVec #define i_val int diff --git a/misc/examples/prime.c b/misc/examples/prime.c index 41d637b8..f6e89e09 100644 --- a/misc/examples/prime.c +++ b/misc/examples/prime.c @@ -2,7 +2,9 @@ #include #include #include -#include +#include +#include + cbits sieveOfEratosthenes(size_t n) { @@ -41,7 +43,7 @@ int main(void) puts(""); puts("Show the last 50 primes using a temporary crange generator:"); - c_FORFILTER (i, crange, crange_literal(n - 1, 0, -2) + c_FORFILTER (i, crange, crange_LITERAL(n - 1, 0, -2) , cbits_test(&primes, *i.ref>>1) , c_FLT_TAKE(i, 50)) { printf("%lld ", *i.ref); diff --git a/misc/examples/regex_replace.c b/misc/examples/regex_replace.c index d621c0db..a170856b 100644 --- a/misc/examples/regex_replace.c +++ b/misc/examples/regex_replace.c @@ -26,11 +26,11 @@ int main() printf("fixed: %s\n", cstr_str(&str)); /* US date format, and add 10 years to dates: */ - cstr_take(&str, cregex_replace_pattern_n(pattern, input, "$1/$3/$2", 0, add_10_years, CREG_DEFAULT)); + cstr_take(&str, cregex_replace_pattern_ex(pattern, input, "$1/$3/$2", 0, add_10_years, CREG_DEFAULT)); printf("us+10: %s\n", cstr_str(&str)); /* Wrap first date inside []: */ - cstr_take(&str, cregex_replace_pattern_n(pattern, input, "[$0]", 1, NULL, CREG_DEFAULT)); + cstr_take(&str, cregex_replace_pattern_ex(pattern, input, "[$0]", 1, NULL, CREG_DEFAULT)); printf("brack: %s\n", cstr_str(&str)); /* Shows how to compile RE separately */ diff --git a/misc/examples/utf8replace_c.c b/misc/examples/utf8replace_c.c index 74b765dc..3645bd0a 100644 --- a/misc/examples/utf8replace_c.c +++ b/misc/examples/utf8replace_c.c @@ -8,10 +8,10 @@ int main() { printf("%s\n", cstr_str(&hello)); /* replace second smiley at utf8 codepoint pos 7 */ - cstr_u8_replace(&hello, cstr_u8_to_pos(&hello, 7), 1, c_SV("🐨")); + cstr_u8_replace_at(&hello, cstr_u8_to_pos(&hello, 7), 1, c_SV("🐨")); printf("%s\n", cstr_str(&hello)); - cstr_replace(&hello, "🐨", "ø", 1); + cstr_replace_ex(&hello, "🐨", "ø", 1); printf("%s\n", cstr_str(&hello)); upper = cstr_toupper_sv(cstr_sv(&hello)); -- cgit v1.2.3