[llvm-commits] [llvm] r71998 - /llvm/trunk/lib/Support/MemoryBuffer.cpp
Eli Friedman
eli.friedman at gmail.com
Mon May 18 01:44:07 PDT 2009
Author: efriedma
Date: Mon May 18 03:44:04 2009
New Revision: 71998
URL: http://llvm.org/viewvc/llvm-project?rev=71998&view=rev
Log:
Tweak MemoryBuffer::getSTDIN so that it returns after the first EOF.
It doesn't matter for piped input, but it's annoying when typing at the
console.
Modified:
llvm/trunk/lib/Support/MemoryBuffer.cpp
Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=71998&r1=71997&r2=71998&view=diff
==============================================================================
--- llvm/trunk/lib/Support/MemoryBuffer.cpp (original)
+++ llvm/trunk/lib/Support/MemoryBuffer.cpp Mon May 18 03:44:04 2009
@@ -258,13 +258,16 @@
MemoryBuffer *MemoryBuffer::getSTDIN() {
char Buffer[4096*4];
-
+
std::vector<char> FileData;
-
+
// Read in all of the data from stdin, we cannot mmap stdin.
sys::Program::ChangeStdinToBinary();
- while (size_t ReadBytes = fread(Buffer, sizeof(char), 4096*4, stdin))
+ size_t ReadBytes;
+ do {
+ ReadBytes = fread(Buffer, sizeof(char), sizeof(Buffer), stdin);
FileData.insert(FileData.end(), Buffer, Buffer+ReadBytes);
+ } while (ReadBytes == sizeof(Buffer));
FileData.push_back(0); // &FileData[Size] is invalid. So is &*FileData.end().
size_t Size = FileData.size();
More information about the llvm-commits
mailing list