Jesse Allen : msvcrt: Fix printf sign flags.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Dec 21 14:26:06 CST 2005


Module: wine
Branch: refs/heads/master
Commit: 180326bb0aa5adfe6906728f40f1cd27be617f1c
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=180326bb0aa5adfe6906728f40f1cd27be617f1c

Author: Jesse Allen <the3dfxdude at gmail.com>
Date:   Wed Dec 21 20:07:03 2005 +0100

msvcrt: Fix printf sign flags.
Fix the printf sign flags so that '+' doesn't always override ' '
space alone.  If they both appear, continue parsing and let '+' take
precedence.

---

 dlls/msvcrt/tests/printf.c |   10 ++++++++++
 dlls/msvcrt/wcs.c          |    5 ++++-
 2 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/dlls/msvcrt/tests/printf.c b/dlls/msvcrt/tests/printf.c
index 3979a95..d96c61e 100644
--- a/dlls/msvcrt/tests/printf.c
+++ b/dlls/msvcrt/tests/printf.c
@@ -56,6 +56,16 @@ static void test_sprintf( void )
     ok(!strcmp(buffer, "I"), "Problem with \"I\" interpretation\n");
     ok( r==1, "return count wrong\n");
 
+    format = "% d";
+    r = sprintf(buffer,format,1);
+    ok(!strcmp(buffer, " 1"),"Problem with sign place-holder: '%s'\n",buffer);
+    ok( r==2, "return count wrong\n");
+
+    format = "%+ d";
+    r = sprintf(buffer,format,1);
+    ok(!strcmp(buffer, "+1"),"Problem with sign flags: '%s'\n",buffer);
+    ok( r==2, "return count wrong\n");
+
     format = "%S";
     r = sprintf(buffer,format,wide);
     ok(!strcmp(buffer,"wide"),"Problem with wide string format\n");
diff --git a/dlls/msvcrt/wcs.c b/dlls/msvcrt/wcs.c
index efb93d8..83a713e 100644
--- a/dlls/msvcrt/wcs.c
+++ b/dlls/msvcrt/wcs.c
@@ -438,7 +438,10 @@ static int pf_vsnprintf( pf_output *out,
         while (*p)
         {
             if( *p == '+' || *p == ' ' )
-                flags.Sign = '+';
+            {
+                if ( flags.Sign != '+' )
+                    flags.Sign = *p;
+            }
             else if( *p == '-' )
                 flags.LeftAlign = *p;
             else if( *p == '0' )




More information about the wine-cvs mailing list