msvcrt: Fix *printf() handling of negative field width.
This commit is contained in:
parent
fdff5c3a3a
commit
bbe9c51b31
|
@ -279,6 +279,11 @@ static void test_sprintf( void )
|
||||||
ok(!strcmp(buffer,"f"),"Precision ignored \"%s\"\n",buffer);
|
ok(!strcmp(buffer,"f"),"Precision ignored \"%s\"\n",buffer);
|
||||||
ok( r==1, "return count wrong\n");
|
ok( r==1, "return count wrong\n");
|
||||||
|
|
||||||
|
format = "%*s";
|
||||||
|
r = sprintf(buffer,format,-5,"foo");
|
||||||
|
ok(!strcmp(buffer,"foo "),"Negative field width ignored \"%s\"\n",buffer);
|
||||||
|
ok( r==5, "return count wrong\n");
|
||||||
|
|
||||||
format = "%#-012p";
|
format = "%#-012p";
|
||||||
r = sprintf(buffer,format,(void *)57);
|
r = sprintf(buffer,format,(void *)57);
|
||||||
ok(!strcmp(buffer,"0X00000039 "),"Pointer formatted incorrectly\n");
|
ok(!strcmp(buffer,"0X00000039 "),"Pointer formatted incorrectly\n");
|
||||||
|
|
|
@ -568,9 +568,14 @@ static int pf_vsnprintf( pf_output *out, const WCHAR *format, va_list valist )
|
||||||
|
|
||||||
/* deal with the field width specifier */
|
/* deal with the field width specifier */
|
||||||
flags.FieldLength = 0;
|
flags.FieldLength = 0;
|
||||||
if( *p == '*' )
|
if( *p == '*' )
|
||||||
{
|
{
|
||||||
flags.FieldLength = va_arg( valist, int );
|
flags.FieldLength = va_arg( valist, int );
|
||||||
|
if (flags.FieldLength < 0)
|
||||||
|
{
|
||||||
|
flags.LeftAlign = '-';
|
||||||
|
flags.FieldLength = -flags.FieldLength;
|
||||||
|
}
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
else while( isdigit(*p) )
|
else while( isdigit(*p) )
|
||||||
|
|
Loading…
Reference in New Issue