Skip to content

Commit

Permalink
fmt/print: add 64-bit length modifier %Li, %Ld, %Lx and %Lu (#905)
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers authored Aug 30, 2023
1 parent 9ac5d49 commit 36b80da
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/fmt/print.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ enum length_modifier {
LENMOD_NONE = 0,
LENMOD_LONG = 1,
LENMOD_LONG_LONG = 2,
LENMOD_INT64 = 3,
LENMOD_SIZE = 42,
};

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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, %x and %u
* </pre>
*
* Reserved for the future:
Expand Down

0 comments on commit 36b80da

Please sign in to comment.