Add llvm::Program::ChangeStderrToBinary().
authorDouglas Gregor <dgregor@apple.com>
Thu, 28 Jan 2010 06:42:08 +0000 (06:42 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 28 Jan 2010 06:42:08 +0000 (06:42 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94743 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/System/Program.h
lib/System/Unix/Program.inc
lib/System/Win32/Program.inc

index 679956272609647be6ea618855ef2a48a60b59ec..69ce47892e14ffa928a410a5af00c482ced2ca4d 100644 (file)
@@ -120,10 +120,12 @@ namespace sys {
     /// @brief Construct a Program by finding it by name.
     static Path FindProgramByName(const std::string& name);
 
-    // These methods change the specified standard stream (stdin or stdout) to
-    // binary mode. They return true if an error occurred
+    // These methods change the specified standard stream (stdin,
+    // stdout, or stderr) to binary mode. They return true if an error
+    // occurred
     static bool ChangeStdinToBinary();
     static bool ChangeStdoutToBinary();
+    static bool ChangeStderrToBinary();
 
     /// A convenience function equivalent to Program prg; prg.Execute(..);
     /// prg.Wait(..);
index 43c3606d9831133d8c346eb7eabd34df7f056802..e8c28062478881b9376cf70686b392d02a1ed9c7 100644 (file)
@@ -323,4 +323,9 @@ bool Program::ChangeStdoutToBinary(){
   return false;
 }
 
+bool Program::ChangeStderrToBinary(){
+  // Do nothing, as Unix doesn't differentiate between text and binary.
+  return false;
+}
+
 }
index a69826fdcef4cb5995e0d90e4bcb85f61578b489..a3b40d0e3650376378f536994cf2fc3e53a7b739 100644 (file)
@@ -379,4 +379,9 @@ bool Program::ChangeStdoutToBinary(){
   return result == -1;
 }
 
+bool Program::ChangeStderrToBinary(){
+  int result = _setmode( _fileno(stderr), _O_BINARY );
+  return result == -1;
+}
+
 }