diff options
| author | Tyge Løvset <[email protected]> | 2022-09-06 18:20:23 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-09-06 18:20:23 +0200 |
| commit | 90311ff7eb34e5fc4fc1c2c38b8d0433642e9659 (patch) | |
| tree | 11352fe3b7530ed1c6b49fa1914ccef7142c92b4 /include/stc/csview.h | |
| parent | 2857a84df612d2e1ae4389e3a747a39d933c0400 (diff) | |
| download | STC-modified-90311ff7eb34e5fc4fc1c2c38b8d0433642e9659.tar.gz STC-modified-90311ff7eb34e5fc4fc1c2c38b8d0433642e9659.zip | |
- Added c_foreach_token(it, ...) macro in csview.h.
- Changed c_foreach_match(it, ...): to access matches, use it.match[j]
- splitstr.c now shows usages of both the above.
Diffstat (limited to 'include/stc/csview.h')
| -rw-r--r-- | include/stc/csview.h | 5 |
1 files changed, 5 insertions, 0 deletions
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 |
