[PATCH v4 5/7] msvcrt: Interpret 'I' as size_t size specifier for integer conversions
Martin Storsjo
martin at martin.st
Tue Nov 3 12:40:39 CST 2015
Signed-off-by: Martin Storsjo <martin at martin.st>
---
v2: Rebased on top of the merged version of preceding patches.
v3: Fixed the test message to output the faulty string.
v4: Unchanged from v3.
---
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";
--
1.8.1.2
More information about the wine-patches
mailing list