[hackers] [libgrapheme] Fix up smaller notational and type aspects for constants || Laslo Hunhold

From: <git_AT_suckless.org>
Date: Thu, 6 Oct 2022 00:03:00 +0200 (CEST)

commit f6ab5a6edf5eae9470f7eb6ee3062fd9a7865ead
Author: Laslo Hunhold <dev_AT_frign.de>
AuthorDate: Thu Oct 6 00:02:29 2022 +0200
Commit: Laslo Hunhold <dev_AT_frign.de>
CommitDate: Thu Oct 6 00:02:29 2022 +0200

    Fix up smaller notational and type aspects for constants
    
    Signed-off-by: Laslo Hunhold <dev_AT_frign.de>

diff --git a/gen/util.c b/gen/util.c
index 012b04a..8f37bfd 100644
--- a/gen/util.c
+++ b/gen/util.c
_AT_@ -76,7 +76,7 @@ hextocp(const char *str, size_t len, uint_least32_t *cp)
                        (uint_least32_t)(str[i] - relative + off);
         }
 
- if (*cp > 0x10ffff) {
+ if (*cp > UINT32_C(0x10FFFF)) {
                 fprintf(stderr, "hextocp: '%.*s' is too large.\n",
                         (int)len, str);
                 return 1;
_AT_@ -251,14 +251,14 @@ properties_compress(const struct properties *prop,
         uint_least32_t cp, i;
 
         /* initialization */
- if (!(comp->offset = malloc((size_t)0x110000 * sizeof(*(comp->offset))))) {
+ if (!(comp->offset = malloc((size_t)UINT32_C(0x110000) * sizeof(*(comp->offset))))) {
                 fprintf(stderr, "malloc: %s\n", strerror(errno));
                 exit(1);
         }
         comp->data = NULL;
         comp->datalen = 0;
 
- for (cp = 0; cp < 0x110000; cp++) {
+ for (cp = 0; cp < UINT32_C(0x110000); cp++) {
                 for (i = 0; i < comp->datalen; i++) {
                         if (!memcmp(&(prop[cp]), &(comp->data[i]), sizeof(*prop))) {
                                 /* found a match! */
diff --git a/src/case.c b/src/case.c
index ac24f71..4d289fd 100644
--- a/src/case.c
+++ b/src/case.c
_AT_@ -9,9 +9,9 @@
 static inline enum case_property
 get_case_property(uint_least32_t cp)
 {
- if (likely(cp <= 0x10FFFF)) {
+ if (likely(cp <= UINT32_C(0x10FFFF))) {
                 return (enum case_property)
- case_minor[case_major[cp >> 8] + (cp & 0xff)];
+ case_minor[case_major[cp >> 8] + (cp & 0xFF)];
         } else {
                 return CASE_PROP_OTHER;
         }
_AT_@ -21,13 +21,13 @@ static inline int_least32_t
 get_case_offset(uint_least32_t cp, const uint_least16_t *major,
                 const int_least32_t *minor)
 {
- if (likely(cp <= 0x10FFFF)) {
+ if (likely(cp <= UINT32_C(0x10FFFF))) {
                 /*
                  * this value might be larger than or equal to 0x110000
                  * for the special-case-mapping. This needs to be handled
                  * separately
                  */
- return minor[major[cp >> 8] + (cp & 0xff)];
+ return minor[major[cp >> 8] + (cp & 0xFF)];
         } else {
                 return 0;
         }
diff --git a/src/character.c b/src/character.c
index 7bcc72f..33d2162 100644
--- a/src/character.c
+++ b/src/character.c
_AT_@ -111,7 +111,7 @@ static const uint_least16_t dont_break_gb12_13[2 * NUM_CHAR_BREAK_PROPS] = {
 static inline enum char_break_property
 get_break_prop(uint_least32_t cp)
 {
- if (likely(cp <= 0x10FFFF)) {
+ if (likely(cp <= UINT32_C(0x10FFFF))) {
                 return (enum char_break_property)
                        char_break_minor[char_break_major[cp >> 8] + (cp & 0xFF)];
         } else {
diff --git a/src/line.c b/src/line.c
index e010cb3..233e80c 100644
--- a/src/line.c
+++ b/src/line.c
_AT_@ -9,7 +9,7 @@
 static inline enum line_break_property
 get_break_prop(uint_least32_t cp)
 {
- if (likely(cp <= 0x10FFFF)) {
+ if (likely(cp <= UINT32_C(0x10FFFF))) {
                 return (enum line_break_property)
                        line_break_minor[line_break_major[cp >> 8] + (cp & 0xff)];
         } else {
diff --git a/src/sentence.c b/src/sentence.c
index 88c21de..8a242c0 100644
--- a/src/sentence.c
+++ b/src/sentence.c
_AT_@ -15,7 +15,7 @@ struct sentence_break_state
 static inline uint_least8_t
 get_sentence_break_prop(uint_least32_t cp)
 {
- if (likely(cp <= 0x10FFFF)) {
+ if (likely(cp <= UINT32_C(0x10FFFF))) {
                 return (uint_least8_t)
                        sentence_break_minor[sentence_break_major[cp >> 8] +
                        (cp & 0xff)];
Received on Thu Oct 06 2022 - 00:03:00 CEST

This archive was generated by hypermail 2.3.0 : Thu Oct 06 2022 - 00:12:40 CEST