programs: Document the reason for the WriteConsole() fall back.

Francois Gouget fgouget at free.fr
Wed Aug 24 07:29:31 CDT 2011


---
 programs/hostname/hostname.c |    4 ++++
 programs/ipconfig/ipconfig.c |    4 ++++
 programs/reg/reg.c           |    4 ++++
 programs/taskkill/taskkill.c |    4 ++++
 4 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/programs/hostname/hostname.c b/programs/hostname/hostname.c
index 77ff23b..8bf8676 100644
--- a/programs/hostname/hostname.c
+++ b/programs/hostname/hostname.c
@@ -53,6 +53,10 @@ static int hostname_vprintfW(const WCHAR *msg, va_list va_args)
         DWORD len;
         char *msgA;
 
+        /* On Windows WriteConsoleW() fails if the output is redirected. So fall
+         * back to WriteFile(), assuming the console encoding is still the right
+         * one in that case.
+         */
         len = WideCharToMultiByte(GetConsoleOutputCP(), 0, msg_buffer, wlen,
             NULL, 0, NULL, NULL);
         msgA = HeapAlloc(GetProcessHeap(), 0, len);
diff --git a/programs/ipconfig/ipconfig.c b/programs/ipconfig/ipconfig.c
index 14974ae..37e7099 100644
--- a/programs/ipconfig/ipconfig.c
+++ b/programs/ipconfig/ipconfig.c
@@ -40,6 +40,10 @@ static int ipconfig_vprintfW(const WCHAR *msg, va_list va_args)
         DWORD len;
         char *msgA;
 
+        /* On Windows WriteConsoleW() fails if the output is redirected. So fall
+         * back to WriteFile(), assuming the console encoding is still the right
+         * one in that case.
+         */
         len = WideCharToMultiByte(GetConsoleOutputCP(), 0, msg_buffer, wlen,
             NULL, 0, NULL, NULL);
         msgA = HeapAlloc(GetProcessHeap(), 0, len);
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
index 0f8aa15..8a6ffc4 100644
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -38,6 +38,10 @@ static int reg_printfW(const WCHAR *msg, ...)
         DWORD len;
         char  *msgA;
 
+        /* On Windows WriteConsoleW() fails if the output is redirected. So fall
+         * back to WriteFile(), assuming the console encoding is still the right
+         * one in that case.
+         */
         len = WideCharToMultiByte(GetConsoleOutputCP(), 0, msg_buffer, wlen,
             NULL, 0, NULL, NULL);
         msgA = HeapAlloc(GetProcessHeap(), 0, len * sizeof(char));
diff --git a/programs/taskkill/taskkill.c b/programs/taskkill/taskkill.c
index 1dc1fcc..c6423c4 100644
--- a/programs/taskkill/taskkill.c
+++ b/programs/taskkill/taskkill.c
@@ -50,6 +50,10 @@ static int taskkill_vprintfW(const WCHAR *msg, va_list va_args)
         DWORD len;
         char *msgA;
 
+        /* On Windows WriteConsoleW() fails if the output is redirected. So fall
+         * back to WriteFile(), assuming the console encoding is still the right
+         * one in that case.
+         */
         len = WideCharToMultiByte(GetConsoleOutputCP(), 0, msg_buffer, wlen,
             NULL, 0, NULL, NULL);
         msgA = HeapAlloc(GetProcessHeap(), 0, len);
-- 
1.7.5.4



More information about the wine-patches mailing list