From 4c5f0ba23ba6294e144243555ed3c02a72259692 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Thu, 22 Sep 2022 13:04:58 +0200 Subject: Updated _advance() iter methods. Some have signed offsets. utf8_peek()/utf8_peek_off() added/changed. --- src/utf8code.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/utf8code.c') diff --git a/src/utf8code.c b/src/utf8code.c index 25244f07..abd21736 100644 --- a/src/utf8code.c +++ b/src/utf8code.c @@ -46,14 +46,11 @@ unsigned utf8_encode(char *out, uint32_t c) return 0; } -uint32_t utf8_peek(const char* s, int pos) { +uint32_t utf8_peek_off(const char* s, int pos) { int inc = -1; if (pos > 0) pos = -pos, inc = 1; while (pos) pos += (*(s += inc) & 0xC0) != 0x80; - - utf8_decode_t d = {.state=0}; - do { utf8_decode(&d, (uint8_t)*s++); } while (d.state); - return d.codep; + return utf8_peek(s); } bool utf8_valid_n(const char* s, size_t nbytes) { -- cgit v1.2.3