diff options
| author | Mattias Andrée <m@maandree.se> | 2025-12-21 14:08:57 +0100 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2025-12-21 14:13:45 +0100 |
| commit | 095193a9905caff27509a299d895d399d42c06aa (patch) | |
| tree | 48b1bcf860866029d9081cf9ecd72388658cfbb9 /libcmap_snprint_range.c | |
| parent | Add range print functions (diff) | |
| download | libcmap-095193a9905caff27509a299d895d399d42c06aa.tar.gz libcmap-095193a9905caff27509a299d895d399d42c06aa.tar.bz2 libcmap-095193a9905caff27509a299d895d399d42c06aa.tar.xz | |
Fix truncation issue in libcmap_sprintf_range, and add LIBCMAP_ULTIMATE_CODEPOINT and LIBCMAP_UNIVERSE_RANGE
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to '')
| -rw-r--r-- | libcmap_snprint_range.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/libcmap_snprint_range.c b/libcmap_snprint_range.c index 268a80e..5dd8a7e 100644 --- a/libcmap_snprint_range.c +++ b/libcmap_snprint_range.c @@ -1,16 +1,12 @@ /* See LICENSE file for copyright and license details. */ -#include "libcmap.h" -#include <stdio.h> +#include "common.h" int libcmap_snprint_range(char *buf, size_t bufsize, const struct libcmap_range *range, const char *endash) { - unsigned long int first = (unsigned long int)range->first; - unsigned long int last = (unsigned long int)range->last; - - if (first == last) - return snprintf(buf, bufsize, "U+%04lX", first); + if (range->first == range->last) + return snprintf(buf, bufsize, SINGLETON_RANGE_FMT, SINGLETON_RANGE_ARGS(range)); else - return snprintf(buf, bufsize, "U+%04lX%sU+%04lX", first, endash ? endash : "–", last); + return snprintf(buf, bufsize, RANGE_FMT, RANGE_ARGS(range, endash)); } |
