Alexandre Julliard : kernel32: Replicate the MS bug with va_list argument counting in FormatMessage.

Alexandre Julliard julliard at winehq.org
Fri Oct 30 11:04:29 CDT 2009


Module: wine
Branch: master
Commit: 0e26e741f7e40e9483fd22d7b326ede1b801f380
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=0e26e741f7e40e9483fd22d7b326ede1b801f380

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Oct 29 20:48:26 2009 +0100

kernel32: Replicate the MS bug with va_list argument counting in FormatMessage.

---

 dlls/kernel32/format_msg.c       |    4 ++++
 dlls/kernel32/tests/format_msg.c |    4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/dlls/kernel32/format_msg.c b/dlls/kernel32/format_msg.c
index ce4e52f..4b5b00c 100644
--- a/dlls/kernel32/format_msg.c
+++ b/dlls/kernel32/format_msg.c
@@ -210,6 +210,8 @@ static LPCSTR format_insertA( int insert, LPCSTR format, DWORD flags,
             while (isdigit(*format)) *p++ = *format++;
     }
 
+    /* replicate MS bug: drop an argument when using va_list with width/precision */
+    if (insert == -1 && args->list) args->last--;
     arg = get_arg( insert, flags, args );
 
     /* check for wide string format */
@@ -333,6 +335,8 @@ static LPCWSTR format_insertW( int insert, LPCWSTR format, DWORD flags,
             while (isdigitW(*format)) *p++ = *format++;
     }
 
+    /* replicate MS bug: drop an argument when using va_list with width/precision */
+    if (insert == -1 && args->list) args->last--;
     arg = get_arg( insert, flags, args );
 
     /* check for ascii string format */
diff --git a/dlls/kernel32/tests/format_msg.c b/dlls/kernel32/tests/format_msg.c
index 43b3ce2..583cae8 100644
--- a/dlls/kernel32/tests/format_msg.c
+++ b/dlls/kernel32/tests/format_msg.c
@@ -337,7 +337,7 @@ static void test_message_from_string_wide(void)
     ok(r==11,"failed: r=%d\n",r);
     r = doitW(FORMAT_MESSAGE_FROM_STRING, fmt_1oou3oou,
               0, 0, out, sizeof(out)/sizeof(WCHAR), 5, 3, 1, 6, 4, 2 );
-    todo_wine ok(!lstrcmpW( s_sp001sp002, out),"failed out=[%s]\n", wine_dbgstr_w(out));
+    ok(!lstrcmpW( s_sp001sp002, out),"failed out=[%s]\n", wine_dbgstr_w(out));
     ok(r==12,"failed: r=%d\n",r);
     /* args are not counted the same way with an argument array */
     {
@@ -589,7 +589,7 @@ static void test_message_from_string(void)
     ok(r==11,"failed: r=%d\n",r);
     r = doit(FORMAT_MESSAGE_FROM_STRING, "%1!*.*u!,%3!*.*u!",
              0, 0, out, sizeof(out), 5, 3, 1, 6, 4, 2 );
-    todo_wine ok(!strcmp( "  001,  0002", out),"failed out=[%s]\n",out);
+    ok(!strcmp( "  001,  0002", out),"failed out=[%s]\n",out);
     ok(r==12,"failed: r=%d\n",r);
     /* args are not counted the same way with an argument array */
     {




More information about the wine-cvs mailing list