From bf708b6a967bae32c08f876ba16a616c10fd61c4 Mon Sep 17 00:00:00 2001 From: Sebastian Reimers Date: Fri, 11 Aug 2023 14:32:07 +0200 Subject: [PATCH] fmt/print: add 64-bit length modifier %Li, %Ld and %Lu --- src/fmt/print.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/fmt/print.c b/src/fmt/print.c index 6a1ec36d2..45da0cb1c 100644 --- a/src/fmt/print.c +++ b/src/fmt/print.c @@ -31,6 +31,7 @@ enum length_modifier { LENMOD_NONE = 0, LENMOD_LONG = 1, LENMOD_LONG_LONG = 2, + LENMOD_INT64 = 3, LENMOD_SIZE = 42, }; @@ -219,6 +220,10 @@ static int vhprintf(const char *fmt, va_list ap, re_vprintf_h *vph, void *arg, case 'i': switch (lenmod) { + case LENMOD_INT64: + RE_VA_ARG(ap, sn, int64_t, safe); + break; + case LENMOD_SIZE: RE_VA_ARG(ap, sn, ssize_t, safe); break; @@ -335,6 +340,10 @@ static int vhprintf(const char *fmt, va_list ap, re_vprintf_h *vph, void *arg, case 'u': switch (lenmod) { + case LENMOD_INT64: + RE_VA_ARG(ap, n, uint64_t, safe); + break; + case LENMOD_SIZE: RE_VA_ARG(ap, n, size_t, safe); break; @@ -400,6 +409,11 @@ static int vhprintf(const char *fmt, va_list ap, re_vprintf_h *vph, void *arg, fm = true; break; + case 'L': + lenmod = LENMOD_INT64; + fm = true; + break; + case 'j': RE_VA_ARG(ap, sa, struct sa *, safe); if (!sa) @@ -500,6 +514,7 @@ static int vhprintf(const char *fmt, va_list ap, re_vprintf_h *vph, void *arg, * %H (re_printf_h *, void *) Print handler with argument * %v (char *fmt, va_list *) Variable argument list * %m (int) Describe an error code + * %L (uint64_t/int64_t) 64-bit length modifier for %i, %d and %u * * * Reserved for the future: