diff options
| author | Tyge Løvset <[email protected]> | 2023-02-05 21:21:55 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2023-02-05 21:21:55 +0100 |
| commit | e6dfaf1720f6833784d17d5364e1dd76324dff6a (patch) | |
| tree | 0808f479425e58971aef993288bb818e60417422 /docs | |
| parent | 217865ae413f9cfcc72af176ec7e98f418bddbea (diff) | |
| download | STC-modified-e6dfaf1720f6833784d17d5364e1dd76324dff6a.tar.gz STC-modified-e6dfaf1720f6833784d17d5364e1dd76324dff6a.zip | |
Some last minute changes: reverted mostly the c_extern from last commit.
Renamed c_ARGSV(sv) macro to c_SVARG(sv). Both available.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/cregex_api.md | 8 | ||||
| -rw-r--r-- | docs/csview_api.md | 10 |
2 files changed, 9 insertions, 9 deletions
diff --git a/docs/cregex_api.md b/docs/cregex_api.md index e74040d8..a115b4af 100644 --- a/docs/cregex_api.md +++ b/docs/cregex_api.md @@ -108,7 +108,7 @@ int main() { // Lets find the first date in the string: csview match[4]; // full-match, year, month, date. if (cregex_find(&re, input, match, CREG_DEFAULT) == CREG_OK) - printf("Found date: %.*s\n", c_ARGSV(match[0])); + printf("Found date: %.*s\n", c_SVARG(match[0])); else printf("Could not find any date\n"); @@ -124,7 +124,7 @@ int main() { For a single match you may use the all-in-one function: ```c if (cregex_find_pattern(pattern, input, match, CREG_DEFAULT)) - printf("Found date: %.*s\n", c_ARGSV(match[0])); + printf("Found date: %.*s\n", c_SVARG(match[0])); ``` To compile, use: `gcc first_match.c src/cregex.c src/utf8code.c`. @@ -137,13 +137,13 @@ To iterate multiple matches in an input string, you may use csview match[5] = {0}; while (cregex_find(&re, input, match, CREG_M_NEXT) == CREG_OK) c_FORRANGE (k, cregex_captures(&re)) - printf("submatch %lld: %.*s\n", k, c_ARGSV(match[k])); + printf("submatch %lld: %.*s\n", k, c_SVARG(match[k])); ``` There is also a safe macro which simplifies this: ```c c_FORMATCH (it, &re, input) c_FORRANGE (k, cregex_captures(&re)) - printf("submatch %lld: %.*s\n", k, c_ARGSV(it.match[k])); + printf("submatch %lld: %.*s\n", k, c_SVARG(it.match[k])); ``` ## Using cregex in a project diff --git a/docs/csview_api.md b/docs/csview_api.md index 3971c6a6..e3c65766 100644 --- a/docs/csview_api.md +++ b/docs/csview_api.md @@ -88,7 +88,7 @@ csview cstr_slice_ex(const cstr* s, intptr_t p, intptr_t q); // nega To iterate tokens in an input string separated by a string: ```c c_FORTOKEN (i, "hello, one, two, three", ", ") - printf("token: %.*s\n", c_ARGSV(i.token)); + printf("token: %.*s\n", c_SVARG(i.token)); ``` #### Helper methods @@ -112,7 +112,7 @@ uint64_t csview_hash(const csview* x); | Name | Value | Usage | |:---------------|:---------------------|:---------------------------------------------| | `csview_NULL` | same as `c_SV("")` | `sview = csview_NULL;` | -| `c_ARGSV(sv)` | printf argument | `printf("sv: %.*s\n", c_ARGSV(sv));` | +| `c_SVARG(sv)` | printf argument | `printf("sv: %.*s\n", c_SVARG(sv));` | ## Example ```c @@ -129,7 +129,7 @@ int main () csview sv2 = cstr_substr(&str1, pos, 4); // get "live" csview sv3 = cstr_slice(&str1, -8, -1); // get "details" printf("%.*s %.*s %.*s\n", - c_ARGSV(sv1), c_ARGSV(sv2), c_ARGSV(sv3)); + c_SVARG(sv1), c_SVARG(sv2), c_SVARG(sv3)); cstr s1 = cstr_lit("Apples are red"); cstr s2 = cstr_from_sv(cstr_substr(&s1, -3, 3)); // "red" cstr s3 = cstr_from_sv(cstr_substr(&s1, 0, 6)); // "Apples" @@ -157,7 +157,7 @@ int main() printf("%s\n", cstr_str(&s1)); c_FOREACH (i, cstr, s1) - printf("%.*s,", c_ARGSV(i.u8.chr)); + printf("%.*s,", c_SVARG(i.u8.chr)); } } ``` @@ -177,7 +177,7 @@ and does not depend on null-terminated strings. *string_split()* function return void print_split(csview input, const char* sep) { c_FORTOKEN_SV (i, input, sep) - printf("[%.*s]\n", c_ARGSV(i.token)); + printf("[%.*s]\n", c_SVARG(i.token)); } #include <stc/cstr.h> |
