[hackers] [libgrapheme] Change parameter order in lg_utf8_decode() || Laslo Hunhold

From: <git_AT_suckless.org>
Date: Thu, 9 Dec 2021 17:40:54 +0100 (CET)

commit 17c56be9f79741c521dc76cf256d6dc2a7428b62
Author: Laslo Hunhold <dev_AT_frign.de>
AuthorDate: Thu Dec 9 17:38:06 2021 +0100
Commit: Laslo Hunhold <dev_AT_frign.de>
CommitDate: Thu Dec 9 17:38:06 2021 +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_AT_frign.de>

diff --git a/grapheme.h b/grapheme.h
index 638f5ba..cdd2599 100644
--- a/grapheme.h
+++ b/grapheme.h
_AT_@ -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
index 5b33435..ab487af 100644
--- a/src/grapheme.c
+++ b/src/grapheme.c
_AT_@ -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
index d2c7265..2d3cd28 100644
--- a/src/utf8.c
+++ b/src/utf8.c
_AT_@ -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
index 033fcb6..a9331af 100644
--- a/test/utf8-decode.c
+++ b/test/utf8-decode.c
_AT_@ -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) {
Received on Thu Dec 09 2021 - 17:40:54 CET

This archive was generated by hypermail 2.3.0 : Thu Dec 09 2021 - 17:48:31 CET