mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-07 11:33:44 +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.
|
// Read in all of the data from stdin, we cannot mmap stdin.
|
||||||
sys::Program::ChangeStdinToBinary();
|
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.insert(FileData.end(), Buffer, Buffer+ReadBytes);
|
||||||
|
|
||||||
FileData.push_back(0); // &FileData[Size] is invalid. So is &*FileData.end().
|
FileData.push_back(0); // &FileData[Size] is invalid. So is &*FileData.end().
|
||||||
size_t Size = FileData.size();
|
size_t Size = FileData.size();
|
||||||
|
if (Size <= 1)
|
||||||
|
return 0;
|
||||||
MemoryBuffer *B = new STDINBufferFile();
|
MemoryBuffer *B = new STDINBufferFile();
|
||||||
B->initCopyOf(&FileData[0], &FileData[Size-1]);
|
B->initCopyOf(&FileData[0], &FileData[Size-1]);
|
||||||
return B;
|
return B;
|
||||||
|
Loading…
Reference in New Issue
Block a user