From 79cbe508944029672ec2de1db9d559473ec02110 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sun, 24 Aug 2008 00:15:59 +0000 Subject: Test if type casting a 'signed int' to a 'signed long long' fails to do sign extension on x86_64. --- lib/mprintf.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/mprintf.c b/lib/mprintf.c index be6832fa1..3a83cf001 100644 --- a/lib/mprintf.c +++ b/lib/mprintf.c @@ -325,6 +325,7 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos, int flags; long max_param=0; long i; + int aux_signed_int; while(*fmt) { if(*fmt++ == '%') { @@ -591,9 +592,17 @@ static long dprintf_Pass1(const char *format, va_stack_t *vto, char **endpos, else if(vto[i].flags & FLAGS_UNSIGNED) vto[i].data.num.as_unsigned = (mp_uintmax_t)va_arg(arglist, unsigned int); - else + else { + /* vto[i].data.num.as_signed = (mp_intmax_t)va_arg(arglist, int); + */ + aux_signed_int = va_arg(arglist, int); + if(sizeof(mp_intmax_t) > sizeof(long)) + vto[i].data.num.as_signed = (mp_intmax_t)aux_signed_int; + else + vto[i].data.num.as_signed = (long)aux_signed_int; + } } break; -- cgit v1.2.3