diff --git a/fdistream.cpp b/fdistream.cpp index 33c85f9..6520a2e 100644 --- a/fdistream.cpp +++ b/fdistream.cpp @@ -16,20 +16,12 @@ using namespace sc::io; -std::streambuf::int_type fdinbuf::uflow() { - if (_ch == EOF) { - return underflow(); - } - return _ch; -} - std::streambuf::int_type fdinbuf::underflow() { - char c; - int num = read(_fd, &c, 1); + int num = read(_fd, &_ch, 1); if (num <= 0) { - _ch = EOF; + return EOF; } - _ch = c; + setg(&_ch, &_ch, &_ch + 1); return _ch; } diff --git a/libscio.hpp b/libscio.hpp index 9119401..d221aad 100644 --- a/libscio.hpp +++ b/libscio.hpp @@ -44,9 +44,8 @@ namespace sc { protected: int _fd; - int_type _ch {EOF}; + char _ch {}; - int_type uflow() override; int_type underflow() override; std::streamsize xsgetn(char* s, std::streamsize n) override; };