Commit aa438e8f by Benjamin Kosnik Committed by Benjamin Kosnik

std_fstream.h (basic_filebuf): _M_pback_destroy to _M_destroy_pback.


2003-04-27  Benjamin Kosnik  <bkoz@redhat.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.

From-SVN: r66149
parent afc6aaab
2003-04-27 Benjamin Kosnik <bkoz@redhat.com> 2003-04-27 Benjamin Kosnik <bkoz@redhat.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.
2003-04-27 Benjamin Kosnik <bkoz@redhat.com>
* include/bits/locale_classes.h (locale::_Impl): Change _M_names * include/bits/locale_classes.h (locale::_Impl): Change _M_names
from fixed size array. from fixed size array.
(locale): Change _S_categories as well. (locale): Change _S_categories as well.
......
...@@ -126,8 +126,7 @@ namespace std ...@@ -126,8 +126,7 @@ namespace std
const bool __testput = this->_M_out_beg < this->_M_out_lim; const bool __testput = this->_M_out_beg < this->_M_out_lim;
if (__testput if (__testput
&& traits_type::eq_int_type(_M_really_overflow(__eof), && traits_type::eq_int_type(_M_overflow(__eof), __eof))
__eof))
__testfail = true; __testfail = true;
#if 0 #if 0
...@@ -135,7 +134,7 @@ namespace std ...@@ -135,7 +134,7 @@ namespace std
if (_M_last_overflowed) if (_M_last_overflowed)
{ {
_M_output_unshift(); _M_output_unshift();
_M_really_overflow(__eof); _M_overflow(__eof);
} }
#endif #endif
} }
...@@ -147,7 +146,7 @@ namespace std ...@@ -147,7 +146,7 @@ namespace std
// NB: Do this here so that re-opened filebufs will be cool... // NB: Do this here so that re-opened filebufs will be cool...
this->_M_mode = ios_base::openmode(0); this->_M_mode = ios_base::openmode(0);
_M_destroy_internal_buffer(); _M_destroy_internal_buffer();
_M_pback_destroy(); _M_destroy_pback();
if (!_M_file.close()) if (!_M_file.close())
__testfail = true; __testfail = true;
...@@ -214,7 +213,7 @@ namespace std ...@@ -214,7 +213,7 @@ namespace std
__ret = traits_type::not_eof(__i); __ret = traits_type::not_eof(__i);
else else
{ {
_M_pback_create(); _M_create_pback();
*this->_M_in_cur = __c; *this->_M_in_cur = __c;
__ret = __i; __ret = __i;
} }
...@@ -233,7 +232,7 @@ namespace std ...@@ -233,7 +232,7 @@ namespace std
{ {
if (!traits_type::eq(__c, *this->_M_in_cur)) if (!traits_type::eq(__c, *this->_M_in_cur))
{ {
_M_pback_create(); _M_create_pback();
*this->_M_in_cur = __c; *this->_M_in_cur = __c;
} }
__ret = __i; __ret = __i;
...@@ -263,14 +262,14 @@ namespace std ...@@ -263,14 +262,14 @@ namespace std
else if (__testput) else if (__testput)
{ {
*this->_M_out_cur = traits_type::to_char_type(__c); *this->_M_out_cur = traits_type::to_char_type(__c);
_M_out_cur_move(1); _M_move_out_cur(1);
__ret = traits_type::not_eof(__c); __ret = traits_type::not_eof(__c);
} }
else else
__ret = this->_M_really_overflow(__c); __ret = this->_M_overflow(__c);
} }
_M_last_overflowed = false; // Set in _M_really_overflow, below. _M_last_overflowed = false; // Set in _M_overflow, below.
return __ret; return __ret;
} }
...@@ -344,7 +343,7 @@ namespace std ...@@ -344,7 +343,7 @@ namespace std
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::int_type typename basic_filebuf<_CharT, _Traits>::int_type
basic_filebuf<_CharT, _Traits>:: basic_filebuf<_CharT, _Traits>::
_M_really_overflow(int_type __c) _M_overflow(int_type __c)
{ {
int_type __ret = traits_type::eof(); int_type __ret = traits_type::eof();
const bool __testput = this->_M_out_beg < this->_M_out_lim; const bool __testput = this->_M_out_beg < this->_M_out_lim;
...@@ -449,7 +448,7 @@ namespace std ...@@ -449,7 +448,7 @@ namespace std
if (this->is_open() && !__testfail && (__testin || __testout)) if (this->is_open() && !__testfail && (__testin || __testout))
{ {
// Ditch any pback buffers to avoid confusion. // Ditch any pback buffers to avoid confusion.
_M_pback_destroy(); _M_destroy_pback();
if (__way != ios_base::cur || __off != 0) if (__way != ios_base::cur || __off != 0)
{ {
......
...@@ -173,7 +173,7 @@ namespace std ...@@ -173,7 +173,7 @@ namespace std
if ((__testout || __testboth) if ((__testout || __testboth)
&& __newoffo + __off >= 0 && __endo - __beg >= __newoffo + __off) && __newoffo + __off >= 0 && __endo - __beg >= __newoffo + __off)
{ {
_M_out_cur_move(__newoffo + __off - (this->_M_out_cur - __beg)); _M_move_out_cur(__newoffo + __off - (this->_M_out_cur - __beg));
__ret = pos_type(__newoffo); __ret = pos_type(__newoffo);
} }
} }
...@@ -217,7 +217,7 @@ namespace std ...@@ -217,7 +217,7 @@ namespace std
if (__testposi) if (__testposi)
this->_M_in_cur = this->_M_in_beg + __pos; this->_M_in_cur = this->_M_in_beg + __pos;
if (__testposo) if (__testposo)
_M_out_cur_move((__pos) - (this->_M_out_cur - __beg)); _M_move_out_cur((__pos) - (this->_M_out_cur - __beg));
__ret = pos_type(off_type(__pos)); __ret = pos_type(off_type(__pos));
} }
} }
......
...@@ -48,7 +48,7 @@ namespace std ...@@ -48,7 +48,7 @@ namespace std
if (_M_in_cur < _M_in_end) if (_M_in_cur < _M_in_end)
{ {
char_type __c = *this->_M_in_cur; char_type __c = *this->_M_in_cur;
_M_in_cur_move(1); _M_move_in_cur(1);
__ret = traits_type::to_int_type(__c); __ret = traits_type::to_int_type(__c);
} }
else else
...@@ -67,7 +67,7 @@ namespace std ...@@ -67,7 +67,7 @@ namespace std
__ret = this->pbackfail(traits_type::to_int_type(__c)); __ret = this->pbackfail(traits_type::to_int_type(__c));
else else
{ {
_M_in_cur_move(-1); _M_move_in_cur(-1);
__ret = traits_type::to_int_type(*this->_M_in_cur); __ret = traits_type::to_int_type(*this->_M_in_cur);
} }
return __ret; return __ret;
...@@ -81,7 +81,7 @@ namespace std ...@@ -81,7 +81,7 @@ namespace std
int_type __ret; int_type __ret;
if (_M_in_beg < _M_in_cur) if (_M_in_beg < _M_in_cur)
{ {
_M_in_cur_move(-1); _M_move_in_cur(-1);
__ret = traits_type::to_int_type(*_M_in_cur); __ret = traits_type::to_int_type(*_M_in_cur);
} }
else else
...@@ -98,7 +98,7 @@ namespace std ...@@ -98,7 +98,7 @@ namespace std
if (_M_out_cur < _M_out_end) if (_M_out_cur < _M_out_end)
{ {
*_M_out_cur = __c; *_M_out_cur = __c;
_M_out_cur_move(1); _M_move_out_cur(1);
__ret = traits_type::to_int_type(__c); __ret = traits_type::to_int_type(__c);
} }
else else
...@@ -122,7 +122,7 @@ namespace std ...@@ -122,7 +122,7 @@ namespace std
traits_type::copy(__s, _M_in_cur, __len); traits_type::copy(__s, _M_in_cur, __len);
__ret += __len; __ret += __len;
__s += __len; __s += __len;
_M_in_cur_move(__len); _M_move_in_cur(__len);
} }
if (__ret < __n) if (__ret < __n)
...@@ -156,7 +156,7 @@ namespace std ...@@ -156,7 +156,7 @@ namespace std
traits_type::copy(_M_out_cur, __s, __len); traits_type::copy(_M_out_cur, __s, __len);
__ret += __len; __ret += __len;
__s += __len; __s += __len;
_M_out_cur_move(__len); _M_move_out_cur(__len);
} }
if (__ret < __n) if (__ret < __n)
...@@ -201,7 +201,7 @@ namespace std ...@@ -201,7 +201,7 @@ namespace std
{ {
__xtrct = __sbout->sputn(__sbin->_M_in_cur, __avail); __xtrct = __sbout->sputn(__sbin->_M_in_cur, __avail);
__ret += __xtrct; __ret += __xtrct;
__sbin->_M_in_cur_move(__xtrct); __sbin->_M_move_in_cur(__xtrct);
if (__xtrct != __avail) if (__xtrct != __avail)
break; break;
} }
......
...@@ -152,7 +152,7 @@ namespace std ...@@ -152,7 +152,7 @@ namespace std
// Assumptions: // Assumptions:
// _M_in_cur has already been moved back // _M_in_cur has already been moved back
void void
_M_pback_create() _M_create_pback()
{ {
if (!_M_pback_init) if (!_M_pback_init)
{ {
...@@ -170,7 +170,7 @@ namespace std ...@@ -170,7 +170,7 @@ namespace std
// Assumptions: // Assumptions:
// The pback buffer has only moved forward. // The pback buffer has only moved forward.
void void
_M_pback_destroy() throw() _M_destroy_pback() throw()
{ {
if (_M_pback_init) if (_M_pback_init)
{ {
...@@ -288,7 +288,7 @@ namespace std ...@@ -288,7 +288,7 @@ namespace std
* @endif * @endif
*/ */
int_type int_type
_M_underflow_common(bool __bump); _M_underflow(bool __bump);
// [documentation is inherited] // [documentation is inherited]
virtual int_type virtual int_type
...@@ -303,7 +303,7 @@ namespace std ...@@ -303,7 +303,7 @@ namespace std
pbackfail(int_type __c = _Traits::eof()); pbackfail(int_type __c = _Traits::eof());
// NB: For what the standard expects of the overflow function, // NB: For what the standard expects of the overflow function,
// see _M_really_overflow(), below. Because basic_streambuf's // see _M_overflow(), below. Because basic_streambuf's
// sputc/sputn call overflow directly, and the complications of // sputc/sputn call overflow directly, and the complications of
// this implementation's setting of the initial pointers all // this implementation's setting of the initial pointers all
// equal to _M_buf when initializing, it seems essential to have // equal to _M_buf when initializing, it seems essential to have
...@@ -328,7 +328,7 @@ namespace std ...@@ -328,7 +328,7 @@ namespace std
* @endif * @endif
*/ */
int_type int_type
_M_really_overflow(int_type __c = _Traits::eof()); _M_overflow(int_type __c = _Traits::eof());
// Convert internal byte sequence to external, char-based // Convert internal byte sequence to external, char-based
// sequence via codecvt. // sequence via codecvt.
...@@ -382,8 +382,7 @@ namespace std ...@@ -382,8 +382,7 @@ namespace std
off_type __off = this->_M_out_cur - this->_M_out_lim; off_type __off = this->_M_out_cur - this->_M_out_lim;
// _M_file.sync() will be called within // _M_file.sync() will be called within
if (traits_type::eq_int_type(_M_really_overflow(), if (traits_type::eq_int_type(_M_overflow(), traits_type::eof()))
traits_type::eof()))
__ret = -1; __ret = -1;
else if (__off) else if (__off)
_M_file.seekoff(__off, ios_base::cur, __sync); _M_file.seekoff(__off, ios_base::cur, __sync);
...@@ -414,7 +413,7 @@ namespace std ...@@ -414,7 +413,7 @@ namespace std
++__s; ++__s;
++this->_M_in_cur; ++this->_M_in_cur;
} }
_M_pback_destroy(); _M_destroy_pback();
} }
if (__ret < __n) if (__ret < __n)
__ret += __streambuf_type::xsgetn(__s, __n - __ret); __ret += __streambuf_type::xsgetn(__s, __n - __ret);
...@@ -425,7 +424,7 @@ namespace std ...@@ -425,7 +424,7 @@ namespace std
virtual streamsize virtual streamsize
xsputn(const char_type* __s, streamsize __n) xsputn(const char_type* __s, streamsize __n)
{ {
_M_pback_destroy(); _M_destroy_pback();
return __streambuf_type::xsputn(__s, __n); return __streambuf_type::xsputn(__s, __n);
} }
...@@ -501,7 +500,7 @@ namespace std ...@@ -501,7 +500,7 @@ namespace std
// Explicit specialization declarations, defined in src/fstream.cc. // Explicit specialization declarations, defined in src/fstream.cc.
template<> template<>
basic_filebuf<char>::int_type basic_filebuf<char>::int_type
basic_filebuf<char>::_M_underflow_common(bool __bump); basic_filebuf<char>::_M_underflow(bool __bump);
template<> template<>
basic_filebuf<char>::int_type basic_filebuf<char>::int_type
...@@ -514,7 +513,7 @@ namespace std ...@@ -514,7 +513,7 @@ namespace std
#ifdef _GLIBCPP_USE_WCHAR_T #ifdef _GLIBCPP_USE_WCHAR_T
template<> template<>
basic_filebuf<wchar_t>::int_type basic_filebuf<wchar_t>::int_type
basic_filebuf<wchar_t>::_M_underflow_common(bool __bump); basic_filebuf<wchar_t>::_M_underflow(bool __bump);
template<> template<>
basic_filebuf<wchar_t>::int_type basic_filebuf<wchar_t>::int_type
......
...@@ -239,7 +239,7 @@ namespace std ...@@ -239,7 +239,7 @@ namespace std
// Correctly sets the _M_in_cur pointer, and bumps the // Correctly sets the _M_in_cur pointer, and bumps the
// _M_out_cur pointer as well if necessary. // _M_out_cur pointer as well if necessary.
void void
_M_in_cur_move(off_type __n) // argument needs to be +- _M_move_in_cur(off_type __n) // argument needs to be +-
{ {
const bool __testout = _M_out_cur; const bool __testout = _M_out_cur;
_M_in_cur += __n; _M_in_cur += __n;
...@@ -256,7 +256,7 @@ namespace std ...@@ -256,7 +256,7 @@ namespace std
// the same range: // the same range:
// _M_buf <= _M_*_ <= _M_out_end // _M_buf <= _M_*_ <= _M_out_end
void void
_M_out_cur_move(off_type __n) // argument needs to be +- _M_move_out_cur(off_type __n) // argument needs to be +-
{ {
const bool __testin = _M_in_cur; const bool __testin = _M_in_cur;
......
...@@ -38,7 +38,7 @@ namespace std ...@@ -38,7 +38,7 @@ namespace std
{ {
template<> template<>
basic_filebuf<char>::int_type basic_filebuf<char>::int_type
basic_filebuf<char>::_M_underflow_common(bool __bump) basic_filebuf<char>::_M_underflow(bool __bump)
{ {
int_type __ret = traits_type::eof(); int_type __ret = traits_type::eof();
const bool __testin = _M_mode & ios_base::in; const bool __testin = _M_mode & ios_base::in;
...@@ -51,13 +51,13 @@ namespace std ...@@ -51,13 +51,13 @@ namespace std
// normal buffers and jet outta here before expensive // normal buffers and jet outta here before expensive
// fileops happen... // fileops happen...
if (_M_pback_init) if (_M_pback_init)
_M_pback_destroy(); _M_destroy_pback();
if (_M_in_cur < _M_in_end) if (_M_in_cur < _M_in_end)
{ {
__ret = traits_type::to_int_type(*_M_in_cur); __ret = traits_type::to_int_type(*_M_in_cur);
if (__bump) if (__bump)
_M_in_cur_move(1); _M_move_in_cur(1);
return __ret; return __ret;
} }
...@@ -68,7 +68,7 @@ namespace std ...@@ -68,7 +68,7 @@ namespace std
if (__testget) if (__testget)
{ {
if (__testout) if (__testout)
_M_really_overflow(); _M_overflow();
else if (_M_in_cur != _M_filepos) else if (_M_in_cur != _M_filepos)
_M_file.seekoff(_M_in_cur - _M_filepos, _M_file.seekoff(_M_in_cur - _M_filepos,
ios_base::cur, __testsync, ios_base::in); ios_base::cur, __testsync, ios_base::in);
...@@ -90,7 +90,7 @@ namespace std ...@@ -90,7 +90,7 @@ namespace std
_M_out_cur = _M_in_cur; _M_out_cur = _M_in_cur;
__ret = traits_type::to_int_type(*_M_in_cur); __ret = traits_type::to_int_type(*_M_in_cur);
if (__bump) if (__bump)
_M_in_cur_move(1); _M_move_in_cur(1);
else if (__testsync) else if (__testsync)
{ {
// If we are synced with stdio, we have to unget the // If we are synced with stdio, we have to unget the
...@@ -109,17 +109,17 @@ namespace std ...@@ -109,17 +109,17 @@ namespace std
template<> template<>
basic_filebuf<char>::int_type basic_filebuf<char>::int_type
basic_filebuf<char>::underflow() basic_filebuf<char>::underflow()
{ return _M_underflow_common(false); } { return _M_underflow(false); }
template<> template<>
basic_filebuf<char>::int_type basic_filebuf<char>::int_type
basic_filebuf<char>::uflow() basic_filebuf<char>::uflow()
{ return _M_underflow_common(true); } { return _M_underflow(true); }
#ifdef _GLIBCPP_USE_WCHAR_T #ifdef _GLIBCPP_USE_WCHAR_T
template<> template<>
basic_filebuf<wchar_t>::int_type basic_filebuf<wchar_t>::int_type
basic_filebuf<wchar_t>::_M_underflow_common(bool __bump) basic_filebuf<wchar_t>::_M_underflow(bool __bump)
{ {
int_type __ret = traits_type::eof(); int_type __ret = traits_type::eof();
const bool __testin = _M_mode & ios_base::in; const bool __testin = _M_mode & ios_base::in;
...@@ -132,13 +132,13 @@ namespace std ...@@ -132,13 +132,13 @@ namespace std
// normal buffers and jet outta here before expensive // normal buffers and jet outta here before expensive
// fileops happen... // fileops happen...
if (_M_pback_init) if (_M_pback_init)
_M_pback_destroy(); _M_destroy_pback();
if (_M_in_cur < _M_in_end) if (_M_in_cur < _M_in_end)
{ {
__ret = traits_type::to_int_type(*_M_in_cur); __ret = traits_type::to_int_type(*_M_in_cur);
if (__bump) if (__bump)
_M_in_cur_move(1); _M_move_in_cur(1);
return __ret; return __ret;
} }
...@@ -149,7 +149,7 @@ namespace std ...@@ -149,7 +149,7 @@ namespace std
if (__testget) if (__testget)
{ {
if (__testout) if (__testout)
_M_really_overflow(); _M_overflow();
else if (_M_in_cur != _M_filepos) else if (_M_in_cur != _M_filepos)
_M_file.seekoff(_M_in_cur - _M_filepos, _M_file.seekoff(_M_in_cur - _M_filepos,
ios_base::cur, __testsync, ios_base::in); ios_base::cur, __testsync, ios_base::in);
...@@ -195,7 +195,7 @@ namespace std ...@@ -195,7 +195,7 @@ namespace std
_M_out_cur = _M_in_cur; _M_out_cur = _M_in_cur;
__ret = traits_type::to_int_type(*_M_in_cur); __ret = traits_type::to_int_type(*_M_in_cur);
if (__bump) if (__bump)
_M_in_cur_move(1); _M_move_in_cur(1);
else if (__testsync) else if (__testsync)
{ {
// If we are synced with stdio, we have to unget the // If we are synced with stdio, we have to unget the
...@@ -214,11 +214,11 @@ namespace std ...@@ -214,11 +214,11 @@ namespace std
template<> template<>
basic_filebuf<wchar_t>::int_type basic_filebuf<wchar_t>::int_type
basic_filebuf<wchar_t>::underflow() basic_filebuf<wchar_t>::underflow()
{ return _M_underflow_common(false); } { return _M_underflow(false); }
template<> template<>
basic_filebuf<wchar_t>::int_type basic_filebuf<wchar_t>::int_type
basic_filebuf<wchar_t>::uflow() basic_filebuf<wchar_t>::uflow()
{ return _M_underflow_common(true); } { return _M_underflow(true); }
#endif #endif
} // namespace std } // namespace std
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