msvcrt: Fix *printf() handling of negative field width. Fixes bug
#7255.
Michael Stefaniuc
mstefani at redhat.de
Mon Jan 29 16:18:16 CST 2007
---
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..f60886e 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,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, const WCHAR *format, va_list valist )
/* 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) )
--
1.4.4.2
--
Michael Stefaniuc Tel.: +49-711-96437-199
Sr. Network Engineer Fax.: +49-711-96437-111
Red Hat GmbH Email: mstefani at redhat.com
Hauptstaetterstr. 58 http://www.redhat.de/
D-70178 Stuttgart
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20070129/1441278c/attachment.pgp
More information about the wine-patches
mailing list