diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-05-04 04:01:45 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-05-04 04:01:45 +0200 |
commit | ac1b4bcbaeaee7d2ef9132dcdc254f2d08691650 (patch) | |
tree | 90250966629653f0462cf17bc0b6f2476fb6d1fc /lib/mbstring/u8chk.c | |
parent | 8b923ba5e5bb37ea26350b4c1c688b8697706609 (diff) |
Go all in on string views, and fix manuals
Diffstat (limited to 'lib/mbstring/u8chk.c')
-rw-r--r-- | lib/mbstring/u8chk.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/mbstring/u8chk.c b/lib/mbstring/u8chk.c index 2566bac..20c4f3f 100644 --- a/lib/mbstring/u8chk.c +++ b/lib/mbstring/u8chk.c @@ -1,17 +1,15 @@ #include "rune.h" #include "mbstring.h" -char8_t * -(u8chk)(const char8_t *s, size_t n) +const char8_t * +u8chk(struct u8view sv) { - while (n) { - rune ch; - int m = u8tor(&ch, s); + int w; + rune ch; + while (w = u8next(&ch, &sv)) { if (ch == RUNE_ERROR) - return (char8_t *)s; - n -= m; - s += m; + return sv.p - w; } return nullptr; |