From 97dcb13634c1af1bb24ff8fe1bd02bfe9ce355d0 Mon Sep 17 00:00:00 2001 From: Jason Hood Date: Sat, 28 Oct 2017 16:43:45 +1000 Subject: [PATCH] Fix ANSICON's output when redirected to CON ANSICON switches the standard streams to Unicode, but uses its own routine to write directly to the console when appropriate. However, the newlines written by -e/-E/-t/-T were still done by the CRT, so when output was redirected to CON, "\r\0\n\0" was being written. --- ansicon.c | 9 ++++++--- readme.txt | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ansicon.c b/ansicon.c index 83a5572..392fec9 100644 --- a/ansicon.c +++ b/ansicon.c @@ -85,6 +85,9 @@ use Unicode output (_O_U16TEXT, for compilers/systems that support it); log: 64-bit addresses get an underscore between the 8-digit groups; add error codes to some message. + + v1.80, 28 October, 2017: + write newline with _putws, not putwchar (fixes redirecting to CON). */ #define PDATE L"28 October, 2017" @@ -522,7 +525,7 @@ arg_out: ++cmd; fputws( cmd, stdout ); if (*arg == 'e') - putwchar( '\n' ); + _putws( L"" ); } else // (*arg == 't' || *arg == 'T') { @@ -536,7 +539,7 @@ arg_out: { wprintf( L"==> %s <==\n", arg ); display( arg, title ); - putwchar( '\n' ); + _putws( L"" ); } else display( arg, title ); @@ -578,7 +581,7 @@ void display( LPCTSTR name, BOOL title ) } if (title) { - putwchar( '\n' ); + _putws( L"" ); // Need to flush, otherwise it's written *after* STD_OUTPUT_HANDLE should // it be redirected. fflush( stdout ); diff --git a/readme.txt b/readme.txt index 0af43bc..f305a48 100644 --- a/readme.txt +++ b/readme.txt @@ -297,6 +297,7 @@ Version History 1.80 - 28 October, 2017: - fix unloading; + - fix -e et al when redirecting to CON; * go back to saving the buffer cursor position. 1.72 - 24 December, 2015: