diff options
Diffstat (limited to 'include/istream')
-rw-r--r-- | include/istream | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/include/istream b/include/istream index 0bcc7eeaf639..ee694003a3d8 100644 --- a/include/istream +++ b/include/istream @@ -1251,18 +1251,35 @@ streamsize basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize __n) { __gc_ = 0; - streamsize __c = this->rdbuf()->in_avail(); - switch (__c) - { - case -1: - this->setstate(ios_base::eofbit); - break; - case 0: - break; - default: - read(__s, _VSTD::min(__c, __n)); - break; +#ifndef _LIBCPP_NO_EXCEPTIONS + try + { +#endif // _LIBCPP_NO_EXCEPTIONS + sentry __sen(*this, true); + if (__sen) + { + streamsize __c = this->rdbuf()->in_avail(); + switch (__c) + { + case -1: + this->setstate(ios_base::eofbit); + break; + case 0: + break; + default: + read(__s, _VSTD::min(__c, __n)); + break; + } + } + else + this->setstate(ios_base::failbit); +#ifndef _LIBCPP_NO_EXCEPTIONS } + catch (...) + { + this->__set_badbit_and_consider_rethrow(); + } +#endif // _LIBCPP_NO_EXCEPTIONS return __gc_; } |