From 604b18befd9918a65a8f370a6051864fcda2f623 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Fri, 31 May 2024 20:31:55 +0200 Subject: Pass a tabsize to ucswdth() --- lib/unicode/string/u8wdth.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lib/unicode/string') diff --git a/lib/unicode/string/u8wdth.c b/lib/unicode/string/u8wdth.c index 503ff7c..7a58069 100644 --- a/lib/unicode/string/u8wdth.c +++ b/lib/unicode/string/u8wdth.c @@ -3,15 +3,19 @@ #include "unicode/string.h" size_t -u8wdth(struct u8view sv) +u8wdth(struct u8view sv, int ts) { rune ch; size_t n = 0; while (ucsnext(&ch, &sv) != 0) { - int w = uprop_get_wdth(ch); - if (w > 0) - n += w; + if (ch == '\t') + n += ts - n % ts; + else { + int w = uprop_get_wdth(ch); + if (w > 0) + n += w; + } } return n; -- cgit v1.2.3