From f6034c4f3d200c98dd77073e9e5ea467bb3dbc29 Mon Sep 17 00:00:00 2001 From: Adrian McCarthy Date: Thu, 14 Apr 2016 23:31:17 +0000 Subject: [PATCH] Don't disable stdin buffering on Windows Disabling buffering exposes a bug in the MS VS 2015 CRT implementation of fgets, where you sometimes have to hit Enter twice, depending on if the input had an odd or even number of characters. This was hidden until a few days ago by the Python initialization which was re-enabling buffering on the streams. A few days ago, Enrico make the Python initialization on-demand, which exposed this problem. llvm-svn: 266384 --- lldb/tools/driver/Driver.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index 328b90beab48..c057d71a8300 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -1037,7 +1037,12 @@ Driver::MainLoop () atexit (reset_stdin_termios); } +#ifndef _MSC_VER + // Disabling stdin buffering with MSVC's 2015 CRT exposes a bug in fgets + // which causes it to miss newlines depending on whether there have been an + // odd or even number of characters. Bug has been reported to MS via Connect. ::setbuf (stdin, NULL); +#endif ::setbuf (stdout, NULL); m_debugger.SetErrorFileHandle (stderr, false); @@ -1309,12 +1314,6 @@ wmain(int argc, wchar_t const *wargv[]) main(int argc, char const *argv[]) #endif { -#ifdef _MSC_VER - // disable buffering on windows - setvbuf(stdout, NULL, _IONBF, 0); - setvbuf(stdin , NULL, _IONBF, 0); -#endif - #ifdef _WIN32 // Convert wide arguments to UTF-8 std::vector argvStrings(argc);