mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 04:38:24 +00:00
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
This commit is contained in:
@ -349,10 +349,7 @@ public:
|
|||||||
|
|
||||||
/// raw_fd_ostream ctor - FD is the file descriptor that this writes to. If
|
/// 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.
|
/// ShouldClose is true, this closes the file when the stream is destroyed.
|
||||||
raw_fd_ostream(int fd, bool shouldClose,
|
raw_fd_ostream(int fd, bool shouldClose, bool unbuffered=false);
|
||||||
bool unbuffered=false) : raw_ostream(unbuffered), FD(fd),
|
|
||||||
ShouldClose(shouldClose),
|
|
||||||
Error(false) {}
|
|
||||||
|
|
||||||
~raw_fd_ostream();
|
~raw_fd_ostream();
|
||||||
|
|
||||||
|
@ -409,6 +409,19 @@ raw_fd_ostream::raw_fd_ostream(const char *Filename, std::string &ErrorInfo,
|
|||||||
ShouldClose = true;
|
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() {
|
raw_fd_ostream::~raw_fd_ostream() {
|
||||||
if (FD >= 0) {
|
if (FD >= 0) {
|
||||||
flush();
|
flush();
|
||||||
|
Reference in New Issue
Block a user