mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-13 23:25:06 +00:00
Don't allow pwrite to resize a stream.
The current implementations could exhibit some behavior differences: raw_fd_ostream: Whatever the underlying fd does with seek+write. In a normal file, the write position would be back to the old offset. raw_svector_ostream: The write position is always the end of the stream, so after pwrite the write position would be the new end. This matches what OS_X (all BSD?) do with a pwrite in a O_APPEND fd. Given that we don't need that feature and don't use O_APPEND a lot in LLVM, just disallow it. I am open to suggestions on renaming pwrite to something else, but this fixes the issue for now. Thanks to Yaron Keren for reporting it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235303 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -16,10 +16,18 @@ using namespace llvm;
|
||||
namespace {
|
||||
|
||||
TEST(raw_pwrite_ostreamTest, TestSVector) {
|
||||
SmallString<64> Buffer;
|
||||
SmallVector<char, 0> Buffer;
|
||||
raw_svector_ostream OS(Buffer);
|
||||
OS << "abcd";
|
||||
StringRef Test = "test";
|
||||
OS.pwrite(Test.data(), Test.size(), 0);
|
||||
EXPECT_EQ(Test, OS.str());
|
||||
|
||||
#ifdef GTEST_HAS_DEATH_TEST
|
||||
#ifndef NDEBUG
|
||||
EXPECT_DEATH(OS.pwrite("12345", 5, 0),
|
||||
"We don't support extending the stream");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user