diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/stc/cregex.h | 4 | ||||
| -rw-r--r-- | include/stc/csview.h | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/include/stc/cregex.h b/include/stc/cregex.h index 4812bff2..f0dd13aa 100644 --- a/include/stc/cregex.h +++ b/include/stc/cregex.h @@ -73,12 +73,12 @@ typedef struct { typedef struct { const cregex* re; const char* input; - csview ref[cre_MAXCAPTURES]; + csview match[cre_MAXCAPTURES]; } cregex_iter; #define c_foreach_match(it, Re, Input) \ for (cregex_iter it = {Re, Input}; \ - cregex_find(it.input, it.re, it.ref, cre_m_next) == cre_success;) + cregex_find(it.input, it.re, it.match, cre_m_next) == cre_success;) static inline cregex cregex_init(void) { diff --git a/include/stc/csview.h b/include/stc/csview.h index 555dd538..bfbf1c61 100644 --- a/include/stc/csview.h +++ b/include/stc/csview.h @@ -103,6 +103,11 @@ STC_API csview csview_substr_ex(csview sv, intptr_t pos, size_t n); STC_API csview csview_slice_ex(csview sv, intptr_t p1, intptr_t p2); STC_API csview csview_token(csview sv, csview sep, size_t* start); +#define c_foreach_token(it, input, sep) \ + for (struct { csview token, _sep, _inp; size_t start; } \ + it = {.token=csview_from(input), ._sep=csview_from(sep), ._inp=it.token, .start=0} \ + ; it.start <= it._inp.size && (it.token = csview_token(it._inp, it._sep, &it.start)).str ; ) + /* csview interaction with cstr: */ #ifdef CSTR_H_INCLUDED |
