This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[v3] streambuf/filebuf members
- From: Benjamin Kosnik <bkoz at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 28 Apr 2003 00:51:59 -0400 (EDT)
- Subject: [v3] streambuf/filebuf members
Moves member functions to _M_verb_description, like the rest of the library.
tested x86/linux
2003-04-27 Benjamin Kosnik <bkoz at redhat dot com>
* include/std/std_fstream.h (basic_filebuf): _M_pback_destroy to
_M_destroy_pback. _M_pback_create to
_M_create_pback. _M_underflow_common to
_M_underflow. _M_really_overflow to _M_overflow.
* include/bits/fstream.tcc: Same.
* src/fstream.cc: Same.
* include/std/std_streambuf.h (basic_streambuf): _M_in_cur_move to
_M_move_in_cur. _M_out_cur_move to _M_move_out_cur.
* include/bits/streambuf.tcc: Same.
* include/bits/fstream.tcc: Same.
* include/bits/sstream.tcc: Same.
Index: include/bits/fstream.tcc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/fstream.tcc,v
retrieving revision 1.67
diff -c -p -r1.67 fstream.tcc
*** include/bits/fstream.tcc 26 Apr 2003 08:31:57 -0000 1.67
--- include/bits/fstream.tcc 28 Apr 2003 04:36:12 -0000
*************** namespace std
*** 126,133 ****
const bool __testput = this->_M_out_beg < this->_M_out_lim;
if (__testput
! && traits_type::eq_int_type(_M_really_overflow(__eof),
! __eof))
__testfail = true;
#if 0
--- 126,132 ----
const bool __testput = this->_M_out_beg < this->_M_out_lim;
if (__testput
! && traits_type::eq_int_type(_M_overflow(__eof), __eof))
__testfail = true;
#if 0
*************** namespace std
*** 135,141 ****
if (_M_last_overflowed)
{
_M_output_unshift();
! _M_really_overflow(__eof);
}
#endif
}
--- 134,140 ----
if (_M_last_overflowed)
{
_M_output_unshift();
! _M_overflow(__eof);
}
#endif
}
*************** namespace std
*** 147,153 ****
// NB: Do this here so that re-opened filebufs will be cool...
this->_M_mode = ios_base::openmode(0);
_M_destroy_internal_buffer();
! _M_pback_destroy();
if (!_M_file.close())
__testfail = true;
--- 146,152 ----
// NB: Do this here so that re-opened filebufs will be cool...
this->_M_mode = ios_base::openmode(0);
_M_destroy_internal_buffer();
! _M_destroy_pback();
if (!_M_file.close())
__testfail = true;
*************** namespace std
*** 214,220 ****
__ret = traits_type::not_eof(__i);
else
{
! _M_pback_create();
*this->_M_in_cur = __c;
__ret = __i;
}
--- 213,219 ----
__ret = traits_type::not_eof(__i);
else
{
! _M_create_pback();
*this->_M_in_cur = __c;
__ret = __i;
}
*************** namespace std
*** 233,239 ****
{
if (!traits_type::eq(__c, *this->_M_in_cur))
{
! _M_pback_create();
*this->_M_in_cur = __c;
}
__ret = __i;
--- 232,238 ----
{
if (!traits_type::eq(__c, *this->_M_in_cur))
{
! _M_create_pback();
*this->_M_in_cur = __c;
}
__ret = __i;
*************** namespace std
*** 263,276 ****
else if (__testput)
{
*this->_M_out_cur = traits_type::to_char_type(__c);
! _M_out_cur_move(1);
__ret = traits_type::not_eof(__c);
}
else
! __ret = this->_M_really_overflow(__c);
}
! _M_last_overflowed = false; // Set in _M_really_overflow, below.
return __ret;
}
--- 262,275 ----
else if (__testput)
{
*this->_M_out_cur = traits_type::to_char_type(__c);
! _M_move_out_cur(1);
__ret = traits_type::not_eof(__c);
}
else
! __ret = this->_M_overflow(__c);
}
! _M_last_overflowed = false; // Set in _M_overflow, below.
return __ret;
}
*************** namespace std
*** 344,350 ****
template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::int_type
basic_filebuf<_CharT, _Traits>::
! _M_really_overflow(int_type __c)
{
int_type __ret = traits_type::eof();
const bool __testput = this->_M_out_beg < this->_M_out_lim;
--- 343,349 ----
template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::int_type
basic_filebuf<_CharT, _Traits>::
! _M_overflow(int_type __c)
{
int_type __ret = traits_type::eof();
const bool __testput = this->_M_out_beg < this->_M_out_lim;
*************** namespace std
*** 449,455 ****
if (this->is_open() && !__testfail && (__testin || __testout))
{
// Ditch any pback buffers to avoid confusion.
! _M_pback_destroy();
if (__way != ios_base::cur || __off != 0)
{
--- 448,454 ----
if (this->is_open() && !__testfail && (__testin || __testout))
{
// Ditch any pback buffers to avoid confusion.
! _M_destroy_pback();
if (__way != ios_base::cur || __off != 0)
{
Index: include/bits/sstream.tcc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/sstream.tcc,v
retrieving revision 1.24
diff -c -p -r1.24 sstream.tcc
*** include/bits/sstream.tcc 21 Apr 2003 21:44:43 -0000 1.24
--- include/bits/sstream.tcc 28 Apr 2003 04:36:13 -0000
*************** namespace std
*** 173,179 ****
if ((__testout || __testboth)
&& __newoffo + __off >= 0 && __endo - __beg >= __newoffo + __off)
{
! _M_out_cur_move(__newoffo + __off - (this->_M_out_cur - __beg));
__ret = pos_type(__newoffo);
}
}
--- 173,179 ----
if ((__testout || __testboth)
&& __newoffo + __off >= 0 && __endo - __beg >= __newoffo + __off)
{
! _M_move_out_cur(__newoffo + __off - (this->_M_out_cur - __beg));
__ret = pos_type(__newoffo);
}
}
*************** namespace std
*** 217,223 ****
if (__testposi)
this->_M_in_cur = this->_M_in_beg + __pos;
if (__testposo)
! _M_out_cur_move((__pos) - (this->_M_out_cur - __beg));
__ret = pos_type(off_type(__pos));
}
}
--- 217,223 ----
if (__testposi)
this->_M_in_cur = this->_M_in_beg + __pos;
if (__testposo)
! _M_move_out_cur((__pos) - (this->_M_out_cur - __beg));
__ret = pos_type(off_type(__pos));
}
}
Index: include/bits/streambuf.tcc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/streambuf.tcc,v
retrieving revision 1.33
diff -c -p -r1.33 streambuf.tcc
*** include/bits/streambuf.tcc 26 Apr 2003 08:13:35 -0000 1.33
--- include/bits/streambuf.tcc 28 Apr 2003 04:36:14 -0000
*************** namespace std
*** 48,54 ****
if (_M_in_cur < _M_in_end)
{
char_type __c = *this->_M_in_cur;
! _M_in_cur_move(1);
__ret = traits_type::to_int_type(__c);
}
else
--- 48,54 ----
if (_M_in_cur < _M_in_end)
{
char_type __c = *this->_M_in_cur;
! _M_move_in_cur(1);
__ret = traits_type::to_int_type(__c);
}
else
*************** namespace std
*** 67,73 ****
__ret = this->pbackfail(traits_type::to_int_type(__c));
else
{
! _M_in_cur_move(-1);
__ret = traits_type::to_int_type(*this->_M_in_cur);
}
return __ret;
--- 67,73 ----
__ret = this->pbackfail(traits_type::to_int_type(__c));
else
{
! _M_move_in_cur(-1);
__ret = traits_type::to_int_type(*this->_M_in_cur);
}
return __ret;
*************** namespace std
*** 81,87 ****
int_type __ret;
if (_M_in_beg < _M_in_cur)
{
! _M_in_cur_move(-1);
__ret = traits_type::to_int_type(*_M_in_cur);
}
else
--- 81,87 ----
int_type __ret;
if (_M_in_beg < _M_in_cur)
{
! _M_move_in_cur(-1);
__ret = traits_type::to_int_type(*_M_in_cur);
}
else
*************** namespace std
*** 98,104 ****
if (_M_out_cur < _M_out_end)
{
*_M_out_cur = __c;
! _M_out_cur_move(1);
__ret = traits_type::to_int_type(__c);
}
else
--- 98,104 ----
if (_M_out_cur < _M_out_end)
{
*_M_out_cur = __c;
! _M_move_out_cur(1);
__ret = traits_type::to_int_type(__c);
}
else
*************** namespace std
*** 122,128 ****
traits_type::copy(__s, _M_in_cur, __len);
__ret += __len;
__s += __len;
! _M_in_cur_move(__len);
}
if (__ret < __n)
--- 122,128 ----
traits_type::copy(__s, _M_in_cur, __len);
__ret += __len;
__s += __len;
! _M_move_in_cur(__len);
}
if (__ret < __n)
*************** namespace std
*** 156,162 ****
traits_type::copy(_M_out_cur, __s, __len);
__ret += __len;
__s += __len;
! _M_out_cur_move(__len);
}
if (__ret < __n)
--- 156,162 ----
traits_type::copy(_M_out_cur, __s, __len);
__ret += __len;
__s += __len;
! _M_move_out_cur(__len);
}
if (__ret < __n)
*************** namespace std
*** 201,207 ****
{
__xtrct = __sbout->sputn(__sbin->_M_in_cur, __avail);
__ret += __xtrct;
! __sbin->_M_in_cur_move(__xtrct);
if (__xtrct != __avail)
break;
}
--- 201,207 ----
{
__xtrct = __sbout->sputn(__sbin->_M_in_cur, __avail);
__ret += __xtrct;
! __sbin->_M_move_in_cur(__xtrct);
if (__xtrct != __avail)
break;
}
Index: include/std/std_fstream.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/std/std_fstream.h,v
retrieving revision 1.30
diff -c -p -r1.30 std_fstream.h
*** include/std/std_fstream.h 26 Apr 2003 00:23:17 -0000 1.30
--- include/std/std_fstream.h 28 Apr 2003 04:36:14 -0000
*************** namespace std
*** 152,158 ****
// Assumptions:
// _M_in_cur has already been moved back
void
! _M_pback_create()
{
if (!_M_pback_init)
{
--- 152,158 ----
// Assumptions:
// _M_in_cur has already been moved back
void
! _M_create_pback()
{
if (!_M_pback_init)
{
*************** namespace std
*** 170,176 ****
// Assumptions:
// The pback buffer has only moved forward.
void
! _M_pback_destroy() throw()
{
if (_M_pback_init)
{
--- 170,176 ----
// Assumptions:
// The pback buffer has only moved forward.
void
! _M_destroy_pback() throw()
{
if (_M_pback_init)
{
*************** namespace std
*** 288,294 ****
* @endif
*/
int_type
! _M_underflow_common(bool __bump);
// [documentation is inherited]
virtual int_type
--- 288,294 ----
* @endif
*/
int_type
! _M_underflow(bool __bump);
// [documentation is inherited]
virtual int_type
*************** namespace std
*** 303,309 ****
pbackfail(int_type __c = _Traits::eof());
// NB: For what the standard expects of the overflow function,
! // see _M_really_overflow(), below. Because basic_streambuf's
// sputc/sputn call overflow directly, and the complications of
// this implementation's setting of the initial pointers all
// equal to _M_buf when initializing, it seems essential to have
--- 303,309 ----
pbackfail(int_type __c = _Traits::eof());
// NB: For what the standard expects of the overflow function,
! // see _M_overflow(), below. Because basic_streambuf's
// sputc/sputn call overflow directly, and the complications of
// this implementation's setting of the initial pointers all
// equal to _M_buf when initializing, it seems essential to have
*************** namespace std
*** 328,334 ****
* @endif
*/
int_type
! _M_really_overflow(int_type __c = _Traits::eof());
// Convert internal byte sequence to external, char-based
// sequence via codecvt.
--- 328,334 ----
* @endif
*/
int_type
! _M_overflow(int_type __c = _Traits::eof());
// Convert internal byte sequence to external, char-based
// sequence via codecvt.
*************** namespace std
*** 382,389 ****
off_type __off = this->_M_out_cur - this->_M_out_lim;
// _M_file.sync() will be called within
! if (traits_type::eq_int_type(_M_really_overflow(),
! traits_type::eof()))
__ret = -1;
else if (__off)
_M_file.seekoff(__off, ios_base::cur, __sync);
--- 382,388 ----
off_type __off = this->_M_out_cur - this->_M_out_lim;
// _M_file.sync() will be called within
! if (traits_type::eq_int_type(_M_overflow(), traits_type::eof()))
__ret = -1;
else if (__off)
_M_file.seekoff(__off, ios_base::cur, __sync);
*************** namespace std
*** 414,420 ****
++__s;
++this->_M_in_cur;
}
! _M_pback_destroy();
}
if (__ret < __n)
__ret += __streambuf_type::xsgetn(__s, __n - __ret);
--- 413,419 ----
++__s;
++this->_M_in_cur;
}
! _M_destroy_pback();
}
if (__ret < __n)
__ret += __streambuf_type::xsgetn(__s, __n - __ret);
*************** namespace std
*** 425,431 ****
virtual streamsize
xsputn(const char_type* __s, streamsize __n)
{
! _M_pback_destroy();
return __streambuf_type::xsputn(__s, __n);
}
--- 424,430 ----
virtual streamsize
xsputn(const char_type* __s, streamsize __n)
{
! _M_destroy_pback();
return __streambuf_type::xsputn(__s, __n);
}
*************** namespace std
*** 501,507 ****
// Explicit specialization declarations, defined in src/fstream.cc.
template<>
basic_filebuf<char>::int_type
! basic_filebuf<char>::_M_underflow_common(bool __bump);
template<>
basic_filebuf<char>::int_type
--- 500,506 ----
// Explicit specialization declarations, defined in src/fstream.cc.
template<>
basic_filebuf<char>::int_type
! basic_filebuf<char>::_M_underflow(bool __bump);
template<>
basic_filebuf<char>::int_type
*************** namespace std
*** 514,520 ****
#ifdef _GLIBCPP_USE_WCHAR_T
template<>
basic_filebuf<wchar_t>::int_type
! basic_filebuf<wchar_t>::_M_underflow_common(bool __bump);
template<>
basic_filebuf<wchar_t>::int_type
--- 513,519 ----
#ifdef _GLIBCPP_USE_WCHAR_T
template<>
basic_filebuf<wchar_t>::int_type
! basic_filebuf<wchar_t>::_M_underflow(bool __bump);
template<>
basic_filebuf<wchar_t>::int_type
Index: include/std/std_streambuf.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/std/std_streambuf.h,v
retrieving revision 1.24
diff -c -p -r1.24 std_streambuf.h
*** include/std/std_streambuf.h 22 Apr 2003 17:32:25 -0000 1.24
--- include/std/std_streambuf.h 28 Apr 2003 04:36:15 -0000
*************** namespace std
*** 239,245 ****
// Correctly sets the _M_in_cur pointer, and bumps the
// _M_out_cur pointer as well if necessary.
void
! _M_in_cur_move(off_type __n) // argument needs to be +-
{
const bool __testout = _M_out_cur;
_M_in_cur += __n;
--- 239,245 ----
// Correctly sets the _M_in_cur pointer, and bumps the
// _M_out_cur pointer as well if necessary.
void
! _M_move_in_cur(off_type __n) // argument needs to be +-
{
const bool __testout = _M_out_cur;
_M_in_cur += __n;
*************** namespace std
*** 256,262 ****
// the same range:
// _M_buf <= _M_*_ <= _M_out_end
void
! _M_out_cur_move(off_type __n) // argument needs to be +-
{
const bool __testin = _M_in_cur;
--- 256,262 ----
// the same range:
// _M_buf <= _M_*_ <= _M_out_end
void
! _M_move_out_cur(off_type __n) // argument needs to be +-
{
const bool __testin = _M_in_cur;
Index: src/fstream.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/src/fstream.cc,v
retrieving revision 1.9
diff -c -p -r1.9 fstream.cc
*** src/fstream.cc 26 Apr 2003 00:23:17 -0000 1.9
--- src/fstream.cc 28 Apr 2003 04:36:15 -0000
*************** namespace std
*** 38,44 ****
{
template<>
basic_filebuf<char>::int_type
! basic_filebuf<char>::_M_underflow_common(bool __bump)
{
int_type __ret = traits_type::eof();
const bool __testin = _M_mode & ios_base::in;
--- 38,44 ----
{
template<>
basic_filebuf<char>::int_type
! basic_filebuf<char>::_M_underflow(bool __bump)
{
int_type __ret = traits_type::eof();
const bool __testin = _M_mode & ios_base::in;
*************** namespace std
*** 51,63 ****
// normal buffers and jet outta here before expensive
// fileops happen...
if (_M_pback_init)
! _M_pback_destroy();
if (_M_in_cur < _M_in_end)
{
__ret = traits_type::to_int_type(*_M_in_cur);
if (__bump)
! _M_in_cur_move(1);
return __ret;
}
--- 51,63 ----
// normal buffers and jet outta here before expensive
// fileops happen...
if (_M_pback_init)
! _M_destroy_pback();
if (_M_in_cur < _M_in_end)
{
__ret = traits_type::to_int_type(*_M_in_cur);
if (__bump)
! _M_move_in_cur(1);
return __ret;
}
*************** namespace std
*** 68,74 ****
if (__testget)
{
if (__testout)
! _M_really_overflow();
else if (_M_in_cur != _M_filepos)
_M_file.seekoff(_M_in_cur - _M_filepos,
ios_base::cur, __testsync, ios_base::in);
--- 68,74 ----
if (__testget)
{
if (__testout)
! _M_overflow();
else if (_M_in_cur != _M_filepos)
_M_file.seekoff(_M_in_cur - _M_filepos,
ios_base::cur, __testsync, ios_base::in);
*************** namespace std
*** 90,96 ****
_M_out_cur = _M_in_cur;
__ret = traits_type::to_int_type(*_M_in_cur);
if (__bump)
! _M_in_cur_move(1);
else if (__testsync)
{
// If we are synced with stdio, we have to unget the
--- 90,96 ----
_M_out_cur = _M_in_cur;
__ret = traits_type::to_int_type(*_M_in_cur);
if (__bump)
! _M_move_in_cur(1);
else if (__testsync)
{
// If we are synced with stdio, we have to unget the
*************** namespace std
*** 109,125 ****
template<>
basic_filebuf<char>::int_type
basic_filebuf<char>::underflow()
! { return _M_underflow_common(false); }
template<>
basic_filebuf<char>::int_type
basic_filebuf<char>::uflow()
! { return _M_underflow_common(true); }
#ifdef _GLIBCPP_USE_WCHAR_T
template<>
basic_filebuf<wchar_t>::int_type
! basic_filebuf<wchar_t>::_M_underflow_common(bool __bump)
{
int_type __ret = traits_type::eof();
const bool __testin = _M_mode & ios_base::in;
--- 109,125 ----
template<>
basic_filebuf<char>::int_type
basic_filebuf<char>::underflow()
! { return _M_underflow(false); }
template<>
basic_filebuf<char>::int_type
basic_filebuf<char>::uflow()
! { return _M_underflow(true); }
#ifdef _GLIBCPP_USE_WCHAR_T
template<>
basic_filebuf<wchar_t>::int_type
! basic_filebuf<wchar_t>::_M_underflow(bool __bump)
{
int_type __ret = traits_type::eof();
const bool __testin = _M_mode & ios_base::in;
*************** namespace std
*** 132,144 ****
// normal buffers and jet outta here before expensive
// fileops happen...
if (_M_pback_init)
! _M_pback_destroy();
if (_M_in_cur < _M_in_end)
{
__ret = traits_type::to_int_type(*_M_in_cur);
if (__bump)
! _M_in_cur_move(1);
return __ret;
}
--- 132,144 ----
// normal buffers and jet outta here before expensive
// fileops happen...
if (_M_pback_init)
! _M_destroy_pback();
if (_M_in_cur < _M_in_end)
{
__ret = traits_type::to_int_type(*_M_in_cur);
if (__bump)
! _M_move_in_cur(1);
return __ret;
}
*************** namespace std
*** 149,155 ****
if (__testget)
{
if (__testout)
! _M_really_overflow();
else if (_M_in_cur != _M_filepos)
_M_file.seekoff(_M_in_cur - _M_filepos,
ios_base::cur, __testsync, ios_base::in);
--- 149,155 ----
if (__testget)
{
if (__testout)
! _M_overflow();
else if (_M_in_cur != _M_filepos)
_M_file.seekoff(_M_in_cur - _M_filepos,
ios_base::cur, __testsync, ios_base::in);
*************** namespace std
*** 195,201 ****
_M_out_cur = _M_in_cur;
__ret = traits_type::to_int_type(*_M_in_cur);
if (__bump)
! _M_in_cur_move(1);
else if (__testsync)
{
// If we are synced with stdio, we have to unget the
--- 195,201 ----
_M_out_cur = _M_in_cur;
__ret = traits_type::to_int_type(*_M_in_cur);
if (__bump)
! _M_move_in_cur(1);
else if (__testsync)
{
// If we are synced with stdio, we have to unget the
*************** namespace std
*** 214,224 ****
template<>
basic_filebuf<wchar_t>::int_type
basic_filebuf<wchar_t>::underflow()
! { return _M_underflow_common(false); }
template<>
basic_filebuf<wchar_t>::int_type
basic_filebuf<wchar_t>::uflow()
! { return _M_underflow_common(true); }
#endif
} // namespace std
--- 214,224 ----
template<>
basic_filebuf<wchar_t>::int_type
basic_filebuf<wchar_t>::underflow()
! { return _M_underflow(false); }
template<>
basic_filebuf<wchar_t>::int_type
basic_filebuf<wchar_t>::uflow()
! { return _M_underflow(true); }
#endif
} // namespace std