libgrapheme

Freestanding C library for unicode string handling
git clone https://git.sinitax.com/suckless/libgrapheme
Log | Files | Refs | README | LICENSE | sfeed.txt

commit 17c56be9f79741c521dc76cf256d6dc2a7428b62
parent b5806959dff1f7614e84f116f68f90c7711375ce
Author: Laslo Hunhold <dev@frign.de>
Date:   Thu,  9 Dec 2021 17:38:06 +0100

Change parameter order in lg_utf8_decode()

It is a common convention to order function arguments such that
input arguments come first, followed by output arguments. This already
fit everywhere except with the lg_utf8_decode() function, which is
now adapted.

Signed-off-by: Laslo Hunhold <dev@frign.de>

Diffstat:
Mgrapheme.h | 2+-
Msrc/grapheme.c | 4++--
Msrc/utf8.c | 2+-
Mtest/utf8-decode.c | 4++--
4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/grapheme.h b/grapheme.h @@ -7,7 +7,7 @@ #define LG_CODEPOINT_INVALID UINT32_C(0xFFFD) -size_t lg_utf8_decode(uint32_t *, const uint8_t *, size_t); +size_t lg_utf8_decode(const uint8_t *, size_t, uint32_t *); size_t lg_utf8_encode(uint32_t, uint8_t *, size_t); size_t lg_grapheme_nextbreak(const char *); diff --git a/src/grapheme.c b/src/grapheme.c @@ -178,14 +178,14 @@ lg_grapheme_nextbreak(const char *str) */ /* get first code point */ - len += lg_utf8_decode(&cp0, (uint8_t *)str, 5); + len += lg_utf8_decode((uint8_t *)str, 5, &cp0); if (cp0 == LG_CODEPOINT_INVALID) { return len; } while (cp0 != 0) { /* get next code point */ - ret = lg_utf8_decode(&cp1, (uint8_t *)(str + len), 5); + ret = lg_utf8_decode((uint8_t *)(str + len), 5, &cp1); if (cp1 == LG_CODEPOINT_INVALID || lg_grapheme_isbreak(cp0, cp1, &state)) { diff --git a/src/utf8.c b/src/utf8.c @@ -47,7 +47,7 @@ static const struct { }; size_t -lg_utf8_decode(uint32_t *cp, const uint8_t *s, size_t n) +lg_utf8_decode(const uint8_t *s, size_t n, uint32_t *cp) { size_t off, i; diff --git a/test/utf8-decode.c b/test/utf8-decode.c @@ -256,8 +256,8 @@ main(void) size_t len; uint32_t cp; - len = lg_utf8_decode(&cp, dec_test[i].arr, - dec_test[i].len); + len = lg_utf8_decode(dec_test[i].arr, + dec_test[i].len, &cp); if (len != dec_test[i].exp_len || cp != dec_test[i].exp_cp) {