This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[Patch] streambuf.tcc: consistently size_t type, const-ify
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: libstdc++ at gcc dot gnu dot org
- Date: Thu, 01 May 2003 12:56:09 +0200
- Subject: [Patch] streambuf.tcc: consistently size_t type, const-ify
Hi,
at least for the short and medium term, seems to me the most
consistent and simple choice: trying to change everywhere to
ptrdiff_t leads to lots of trickeries (e.g., signed-unsigned
comparisons, casts (_M_pback_create)...)
Tested x86-linux. Ok?
Paolo.
/////////
2003-05-01 Paolo Carlini <pcarlini@unitus.it>
* include/bits/streambuf.tcc (basic_streambuf::xsgetn):
Const-ify some variables.
(basic_streambuf::xsputn): Likewise; change the type of some
variables to size_t.
(__copy_streambufs): Change some variables to size_t.
diff -prN libstdc++-v3-orig/include/bits/streambuf.tcc libstdc++-v3/include/bits/streambuf.tcc
*** libstdc++-v3-orig/include/bits/streambuf.tcc Wed Apr 30 14:26:32 2003
--- libstdc++-v3/include/bits/streambuf.tcc Thu May 1 12:23:29 2003
*************** namespace std
*** 114,124 ****
streamsize __ret = 0;
while (__ret < __n)
{
! size_t __buf_len = _M_in_end - _M_in_cur;
if (__buf_len > 0)
{
! size_t __remaining = __n - __ret;
! size_t __len = std::min(__buf_len, __remaining);
traits_type::copy(__s, _M_in_cur, __len);
__ret += __len;
__s += __len;
--- 114,124 ----
streamsize __ret = 0;
while (__ret < __n)
{
! const size_t __buf_len = _M_in_end - _M_in_cur;
if (__buf_len > 0)
{
! const size_t __remaining = __n - __ret;
! const size_t __len = std::min(__buf_len, __remaining);
traits_type::copy(__s, _M_in_cur, __len);
__ret += __len;
__s += __len;
*************** namespace std
*** 127,133 ****
if (__ret < __n)
{
! int_type __c = this->uflow();
if (!traits_type::eq_int_type(__c, traits_type::eof()))
{
traits_type::assign(*__s++, traits_type::to_char_type(__c));
--- 127,133 ----
if (__ret < __n)
{
! const int_type __c = this->uflow();
if (!traits_type::eq_int_type(__c, traits_type::eof()))
{
traits_type::assign(*__s++, traits_type::to_char_type(__c));
*************** namespace std
*** 148,158 ****
streamsize __ret = 0;
while (__ret < __n)
{
! off_type __buf_len = _M_out_end - _M_out_cur;
if (__buf_len > 0)
{
! off_type __remaining = __n - __ret;
! off_type __len = std::min(__buf_len, __remaining);
traits_type::copy(_M_out_cur, __s, __len);
__ret += __len;
__s += __len;
--- 148,158 ----
streamsize __ret = 0;
while (__ret < __n)
{
! const size_t __buf_len = _M_out_end - _M_out_cur;
if (__buf_len > 0)
{
! const size_t __remaining = __n - __ret;
! const size_t __len = std::min(__buf_len, __remaining);
traits_type::copy(_M_out_cur, __s, __len);
__ret += __len;
__s += __len;
*************** namespace std
*** 161,167 ****
if (__ret < __n)
{
! int_type __c = this->overflow(traits_type::to_int_type(*__s));
if (!traits_type::eq_int_type(__c, traits_type::eof()))
{
++__ret;
--- 161,167 ----
if (__ret < __n)
{
! const int_type __c = this->overflow(traits_type::to_int_type(*__s));
if (!traits_type::eq_int_type(__c, traits_type::eof()))
{
++__ret;
*************** namespace std
*** 185,191 ****
basic_streambuf<_CharT, _Traits>* __sbout)
{
typedef typename _Traits::int_type int_type;
- typedef typename _Traits::off_type off_type;
streamsize __ret = 0;
try
--- 185,190 ----
*************** namespace std
*** 193,200 ****
for (;;)
{
streamsize __xtrct;
! const off_type __avail = __sbin->_M_in_end
! - __sbin->_M_in_cur;
if (__avail)
{
__xtrct = __sbout->sputn(__sbin->_M_in_cur, __avail);
--- 192,199 ----
for (;;)
{
streamsize __xtrct;
! const size_t __avail = __sbin->_M_in_end
! - __sbin->_M_in_cur;
if (__avail)
{
__xtrct = __sbout->sputn(__sbin->_M_in_cur, __avail);
*************** namespace std
*** 206,213 ****
else
{
streamsize __charsread;
! const off_type __size = __sbout->_M_out_end
! - __sbout->_M_out_cur;
if (__size)
{
_CharT* __buf =
--- 205,212 ----
else
{
streamsize __charsread;
! const size_t __size = __sbout->_M_out_end
! - __sbout->_M_out_cur;
if (__size)
{
_CharT* __buf =