From b9adc30b86ef550655de1e8a8122dae20a6b13df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Thu, 14 Jan 2021 10:24:36 +0100 Subject: RichString: implement safe rewind The current rewind logic causes issues when rewinding over the short string optimization boundary. --- RichString.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'RichString.c') diff --git a/RichString.c b/RichString.c index 5a2c2e14..c4ecc258 100644 --- a/RichString.c +++ b/RichString.c @@ -46,6 +46,10 @@ static void RichString_setLen(RichString* this, int len) { } } +void RichString_rewind(RichString* this, int count) { + RichString_setLen(this, this->chlen - count); +} + #ifdef HAVE_LIBNCURSESW static inline int RichString_writeFromWide(RichString* this, int attrs, const char* data_c, int from, int len) { -- cgit v1.2.3