msvcrt: Fixed printf behaviour on hexadecimal, zero-padded numbers.
This commit is contained in:
parent
c9bd71f32f
commit
79c19aef29
|
@ -508,8 +508,14 @@ int FUNC_NAME(pf_printf)(FUNC_NAME(puts_clbk) pf_puts, void *puts_ctx, const API
|
|||
i = 0;
|
||||
} else if(flags.Format && strchr("diouxX", flags.Format)) {
|
||||
APICHAR *tmp = buf;
|
||||
int max_len = (flags.FieldLength>flags.Precision ? flags.FieldLength : flags.Precision) + 10;
|
||||
int max_len;
|
||||
|
||||
/* 0 padding is added after '0x' in Alternate flag is in use */
|
||||
if((flags.Format=='x' || flags.Format=='X') && flags.PadZero && flags.Alternate
|
||||
&& !flags.LeftAlign && flags.Precision<flags.FieldLength-2)
|
||||
flags.Precision = flags.FieldLength - 2;
|
||||
|
||||
max_len = (flags.FieldLength>flags.Precision ? flags.FieldLength : flags.Precision) + 10;
|
||||
if(max_len > sizeof(buf)/sizeof(APICHAR))
|
||||
tmp = HeapAlloc(GetProcessHeap(), 0, max_len);
|
||||
if(!tmp)
|
||||
|
|
|
@ -323,6 +323,22 @@ static void test_sprintf( void )
|
|||
ok(!strcmp(buffer,"1 "),"Character zero-padded and/or not left-adjusted \"%s\"\n",buffer);
|
||||
ok( r==4, "return count wrong\n");
|
||||
|
||||
format = "%#012x";
|
||||
r = sprintf(buffer,format,1);
|
||||
ok(!strcmp(buffer,"0x0000000001"),"Hexadecimal zero-padded \"%s\"\n",buffer);
|
||||
|
||||
format = "%#04.8x";
|
||||
r = sprintf(buffer,format,1);
|
||||
ok(!strcmp(buffer,"0x00000001"), "Hexadecimal zero-padded precision \"%s\"\n",buffer);
|
||||
|
||||
format = "%#-08.2x";
|
||||
r = sprintf(buffer,format,1);
|
||||
ok(!strcmp(buffer,"0x01 "), "Hexadecimal zero-padded not left-adjusted \"%s\"\n",buffer);
|
||||
|
||||
format = "%#08o";
|
||||
r = sprintf(buffer,format,1);
|
||||
ok(!strcmp(buffer,"00000001"), "Octal zero-padded \"%s\"\n",buffer);
|
||||
|
||||
if (sizeof(void *) == 8)
|
||||
{
|
||||
format = "%p";
|
||||
|
|
Loading…
Reference in New Issue