amccarth created this revision.
amccarth added a reviewer: zturner.
amccarth added a subscriber: lldb-commits.

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.

http://reviews.llvm.org/D19136

Files:
  tools/driver/Driver.cpp

Index: tools/driver/Driver.cpp
===================================================================
--- tools/driver/Driver.cpp
+++ tools/driver/Driver.cpp
@@ -1037,8 +1037,10 @@
         atexit (reset_stdin_termios);
     }
 
+#ifndef _MSC_VER
     ::setbuf (stdin, NULL);
     ::setbuf (stdout, NULL);
+#endif
 
     m_debugger.SetErrorFileHandle (stderr, false);
     m_debugger.SetOutputFileHandle (stdout, false);
@@ -1309,12 +1311,6 @@
 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);


Index: tools/driver/Driver.cpp
===================================================================
--- tools/driver/Driver.cpp
+++ tools/driver/Driver.cpp
@@ -1037,8 +1037,10 @@
         atexit (reset_stdin_termios);
     }
 
+#ifndef _MSC_VER
     ::setbuf (stdin, NULL);
     ::setbuf (stdout, NULL);
+#endif
 
     m_debugger.SetErrorFileHandle (stderr, false);
     m_debugger.SetOutputFileHandle (stdout, false);
@@ -1309,12 +1311,6 @@
 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);
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to