[Lldb-commits] [lldb] r266384 - Don't disable stdin buffering on Windows

Adrian McCarthy via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 14 16:31:18 PDT 2016


Author: amccarth
Date: Thu Apr 14 18:31:17 2016
New Revision: 266384

URL: http://llvm.org/viewvc/llvm-project?rev=266384&view=rev
Log:
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.

Modified:
    lldb/trunk/tools/driver/Driver.cpp

Modified: lldb/trunk/tools/driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=266384&r1=266383&r2=266384&view=diff
==============================================================================
--- lldb/trunk/tools/driver/Driver.cpp (original)
+++ lldb/trunk/tools/driver/Driver.cpp Thu Apr 14 18:31:17 2016
@@ -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<std::string> argvStrings(argc);




More information about the lldb-commits mailing list