taskkill: Fix the string resources so their format placeholders can be reordered.

Francois Gouget fgouget at free.fr
Sat Nov 19 08:10:07 CST 2011


---
 programs/taskkill/taskkill.c  |   19 ++++++++++---------
 programs/taskkill/taskkill.rc |   14 +++++++-------
 2 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/programs/taskkill/taskkill.c b/programs/taskkill/taskkill.c
index c6423c4..a8ef5dd 100644
--- a/programs/taskkill/taskkill.c
+++ b/programs/taskkill/taskkill.c
@@ -36,13 +36,14 @@ struct pid_close_info
     BOOL found;
 };
 
-static int taskkill_vprintfW(const WCHAR *msg, va_list va_args)
+static int taskkill_vprintfW(const WCHAR *msg, __ms_va_list va_args)
 {
     int wlen;
     DWORD count, ret;
     WCHAR msg_buffer[8192];
 
-    wlen = vsprintfW(msg_buffer, msg, va_args);
+    wlen = FormatMessageW(FORMAT_MESSAGE_FROM_STRING, msg, 0, 0, msg_buffer,
+                          sizeof(msg_buffer)/sizeof(*msg_buffer), &va_args);
 
     ret = WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), msg_buffer, wlen, &count, NULL);
     if (!ret)
@@ -71,35 +72,35 @@ static int taskkill_vprintfW(const WCHAR *msg, va_list va_args)
 
 static int taskkill_printfW(const WCHAR *msg, ...)
 {
-    va_list va_args;
+    __ms_va_list va_args;
     int len;
 
-    va_start(va_args, msg);
+    __ms_va_start(va_args, msg);
     len = taskkill_vprintfW(msg, va_args);
-    va_end(va_args);
+    __ms_va_end(va_args);
 
     return len;
 }
 
 static int taskkill_message_printfW(int msg, ...)
 {
-    va_list va_args;
+    __ms_va_list va_args;
     WCHAR msg_buffer[8192];
     int len;
 
     LoadStringW(GetModuleHandleW(NULL), msg, msg_buffer,
         sizeof(msg_buffer)/sizeof(WCHAR));
 
-    va_start(va_args, msg);
+    __ms_va_start(va_args, msg);
     len = taskkill_vprintfW(msg_buffer, va_args);
-    va_end(va_args);
+    __ms_va_end(va_args);
 
     return len;
 }
 
 static int taskkill_message(int msg)
 {
-    static const WCHAR formatW[] = {'%','s',0};
+    static const WCHAR formatW[] = {'%','1',0};
     WCHAR msg_buffer[8192];
 
     LoadStringW(GetModuleHandleW(NULL), msg, msg_buffer,
diff --git a/programs/taskkill/taskkill.rc b/programs/taskkill/taskkill.rc
index 5453945..b45a0b1 100644
--- a/programs/taskkill/taskkill.rc
+++ b/programs/taskkill/taskkill.rc
@@ -28,14 +28,14 @@ STRINGTABLE
     STRING_INVALID_OPTION, "Error: Unknown or invalid command line option specified.\n"
     STRING_INVALID_PARAM, "Error: Invalid command line parameter specified.\n"
     STRING_MISSING_OPTION, "Error: One of options /im or /pid must be specified.\n"
-    STRING_MISSING_PARAM, "Error: Option %s expects a command line parameter.\n"
+    STRING_MISSING_PARAM, "Error: Option %1 expects a command line parameter.\n"
     STRING_MUTUAL_EXCLUSIVE, "Error: Options /im and /pid are mutually exclusive.\n"
-    STRING_CLOSE_PID_SEARCH, "Close message sent to top-level windows of process with PID %u.\n"
-    STRING_CLOSE_PROC_SRCH, "Close message sent to top-level windows of process \"%s\" with PID %u.\n"
-    STRING_TERM_PID_SEARCH, "Process with PID %u was forcibly terminated.\n"
-    STRING_TERM_PROC_SEARCH, "Process \"%s\" with PID %u was forcibly terminated.\n"
-    STRING_SEARCH_FAILED, "Error: Could not find process \"%s\".\n"
+    STRING_CLOSE_PID_SEARCH, "Close message sent to top-level windows of process with PID %1!u!.\n"
+    STRING_CLOSE_PROC_SRCH, "Close message sent to top-level windows of process \"%1\" with PID %2!u!.\n"
+    STRING_TERM_PID_SEARCH, "Process with PID %1!u! was forcibly terminated.\n"
+    STRING_TERM_PROC_SEARCH, "Process \"%1\" with PID %2!u! was forcibly terminated.\n"
+    STRING_SEARCH_FAILED, "Error: Could not find process \"%1\".\n"
     STRING_ENUM_FAILED, "Error: Unable to enumerate the process list.\n"
-    STRING_TERMINATE_FAILED, "Error: Unable to terminate process \"%s\".\n"
+    STRING_TERMINATE_FAILED, "Error: Unable to terminate process \"%1\".\n"
     STRING_SELF_TERMINATION, "Error: Process self-termination is not permitted.\n"
 }
-- 
1.7.7.1




More information about the wine-patches mailing list