+2003-04-12 Paolo Carlini <pcarlini@unitus.it>
+
+ Remove _M_buf_size_opt, use directly _M_buf_size instead.
+ * include/bits/fstream.tcc
+ (basic_filebuf::_M_allocate_internal_buffer, setbuf): Remove
+ references to _M_buf_size_opt.
+ * include/bits/sstream.tcc (basic_stringbuf::overflow): Likewise.
+ * include/bits/streambuf.tcc (__copy_streambufs): Likewise, rename
+ __bufsize to __in_avail and __size_opt to __buf_size.
+ * include/ext/stdio_filebuf.h (stdio_filebuf::stdio_filebuf): Likewise.
+ * include/std/std_sstream.h (_M_stringbuf_init, setbuf): Likewise.
+ * include/std/std_streambuf.h (~basic_streambuf(),
+ basic_streambuf()): Likewise, remove _M_buf_size_opt member.
+ * testsuite/27_io/basic_filebuf/close/char/3.cc: Set _M_buf_size.
+ * testsuite/27_io/basic_filebuf/in_avail/char/1.cc: Likewise.
+ * testsuite/27_io/basic_filebuf/sbumpc/char/1.cc: Likewise.
+ * testsuite/27_io/basic_filebuf/seekoff/char/1.cc: Likewise.
+ * testsuite/27_io/basic_filebuf/seekpos/char/1.cc: Likewise.
+ * testsuite/27_io/basic_filebuf/sgetc/char/1.cc: Likewise.
+ * testsuite/27_io/basic_filebuf/sgetn/char/1.cc: Likewise.
+ * testsuite/27_io/basic_filebuf/snextc/char/1.cc: Likewise.
+ * testsuite/27_io/basic_filebuf/sputbackc/char/1.cc: Likewise.
+ * testsuite/27_io/basic_filebuf/sputc/char/1.cc: Likewise.
+ * testsuite/27_io/basic_filebuf/sputn/char/1.cc: Likewise.
+ * testsuite/27_io/basic_filebuf/sungetc/char/1.cc: Likewise.
+
2003-04-12 Paolo Carlini <pcarlini at unitus dot it>
* include/ext/stdio_filebuf.h
basic_filebuf<_CharT, _Traits>::
_M_allocate_internal_buffer()
{
- if (!this->_M_buf && this->_M_buf_size_opt)
+ if (!this->_M_buf && this->_M_buf_size)
{
- this->_M_buf_size = this->_M_buf_size_opt;
-
// Allocate internal buffer.
this->_M_buf = new char_type[this->_M_buf_size];
_M_buf_allocated = true;
setbuf(char_type* __s, streamsize __n)
{
if (!this->is_open() && __s == 0 && __n == 0)
- this->_M_buf_size_opt = 0;
+ this->_M_buf_size = 0;
else if (__s && __n)
{
// This is implementation-defined behavior, and assumes
// Step 2: Use the external array.
this->_M_buf = __s;
- this->_M_buf_size_opt = this->_M_buf_size = __n;
+ this->_M_buf_size = __n;
// Consistently set the end of buffer pointer.
this->_M_out_end = this->_M_buf + this->_M_buf_size;
_M_set_indeterminate();
if (__builtin_expect(__testeof, false))
return traits_type::not_eof(__c);
- // In virtue of DR 169 (TC) we are allowed to grow more than
- // one char the first time and also...
- __size_type __len = std::max(__size_type(_M_string.capacity() + 1),
- this->_M_buf_size_opt);
+ // NB: Start ostringstream buffers at 512 chars. This is an
+ // experimental value (pronounced "arbitrary" in some of the
+ // hipper english-speaking countries), and can be changed to
+ // suit particular needs.
+ __size_type __len = std::max(__size_type(_M_string.capacity() + 1),
+ __size_type(512));
bool __testput = this->_M_out_cur < this->_M_out_end;
if (__builtin_expect(!__testput && __len > _M_string.max_size(), false))
return traits_type::eof();
{
// Force-allocate, re-sync.
_M_string = this->str();
- // ... the next time. That's easy to implement thanks to the
- // exponential growth policy builtin into basic_string.
+ // In virtue of DR 169 (TC) we are allowed to grow more than
+ // one char. That's easy to implement thanks to the exponential
+ // growth policy builtin into basic_string.
_M_string.reserve(__len);
_M_really_sync(const_cast<char_type*>(_M_string.data()),
this->_M_in_cur - this->_M_in_beg,
typedef typename _Traits::off_type off_type;
streamsize __ret = 0;
- streamsize __bufsize = __sbin->in_avail();
+ streamsize __in_avail = __sbin->in_avail();
streamsize __xtrct;
- const off_type __size_opt =
- __sbin->_M_buf_size_opt > 0 ? __sbin->_M_buf_size_opt : 1;
+ const off_type __buf_size =
+ __sbin->_M_buf_size > 0 ? __sbin->_M_buf_size : 1;
try
{
- while (__bufsize != -1)
+ while (__in_avail != -1)
{
- if (__bufsize != 0 && __sbin->gptr() != NULL
- && __sbin->gptr() + __bufsize <= __sbin->egptr())
+ if (__in_avail != 0 && __sbin->gptr()
+ && __sbin->gptr() + __in_avail <= __sbin->egptr())
{
- __xtrct = __sbout->sputn(__sbin->gptr(), __bufsize);
+ __xtrct = __sbout->sputn(__sbin->gptr(), __in_avail);
__ret += __xtrct;
__sbin->_M_in_cur_move(__xtrct);
- if (__xtrct != __bufsize)
+ if (__xtrct != __in_avail)
break;
}
else
{
streamsize __charsread;
const streamsize __size =
- std::min(__size_opt, off_type(__sbout->_M_out_end -
+ std::min(__buf_size, off_type(__sbout->_M_out_end -
__sbout->_M_out_cur));
if (__size > 1)
{
}
if (_Traits::eq_int_type(__sbin->sgetc(), _Traits::eof()))
break;
- __bufsize = __sbin->in_avail();
+ __in_avail = __sbin->in_avail();
}
}
catch(exception& __fail)
// Specify not to use an allocated buffer.
this->_M_buf = _M_unbuf;
this->_M_buf_size = __size;
- this->_M_buf_size_opt = 0;
}
else
{
- this->_M_buf_size_opt = __size;
+ this->_M_buf_size = __size;
_M_allocate_internal_buffer();
}
_M_set_indeterminate();
// Specify not to use an allocated buffer.
this->_M_buf = _M_unbuf;
this->_M_buf_size = __size;
- this->_M_buf_size_opt = 0;
}
else
{
- this->_M_buf_size_opt = __size;
+ this->_M_buf_size = __size;
_M_allocate_internal_buffer();
}
_M_set_indeterminate();
void
_M_stringbuf_init(ios_base::openmode __mode)
{
- // NB: Start ostringstream buffers at 512 bytes. This is an
- // experimental value (pronounced "arbitrary" in some of the
- // hipper english-speaking countries), and can be changed to
- // suit particular needs.
- this->_M_buf_size_opt = 512;
this->_M_mode = __mode;
-
+
__size_type __len = 0;
if (this->_M_mode & (ios_base::ate | ios_base::app))
__len = _M_string.size();
// Step 2: Use the external array.
this->_M_buf = __s;
- this->_M_buf_size_opt = this->_M_buf_size = __n;
+ this->_M_buf_size = __n;
_M_really_sync(__s, 0, 0);
}
return this;
/**
* @if maint
- * Actual size of allocated internal buffer, in bytes. Unused
- * for sstreams, which have readily available _M_string.capacity().
+ * Actual size of allocated internal buffer. Unused for sstreams,
+ * which have readily available _M_string.capacity().
* @endif
*/
size_t _M_buf_size;
- /**
- * @if maint
- * Optimal or preferred size of internal buffer, in bytes.
- * @endif
- */
- size_t _M_buf_size_opt;
-
/**
* @if maint
* True iff _M_in_* and _M_out_* buffers should always point to
{
_M_buf_unified = false;
_M_buf_size = 0;
- _M_buf_size_opt = 0;
_M_mode = ios_base::openmode(0);
}
* - this is not an error
*/
basic_streambuf()
- : _M_buf(NULL), _M_buf_size(0), _M_buf_size_opt(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_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)
{
public:
void
- set_size(int_type __size) { _M_buf_size_opt = __size; }
+ set_size(int_type __size) { _M_buf_size = __size; }
};
derived_filebuf fb_01; // in
{
public:
void
- set_size(int_type __size) { _M_buf_size_opt = __size; }
+ set_size(int_type __size) { _M_buf_size = __size; }
};
derived_filebuf fb_01; // in
{
public:
void
- set_size(int_type __size) { _M_buf_size_opt = __size; }
+ set_size(int_type __size) { _M_buf_size = __size; }
};
derived_filebuf fb_01; // in
{
public:
void
- set_size(int_type __size) { _M_buf_size_opt = __size; }
+ set_size(int_type __size) { _M_buf_size = __size; }
};
derived_filebuf fb_03; // in | out
{
public:
void
- set_size(int_type __size) { _M_buf_size_opt = __size; }
+ set_size(int_type __size) { _M_buf_size = __size; }
};
derived_filebuf fb_03; // in | out
{
public:
void
- set_size(int_type __size) { _M_buf_size_opt = __size; }
+ set_size(int_type __size) { _M_buf_size = __size; }
};
derived_filebuf fb_01; // in
{
public:
void
- set_size(int_type __size) { _M_buf_size_opt = __size; }
+ set_size(int_type __size) { _M_buf_size = __size; }
};
derived_filebuf fb_01; // in
{
public:
void
- set_size(int_type __size) { _M_buf_size_opt = __size; }
+ set_size(int_type __size) { _M_buf_size = __size; }
};
derived_filebuf fb_01; // in
{
public:
void
- set_size(int_type __size) { _M_buf_size_opt = __size; }
+ set_size(int_type __size) { _M_buf_size = __size; }
};
derived_filebuf fb_01; // in
{
public:
void
- set_size(int_type __size) { _M_buf_size_opt = __size; }
+ set_size(int_type __size) { _M_buf_size = __size; }
};
derived_filebuf fb_01; // in
{
public:
void
- set_size(int_type __size) { _M_buf_size_opt = __size; }
+ set_size(int_type __size) { _M_buf_size = __size; }
};
derived_filebuf fb_01; // in
{
public:
void
- set_size(int_type __size) { _M_buf_size_opt = __size; }
+ set_size(int_type __size) { _M_buf_size = __size; }
};
derived_filebuf fb_01; // in