Skip to content

Commit

Permalink
Add %D and %I for 64 bit formatting.
Browse files Browse the repository at this point in the history
Instead of breaking old code with changing %i and %d.
  • Loading branch information
bakpakin committed Oct 9, 2023
1 parent 549ee95 commit 741a503
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/core/pp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 741a503

Please sign in to comment.