aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/unicode/string.h5
-rw-r--r--lib/unicode/string/u8wdth.c5
2 files changed, 5 insertions, 5 deletions
diff --git a/include/unicode/string.h b/include/unicode/string.h
index 077a45a..4f3760b 100644
--- a/include/unicode/string.h
+++ b/include/unicode/string.h
@@ -30,7 +30,7 @@ typedef enum {
/* clang-format on */
-[[nodiscard]] size_t u8wdth(u8view_t, int);
+[[nodiscard]] ptrdiff_t u8wdth(u8view_t, ptrdiff_t, int);
[[nodiscard]] size_t u8gcnt(u8view_t);
[[nodiscard]] size_t u8wcnt(u8view_t);
[[nodiscard]] size_t u8wcnt_human(u8view_t);
@@ -44,7 +44,8 @@ size_t u8wnext_human(u8view_t *, u8view_t *);
[[nodiscard]] char8_t *u8norm(size_t *, u8view_t, allocator_t, normform_t);
/* Encoding-generic macros */
-#define ucswdth(sv, ts) _Generic((sv), u8view_t: u8wdth)((sv), (ts))
+#define ucswdth(sv, curwdth, ts) \
+ _Generic((sv), u8view_t: u8wdth)((sv), (curwdth), (ts))
#define ucsgcnt(sv) _Generic((sv), u8view_t: u8gcnt)((sv))
#define ucswcnt(sv) _Generic((sv), u8view_t: u8wcnt)((sv))
#define ucswcnt_human(sv) _Generic((sv), u8view_t: u8wcnt_human)((sv))
diff --git a/lib/unicode/string/u8wdth.c b/lib/unicode/string/u8wdth.c
index db51b06..71581d3 100644
--- a/lib/unicode/string/u8wdth.c
+++ b/lib/unicode/string/u8wdth.c
@@ -2,11 +2,10 @@
#include "unicode/prop.h"
#include "unicode/string.h"
-size_t
-u8wdth(u8view_t sv, int ts)
+ptrdiff_t
+u8wdth(u8view_t sv, ptrdiff_t n, int ts)
{
rune ch;
- size_t n = 0;
while (ucsnext(&ch, &sv) != 0) {
if (ch == '\t')