Michael Stefaniuc : msvcrt: Fix *printf() handling of negative field
width.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Feb 5 07:44:56 CST 2007
Module: wine
Branch: master
Commit: bbe9c51b31e8a5d7f91853350552e63ffc638de0
URL: http://source.winehq.org/git/wine.git/?a=commit;h=bbe9c51b31e8a5d7f91853350552e63ffc638de0
Author: Michael Stefaniuc <mstefani at redhat.de>
Date: Mon Jan 29 23:53:46 2007 +0100
msvcrt: Fix *printf() handling of negative field width.
---
dlls/msvcrt/tests/printf.c | 5 +++++
dlls/msvcrt/wcs.c | 7 ++++++-
2 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/dlls/msvcrt/tests/printf.c b/dlls/msvcrt/tests/printf.c
index 53d88f4..23cc5c8 100644
--- a/dlls/msvcrt/tests/printf.c
+++ b/dlls/msvcrt/tests/printf.c
@@ -279,6 +279,11 @@ static void test_sprintf( void )
ok(!strcmp(buffer,"f"),"Precision ignored \"%s\"\n",buffer);
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";
r = sprintf(buffer,format,(void *)57);
ok(!strcmp(buffer,"0X00000039 "),"Pointer formatted incorrectly\n");
diff --git a/dlls/msvcrt/wcs.c b/dlls/msvcrt/wcs.c
index ad3887f..32668a3 100644
--- a/dlls/msvcrt/wcs.c
+++ b/dlls/msvcrt/wcs.c
@@ -568,9 +568,14 @@ static int pf_vsnprintf( pf_output *out,
/* deal with the field width specifier */
flags.FieldLength = 0;
- if( *p == '*' )
+ if( *p == '*' )
{
flags.FieldLength = va_arg( valist, int );
+ if (flags.FieldLength < 0)
+ {
+ flags.LeftAlign = '-';
+ flags.FieldLength = -flags.FieldLength;
+ }
p++;
}
else while( isdigit(*p) )
More information about the wine-cvs
mailing list