mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-05 12:31:33 +00:00
Make getSTDIN return null if the standard input is empty, as the header file
documentation implies and as its uses depend. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40939 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
53424ad141
commit
2372ccc111
@ -248,11 +248,13 @@ MemoryBuffer *MemoryBuffer::getSTDIN() {
|
||||
|
||||
// Read in all of the data from stdin, we cannot mmap stdin.
|
||||
sys::Program::ChangeStdinToBinary();
|
||||
while (size_t ReadBytes = fread(Buffer, 1, 4096*4, stdin))
|
||||
while (size_t ReadBytes = fread(Buffer, sizeof(char), 4096*4, stdin))
|
||||
FileData.insert(FileData.end(), Buffer, Buffer+ReadBytes);
|
||||
|
||||
|
||||
FileData.push_back(0); // &FileData[Size] is invalid. So is &*FileData.end().
|
||||
size_t Size = FileData.size();
|
||||
if (Size <= 1)
|
||||
return 0;
|
||||
MemoryBuffer *B = new STDINBufferFile();
|
||||
B->initCopyOf(&FileData[0], &FileData[Size-1]);
|
||||
return B;
|
||||
|
Loading…
Reference in New Issue
Block a user