Advance over * argument for precision.

Honor precision argument for strings.
oldstable
Uwe Bonnes 2005-02-25 19:16:46 +00:00 committed by Alexandre Julliard
parent 20894e2ffb
commit 0fb9ef68f3
2 changed files with 19 additions and 0 deletions

View File

@ -76,6 +76,16 @@ static void test_sprintf( void )
ok(!strcmp(buffer,"0foo"),"String not zero-prefixed \"%s\"\n",buffer);
ok( r==4, "return count wrong\n");
format = "%.1s";
r = sprintf(buffer,format,"foo");
ok(!strcmp(buffer,"f"),"Precision ignored \"%s\"\n",buffer);
ok( r==1, "return count wrong\n");
format = "%.*s";
r = sprintf(buffer,format,1,"foo");
ok(!strcmp(buffer,"f"),"Precision ignored \"%s\"\n",buffer);
ok( r==1, "return count wrong\n");
format = "%#-012p";
r = sprintf(buffer,format,(void *)57);
ok(!strcmp(buffer,"0X00000039 "),"Pointer formatted incorrectly\n");

View File

@ -309,6 +309,9 @@ static inline int pf_output_format_W( pf_output *out, LPCWSTR str,
if( len < 0 )
len = strlenW( str );
if (flags->Precision && flags->Precision < len)
len = flags->Precision;
r = pf_fill( out, len, flags, 1 );
if( r>=0 )
@ -328,6 +331,9 @@ static inline int pf_output_format_A( pf_output *out, LPCSTR str,
if( len < 0 )
len = strlen( str );
if (flags->Precision && flags->Precision < len)
len = flags->Precision;
r = pf_fill( out, len, flags, 1 );
if( r>=0 )
@ -461,7 +467,10 @@ static int pf_vsnprintf( pf_output *out, const WCHAR *format, va_list valist )
{
p++;
if( *p == '*' )
{
flags.Precision = va_arg( valist, int );
p++;
}
else while( isdigit(*p) )
{
flags.Precision *= 10;