libgrapheme

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

commit da1aba6af03c664d5f66480b2252de857a61985b
parent f128a915ba3140dc0b755d2f77d599cdbc2df7be
Author: Laslo Hunhold <dev@frign.de>
Date:   Mon, 13 Dec 2021 20:16:09 +0100

Cast pedantically

This is mostly to really indicate that an implicit cast is wanted and
the context allows it or to preserve const-correctness.

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

Diffstat:
Msrc/grapheme.c | 2+-
Msrc/utf8.c | 2+-
Msrc/util.c | 6+++---
3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/grapheme.c b/src/grapheme.c @@ -17,7 +17,7 @@ bool lg_grapheme_isbreak(uint_least32_t a, uint_least32_t b, LG_SEGMENTATION_STATE *state) { struct lg_internal_heisenstate *p[2] = { 0 }; - int flags = 0; + uint_least16_t flags = 0; bool isbreak = true; /* set state depending on state pointer */ diff --git a/src/utf8.c b/src/utf8.c @@ -161,7 +161,7 @@ lg_utf8_encode(uint_least32_t cp, uint8_t *s, size_t n) * We do not overwrite the mask because we guaranteed earlier * that there are no bits higher than the mask allows. */ - s[0] = lut[off].lower | (cp >> (6 * off)); + s[0] = lut[off].lower | (uint8_t)(cp >> (6 * off)); for (i = 1; i <= off; i++) { /* diff --git a/src/util.c b/src/util.c @@ -41,10 +41,10 @@ heisenstate_set(struct lg_internal_heisenstate *h, int slot, int state) static int cp_cmp(const void *a, const void *b) { - uint_least32_t cp = *(uint_least32_t *)a; - uint_least32_t *range = (uint_least32_t *)b; + uint_least32_t cp = *(const uint_least32_t *)a; + const uint_least32_t *range = (const uint_least32_t *)b; - return (cp >= range[0] && cp <= range[1]) ? 0 : (cp - range[0]); + return (cp >= range[0] && cp <= range[1]) ? 0 : (int)(cp - range[0]); } int