libgrapheme

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

commit f6ab5a6edf5eae9470f7eb6ee3062fd9a7865ead
parent 3ebd28c3e3ce50fd3370c587a0ec66e6c9489c83
Author: Laslo Hunhold <dev@frign.de>
Date:   Thu,  6 Oct 2022 00:02:29 +0200

Fix up smaller notational and type aspects for constants

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

Diffstat:
Mgen/util.c | 6+++---
Msrc/case.c | 8++++----
Msrc/character.c | 2+-
Msrc/line.c | 2+-
Msrc/sentence.c | 2+-
5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/gen/util.c b/gen/util.c @@ -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; @@ -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 @@ -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; } @@ -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 @@ -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 @@ -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 @@ -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)];