Commit 6cf5465d by Benjamin Kosnik

[multiple changes]


2001-10-25  Benjamin Kosnik  <bkoz@redhat.com>

	libstdc++/4545
	* include/bits/ostream.tcc (ostream::operator<<(streambuf*)): Fix
	exceptions.
	* include/bits/istream.tcc (istream::operator>>(streambuf*): Make
	consistent, where possible.
	* include/bits/streambuf.tcc: Tweak.

2001-10-25  Brendan Kehoe  <brendan@zen.org>

	libstdc++/4536
	* bits/ostream.tcc (seekp): Scope use as ios_base::failbit.
 	* bits/istream.tcc (seekg): Likewise.

From-SVN: r46528
parent 3b2a3c4c
2001-10-25 Benjamin Kosnik <bkoz@redhat.com> 2001-10-25 Benjamin Kosnik <bkoz@redhat.com>
libstdc++/4545
* include/bits/ostream.tcc (ostream::operator<<(streambuf*)): Fix
exceptions.
* include/bits/istream.tcc (istream::operator>>(streambuf*): Make
consistent, where possible.
* include/bits/streambuf.tcc: Tweak.
2001-10-25 Brendan Kehoe <brendan@zen.org>
libstdc++/4536
* bits/ostream.tcc (seekp): Scope use as ios_base::failbit.
* bits/istream.tcc (seekg): Likewise.
2001-10-25 Benjamin Kosnik <bkoz@redhat.com>
Peter Schmid <schmid@snake.iap.physik.tu-darmstadt.de> Peter Schmid <schmid@snake.iap.physik.tu-darmstadt.de>
Ulrich Weigand <Ulrich.Weigand@de.ibm.com> Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
......
...@@ -454,13 +454,29 @@ namespace std ...@@ -454,13 +454,29 @@ namespace std
basic_istream<_CharT, _Traits>:: basic_istream<_CharT, _Traits>::
operator>>(__streambuf_type* __sbout) operator>>(__streambuf_type* __sbout)
{ {
sentry __cerb(*this, false);
if (__cerb)
{
try
{
streamsize __xtrct = 0; streamsize __xtrct = 0;
if (__sbout)
{
__streambuf_type* __sbin = this->rdbuf(); __streambuf_type* __sbin = this->rdbuf();
sentry __cerb(*this, false);
if (__sbout && __cerb)
__xtrct = __copy_streambufs(*this, __sbin, __sbout); __xtrct = __copy_streambufs(*this, __sbin, __sbout);
}
if (!__sbout || !__xtrct) if (!__sbout || !__xtrct)
this->setstate(ios_base::failbit); this->setstate(ios_base::failbit);
}
catch(exception& __fail)
{
// 27.6.2.5.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
this->setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
}
return *this; return *this;
} }
...@@ -963,7 +979,7 @@ namespace std ...@@ -963,7 +979,7 @@ namespace std
// 129. Need error indication from seekp() and seekg() // 129. Need error indication from seekp() and seekg()
if (__err == pos_type(off_type(-1))) if (__err == pos_type(off_type(-1)))
this->setstate(failbit); this->setstate(ios_base::failbit);
#endif #endif
} }
catch(exception& __fail) catch(exception& __fail)
...@@ -996,7 +1012,7 @@ namespace std ...@@ -996,7 +1012,7 @@ namespace std
// 129. Need error indication from seekp() and seekg() // 129. Need error indication from seekp() and seekg()
if (__err == pos_type(off_type(-1))) if (__err == pos_type(off_type(-1)))
this->setstate(failbit); this->setstate(ios_base::failbit);
#endif #endif
} }
catch(exception& __fail) catch(exception& __fail)
......
...@@ -111,6 +111,38 @@ namespace std ...@@ -111,6 +111,38 @@ namespace std
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::operator<<(__streambuf_type* __sbin)
{
sentry __cerb(*this);
if (__cerb)
{
try
{
streamsize __xtrct = 0;
if (__sbin)
{
__streambuf_type* __sbout = this->rdbuf();
__xtrct = __copy_streambufs(*this, __sbin, __sbout);
}
else
this->setstate(ios_base::badbit);
if (!__xtrct)
this->setstate(ios_base::failbit);
}
catch(exception& __fail)
{
// 27.6.2.5.1 Common requirements.
// Turn this on without causing an ios::failure to be thrown.
this->setstate(ios_base::badbit);
if ((this->exceptions() & ios_base::badbit) != 0)
__throw_exception_again;
}
}
return *this;
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::operator<<(bool __n) basic_ostream<_CharT, _Traits>::operator<<(bool __n)
{ {
sentry __cerb(*this); sentry __cerb(*this);
...@@ -338,20 +370,6 @@ namespace std ...@@ -338,20 +370,6 @@ namespace std
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::operator<<(__streambuf_type* __sbin)
{
streamsize __xtrct = 0;
__streambuf_type* __sbout = this->rdbuf();
sentry __cerb(*this);
if (__sbin && __cerb)
__xtrct = __copy_streambufs(*this, __sbin, __sbout);
if (!__sbin || !__xtrct)
this->setstate(ios_base::failbit);
return *this;
}
template<typename _CharT, typename _Traits>
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::put(char_type __c) basic_ostream<_CharT, _Traits>::put(char_type __c)
{ {
sentry __cerb(*this); sentry __cerb(*this);
...@@ -418,7 +436,7 @@ namespace std ...@@ -418,7 +436,7 @@ namespace std
// 129. Need error indication from seekp() and seekg() // 129. Need error indication from seekp() and seekg()
if (__err == pos_type(off_type(-1))) if (__err == pos_type(off_type(-1)))
this->setstate(failbit); this->setstate(ios_base::failbit);
#endif #endif
} }
return *this; return *this;
...@@ -440,7 +458,7 @@ namespace std ...@@ -440,7 +458,7 @@ namespace std
// 129. Need error indication from seekp() and seekg() // 129. Need error indication from seekp() and seekg()
if (__err == pos_type(off_type(-1))) if (__err == pos_type(off_type(-1)))
this->setstate(failbit); this->setstate(ios_base::failbit);
} }
#endif #endif
return *this; return *this;
...@@ -753,4 +771,3 @@ namespace std ...@@ -753,4 +771,3 @@ namespace std
// Local Variables: // Local Variables:
// mode:C++ // mode:C++
// End: // End:
...@@ -198,7 +198,8 @@ namespace std { ...@@ -198,7 +198,8 @@ namespace std {
streamsize __bufsize = __sbin->in_avail(); streamsize __bufsize = __sbin->in_avail();
streamsize __xtrct; streamsize __xtrct;
bool __testput = __sbout->_M_mode & ios_base::out; bool __testput = __sbout->_M_mode & ios_base::out;
try { try
{
while (__testput && __bufsize != -1) while (__testput && __bufsize != -1)
{ {
__xtrct = __sbout->sputn(__sbin->gptr(), __bufsize); __xtrct = __sbout->sputn(__sbin->gptr(), __bufsize);
...@@ -214,7 +215,9 @@ namespace std { ...@@ -214,7 +215,9 @@ namespace std {
break; break;
} }
} }
catch(exception& __fail) { catch(exception& __fail)
{
__ios.setstate(ios_base::failbit);
if ((__ios.exceptions() & ios_base::failbit) != 0) if ((__ios.exceptions() & ios_base::failbit) != 0)
__throw_exception_again; __throw_exception_again;
} }
...@@ -223,4 +226,3 @@ namespace std { ...@@ -223,4 +226,3 @@ namespace std {
} // namespace std } // namespace std
#endif // _CPP_BITS_STREAMBUF_TCC #endif // _CPP_BITS_STREAMBUF_TCC
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment