Commit 49433044 by Benjamin Kosnik Committed by Benjamin Kosnik

std_streambuf.h (basic_streambuf::_M_buf): Change to size_t, from int_type.


2002-07-04  Benjamin Kosnik  <bkoz@redhat.com>
            Jack Reeves  <jackw_reeves@hotmail.com>

	* include/std/std_streambuf.h (basic_streambuf::_M_buf): Change to
	size_t, from int_type.
 	(basic_streambuf::_M_buf_size_opt): Same.
 	(basic_streambuf::_S_pback_sizex): Same.
	* include/bits/streambuf.tcc: Same.
	* include/std/std_streambuf.h (basic_streambuf::snextc): Use
	eq_int_type.
	(basic_streambuf::uflow): Same.
	* include/bits/sstream.tcc (basic_stringbuf::overflow): Use
	to_char_type.
	* include/bits/basic_ios.tcc (basic_ios::init): Use _CharT().
	* include/bits/streambuf.tcc (basic_streambuf::xsgetn): Use
	eq_int_type.
	(basic_streambuf::xsputn): Same.
	(__copy_streambufs): Same.

Co-Authored-By: Jack Reeves <jackw_reeves@hotmail.com>

From-SVN: r55242
parent 5acf59f8
2002-07-04 Benjamin Kosnik <bkoz@redhat.com>
Jack Reeves <jackw_reeves@hotmail.com>
* include/std/std_streambuf.h (basic_streambuf::_M_buf): Change to
size_t, from int_type.
(basic_streambuf::_M_buf_size_opt): Same.
(basic_streambuf::_S_pback_sizex): Same.
* include/bits/streambuf.tcc: Same.
* include/std/std_streambuf.h (basic_streambuf::snextc): Use
eq_int_type.
(basic_streambuf::uflow): Same.
* include/bits/sstream.tcc (basic_stringbuf::overflow): Use
to_char_type.
* include/bits/basic_ios.tcc (basic_ios::init): Use _CharT().
* include/bits/streambuf.tcc (basic_streambuf::xsgetn): Use
eq_int_type.
(basic_streambuf::xsputn): Same.
(__copy_streambufs): Same.
2002-07-03 Benjamin Kosnik <bkoz@redhat.com> 2002-07-03 Benjamin Kosnik <bkoz@redhat.com>
* include/std/std_memory.h: Fix formatting. * include/std/std_memory.h: Fix formatting.
......
...@@ -156,7 +156,7 @@ namespace std ...@@ -156,7 +156,7 @@ namespace std
// unformatted input and output with non-required basic_ios // unformatted input and output with non-required basic_ios
// instantiations is possible even without imbuing the expected // instantiations is possible even without imbuing the expected
// ctype<char_type> facet. // ctype<char_type> facet.
_M_fill = 0; _M_fill = _CharT();
_M_fill_init = false; _M_fill_init = false;
_M_exception = goodbit; _M_exception = goodbit;
......
...@@ -95,13 +95,13 @@ namespace std ...@@ -95,13 +95,13 @@ namespace std
__len *= 2; __len *= 2;
if (__testwrite) if (__testwrite)
__ret = this->sputc(__c); __ret = this->sputc(traits_type::to_char_type(__c));
else if (__len <= _M_string.max_size()) else if (__len <= _M_string.max_size())
{ {
// Force-allocate, re-sync. // Force-allocate, re-sync.
_M_string = this->str(); _M_string = this->str();
_M_string.reserve(__len); _M_string.reserve(__len);
_M_buf_size = static_cast<int_type>(__len); _M_buf_size = __len;
_M_really_sync(_M_in_cur - _M_in_beg, _M_really_sync(_M_in_cur - _M_in_beg,
_M_out_cur - _M_out_beg); _M_out_cur - _M_out_beg);
*_M_out_cur = traits_type::to_char_type(__c); *_M_out_cur = traits_type::to_char_type(__c);
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
namespace std namespace std
{ {
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
const typename basic_streambuf<_CharT, _Traits>::int_type const size_t
basic_streambuf<_CharT, _Traits>::_S_pback_size; basic_streambuf<_CharT, _Traits>::_S_pback_size;
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
...@@ -138,7 +138,7 @@ namespace std ...@@ -138,7 +138,7 @@ namespace std
if (__ret < __n) if (__ret < __n)
{ {
int_type __c = this->uflow(); int_type __c = this->uflow();
if (__c != traits_type::eof()) if (!traits_type::eq_int_type(__c, traits_type::eof()))
{ {
traits_type::assign(*__s++, traits_type::to_char_type(__c)); traits_type::assign(*__s++, traits_type::to_char_type(__c));
++__ret; ++__ret;
...@@ -177,7 +177,7 @@ namespace std ...@@ -177,7 +177,7 @@ namespace std
if (__ret < __n) if (__ret < __n)
{ {
int_type __c = this->overflow(traits_type::to_int_type(*__s)); int_type __c = this->overflow(traits_type::to_int_type(*__s));
if (__c != traits_type::eof()) if (!traits_type::eq_int_type(__c, traits_type::eof()))
{ {
++__ret; ++__ret;
++__s; ++__s;
...@@ -214,7 +214,7 @@ namespace std ...@@ -214,7 +214,7 @@ namespace std
__sbin->_M_in_cur_move(__xtrct); __sbin->_M_in_cur_move(__xtrct);
if (__xtrct == __bufsize) if (__xtrct == __bufsize)
{ {
if (__sbin->sgetc() == _Traits::eof()) if (_Traits::eq_int_type(__sbin->sgetc(), _Traits::eof()))
break; break;
__bufsize = __sbin->in_avail(); __bufsize = __sbin->in_avail();
} }
......
...@@ -91,10 +91,10 @@ namespace std ...@@ -91,10 +91,10 @@ namespace std
char_type* _M_buf; char_type* _M_buf;
// Actual size of allocated internal buffer, in bytes. // Actual size of allocated internal buffer, in bytes.
int_type _M_buf_size; size_t _M_buf_size;
// Optimal or preferred size of internal buffer, in bytes. // Optimal or preferred size of internal buffer, in bytes.
int_type _M_buf_size_opt; size_t _M_buf_size_opt;
// True iff _M_in_* and _M_out_* buffers should always point to // True iff _M_in_* and _M_out_* buffers should always point to
// the same place. True for fstreams, false for sstreams. // the same place. True for fstreams, false for sstreams.
...@@ -126,7 +126,7 @@ namespace std ...@@ -126,7 +126,7 @@ namespace std
// requirements. The only basic_streambuf member function that // requirements. The only basic_streambuf member function that
// needs access to these data members is in_avail... // needs access to these data members is in_avail...
// NB: pbacks of over one character are not currently supported. // NB: pbacks of over one character are not currently supported.
static const int_type _S_pback_size = 1; static const size_t _S_pback_size = 1;
char_type _M_pback[_S_pback_size]; char_type _M_pback[_S_pback_size];
char_type* _M_pback_cur_save; char_type* _M_pback_cur_save;
char_type* _M_pback_end_save; char_type* _M_pback_end_save;
...@@ -140,8 +140,8 @@ namespace std ...@@ -140,8 +140,8 @@ namespace std
{ {
if (!_M_pback_init) if (!_M_pback_init)
{ {
int_type __dist = _M_in_end - _M_in_cur; size_t __dist = _M_in_end - _M_in_cur;
int_type __len = min(_S_pback_size, __dist); size_t __len = min(_S_pback_size, __dist);
traits_type::copy(_M_pback, _M_in_cur, __len); traits_type::copy(_M_pback, _M_in_cur, __len);
_M_pback_cur_save = _M_in_cur; _M_pback_cur_save = _M_in_cur;
_M_pback_end_save = _M_in_end; _M_pback_end_save = _M_in_end;
...@@ -159,12 +159,12 @@ namespace std ...@@ -159,12 +159,12 @@ namespace std
if (_M_pback_init) if (_M_pback_init)
{ {
// Length _M_in_cur moved in the pback buffer. // Length _M_in_cur moved in the pback buffer.
int_type __off_cur = _M_in_cur - _M_pback; size_t __off_cur = _M_in_cur - _M_pback;
// For in | out buffers, the end can be pushed back... // For in | out buffers, the end can be pushed back...
int_type __off_end = 0; size_t __off_end = 0;
int_type __pback_len = _M_in_end - _M_pback; size_t __pback_len = _M_in_end - _M_pback;
int_type __save_len = _M_pback_end_save - _M_buf; size_t __save_len = _M_pback_end_save - _M_buf;
if (__pback_len > __save_len) if (__pback_len > __save_len)
__off_end = __pback_len - __save_len; __off_end = __pback_len - __save_len;
...@@ -288,8 +288,8 @@ namespace std ...@@ -288,8 +288,8 @@ namespace std
{ {
if (_M_pback_init) if (_M_pback_init)
{ {
int_type __save_len = _M_pback_end_save - _M_pback_cur_save; size_t __save_len = _M_pback_end_save - _M_pback_cur_save;
int_type __pback_len = _M_in_cur - _M_pback; size_t __pback_len = _M_in_cur - _M_pback;
__ret = __save_len - __pback_len; __ret = __save_len - __pback_len;
} }
else else
...@@ -304,7 +304,8 @@ namespace std ...@@ -304,7 +304,8 @@ namespace std
snextc() snextc()
{ {
int_type __eof = traits_type::eof(); int_type __eof = traits_type::eof();
return (this->sbumpc() == __eof ? __eof : this->sgetc()); return (traits_type::eq_int_type(this->sbumpc(), __eof)
? __eof : this->sgetc());
} }
int_type int_type
...@@ -342,10 +343,10 @@ namespace std ...@@ -342,10 +343,10 @@ namespace std
protected: protected:
basic_streambuf() basic_streambuf()
: _M_buf(NULL), _M_buf_size(0), : _M_buf(NULL), _M_buf_size(0), _M_buf_size_opt(BUFSIZ),
_M_buf_size_opt(static_cast<int_type>(BUFSIZ)), _M_buf_unified(false), _M_buf_unified(false), _M_in_beg(0), _M_in_cur(0), _M_in_end(0),
_M_in_beg(0), _M_in_cur(0), _M_in_end(0), _M_out_beg(0), _M_out_cur(0), _M_out_beg(0), _M_out_cur(0), _M_out_end(0),
_M_out_end(0), _M_mode(ios_base::openmode(0)), _M_buf_locale(locale()), _M_mode(ios_base::openmode(0)), _M_buf_locale(locale()),
_M_buf_locale_init(false), _M_pback_cur_save(0), _M_pback_end_save(0), _M_buf_locale_init(false), _M_pback_cur_save(0), _M_pback_end_save(0),
_M_pback_init(false) _M_pback_init(false)
{ } { }
...@@ -438,7 +439,7 @@ namespace std ...@@ -438,7 +439,7 @@ namespace std
uflow() uflow()
{ {
int_type __ret = traits_type::eof(); int_type __ret = traits_type::eof();
bool __testeof = this->underflow() == __ret; bool __testeof = traits_type::eq_int_type(this->underflow(), __ret);
bool __testpending = _M_in_cur && _M_in_cur < _M_in_end; bool __testpending = _M_in_cur && _M_in_cur < _M_in_end;
if (!__testeof && __testpending) if (!__testeof && __testpending)
{ {
......
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