From 83f32ab6a37ce137cb0ac7c9ffc3f8e66a6fe104 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 21 Dec 2025 15:16:20 +0100 Subject: Add libcmap_fprint_range, libcmap_print_range, libcmap_dprint_range MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libcmap.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) (limited to 'libcmap.h') diff --git a/libcmap.h b/libcmap.h index 324f790..a04b38e 100644 --- a/libcmap.h +++ b/libcmap.h @@ -4,6 +4,8 @@ #include #include +#include + #if defined(__GNUC__) # define LIBCMAP_PURE_ __attribute__((__pure__)) @@ -224,6 +226,7 @@ const struct libcmap_block *libcmap_find_block(uint32_t codepoint, size_t *offse */ const struct libcmap_script *libcmap_find_script(uint32_t codepoint, size_t *offset_out, size_t *subrange_out); + /** * Print a string representing a Unicode codepoint range * @@ -233,7 +236,9 @@ const struct libcmap_script *libcmap_find_script(uint32_t codepoint, size_t *off * @param endash Desired delimiter between the first and the last * codepoint, or `NULL` for the default (not ASCII) * @return The number of bytes in the string, excluding the - * terminating NUL byte + * terminating NUL byte, -1 on failure + * + * @throws Any error specified for sprintf(3) * * A NUL byte will added to the end of the string, but this byte * will not be counted in the return value @@ -250,7 +255,9 @@ int libcmap_sprint_range(char *buf, const struct libcmap_range *range, const cha * @param endash Desired delimiter between the first and the last * codepoint, or `NULL` for the default (not ASCII) * @return The number of bytes in the string, excluding the - * terminating NUL byte + * terminating NUL byte, -1 on failure + * + * @throws Any error specified for snprintf(3) * * A NUL byte will added to the end of the string, but this byte * will not be counted in the return value @@ -268,6 +275,45 @@ int libcmap_sprint_range(char *buf, const struct libcmap_range *range, const cha */ int libcmap_snprint_range(char *buf, size_t bufsize, const struct libcmap_range *range, const char *endash); +/** + * Print a string representing a Unicode codepoint range + * + * @param fp The file to write to + * @param range The range to print a representation of + * @param endash Desired delimiter between the first and the last + * codepoint, or `NULL` for the default (not ASCII) + * @return The number of bytes in the string, -1 on failure + * + * @throws Any error specified for fprintf(3) + */ +int libcmap_fprint_range(FILE *fp, const struct libcmap_range *range, const char *endash); + +/** + * Print, to standard output, a string representing a + * Unicode codepoint range + * + * @param range The range to print a representation of + * @param endash Desired delimiter between the first and the last + * codepoint, or `NULL` for the default (not ASCII) + * @return The number of bytes in the string, -1 on failure + * + * @throws Any error specified for fprintf(3) + */ +int libcmap_print_range(const struct libcmap_range *range, const char *endash); + +/** + * Print a string representing a Unicode codepoint range + * + * @param fd The file descriptor + * @param range The range to print a representation of + * @param endash Desired delimiter between the first and the last + * codepoint, or `NULL` for the default (not ASCII) + * @return The number of bytes in the string, -1 on failure + * + * @throws Any error specified for dprintf(3) + */ +int libcmap_dprint_range(int fd, const struct libcmap_range *range, const char *endash); + #undef LIBCMAP_PURE_ #undef LIBCMAP_CONST_ -- cgit v1.3.1