Remove _M_buf_size_opt, use directly _M_buf_size instead.
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. From-SVN: r65518
This commit is contained in:
parent
2bd020439a
commit
7ef9fd85ef
19 changed files with 69 additions and 57 deletions
|
@ -1,3 +1,29 @@
|
||||||
|
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>
|
2003-04-12 Paolo Carlini <pcarlini at unitus dot it>
|
||||||
|
|
||||||
* include/ext/stdio_filebuf.h
|
* include/ext/stdio_filebuf.h
|
||||||
|
|
|
@ -44,10 +44,8 @@ namespace std
|
||||||
basic_filebuf<_CharT, _Traits>::
|
basic_filebuf<_CharT, _Traits>::
|
||||||
_M_allocate_internal_buffer()
|
_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.
|
// Allocate internal buffer.
|
||||||
this->_M_buf = new char_type[this->_M_buf_size];
|
this->_M_buf = new char_type[this->_M_buf_size];
|
||||||
_M_buf_allocated = true;
|
_M_buf_allocated = true;
|
||||||
|
@ -416,7 +414,7 @@ namespace std
|
||||||
setbuf(char_type* __s, streamsize __n)
|
setbuf(char_type* __s, streamsize __n)
|
||||||
{
|
{
|
||||||
if (!this->is_open() && __s == 0 && __n == 0)
|
if (!this->is_open() && __s == 0 && __n == 0)
|
||||||
this->_M_buf_size_opt = 0;
|
this->_M_buf_size = 0;
|
||||||
else if (__s && __n)
|
else if (__s && __n)
|
||||||
{
|
{
|
||||||
// This is implementation-defined behavior, and assumes
|
// This is implementation-defined behavior, and assumes
|
||||||
|
@ -429,7 +427,7 @@ namespace std
|
||||||
|
|
||||||
// Step 2: Use the external array.
|
// Step 2: Use the external array.
|
||||||
this->_M_buf = __s;
|
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.
|
// Consistently set the end of buffer pointer.
|
||||||
this->_M_out_end = this->_M_buf + this->_M_buf_size;
|
this->_M_out_end = this->_M_buf + this->_M_buf_size;
|
||||||
_M_set_indeterminate();
|
_M_set_indeterminate();
|
||||||
|
|
|
@ -88,10 +88,12 @@ namespace std
|
||||||
if (__builtin_expect(__testeof, false))
|
if (__builtin_expect(__testeof, false))
|
||||||
return traits_type::not_eof(__c);
|
return traits_type::not_eof(__c);
|
||||||
|
|
||||||
// In virtue of DR 169 (TC) we are allowed to grow more than
|
// NB: Start ostringstream buffers at 512 chars. This is an
|
||||||
// one char the first time and also...
|
// experimental value (pronounced "arbitrary" in some of the
|
||||||
__size_type __len = std::max(__size_type(_M_string.capacity() + 1),
|
// hipper english-speaking countries), and can be changed to
|
||||||
this->_M_buf_size_opt);
|
// 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;
|
bool __testput = this->_M_out_cur < this->_M_out_end;
|
||||||
if (__builtin_expect(!__testput && __len > _M_string.max_size(), false))
|
if (__builtin_expect(!__testput && __len > _M_string.max_size(), false))
|
||||||
return traits_type::eof();
|
return traits_type::eof();
|
||||||
|
@ -102,8 +104,9 @@ namespace std
|
||||||
{
|
{
|
||||||
// Force-allocate, re-sync.
|
// Force-allocate, re-sync.
|
||||||
_M_string = this->str();
|
_M_string = this->str();
|
||||||
// ... the next time. That's easy to implement thanks to the
|
// In virtue of DR 169 (TC) we are allowed to grow more than
|
||||||
// exponential growth policy builtin into basic_string.
|
// one char. That's easy to implement thanks to the exponential
|
||||||
|
// growth policy builtin into basic_string.
|
||||||
_M_string.reserve(__len);
|
_M_string.reserve(__len);
|
||||||
_M_really_sync(const_cast<char_type*>(_M_string.data()),
|
_M_really_sync(const_cast<char_type*>(_M_string.data()),
|
||||||
this->_M_in_cur - this->_M_in_beg,
|
this->_M_in_cur - this->_M_in_beg,
|
||||||
|
|
|
@ -192,29 +192,29 @@ namespace std
|
||||||
typedef typename _Traits::off_type off_type;
|
typedef typename _Traits::off_type off_type;
|
||||||
|
|
||||||
streamsize __ret = 0;
|
streamsize __ret = 0;
|
||||||
streamsize __bufsize = __sbin->in_avail();
|
streamsize __in_avail = __sbin->in_avail();
|
||||||
streamsize __xtrct;
|
streamsize __xtrct;
|
||||||
const off_type __size_opt =
|
const off_type __buf_size =
|
||||||
__sbin->_M_buf_size_opt > 0 ? __sbin->_M_buf_size_opt : 1;
|
__sbin->_M_buf_size > 0 ? __sbin->_M_buf_size : 1;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
while (__bufsize != -1)
|
while (__in_avail != -1)
|
||||||
{
|
{
|
||||||
if (__bufsize != 0 && __sbin->gptr() != NULL
|
if (__in_avail != 0 && __sbin->gptr()
|
||||||
&& __sbin->gptr() + __bufsize <= __sbin->egptr())
|
&& __sbin->gptr() + __in_avail <= __sbin->egptr())
|
||||||
{
|
{
|
||||||
__xtrct = __sbout->sputn(__sbin->gptr(), __bufsize);
|
__xtrct = __sbout->sputn(__sbin->gptr(), __in_avail);
|
||||||
__ret += __xtrct;
|
__ret += __xtrct;
|
||||||
__sbin->_M_in_cur_move(__xtrct);
|
__sbin->_M_in_cur_move(__xtrct);
|
||||||
if (__xtrct != __bufsize)
|
if (__xtrct != __in_avail)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
streamsize __charsread;
|
streamsize __charsread;
|
||||||
const streamsize __size =
|
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));
|
__sbout->_M_out_cur));
|
||||||
if (__size > 1)
|
if (__size > 1)
|
||||||
{
|
{
|
||||||
|
@ -246,7 +246,7 @@ namespace std
|
||||||
}
|
}
|
||||||
if (_Traits::eq_int_type(__sbin->sgetc(), _Traits::eof()))
|
if (_Traits::eq_int_type(__sbin->sgetc(), _Traits::eof()))
|
||||||
break;
|
break;
|
||||||
__bufsize = __sbin->in_avail();
|
__in_avail = __sbin->in_avail();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(exception& __fail)
|
catch(exception& __fail)
|
||||||
|
|
|
@ -129,11 +129,10 @@ namespace __gnu_cxx
|
||||||
// Specify not to use an allocated buffer.
|
// Specify not to use an allocated buffer.
|
||||||
this->_M_buf = _M_unbuf;
|
this->_M_buf = _M_unbuf;
|
||||||
this->_M_buf_size = __size;
|
this->_M_buf_size = __size;
|
||||||
this->_M_buf_size_opt = 0;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->_M_buf_size_opt = __size;
|
this->_M_buf_size = __size;
|
||||||
_M_allocate_internal_buffer();
|
_M_allocate_internal_buffer();
|
||||||
}
|
}
|
||||||
_M_set_indeterminate();
|
_M_set_indeterminate();
|
||||||
|
@ -154,11 +153,10 @@ namespace __gnu_cxx
|
||||||
// Specify not to use an allocated buffer.
|
// Specify not to use an allocated buffer.
|
||||||
this->_M_buf = _M_unbuf;
|
this->_M_buf = _M_unbuf;
|
||||||
this->_M_buf_size = __size;
|
this->_M_buf_size = __size;
|
||||||
this->_M_buf_size_opt = 0;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->_M_buf_size_opt = __size;
|
this->_M_buf_size = __size;
|
||||||
_M_allocate_internal_buffer();
|
_M_allocate_internal_buffer();
|
||||||
}
|
}
|
||||||
_M_set_indeterminate();
|
_M_set_indeterminate();
|
||||||
|
|
|
@ -177,13 +177,8 @@ namespace std
|
||||||
void
|
void
|
||||||
_M_stringbuf_init(ios_base::openmode __mode)
|
_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;
|
this->_M_mode = __mode;
|
||||||
|
|
||||||
__size_type __len = 0;
|
__size_type __len = 0;
|
||||||
if (this->_M_mode & (ios_base::ate | ios_base::app))
|
if (this->_M_mode & (ios_base::ate | ios_base::app))
|
||||||
__len = _M_string.size();
|
__len = _M_string.size();
|
||||||
|
@ -235,7 +230,7 @@ namespace std
|
||||||
|
|
||||||
// Step 2: Use the external array.
|
// Step 2: Use the external array.
|
||||||
this->_M_buf = __s;
|
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);
|
_M_really_sync(__s, 0, 0);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -172,19 +172,12 @@ namespace std
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @if maint
|
* @if maint
|
||||||
* Actual size of allocated internal buffer, in bytes. Unused
|
* Actual size of allocated internal buffer. Unused for sstreams,
|
||||||
* for sstreams, which have readily available _M_string.capacity().
|
* which have readily available _M_string.capacity().
|
||||||
* @endif
|
* @endif
|
||||||
*/
|
*/
|
||||||
size_t _M_buf_size;
|
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
|
* @if maint
|
||||||
* True iff _M_in_* and _M_out_* buffers should always point to
|
* True iff _M_in_* and _M_out_* buffers should always point to
|
||||||
|
@ -340,7 +333,6 @@ namespace std
|
||||||
{
|
{
|
||||||
_M_buf_unified = false;
|
_M_buf_unified = false;
|
||||||
_M_buf_size = 0;
|
_M_buf_size = 0;
|
||||||
_M_buf_size_opt = 0;
|
|
||||||
_M_mode = ios_base::openmode(0);
|
_M_mode = ios_base::openmode(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,9 +544,9 @@ namespace std
|
||||||
* - this is not an error
|
* - this is not an error
|
||||||
*/
|
*/
|
||||||
basic_streambuf()
|
basic_streambuf()
|
||||||
: _M_buf(NULL), _M_buf_size(0), _M_buf_size_opt(BUFSIZ),
|
: _M_buf(NULL), _M_buf_size(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_beg(0), _M_out_cur(0), _M_out_end(0), _M_out_lim(0),
|
_M_out_cur(0), _M_out_end(0), _M_out_lim(0),
|
||||||
_M_mode(ios_base::openmode(0)), _M_buf_locale(locale()),
|
_M_mode(ios_base::openmode(0)), _M_buf_locale(locale()),
|
||||||
_M_pback_cur_save(0), _M_pback_end_save(0),
|
_M_pback_cur_save(0), _M_pback_end_save(0),
|
||||||
_M_pback_init(false)
|
_M_pback_init(false)
|
||||||
|
|
|
@ -54,7 +54,7 @@ class derived_filebuf: public std::filebuf
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void
|
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
|
derived_filebuf fb_01; // in
|
||||||
|
|
|
@ -54,7 +54,7 @@ class derived_filebuf: public std::filebuf
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void
|
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
|
derived_filebuf fb_01; // in
|
||||||
|
|
|
@ -41,7 +41,7 @@ class derived_filebuf: public std::filebuf
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void
|
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
|
derived_filebuf fb_01; // in
|
||||||
|
|
|
@ -39,7 +39,7 @@ class derived_filebuf: public std::filebuf
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void
|
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
|
derived_filebuf fb_03; // in | out
|
||||||
|
|
|
@ -39,7 +39,7 @@ class derived_filebuf: public std::filebuf
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void
|
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
|
derived_filebuf fb_03; // in | out
|
||||||
|
|
|
@ -54,7 +54,7 @@ class derived_filebuf: public std::filebuf
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void
|
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
|
derived_filebuf fb_01; // in
|
||||||
|
|
|
@ -41,7 +41,7 @@ class derived_filebuf: public std::filebuf
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void
|
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
|
derived_filebuf fb_01; // in
|
||||||
|
|
|
@ -41,7 +41,7 @@ class derived_filebuf: public std::filebuf
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void
|
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
|
derived_filebuf fb_01; // in
|
||||||
|
|
|
@ -54,7 +54,7 @@ class derived_filebuf: public std::filebuf
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void
|
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
|
derived_filebuf fb_01; // in
|
||||||
|
|
|
@ -54,7 +54,7 @@ class derived_filebuf: public std::filebuf
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void
|
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
|
derived_filebuf fb_01; // in
|
||||||
|
|
|
@ -54,7 +54,7 @@ class derived_filebuf: public std::filebuf
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void
|
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
|
derived_filebuf fb_01; // in
|
||||||
|
|
|
@ -54,7 +54,7 @@ class derived_filebuf: public std::filebuf
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void
|
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
|
derived_filebuf fb_01; // in
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue