From 106a59586aeba3fb1a0883e2fdaa51753fdbb68b Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sun, 21 Apr 2024 19:53:14 +0200 Subject: Rename u8glen() to u8gcnt() --- include/unicode/string.h | 2 +- lib/unicode/string/u8gcnt.c | 10 ++++++++++ lib/unicode/string/u8glen.c | 10 ---------- man/u8len.3 | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) create mode 100644 lib/unicode/string/u8gcnt.c delete mode 100644 lib/unicode/string/u8glen.c diff --git a/include/unicode/string.h b/include/unicode/string.h index 0cee934..e989380 100644 --- a/include/unicode/string.h +++ b/include/unicode/string.h @@ -17,7 +17,7 @@ enum [[clang::flag_enum]] caseflags { /* clang-format on */ -[[nodiscard]] size_t u8glen(const char8_t *, size_t); +[[nodiscard]] size_t u8gcnt(const char8_t *, size_t); size_t u8gnext(struct u8view *, const char8_t **, size_t *); #define mlib_warn_trunc nodiscard("don’t forget to check for truncation") diff --git a/lib/unicode/string/u8gcnt.c b/lib/unicode/string/u8gcnt.c new file mode 100644 index 0000000..81a0f97 --- /dev/null +++ b/lib/unicode/string/u8gcnt.c @@ -0,0 +1,10 @@ +#include "unicode/string.h" + +size_t +u8gcnt(const char8_t *s, size_t n) +{ + size_t m = 0; + while (u8gnext(nullptr, &s, &n)) + m++; + return m; +} diff --git a/lib/unicode/string/u8glen.c b/lib/unicode/string/u8glen.c deleted file mode 100644 index 394a62d..0000000 --- a/lib/unicode/string/u8glen.c +++ /dev/null @@ -1,10 +0,0 @@ -#include "unicode/string.h" - -size_t -u8glen(const char8_t *s, size_t n) -{ - size_t m = 0; - while (u8gnext(nullptr, &s, &n)) - m++; - return m; -} diff --git a/man/u8len.3 b/man/u8len.3 index a2968e7..ad5002f 100644 --- a/man/u8len.3 +++ b/man/u8len.3 @@ -39,7 +39,7 @@ size_t blen = strlen((char *)sv.p); size_t cplen = u8len(U8_ARGS(sv)); .Ed .Sh SEE ALSO -.Xr u8glen 3 , +.Xr u8gcnt 3 , .Xr U8V 3 , .Xr unicode 7 , .Xr utf\-8 7 @@ -62,5 +62,5 @@ that spans a single column. To count user-preceived codepoints .Pq also known as graphemes , you may want to use the -.Xr u8glen 3 +.Xr u8gcnt 3 function. -- cgit v1.2.3