From 1051937c214309dfa42f861feca2bf420b1f2edb Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 28 Jan 2010 06:42:08 +0000 Subject: [PATCH] Add llvm::Program::ChangeStderrToBinary(). llvm-svn: 94743 --- llvm/include/llvm/System/Program.h | 6 ++++-- llvm/lib/System/Unix/Program.inc | 5 +++++ llvm/lib/System/Win32/Program.inc | 5 +++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/llvm/include/llvm/System/Program.h b/llvm/include/llvm/System/Program.h index 679956272609..69ce47892e14 100644 --- a/llvm/include/llvm/System/Program.h +++ b/llvm/include/llvm/System/Program.h @@ -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(..); diff --git a/llvm/lib/System/Unix/Program.inc b/llvm/lib/System/Unix/Program.inc index 43c3606d9831..e8c280624788 100644 --- a/llvm/lib/System/Unix/Program.inc +++ b/llvm/lib/System/Unix/Program.inc @@ -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; +} + } diff --git a/llvm/lib/System/Win32/Program.inc b/llvm/lib/System/Win32/Program.inc index a69826fdcef4..a3b40d0e3650 100644 --- a/llvm/lib/System/Win32/Program.inc +++ b/llvm/lib/System/Win32/Program.inc @@ -379,4 +379,9 @@ bool Program::ChangeStdoutToBinary(){ return result == -1; } +bool Program::ChangeStderrToBinary(){ + int result = _setmode( _fileno(stderr), _O_BINARY ); + return result == -1; +} + }