aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2004-12-21 07:51:33 +0000
committerReid Spencer <rspencer@reidspencer.com>2004-12-21 07:51:33 +0000
commit0a834720db07360e9dbf5624e0e3594910430391 (patch)
tree214f154f1e3c87c541826af7e080efcbe621f8de /lib
parentef371581381f8c4e21c611d6361f6095529b7f64 (diff)
For PR351:
Remove unix specific code (use of errno and read) from the reader. Thanks to Jeff Cohen for pointing this out. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19081 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Bytecode/Reader/ReaderWrappers.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/Bytecode/Reader/ReaderWrappers.cpp b/lib/Bytecode/Reader/ReaderWrappers.cpp
index c799567a4a..9b8491327f 100644
--- a/lib/Bytecode/Reader/ReaderWrappers.cpp
+++ b/lib/Bytecode/Reader/ReaderWrappers.cpp
@@ -20,6 +20,7 @@
#include "llvm/ADT/StringExtras.h"
#include "llvm/System/MappedFile.h"
#include <cerrno>
+#include <iostream>
using namespace llvm;
//===----------------------------------------------------------------------===//
@@ -41,10 +42,6 @@ namespace {
};
}
-static std::string ErrnoMessage (int savedErrNum, std::string descr) {
- return ::strerror(savedErrNum) + std::string(", while trying to ") + descr;
-}
-
BytecodeFileReader::BytecodeFileReader(const std::string &Filename,
llvm::BytecodeHandler* H )
: BytecodeReader(H)
@@ -133,14 +130,14 @@ namespace {
BytecodeStdinReader::BytecodeStdinReader( BytecodeHandler* H )
: BytecodeReader(H)
{
- int BlockSize;
- unsigned char Buffer[4096*4];
+ char Buffer[4096*4];
// Read in all of the data from stdin, we cannot mmap stdin...
- while ((BlockSize = ::read(0 /*stdin*/, Buffer, 4096*4))) {
- if (BlockSize == -1)
- throw ErrnoMessage(errno, "read from standard input");
-
+ while (std::cin.good()) {
+ std::cin.read(Buffer, 4096*4);
+ int BlockSize = std::cin.gcount();
+ if (0 >= BlockSize)
+ break;
FileData.insert(FileData.end(), Buffer, Buffer+BlockSize);
}