From 32f5553c03dc97912b0aa77583a23972e1a882e1 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Wed, 7 Jun 2006 23:18:34 +0000 Subject: For PR787: Provide new llvm::sys::Program facilities for converting the stdout and stdin to binary mode. There is no standard way to do this and the available mechanisms are platform specific. Adjust the bytecode reader and writer to use these methods when their input is stdin or output is stdout. THis avoids the problem with \n writing CRLF to a bytecode file on windows. Patch Contributed by Michael Smith. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28722 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bytecode/Writer/Writer.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/Bytecode/Writer/Writer.cpp') diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp index 83e8a57acf..4dc80d1809 100644 --- a/lib/Bytecode/Writer/Writer.cpp +++ b/lib/Bytecode/Writer/Writer.cpp @@ -29,6 +29,7 @@ #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Support/Compressor.h" #include "llvm/Support/MathExtras.h" +#include "llvm/System/Program.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/Statistic.h" #include @@ -1217,6 +1218,11 @@ void llvm::WriteBytecodeToFile(const Module *M, std::ostream &Out, bool compress ) { assert(M && "You can't write a null module!!"); + // Make sure that std::cout is put into binary mode for systems + // that care. + if (&Out == std::cout) + sys::Program::ChangeStdoutToBinary(); + // Create a vector of unsigned char for the bytecode output. We // reserve 256KBytes of space in the vector so that we avoid doing // lots of little allocations. 256KBytes is sufficient for a large -- cgit v1.2.3-70-g09d2