* include/std/std_streambuf.h (_S_pback_size, _M_pback,
_M_pback_cur_save, _M_pback_end_save, _M_pback_init,
_M_pback_create(), _M_pback_destroy()): Move to basic_filebuf.
(basic_streambuf::basic_streambuf()): Adjust.
* include/std/std_fstream.h (_S_pback_size, _M_pback,
_M_pback_cur_save, _M_pback_end_save, _M_pback_init,
_M_pback_create(), _M_pback_destroy()): Moved here
from basic_streambuf.
* include/bits/fstream.tcc (basic_filebuf::basic_filebuf()):
Adjust.
(basic_filebuf::_S_pback_size): Add declaration.
* include/bits/streambuf.tcc (basic_streambuf::_S_pback_size):
Remove declaration.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@65950
138bc75d-0d04-0410-961f-
82ee72b054a4
+2003-04-22 Paolo Carlini <pcarlini@unitus.it>
+
+ * include/std/std_streambuf.h (_S_pback_size, _M_pback,
+ _M_pback_cur_save, _M_pback_end_save, _M_pback_init,
+ _M_pback_create(), _M_pback_destroy()): Move to basic_filebuf.
+ (basic_streambuf::basic_streambuf()): Adjust.
+ * include/std/std_fstream.h (_S_pback_size, _M_pback,
+ _M_pback_cur_save, _M_pback_end_save, _M_pback_init,
+ _M_pback_create(), _M_pback_destroy()): Moved here
+ from basic_streambuf.
+ * include/bits/fstream.tcc (basic_filebuf::basic_filebuf()):
+ Adjust.
+ (basic_filebuf::_S_pback_size): Add declaration.
+ * include/bits/streambuf.tcc (basic_streambuf::_S_pback_size):
+ Remove declaration.
+
2003-04-21 Paolo Carlini <pcarlini@unitus.it>
Consistently use _M_in_beg instead of eback(), _M_in_cur
namespace std
{
template<typename _CharT, typename _Traits>
+ const size_t
+ basic_filebuf<_CharT, _Traits>::_S_pback_size;
+
+ template<typename _CharT, typename _Traits>
void
basic_filebuf<_CharT, _Traits>::
_M_allocate_internal_buffer()
basic_filebuf<_CharT, _Traits>::
basic_filebuf() : __streambuf_type(), _M_file(&_M_lock),
_M_state_cur(__state_type()), _M_state_beg(__state_type()),
- _M_buf_allocated(false), _M_last_overflowed(false)
+ _M_buf_allocated(false), _M_last_overflowed(false),
+ _M_pback_cur_save(0), _M_pback_end_save(0), _M_pback_init(false)
{ this->_M_buf_unified = true; }
template<typename _CharT, typename _Traits>
namespace std
{
template<typename _CharT, typename _Traits>
- const size_t
- basic_streambuf<_CharT, _Traits>::_S_pback_size;
-
- template<typename _CharT, typename _Traits>
typename basic_streambuf<_CharT, _Traits>::int_type
basic_streambuf<_CharT, _Traits>::
sbumpc()
*/
char_type* _M_filepos;
+ //@{
+ /**
+ * @if maint
+ * Necessary bits for putback buffer management.
+ *
+ * @note pbacks of over one character are not currently supported.
+ * @endif
+ */
+ static const size_t _S_pback_size = 1;
+ char_type _M_pback[_S_pback_size];
+ char_type* _M_pback_cur_save;
+ char_type* _M_pback_end_save;
+ bool _M_pback_init;
+ //@}
+
+ // Initializes pback buffers, and moves normal buffers to safety.
+ // Assumptions:
+ // _M_in_cur has already been moved back
+ void
+ _M_pback_create()
+ {
+ if (!_M_pback_init)
+ {
+ size_t __dist = this->_M_in_end - this->_M_in_cur;
+ size_t __len = std::min(_S_pback_size, __dist);
+ traits_type::copy(_M_pback, this->_M_in_cur, __len);
+ _M_pback_cur_save = this->_M_in_cur;
+ _M_pback_end_save = this->_M_in_end;
+ this->setg(_M_pback, _M_pback, _M_pback + __len);
+ _M_pback_init = true;
+ }
+ }
+
+ // Deactivates pback buffer contents, and restores normal buffer.
+ // Assumptions:
+ // The pback buffer has only moved forward.
+ void
+ _M_pback_destroy()
+ {
+ if (_M_pback_init)
+ {
+ // Length _M_in_cur moved in the pback buffer.
+ size_t __off_cur = this->_M_in_cur - _M_pback;
+
+ // For in | out buffers, the end can be pushed back...
+ size_t __off_end = 0;
+ size_t __pback_len = this->_M_in_end - _M_pback;
+ size_t __save_len = _M_pback_end_save - this->_M_buf;
+ if (__pback_len > __save_len)
+ __off_end = __pback_len - __save_len;
+
+ this->setg(this->_M_buf, _M_pback_cur_save + __off_cur,
+ _M_pback_end_save + __off_end);
+ _M_pback_cur_save = NULL;
+ _M_pback_end_save = NULL;
+ _M_pback_init = false;
+ }
+ }
+
public:
// Constructors/destructor:
/**
*/
locale _M_buf_locale;
- //@{
- /**
- * @if maint
- * Necessary bits for putback buffer management. Only used in
- * the basic_filebuf class, as necessary for the standard
- * requirements.
- *
- * @note pbacks of over one character are not currently supported.
- * @endif
- */
- static const size_t _S_pback_size = 1;
- char_type _M_pback[_S_pback_size];
- char_type* _M_pback_cur_save;
- char_type* _M_pback_end_save;
- bool _M_pback_init;
- //@}
-
/**
* @if maint
* Yet unused.
*/
fpos<__state_type> _M_pos;
- // Initializes pback buffers, and moves normal buffers to safety.
- // Assumptions:
- // _M_in_cur has already been moved back
- void
- _M_pback_create()
- {
- if (!_M_pback_init)
- {
- size_t __dist = _M_in_end - _M_in_cur;
- size_t __len = std::min(_S_pback_size, __dist);
- traits_type::copy(_M_pback, _M_in_cur, __len);
- _M_pback_cur_save = _M_in_cur;
- _M_pback_end_save = _M_in_end;
- this->setg(_M_pback, _M_pback, _M_pback + __len);
- _M_pback_init = true;
- }
- }
-
- // Deactivates pback buffer contents, and restores normal buffer.
- // Assumptions:
- // The pback buffer has only moved forward.
- void
- _M_pback_destroy()
- {
- if (_M_pback_init)
- {
- // Length _M_in_cur moved in the pback buffer.
- size_t __off_cur = _M_in_cur - _M_pback;
-
- // For in | out buffers, the end can be pushed back...
- size_t __off_end = 0;
- size_t __pback_len = _M_in_end - _M_pback;
- size_t __save_len = _M_pback_end_save - _M_buf;
- if (__pback_len > __save_len)
- __off_end = __pback_len - __save_len;
-
- this->setg(_M_buf, _M_pback_cur_save + __off_cur,
- _M_pback_end_save + __off_end);
- _M_pback_cur_save = NULL;
- _M_pback_end_save = NULL;
- _M_pback_init = false;
- }
- }
-
// Correctly sets the _M_in_cur pointer, and bumps the
// _M_out_cur pointer as well if necessary.
void
: _M_buf(NULL), _M_buf_size(BUFSIZ), _M_buf_unified(false),
_M_in_beg(0), _M_in_cur(0), _M_in_end(0), _M_out_beg(0),
_M_out_cur(0), _M_out_end(0), _M_out_lim(0),
- _M_mode(ios_base::openmode(0)), _M_buf_locale(locale()),
- _M_pback_cur_save(0), _M_pback_end_save(0),
- _M_pback_init(false)
+ _M_mode(ios_base::openmode(0)), _M_buf_locale(locale())
{ }
// [27.5.2.3.1] get area access