Advance over * argument for precision.
Honor precision argument for strings.
This commit is contained in:
parent
20894e2ffb
commit
0fb9ef68f3
@ -76,6 +76,16 @@ static void test_sprintf( void )
|
|||||||
ok(!strcmp(buffer,"0foo"),"String not zero-prefixed \"%s\"\n",buffer);
|
ok(!strcmp(buffer,"0foo"),"String not zero-prefixed \"%s\"\n",buffer);
|
||||||
ok( r==4, "return count wrong\n");
|
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";
|
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");
|
||||||
|
@ -309,6 +309,9 @@ static inline int pf_output_format_W( pf_output *out, LPCWSTR str,
|
|||||||
if( len < 0 )
|
if( len < 0 )
|
||||||
len = strlenW( str );
|
len = strlenW( str );
|
||||||
|
|
||||||
|
if (flags->Precision && flags->Precision < len)
|
||||||
|
len = flags->Precision;
|
||||||
|
|
||||||
r = pf_fill( out, len, flags, 1 );
|
r = pf_fill( out, len, flags, 1 );
|
||||||
|
|
||||||
if( r>=0 )
|
if( r>=0 )
|
||||||
@ -328,6 +331,9 @@ static inline int pf_output_format_A( pf_output *out, LPCSTR str,
|
|||||||
if( len < 0 )
|
if( len < 0 )
|
||||||
len = strlen( str );
|
len = strlen( str );
|
||||||
|
|
||||||
|
if (flags->Precision && flags->Precision < len)
|
||||||
|
len = flags->Precision;
|
||||||
|
|
||||||
r = pf_fill( out, len, flags, 1 );
|
r = pf_fill( out, len, flags, 1 );
|
||||||
|
|
||||||
if( r>=0 )
|
if( r>=0 )
|
||||||
@ -461,7 +467,10 @@ static int pf_vsnprintf( pf_output *out, const WCHAR *format, va_list valist )
|
|||||||
{
|
{
|
||||||
p++;
|
p++;
|
||||||
if( *p == '*' )
|
if( *p == '*' )
|
||||||
|
{
|
||||||
flags.Precision = va_arg( valist, int );
|
flags.Precision = va_arg( valist, int );
|
||||||
|
p++;
|
||||||
|
}
|
||||||
else while( isdigit(*p) )
|
else while( isdigit(*p) )
|
||||||
{
|
{
|
||||||
flags.Precision *= 10;
|
flags.Precision *= 10;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user