llvm.org GIT mirror llvm / a872a0f
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116509 91177308-0d34-0410-b5e6-96231b3b80d8 Francois Pichet 9 years ago
2 changed file(s) with 14 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
348348
349349 /// raw_fd_ostream ctor - FD is the file descriptor that this writes to. If
350350 /// ShouldClose is true, this closes the file when the stream is destroyed.
351 raw_fd_ostream(int fd, bool shouldClose,
352 bool unbuffered=false) : raw_ostream(unbuffered), FD(fd),
353 ShouldClose(shouldClose),
354 Error(false) {}
351 raw_fd_ostream(int fd, bool shouldClose, bool unbuffered=false);
355352
356353 ~raw_fd_ostream();
357354
408408 ShouldClose = true;
409409 }
410410
411 /// raw_fd_ostream ctor - FD is the file descriptor that this writes to. If
412 /// ShouldClose is true, this closes the file when the stream is destroyed.
413 raw_fd_ostream::raw_fd_ostream(int fd, bool shouldClose, bool unbuffered)
414 : raw_ostream(unbuffered), FD(fd),
415 ShouldClose(shouldClose), Error(false) {
416 #ifdef O_BINARY
417 // Setting STDOUT and STDERR to binary mode is necessary in Win32
418 // to avoid undesirable linefeed conversion.
419 if (fd == STDOUT_FILENO || fd == STDERR_FILENO)
420 setmode(fd, O_BINARY);
421 #endif
422 }
423
411424 raw_fd_ostream::~raw_fd_ostream() {
412425 if (FD >= 0) {
413426 flush();