aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2008-08-24 00:15:59 +0000
committerYang Tse <yangsita@gmail.com>2008-08-24 00:15:59 +0000
commit79cbe508944029672ec2de1db9d559473ec02110 (patch)
tree0ca02f5837c00e7bd4baa80476d81013c9b05ff6
parent1c04aa54a78e24cc9d5896e31e97c89f5d3c2139 (diff)
Test if type casting a 'signed int' to a 'signed long long' fails to do sign extension on x86_64.
-rw-r--r--lib/mprintf.c11
1 files changed, 10 insertions, 1 deletions
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;