Commit ac5b7972 by Paolo Carlini Committed by Paolo Carlini

streambuf.tcc (__copy_streambufs): Don't use in_avail(), simplify.

2003-04-26  Paolo Carlini  <pcarlini@unitus.it>

	* include/bits/streambuf.tcc (__copy_streambufs): Don't
	use in_avail(), simplify.

2003-04-26  Paolo Carlini  <pcarlini@unitus.it>

	* include/std/std_sstream.h (setbuf): don't set _M_buf_size,
	in basic_stringbuf it's unused.

	* include/std/std_sstream.h (underflow): consistently use
	_M_in_cur, not gptr().

From-SVN: r66100
parent 04ab0b3e
2003-04-26 Paolo Carlini <pcarlini@unitus.it>
* include/bits/streambuf.tcc (__copy_streambufs): Don't
use in_avail(), simplify.
2003-04-26 Paolo Carlini <pcarlini@unitus.it>
* include/std/std_sstream.h (setbuf): don't set _M_buf_size,
in basic_stringbuf it's unused.
* include/std/std_sstream.h (underflow): consistently use
_M_in_cur, not gptr().
2003-04-25 Ranjit Mathew <rmathew@hotmail.com> 2003-04-25 Ranjit Mathew <rmathew@hotmail.com>
Phil Edwards <pme@gcc.gnu.org> Phil Edwards <pme@gcc.gnu.org>
......
...@@ -188,30 +188,29 @@ namespace std ...@@ -188,30 +188,29 @@ namespace std
typedef typename _Traits::off_type off_type; typedef typename _Traits::off_type off_type;
streamsize __ret = 0; streamsize __ret = 0;
streamsize __in_avail = __sbin->in_avail();
streamsize __xtrct;
const off_type __buf_size = const off_type __buf_size =
__sbin->_M_buf_size > 0 ? __sbin->_M_buf_size : 1; __sbin->_M_buf_size > 0 ? __sbin->_M_buf_size : 1;
try try
{ {
while (__in_avail != -1) for (;;)
{ {
if (__in_avail != 0 && __sbin->_M_in_cur streamsize __xtrct;
&& __sbin->_M_in_cur + __in_avail <= __sbin->_M_in_end) const off_type __avail = __sbin->_M_in_end
- __sbin->_M_in_cur;
if (__avail)
{ {
__xtrct = __sbout->sputn(__sbin->_M_in_cur, __in_avail); __xtrct = __sbout->sputn(__sbin->_M_in_cur, __avail);
__ret += __xtrct; __ret += __xtrct;
__sbin->_M_in_cur_move(__xtrct); __sbin->_M_in_cur_move(__xtrct);
if (__xtrct != __in_avail) if (__xtrct != __avail)
break; break;
} }
else else
{ {
streamsize __charsread; streamsize __charsread;
const streamsize __size = const off_type __size = std::min(__buf_size,
std::min(__buf_size, off_type(__sbout->_M_out_end - off_type(__sbout->_M_out_end
__sbout->_M_out_cur)); - __sbout->_M_out_cur));
if (__size > 1) if (__size > 1)
{ {
_CharT* __buf = _CharT* __buf =
...@@ -242,7 +241,6 @@ namespace std ...@@ -242,7 +241,6 @@ namespace std
} }
if (_Traits::eq_int_type(__sbin->sgetc(), _Traits::eof())) if (_Traits::eq_int_type(__sbin->sgetc(), _Traits::eof()))
break; break;
__in_avail = __sbin->in_avail();
} }
} }
catch(exception& __fail) catch(exception& __fail)
......
...@@ -191,7 +191,7 @@ namespace std ...@@ -191,7 +191,7 @@ namespace std
underflow() underflow()
{ {
if (this->_M_in_cur < this->_M_in_end) if (this->_M_in_cur < this->_M_in_end)
return traits_type::to_int_type(*gptr()); return traits_type::to_int_type(*this->_M_in_cur);
else else
return traits_type::eof(); return traits_type::eof();
} }
...@@ -230,7 +230,6 @@ namespace std ...@@ -230,7 +230,6 @@ namespace std
// Step 2: Use the external array. // Step 2: Use the external array.
this->_M_buf = __s; this->_M_buf = __s;
this->_M_buf_size = __n;
_M_really_sync(__s, 0, 0); _M_really_sync(__s, 0, 0);
} }
return this; return this;
......
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