Module: wine Branch: master Commit: 494572ed4d49dd36508759c300c59124aa88181e URL: http://source.winehq.org/git/wine.git/?a=commit;h=494572ed4d49dd36508759c300...
Author: Martin Storsjo martin@martin.st Date: Tue Nov 3 20:40:39 2015 +0200
msvcrt: Interpret 'I' as size_t size specifier for integer conversions.
Signed-off-by: Martin Storsjo martin@martin.st Signed-off-by: Piotr Caban piotr@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/msvcrt/printf.h | 6 +++--- dlls/msvcrt/tests/printf.c | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/dlls/msvcrt/printf.h b/dlls/msvcrt/printf.h index 1e215aa..f68eaf6 100644 --- a/dlls/msvcrt/printf.h +++ b/dlls/msvcrt/printf.h @@ -34,7 +34,7 @@ typedef struct FUNC_NAME(pf_flags_t) { APICHAR Sign, LeftAlign, Alternate, PadZero; int FieldLength, Precision; - APICHAR IntegerLength, IntegerDouble; + APICHAR IntegerLength, IntegerDouble, IntegerNative; APICHAR WideString; APICHAR Format; } FUNC_NAME(pf_flags); @@ -470,7 +470,7 @@ int FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx, const API else if(isdigit(*(p+1)) || !*(p+1)) break; else - p++; + flags.IntegerNative = *p++; } else if(*p == 'w') flags.WideString = *p++; else if((*p == 'F' || *p == 'N') && legacy_msvcrt_compat) @@ -533,7 +533,7 @@ int FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx, const API if(!tmp) return -1;
- if(flags.IntegerDouble) + if(flags.IntegerDouble || (flags.IntegerNative && sizeof(void*) == 8)) FUNC_NAME(pf_integer_conv)(tmp, max_len, &flags, pf_args(args_ctx, pos, VT_I8, valist).get_longlong); else if(flags.Format=='d' || flags.Format=='i') diff --git a/dlls/msvcrt/tests/printf.c b/dlls/msvcrt/tests/printf.c index c5bc102..c8797f3 100644 --- a/dlls/msvcrt/tests/printf.c +++ b/dlls/msvcrt/tests/printf.c @@ -422,6 +422,11 @@ static void test_sprintf( void ) r = sprintf(buffer,format,(void *)57); ok(!strcmp(buffer,"0X0000000000000039 "),"Pointer formatted incorrectly\n"); ok( r==20, "return count wrong\n"); + + format = "%Ix %d"; + r = sprintf(buffer,format,(size_t)0x12345678123456,1); + ok(!strcmp(buffer,"12345678123456 1"),"buffer = %s\n",buffer); + ok( r==16, "return count wrong\n"); } else { @@ -449,6 +454,11 @@ static void test_sprintf( void ) r = sprintf(buffer,format,(void *)57); ok(!strcmp(buffer,"0X00000039 "),"Pointer formatted incorrectly\n"); ok( r==12, "return count wrong\n"); + + format = "%Ix %d"; + r = sprintf(buffer,format,0x123456,1); + ok(!strcmp(buffer,"123456 1"),"buffer = %s\n",buffer); + ok( r==8, "return count wrong\n"); }
format = "%04s";