From cd6d0773b3ae89301ac0629595f291d8a1915ae5 Mon Sep 17 00:00:00 2001 From: Eric-Paul Ickhorn Date: Tue, 12 Dec 2023 23:26:31 +0100 Subject: [PATCH] Fixed a bug which made reading an UTF-8 character impossible. --- core/src-c/runes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src-c/runes.c b/core/src-c/runes.c index b545c59..17d2da3 100644 --- a/core/src-c/runes.c +++ b/core/src-c/runes.c @@ -1,9 +1,9 @@ #include -isz_t rr_distance_to_last_utf8_rune_start(const char *string, usz_t offset) +isz_t rr_distance_to_last_utf8_rune_start(const char *string, isz_t offset) { usz_t bytes_walked = 0; - while(bytes_walked < offset) + while((offset - bytes_walked) >= 0) { if(bytes_walked > 4) return -1;