mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 15:11:24 +00:00
Revert r234615, "Have one raw_fd_ostream constructor forward to the other."
It broke MSVCRT hosts: LLVM :: Object/check_binary_output.ll LLVM :: Object/extract.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234721 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
032f4a9ad1
commit
47882583cb
@ -487,41 +487,47 @@ void format_object_base::home() {
|
|||||||
// raw_fd_ostream
|
// raw_fd_ostream
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
static int getFD(StringRef Filename, std::error_code &EC,
|
raw_fd_ostream::raw_fd_ostream(StringRef Filename, std::error_code &EC,
|
||||||
sys::fs::OpenFlags Flags) {
|
sys::fs::OpenFlags Flags)
|
||||||
|
: Error(false), UseAtomicWrites(false), pos(0) {
|
||||||
|
EC = std::error_code();
|
||||||
// Handle "-" as stdout. Note that when we do this, we consider ourself
|
// Handle "-" as stdout. Note that when we do this, we consider ourself
|
||||||
// the owner of stdout. This means that we can do things like close the
|
// the owner of stdout. This means that we can do things like close the
|
||||||
// file descriptor when we're done and set the "binary" flag globally.
|
// file descriptor when we're done and set the "binary" flag globally.
|
||||||
if (Filename == "-") {
|
if (Filename == "-") {
|
||||||
EC = std::error_code();
|
FD = STDOUT_FILENO;
|
||||||
// If user requested binary then put stdout into binary mode if
|
// If user requested binary then put stdout into binary mode if
|
||||||
// possible.
|
// possible.
|
||||||
if (!(Flags & sys::fs::F_Text))
|
if (!(Flags & sys::fs::F_Text))
|
||||||
sys::ChangeStdoutToBinary();
|
sys::ChangeStdoutToBinary();
|
||||||
return STDOUT_FILENO;
|
// Close stdout when we're done, to detect any output errors.
|
||||||
|
ShouldClose = true;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FD;
|
|
||||||
EC = sys::fs::openFileForWrite(Filename, FD, Flags);
|
EC = sys::fs::openFileForWrite(Filename, FD, Flags);
|
||||||
if (EC)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
return FD;
|
if (EC) {
|
||||||
|
ShouldClose = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ok, we successfully opened the file, so it'll need to be closed.
|
||||||
|
ShouldClose = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
raw_fd_ostream::raw_fd_ostream(StringRef Filename, std::error_code &EC,
|
|
||||||
sys::fs::OpenFlags Flags)
|
|
||||||
: raw_fd_ostream(getFD(Filename, EC, Flags), true) {}
|
|
||||||
|
|
||||||
/// FD is the file descriptor that this writes to. If ShouldClose is true, this
|
/// FD is the file descriptor that this writes to. If ShouldClose is true, this
|
||||||
/// closes the file when the stream is destroyed.
|
/// closes the file when the stream is destroyed.
|
||||||
raw_fd_ostream::raw_fd_ostream(int fd, bool shouldClose, bool unbuffered)
|
raw_fd_ostream::raw_fd_ostream(int fd, bool shouldClose, bool unbuffered)
|
||||||
: raw_ostream(unbuffered), FD(fd),
|
: raw_ostream(unbuffered), FD(fd), ShouldClose(shouldClose), Error(false),
|
||||||
ShouldClose(shouldClose), Error(false), UseAtomicWrites(false) {
|
UseAtomicWrites(false) {
|
||||||
if (FD < 0 ) {
|
#ifdef O_BINARY
|
||||||
ShouldClose = false;
|
// Setting STDOUT to binary mode is necessary in Win32
|
||||||
return;
|
// to avoid undesirable linefeed conversion.
|
||||||
}
|
// Don't touch STDERR, or w*printf() (in assert()) would barf wide chars.
|
||||||
|
if (fd == STDOUT_FILENO)
|
||||||
|
setmode(fd, O_BINARY);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Get the starting position.
|
// Get the starting position.
|
||||||
off_t loc = ::lseek(FD, 0, SEEK_CUR);
|
off_t loc = ::lseek(FD, 0, SEEK_CUR);
|
||||||
|
Loading…
Reference in New Issue
Block a user