[hackers] [libgrapheme] Rename LG_CODEPOINT_INVALID to LG_INVALID_CODE_POINT || Laslo Hunhold

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

commit d515a3d96e1301b7d9ba0d38a00038894ebefcd4
Author: Laslo Hunhold <dev_AT_frign.de>
AuthorDate: Fri Dec 17 01:28:29 2021 +0100
Commit: Laslo Hunhold <dev_AT_frign.de>
CommitDate: Fri Dec 17 01:28:29 2021 +0100

    Rename LG_CODEPOINT_INVALID to LG_INVALID_CODE_POINT
    
    It's a bad habit but the word "code point" is made up of two different
    words and should not be written together. The new ordering makes
    it easier to read as it has a more natural sound to it.
    
    Signed-off-by: Laslo Hunhold <dev_AT_frign.de>

diff --git a/grapheme.h b/grapheme.h
index 3294c8e..f8eefba 100644
--- a/grapheme.h
+++ b/grapheme.h
_AT_@ -17,7 +17,7 @@ typedef struct lg_internal_segmentation_state {
         uint_least16_t flags;
 } LG_SEGMENTATION_STATE;
 
-#define LG_CODEPOINT_INVALID UINT32_C(0xFFFD)
+#define LG_INVALID_CODE_POINT UINT32_C(0xFFFD)
 
 size_t lg_grapheme_nextbreak(const char *);
 
diff --git a/src/grapheme.c b/src/grapheme.c
index 78d0993..ed26397 100644
--- a/src/grapheme.c
+++ b/src/grapheme.c
_AT_@ -203,7 +203,7 @@ lg_grapheme_nextbreak(const char *str)
 
         /* get first code point */
         len += lg_utf8_decode(str, 5, &cp0);
- if (cp0 == LG_CODEPOINT_INVALID) {
+ if (cp0 == LG_INVALID_CODE_POINT) {
                 return len;
         }
 
_AT_@ -211,7 +211,7 @@ lg_grapheme_nextbreak(const char *str)
                 /* get next code point */
                 ret = lg_utf8_decode(str + len, 5, &cp1);
 
- if (cp1 == LG_CODEPOINT_INVALID ||
+ if (cp1 == LG_INVALID_CODE_POINT ||
                     lg_grapheme_isbreak(cp0, cp1, &state)) {
                         /* we read an invalid cp or have a breakpoint */
                         break;
diff --git a/src/utf8.c b/src/utf8.c
index 75eeaba..c04fc0b 100644
--- a/src/utf8.c
+++ b/src/utf8.c
_AT_@ -54,7 +54,7 @@ lg_utf8_decode(const char *s, size_t n, uint_least32_t *cp)
 
         if (s == NULL || n == 0) {
                 /* a sequence must be at least 1 byte long */
- *cp = LG_CODEPOINT_INVALID;
+ *cp = LG_INVALID_CODE_POINT;
                 return 0;
         }
 
_AT_@ -79,7 +79,7 @@ lg_utf8_decode(const char *s, size_t n, uint_least32_t *cp)
                  * this also includes the cases where bits higher than
                  * the 8th are set on systems with CHAR_BIT > 8
                  */
- *cp = LG_CODEPOINT_INVALID;
+ *cp = LG_INVALID_CODE_POINT;
                 return 1;
         }
         if (1 + off > n) {
_AT_@ -87,7 +87,7 @@ lg_utf8_decode(const char *s, size_t n, uint_least32_t *cp)
                  * input is not long enough, set cp as invalid and
                  * return number of bytes needed
                  */
- *cp = LG_CODEPOINT_INVALID;
+ *cp = LG_INVALID_CODE_POINT;
                 return 1 + off;
         }
 
_AT_@ -107,7 +107,7 @@ lg_utf8_decode(const char *s, size_t n, uint_least32_t *cp)
                          * higher than the 8th are set on systems
                          * with CHAR_BIT > 8
                          */
- *cp = LG_CODEPOINT_INVALID;
+ *cp = LG_INVALID_CODE_POINT;
                         return 1 + (i - 1);
                 }
                 /*
_AT_@ -126,7 +126,7 @@ lg_utf8_decode(const char *s, size_t n, uint_least32_t *cp)
                  * not representable in UTF-16 (>0x10FFFF) (RFC-3629
                  * specifies the latter two conditions)
                  */
- *cp = LG_CODEPOINT_INVALID;
+ *cp = LG_INVALID_CODE_POINT;
         }
 
         return 1 + off;
_AT_@ -144,7 +144,7 @@ lg_utf8_encode(uint_least32_t cp, char *s, size_t n)
                  * (0xD800..0xDFFF) or not representable in UTF-16
                  * (>0x10FFFF), which RFC-3629 deems invalid for UTF-8.
                  */
- cp = LG_CODEPOINT_INVALID;
+ cp = LG_INVALID_CODE_POINT;
         }
 
         /* determine necessary sequence type */
diff --git a/test/utf8-decode.c b/test/utf8-decode.c
index b4dc7f2..0749688 100644
--- a/test/utf8-decode.c
+++ b/test/utf8-decode.c
_AT_@ -21,7 +21,7 @@ static const struct {
                 .arr = NULL,
                 .len = 0,
                 .exp_len = 0,
- .exp_cp = LG_CODEPOINT_INVALID,
+ .exp_cp = LG_INVALID_CODE_POINT,
         },
         {
                 /* invalid lead byte
_AT_@ -31,7 +31,7 @@ static const struct {
                 .arr = (char *)(unsigned char[]){ 0xFD },
                 .len = 1,
                 .exp_len = 1,
- .exp_cp = LG_CODEPOINT_INVALID,
+ .exp_cp = LG_INVALID_CODE_POINT,
         },
         {
                 /* valid 1-byte sequence
_AT_@ -61,7 +61,7 @@ static const struct {
                 .arr = (char *)(unsigned char[]){ 0xC3 },
                 .len = 1,
                 .exp_len = 2,
- .exp_cp = LG_CODEPOINT_INVALID,
+ .exp_cp = LG_INVALID_CODE_POINT,
         },
         {
                 /* invalid 2-byte sequence (second byte malformed)
_AT_@ -71,7 +71,7 @@ static const struct {
                 .arr = (char *)(unsigned char[]){ 0xC3, 0xFF },
                 .len = 2,
                 .exp_len = 1,
- .exp_cp = LG_CODEPOINT_INVALID,
+ .exp_cp = LG_INVALID_CODE_POINT,
         },
         {
                 /* invalid 2-byte sequence (overlong encoded)
_AT_@ -81,7 +81,7 @@ static const struct {
                 .arr = (char *)(unsigned char[]){ 0xC1, 0xBF },
                 .len = 2,
                 .exp_len = 2,
- .exp_cp = LG_CODEPOINT_INVALID,
+ .exp_cp = LG_INVALID_CODE_POINT,
         },
         {
                 /* valid 3-byte sequence
_AT_@ -101,7 +101,7 @@ static const struct {
                 .arr = (char *)(unsigned char[]){ 0xE0 },
                 .len = 1,
                 .exp_len = 3,
- .exp_cp = LG_CODEPOINT_INVALID,
+ .exp_cp = LG_INVALID_CODE_POINT,
         },
         {
                 /* invalid 3-byte sequence (second byte malformed)
_AT_@ -111,7 +111,7 @@ static const struct {
                 .arr = (char *)(unsigned char[]){ 0xE0, 0x7F, 0xBF },
                 .len = 3,
                 .exp_len = 1,
- .exp_cp = LG_CODEPOINT_INVALID,
+ .exp_cp = LG_INVALID_CODE_POINT,
         },
         {
                 /* invalid 3-byte sequence (third byte missing)
_AT_@ -121,7 +121,7 @@ static const struct {
                 .arr = (char *)(unsigned char[]){ 0xE0, 0xBF },
                 .len = 2,
                 .exp_len = 3,
- .exp_cp = LG_CODEPOINT_INVALID,
+ .exp_cp = LG_INVALID_CODE_POINT,
         },
         {
                 /* invalid 3-byte sequence (third byte malformed)
_AT_@ -131,7 +131,7 @@ static const struct {
                 .arr = (char *)(unsigned char[]){ 0xE0, 0xBF, 0x7F },
                 .len = 3,
                 .exp_len = 2,
- .exp_cp = LG_CODEPOINT_INVALID,
+ .exp_cp = LG_INVALID_CODE_POINT,
         },
         {
                 /* invalid 3-byte sequence (overlong encoded)
_AT_@ -141,7 +141,7 @@ static const struct {
                 .arr = (char *)(unsigned char[]){ 0xE0, 0x9F, 0xBF },
                 .len = 3,
                 .exp_len = 3,
- .exp_cp = LG_CODEPOINT_INVALID,
+ .exp_cp = LG_INVALID_CODE_POINT,
         },
         {
                 /* invalid 3-byte sequence (UTF-16 surrogate half)
_AT_@ -151,7 +151,7 @@ static const struct {
                 .arr = (char *)(unsigned char[]){ 0xED, 0xA0, 0x80 },
                 .len = 3,
                 .exp_len = 3,
- .exp_cp = LG_CODEPOINT_INVALID,
+ .exp_cp = LG_INVALID_CODE_POINT,
         },
         {
                 /* valid 4-byte sequence
_AT_@ -171,7 +171,7 @@ static const struct {
                 .arr = (char *)(unsigned char[]){ 0xF3 },
                 .len = 1,
                 .exp_len = 4,
- .exp_cp = LG_CODEPOINT_INVALID,
+ .exp_cp = LG_INVALID_CODE_POINT,
         },
         {
                 /* invalid 4-byte sequence (second byte malformed)
_AT_@ -181,7 +181,7 @@ static const struct {
                 .arr = (char *)(unsigned char[]){ 0xF3, 0x7F, 0xBF, 0xBF },
                 .len = 4,
                 .exp_len = 1,
- .exp_cp = LG_CODEPOINT_INVALID,
+ .exp_cp = LG_INVALID_CODE_POINT,
         },
         {
                 /* invalid 4-byte sequence (third byte missing)
_AT_@ -191,7 +191,7 @@ static const struct {
                 .arr = (char *)(unsigned char[]){ 0xF3, 0xBF },
                 .len = 2,
                 .exp_len = 4,
- .exp_cp = LG_CODEPOINT_INVALID,
+ .exp_cp = LG_INVALID_CODE_POINT,
         },
         {
                 /* invalid 4-byte sequence (third byte malformed)
_AT_@ -201,7 +201,7 @@ static const struct {
                 .arr = (char *)(unsigned char[]){ 0xF3, 0xBF, 0x7F, 0xBF },
                 .len = 4,
                 .exp_len = 2,
- .exp_cp = LG_CODEPOINT_INVALID,
+ .exp_cp = LG_INVALID_CODE_POINT,
         },
         {
                 /* invalid 4-byte sequence (fourth byte missing)
_AT_@ -211,7 +211,7 @@ static const struct {
                 .arr = (char *)(unsigned char[]){ 0xF3, 0xBF, 0xBF },
                 .len = 3,
                 .exp_len = 4,
- .exp_cp = LG_CODEPOINT_INVALID,
+ .exp_cp = LG_INVALID_CODE_POINT,
         },
         {
                 /* invalid 4-byte sequence (fourth byte malformed)
_AT_@ -221,7 +221,7 @@ static const struct {
                 .arr = (char *)(unsigned char[]){ 0xF3, 0xBF, 0xBF, 0x7F },
                 .len = 4,
                 .exp_len = 3,
- .exp_cp = LG_CODEPOINT_INVALID,
+ .exp_cp = LG_INVALID_CODE_POINT,
         },
         {
                 /* invalid 4-byte sequence (overlong encoded)
_AT_@ -231,7 +231,7 @@ static const struct {
                 .arr = (char *)(unsigned char[]){ 0xF0, 0x80, 0x81, 0xBF },
                 .len = 4,
                 .exp_len = 4,
- .exp_cp = LG_CODEPOINT_INVALID,
+ .exp_cp = LG_INVALID_CODE_POINT,
         },
         {
                 /* invalid 4-byte sequence (UTF-16-unrepresentable)
_AT_@ -241,7 +241,7 @@ static const struct {
                 .arr = (char *)(unsigned char[]){ 0xF4, 0x90, 0x80, 0x80 },
                 .len = 4,
                 .exp_len = 4,
- .exp_cp = LG_CODEPOINT_INVALID,
+ .exp_cp = LG_INVALID_CODE_POINT,
         },
 };
 
Received on Fri Dec 17 2021 - 01:30:18 CET

This archive was generated by hypermail 2.3.0 : Fri Dec 17 2021 - 01:36:32 CET