From 741a5036e8f986f9d3dfc94dc8bb387a32c0f84c Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Sun, 8 Oct 2023 21:23:03 -0500 Subject: [PATCH] Add %D and %I for 64 bit formatting. Instead of breaking old code with changing %i and %d. --- src/core/pp.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/core/pp.c b/src/core/pp.c index 98907b9e..261fca04 100644 --- a/src/core/pp.c +++ b/src/core/pp.c @@ -772,6 +772,8 @@ struct FmtMapping { /* Janet uses fixed width integer types for most things, so map * format specifiers to these fixed sizes */ static const struct FmtMapping format_mappings[] = { + {'D', PRId64}, + {'I', PRIi64}, {'d', PRId64}, {'i', PRIi64}, {'o', PRIo64}, @@ -856,6 +858,12 @@ void janet_formatbv(JanetBuffer *b, const char *format, va_list args) { } case 'd': case 'i': { + int64_t n = (int64_t) va_arg(args, int32_t); + nb = snprintf(item, MAX_ITEM, form, n); + break; + } + case 'D': + case 'I': { int64_t n = va_arg(args, int64_t); nb = snprintf(item, MAX_ITEM, form, n); break; @@ -1017,6 +1025,8 @@ void janet_buffer_format( janet_getinteger(argv, arg)); break; } + case 'D': + case 'I': case 'd': case 'i': { int64_t n = janet_getinteger64(argv, arg);