diff options
| author | Tyge Løvset <[email protected]> | 2022-09-22 13:04:58 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-09-22 13:04:58 +0200 |
| commit | 4c5f0ba23ba6294e144243555ed3c02a72259692 (patch) | |
| tree | 380b249e1c36b83b65507da5a2af4f843252a474 /include/stc/cstr.h | |
| parent | 61c222312bb1cc03ab987fdbc541039723c9e243 (diff) | |
| download | STC-modified-4c5f0ba23ba6294e144243555ed3c02a72259692.tar.gz STC-modified-4c5f0ba23ba6294e144243555ed3c02a72259692.zip | |
Updated _advance() iter methods. Some have signed offsets.
utf8_peek()/utf8_peek_off() added/changed.
Diffstat (limited to 'include/stc/cstr.h')
| -rw-r--r-- | include/stc/cstr.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/stc/cstr.h b/include/stc/cstr.h index 1e7a351f..54d55d4c 100644 --- a/include/stc/cstr.h +++ b/include/stc/cstr.h @@ -238,6 +238,13 @@ STC_INLINE void cstr_next(cstr_iter* it) { it->u8.chr.size = utf8_chr_size(it->ref); if (it->ref == it->u8.end) it->ref = NULL; } +STC_INLINE cstr_iter cstr_advance(cstr_iter it, isize_t pos) { + int inc = -1; + if (pos > 0) pos = -pos, inc = 1; + while (pos && it.ref != it.u8.end) pos += (*(it.ref += inc) & 0xC0) != 0x80; + it.u8.chr.size = utf8_chr_size(it.ref); + return it; +} STC_INLINE void cstr_clear(cstr* self) |
