[hackers] [libgrapheme] Rename GRAPHEME_SEGMENTATION_STATE to GRAPHEME_STATE || Laslo Hunhold

From: <git_AT_suckless.org>
Date: Sat, 18 Dec 2021 13:17:30 +0100 (CET)

commit fdfcc49755f22074116fd52765bea1a60d3539ba
Author: Laslo Hunhold <dev_AT_frign.de>
AuthorDate: Sat Dec 18 13:13:37 2021 +0100
Commit: Laslo Hunhold <dev_AT_frign.de>
CommitDate: Sat Dec 18 13:13:37 2021 +0100

    Rename GRAPHEME_SEGMENTATION_STATE to GRAPHEME_STATE
    
    The name was getting a bit long and the user doesn't really have to
    care about the fact it's specifically a segmentation state. If we,
    for any reason, require another state type, we could simply define
    a union accordingly:
    
    typedef union grapheme_internal_state {
            struct grapheme_internal_segmentation_state {
                    ...
            } segmentation;
            struct grapheme_internal_whatever_state {
                    ...
            } whatever;
    } GRAPHEME_STATE;
    
    This would not change the outside behaviour (given we defined
    GRAPHEME_STATE as an opaque state), but we guarantee that
    
       GRAPHEME_STATE state = { 0 };
    
    and
    
       memset(&state, 0, sizeof(state));
    
    continue to work.
    
    Signed-off-by: Laslo Hunhold <dev_AT_frign.de>

diff --git a/grapheme.h b/grapheme.h
index a8805bd..1d09ab9 100644
--- a/grapheme.h
+++ b/grapheme.h
_AT_@ -15,14 +15,13 @@ typedef struct grapheme_internal_segmentation_state {
         struct grapheme_internal_heisenstate a;
         struct grapheme_internal_heisenstate b;
         uint_least16_t flags;
-} GRAPHEME_SEGMENTATION_STATE;
+} GRAPHEME_STATE;
 
 #define GRAPHEME_INVALID_CODE_POINT UINT32_C(0xFFFD)
 
 size_t grapheme_character_nextbreak(const char *);
 
-bool grapheme_character_isbreak(uint_least32_t, uint_least32_t,
- GRAPHEME_SEGMENTATION_STATE *);
+bool grapheme_character_isbreak(uint_least32_t, uint_least32_t, GRAPHEME_STATE *);
 
 size_t grapheme_utf8_decode(const char *, size_t, uint_least32_t *);
 size_t grapheme_utf8_encode(uint_least32_t, char *, size_t);
diff --git a/man/grapheme_character_isbreak.3 b/man/grapheme_character_isbreak.3
index a7568f6..a900dc9 100644
--- a/man/grapheme_character_isbreak.3
+++ b/man/grapheme_character_isbreak.3
_AT_@ -7,7 +7,7 @@
 .Sh SYNOPSIS
 .In grapheme.h
 .Ft size_t
-.Fn grapheme_character_isbreak "uint_least32_t cp1" "uint_least32_t cp2" "GRAPHEME_SEGMENTATION_STATE *state"
+.Fn grapheme_character_isbreak "uint_least32_t cp1" "uint_least32_t cp2" "GRAPHEME_STATE *state"
 .Sh DESCRIPTION
 The
 .Fn grapheme_character_isbreak
_AT_@ -51,7 +51,7 @@ if there is not.
 int
 main(void)
 {
- GRAPHEME_SEGMENTATION_STATE state = { 0 };
+ GRAPHEME_STATE state = { 0 };
         uint_least32_t s1[] = ..., s2[] = ...; /* two input arrays */
         size_t i;
 
diff --git a/src/character.c b/src/character.c
index 7d89871..2ee1a72 100644
--- a/src/character.c
+++ b/src/character.c
_AT_@ -14,8 +14,7 @@ enum {
 };
 
 bool
-grapheme_character_isbreak(uint_least32_t a, uint_least32_t b,
- GRAPHEME_SEGMENTATION_STATE *state)
+grapheme_character_isbreak(uint_least32_t a, uint_least32_t b, GRAPHEME_STATE *state)
 {
         struct grapheme_internal_heisenstate *p[2] = { 0 };
         uint_least16_t flags = 0;
_AT_@ -184,7 +183,7 @@ grapheme_character_nextbreak(const char *str)
 {
         uint_least32_t cp0, cp1;
         size_t ret, len = 0;
- GRAPHEME_SEGMENTATION_STATE state = { 0 };
+ GRAPHEME_STATE state = { 0 };
 
         if (str == NULL) {
                 return 0;
diff --git a/test/character-performance.c b/test/character-performance.c
index ecf5a7f..a7fdf8f 100644
--- a/test/character-performance.c
+++ b/test/character-performance.c
_AT_@ -17,7 +17,7 @@ main(int argc, char *argv[])
         struct timespec start, end;
         size_t i, j, bufsiz, off;
         uint32_t *buf;
- GRAPHEME_SEGMENTATION_STATE state;
+ GRAPHEME_STATE state;
         double cp_per_sec;
 
         (void)argc;
diff --git a/test/character.c b/test/character.c
index d7a4d27..02dbde9 100644
--- a/test/character.c
+++ b/test/character.c
_AT_@ -11,7 +11,7 @@
 int
 main(int argc, char *argv[])
 {
- GRAPHEME_SEGMENTATION_STATE state;
+ GRAPHEME_STATE state;
         size_t i, j, k, len, failed;
 
         (void)argc;
Received on Sat Dec 18 2021 - 13:17:30 CET

This archive was generated by hypermail 2.3.0 : Sat Dec 18 2021 - 13:24:33 CET