aboutsummaryrefslogtreecommitdiffstats
path: root/libcmap_sprint_range.c
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2025-12-21 14:08:57 +0100
committerMattias Andrée <m@maandree.se>2025-12-21 14:13:45 +0100
commit095193a9905caff27509a299d895d399d42c06aa (patch)
tree48b1bcf860866029d9081cf9ecd72388658cfbb9 /libcmap_sprint_range.c
parentAdd range print functions (diff)
downloadlibcmap-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_sprint_range.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/libcmap_sprint_range.c b/libcmap_sprint_range.c
index 800fee5..64d762a 100644
--- a/libcmap_sprint_range.c
+++ b/libcmap_sprint_range.c
@@ -1,10 +1,14 @@
/* See LICENSE file for copyright and license details. */
-#include "libcmap.h"
-#include <limits.h>
+#include "common.h"
int
libcmap_sprint_range(char *buf, const struct libcmap_range *range, const char *endash)
{
- return libcmap_snprint_range(buf, buf ? SIZE_MAX : (size_t)0, range, endash);
+ if (!buf)
+ return libcmap_snprint_range(NULL, 0, range, endash);
+ else if (range->first == range->last)
+ return sprintf(buf, SINGLETON_RANGE_FMT, SINGLETON_RANGE_ARGS(range));
+ else
+ return sprintf(buf, RANGE_FMT, RANGE_ARGS(range, endash));
}