diff options
| author | Tyge Løvset <[email protected]> | 2022-12-05 22:17:59 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-12-05 22:17:59 +0100 |
| commit | 0eadaa1220e1ba0382638067aaf8566c216765fd (patch) | |
| tree | 5c85ee0180526184084196ff0d2da5462e02bcd2 | |
| parent | 11b835f89aca22d7d42edefbf31ca7e6d0d61b61 (diff) | |
| download | STC-modified-0eadaa1220e1ba0382638067aaf8566c216765fd.tar.gz STC-modified-0eadaa1220e1ba0382638067aaf8566c216765fd.zip | |
Minor corrections/changes.
| -rw-r--r-- | docs/cregex_api.md | 7 | ||||
| -rw-r--r-- | examples/new_arr.c | 6 | ||||
| -rw-r--r-- | examples/prime.c | 2 | ||||
| -rw-r--r-- | examples/regex_replace.c | 2 | ||||
| -rw-r--r-- | include/stc/carr2.h | 2 | ||||
| -rw-r--r-- | include/stc/cbits.h | 2 |
6 files changed, 10 insertions, 11 deletions
diff --git a/docs/cregex_api.md b/docs/cregex_api.md index feb17a9a..f1fd7461 100644 --- a/docs/cregex_api.md +++ b/docs/cregex_api.md @@ -86,9 +86,9 @@ If an error occurs ```cregex_compile``` returns a negative value, see error code ### Getting the first match ```c -#define i_implement -#include <stc/cstr.h> +#define i_extern // include external utf8 and cregex functions implementation. #include <stc/cregex.h> +#include <stc/cstr.h> int main() { const char* input = "start date is 2023-03-01, and end date is 2025-12-31."; @@ -104,7 +104,7 @@ int main() { printf("Could not find any date\n"); // Lets change all dates into US date format MM/DD/YYYY: - cstr us_input = cregex_replace(&re, input, "$2/$3/$1"); + cstr us_input = cregex_replace(&re, input, "$2/$3/$1", 0); printf("US input: %s\n", cstr_str(&us_input)); // Free allocated data @@ -112,7 +112,6 @@ int main() { cregex_drop(&re); } ``` - For a single match you may use the all-in-one function: ```c if (cregex_find_pattern(pattern, input, match, cre_default)) diff --git a/examples/new_arr.c b/examples/new_arr.c index 51955b46..79e7c7a6 100644 --- a/examples/new_arr.c +++ b/examples/new_arr.c @@ -13,7 +13,7 @@ int main() { int w = 7, h = 5, d = 3; - c_autodrop (carr2_int, volume, carr2_int_new_uninit(w, h)) + c_with (carr2_int volume = carr2_int_new_uninit(w, h), carr2_int_drop(&volume)) { int *dat = carr2_int_data(&volume); for (size_t i = 0; i < carr2_int_size(&volume); ++i) @@ -29,7 +29,7 @@ int main() puts("\n"); } - c_autodrop (carr3_int, volume, carr3_int_new_uninit(w, h, d)) + c_with (carr3_int volume = carr3_int_new_uninit(w, h, d), carr3_int_drop(&volume)) { int *dat = carr3_int_data(&volume); for (size_t i = 0; i < carr3_int_size(&volume); ++i) @@ -46,7 +46,7 @@ int main() puts(""); } - c_autodrop (carr2_str, text2d, carr2_str_with_size(h, d, cstr_init())) + c_with (carr2_str text2d = carr2_str_with_size(h, d, cstr_null), carr2_str_drop(&text2d)) { cstr_assign(&text2d.data[2][1], "hello"); cstr_assign(&text2d.data[4][0], "world"); diff --git a/examples/prime.c b/examples/prime.c index d2fc5efa..287fb69b 100644 --- a/examples/prime.c +++ b/examples/prime.c @@ -28,7 +28,7 @@ int main(void) printf("computing prime numbers up to %" c_ZU "\n", n); clock_t t1 = clock(); - c_autodrop (cbits, primes, sieveOfEratosthenes(n + 1)) { + c_with (cbits primes = sieveOfEratosthenes(n + 1), cbits_drop(&primes)) { puts("done"); size_t np = cbits_count(&primes); clock_t t2 = clock(); diff --git a/examples/regex_replace.c b/examples/regex_replace.c index 4091a59e..e88c559f 100644 --- a/examples/regex_replace.c +++ b/examples/regex_replace.c @@ -34,7 +34,7 @@ int main() printf("brack: %s\n", cstr_str(&str)); /* Shows how to compile RE separately */ - c_autodrop (cregex, re, cregex_from(pattern, cre_default)) { + c_with (cregex re = cregex_from(pattern, cre_default), cregex_drop(&re)) { if (cregex_captures(&re) == 0) continue; // break c_with /* European date format. */ diff --git a/include/stc/carr2.h b/include/stc/carr2.h index 1399b8f6..2574a933 100644 --- a/include/stc/carr2.h +++ b/include/stc/carr2.h @@ -35,7 +35,7 @@ int main() { int w = 7, h = 5; - c_autodrop (carr2_int, image, carr2_int_new_uninit(w, h)) + c_with (carr2_int image = carr2_int_new_uninit(w, h), carr2_int_drop(&image)) { int *dat = carr2_int_data(&image); for (int i = 0; i < carr2_int_size(&image); ++i) diff --git a/include/stc/cbits.h b/include/stc/cbits.h index 3a5c63e6..031ef80c 100644 --- a/include/stc/cbits.h +++ b/include/stc/cbits.h @@ -27,7 +27,7 @@ Similar to boost::dynamic_bitset / std::bitset #include "cbits.h" int main() { - c_autodrop (cbits, bset, cbits_with_size(23, true)) + c_with (cbits bset = cbits_with_size(23, true), cbits_drop(&bset)) { cbits_reset(&bset, 9); cbits_resize(&bset, 43, false); |
