From 73c85c7725981585acf752a3a32aca6f50b304a0 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Thu, 1 Nov 2012 17:32:07 +0000 Subject: [PATCH] peek should set eofbit if sgetc() returns eof. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@167238 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/istream | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/istream b/include/istream index 72b2004d..7b481864 100644 --- a/include/istream +++ b/include/istream @@ -1189,7 +1189,11 @@ basic_istream<_CharT, _Traits>::peek() #endif // _LIBCPP_NO_EXCEPTIONS sentry __sen(*this, true); if (__sen) + { __r = this->rdbuf()->sgetc(); + if (traits_type::eq_int_type(__r, traits_type::eof())) + this->setstate(ios_base::eofbit); + } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...)