From 725a576da816af9fb990c461c62490a0cc8a25dc Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Wed, 19 Jan 2011 22:34:59 +0000 Subject: [PATCH] Fixed r28259 which broke hh and h modifier. We must differentiate between the value type and the va_arg type ... [r28262] --- ir/libcore/lc_printf.c | 5 +++-- ir/libcore/lc_printf.h | 4 ++-- ir/libcore/lc_printf_arg_types.def | 23 ++++++++++++----------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/ir/libcore/lc_printf.c b/ir/libcore/lc_printf.c index 959200d93..1ac0cfacd 100644 --- a/ir/libcore/lc_printf.c +++ b/ir/libcore/lc_printf.c @@ -144,7 +144,7 @@ static int dispatch_snprintf(char *buf, size_t len, const char *fmt, int res = 0; switch (lc_arg_type) { -#define LC_ARG_TYPE(type,name) \ +#define LC_ARG_TYPE(type,name,va_type) \ case lc_arg_type_ ## name: res = snprintf(buf, len, fmt, val->v_ ## name); break; #include "lc_printf_arg_types.def" #undef LC_ARG_TYPE @@ -491,7 +491,8 @@ int lc_evpprintf(const lc_arg_env_t *env, lc_appendable_t *app, const char *fmt, /* Store the value according to argument information */ switch (occ.lc_arg_type) { -#define LC_ARG_TYPE(type,name) case lc_arg_type_ ## name: val.v_ ## name = va_arg(args, type); break; +#define LC_ARG_TYPE(type,name,va_type) \ + case lc_arg_type_ ## name: val.v_ ## name = va_arg(args, va_type); break; #include "lc_printf_arg_types.def" #undef LC_ARG_TYPE } diff --git a/ir/libcore/lc_printf.h b/ir/libcore/lc_printf.h index 854d04831..53fb20477 100644 --- a/ir/libcore/lc_printf.h +++ b/ir/libcore/lc_printf.h @@ -64,13 +64,13 @@ typedef struct lc_arg_occ_t { * @c ARG_TYPE macro is the name of the union member preceded by $c v_ */ typedef union { -#define LC_ARG_TYPE(type,name) type v_ ## name; +#define LC_ARG_TYPE(type,name,va_type) type v_ ## name; #include "lc_printf_arg_types.def" #undef LC_ARG_TYPE } lc_arg_value_t; enum { -#define LC_ARG_TYPE(type,name) lc_arg_type_ ## name, +#define LC_ARG_TYPE(type,name,va_type) lc_arg_type_ ## name, #include "lc_printf_arg_types.def" #undef LC_ARG_TYPE lc_arg_type_last diff --git a/ir/libcore/lc_printf_arg_types.def b/ir/libcore/lc_printf_arg_types.def index 6de88bc91..ccfa5da44 100644 --- a/ir/libcore/lc_printf_arg_types.def +++ b/ir/libcore/lc_printf_arg_types.def @@ -1,11 +1,12 @@ -LC_ARG_TYPE(int, char) -LC_ARG_TYPE(int, short) -LC_ARG_TYPE(int, int) -LC_ARG_TYPE(long, long) -LC_ARG_TYPE(LC_LONGLONG, long_long) -LC_ARG_TYPE(double, double) -LC_ARG_TYPE(LC_LONGDOUBLE, long_double) -LC_ARG_TYPE(void *, ptr) -LC_ARG_TYPE(intmax_t, intmax_t) -LC_ARG_TYPE(ptrdiff_t, ptrdiff_t) -LC_ARG_TYPE(size_t, size_t) +/* type | name | va_arg type */ +LC_ARG_TYPE(char, char, int) +LC_ARG_TYPE(short, short, int) +LC_ARG_TYPE(int, int, int) +LC_ARG_TYPE(long, long, long) +LC_ARG_TYPE(LC_LONGLONG, long_long, LC_LONGLONG) +LC_ARG_TYPE(double, double, double) +LC_ARG_TYPE(LC_LONGDOUBLE, long_double, LC_LONGDOUBLE) +LC_ARG_TYPE(void *, ptr, void *) +LC_ARG_TYPE(intmax_t, intmax_t, intmax_t) +LC_ARG_TYPE(ptrdiff_t, ptrdiff_t, ptrdiff_t) +LC_ARG_TYPE(size_t, size_t, size_t) -- 2.20.1