libgrapheme

unicode string library
git clone git://git.suckless.org/libgrapheme
Log | Files | Refs | README | LICENSE

commit f70ea8c12ab5b7ad6f90f8860544779a43ce8a9e
parent 995e37182dc53da55dc4cf34868513610215c79e
Author: Laslo Hunhold <dev@frign.de>
Date:   Sun,  2 Oct 2022 22:30:08 +0200

Drop get_codepoint*() and set_codepoint*() functions

These are, now that all code has been refactored with Herodotus and
Proper, no longer used and can be dropped.

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

Diffstat:
Msrc/util.c | 62--------------------------------------------------------------
Msrc/util.h | 6------
2 files changed, 0 insertions(+), 68 deletions(-)

diff --git a/src/util.c b/src/util.c @@ -408,65 +408,3 @@ proper_advance(struct proper *p) return 0; } - -inline size_t -get_codepoint(const void *str, size_t len, size_t offset, uint_least32_t *cp) -{ - if (offset < len) { - *cp = ((const uint_least32_t *)str)[offset]; - return 1; - } else { - *cp = GRAPHEME_INVALID_CODEPOINT; - return 0; - } -} - -inline size_t -get_codepoint_utf8(const void *str, size_t len, size_t offset, uint_least32_t *cp) -{ - size_t ret; - - if (offset < len) { - ret = grapheme_decode_utf8((const char *)str + offset, - len - offset, cp); - - if (unlikely(len == SIZE_MAX && cp == 0)) { - return 0; - } else { - return ret; - } - } else { - *cp = GRAPHEME_INVALID_CODEPOINT; - return 0; - } -} - -inline size_t -set_codepoint(uint_least32_t cp, void *str, size_t len, size_t offset) -{ - if (str == NULL || len == 0) { - return 1; - } - - if (offset < len) { - ((uint_least32_t *)str)[offset] = cp; - return 1; - } else { - return 0; - } -} - -inline size_t -set_codepoint_utf8(uint_least32_t cp, void *str, size_t len, size_t offset) -{ - if (str == NULL || len == 0) { - return grapheme_encode_utf8(cp, NULL, 0); - } - - if (offset < len) { - return grapheme_encode_utf8(cp, (char *)str + offset, - len - offset); - } else { - return grapheme_encode_utf8(cp, NULL, 0); - } -} diff --git a/src/util.h b/src/util.h @@ -113,10 +113,4 @@ void proper_init(const HERODOTUS_READER *, void *, uint_least8_t, struct proper *); int proper_advance(struct proper *); -size_t get_codepoint(const void *, size_t, size_t, uint_least32_t *); -size_t get_codepoint_utf8(const void *, size_t, size_t, uint_least32_t *); - -size_t set_codepoint(uint_least32_t, void *, size_t, size_t); -size_t set_codepoint_utf8(uint_least32_t, void *, size_t, size_t); - #endif /* UTIL_H */