peek should set eofbit if sgetc() returns eof.
authorHoward Hinnant <hhinnant@apple.com>
Thu, 1 Nov 2012 17:32:07 +0000 (17:32 +0000)
committerHoward Hinnant <hhinnant@apple.com>
Thu, 1 Nov 2012 17:32:07 +0000 (17:32 +0000)
llvm-svn: 167238

libcxx/include/istream

index 72b2004..7b48186 100644 (file)
@@ -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 (...)