[llvm-commits] [llvm] r116509 - in /llvm/trunk: include/llvm/Support/raw_ostream.h lib/Support/raw_ostream.cpp
Francois Pichet
pichet2000 at gmail.com
Thu Oct 14 13:30:59 PDT 2010
Author: fpichet
Date: Thu Oct 14 15:30:58 2010
New Revision: 116509
URL: http://llvm.org/viewvc/llvm-project?rev=116509&view=rev
Log:
Always use binary mode for output stream. This is important to prevent unwanted end of line conversion on Windows. Should not affect Unix where O_BINARY is not defined. This fix /clang/test/lexer/preamble.c XFAIL on WIN32.
Modified:
llvm/trunk/include/llvm/Support/raw_ostream.h
llvm/trunk/lib/Support/raw_ostream.cpp
Modified: llvm/trunk/include/llvm/Support/raw_ostream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/raw_ostream.h?rev=116509&r1=116508&r2=116509&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/raw_ostream.h (original)
+++ llvm/trunk/include/llvm/Support/raw_ostream.h Thu Oct 14 15:30:58 2010
@@ -349,10 +349,7 @@
/// raw_fd_ostream ctor - FD is the file descriptor that this writes to. If
/// ShouldClose is true, this closes the file when the stream is destroyed.
- raw_fd_ostream(int fd, bool shouldClose,
- bool unbuffered=false) : raw_ostream(unbuffered), FD(fd),
- ShouldClose(shouldClose),
- Error(false) {}
+ raw_fd_ostream(int fd, bool shouldClose, bool unbuffered=false);
~raw_fd_ostream();
Modified: llvm/trunk/lib/Support/raw_ostream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/raw_ostream.cpp?rev=116509&r1=116508&r2=116509&view=diff
==============================================================================
--- llvm/trunk/lib/Support/raw_ostream.cpp (original)
+++ llvm/trunk/lib/Support/raw_ostream.cpp Thu Oct 14 15:30:58 2010
@@ -409,6 +409,19 @@
ShouldClose = true;
}
+/// raw_fd_ostream ctor - FD is the file descriptor that this writes to. If
+/// ShouldClose is true, this closes the file when the stream is destroyed.
+raw_fd_ostream::raw_fd_ostream(int fd, bool shouldClose, bool unbuffered)
+ : raw_ostream(unbuffered), FD(fd),
+ ShouldClose(shouldClose), Error(false) {
+#ifdef O_BINARY
+ // Setting STDOUT and STDERR to binary mode is necessary in Win32
+ // to avoid undesirable linefeed conversion.
+ if (fd == STDOUT_FILENO || fd == STDERR_FILENO)
+ setmode(fd, O_BINARY);
+#endif
+}
+
raw_fd_ostream::~raw_fd_ostream() {
if (FD >= 0) {
flush();
More information about the llvm-commits
mailing list