This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[v3] Don't use _M_out_lim in filebuf, etc...
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 24 Jun 2003 15:53:08 +0200
- Subject: [v3] Don't use _M_out_lim in filebuf, etc...
Hi,
the below completes the first stage of the project started a while ago.
Expect some instabilities for a while...
Tested x86-linux, reviewed by Benjamin.
Paolo.
//////////
2003-06-24 Paolo Carlini <pcarlini@unitus.it>
Nathan C. Myers <ncm-nospam@cantrip.org>
* include/std/std_fstream.h (_M_filepos): Remove.
(_M_reading, _M_writing): New, encode the various I/O modes:
'read', 'write' and 'uncommitted'.
(sync): If there is something to flush, do it, then go to
'uncommitted' mode.
* include/bits/fstream.tcc (_M_set_buffer): Overhaul to deal
with three different cases: __off > 0 (upon underflow),
__off == 0 (upon overflow), __off == -1 (upon open, setbuf,
seekoff/pos).
(_M_underflow): Don't call overflow, set _M_reading to true
on success, tweak.
(pbackfail): Set _M_reading to true on pback creation, tweak.
(overflow): Don't seek, deal with overflow in 'uncommitted' mode,
set _M_writing to true on success, tweak.
(seekoff): Simplify, set _M_reading, _M_writing to false, call
_M_set_buffer(-1) ('uncommitted').
(open, close, setbuf): Set _M_reading, _M_writing to false and
call _M_set_buffer(-1), tweak.
(basic_filebuf): Don't set _M_buf_unified.
(_M_destroy_internal_buffer): Don't call setg and setp.
* include/ext/stdio_filebuf.h (stdio_filebuf): Use _M_reading,
_M_writing and _M_set_buffer(-1).
* include/std/std_streambuf.h (_M_move_out_cur, _M_move_in_cur,
_M_out_lim, _M_buf_unified): Remove.
(basic_streambuf): Don't set _M_out_lim and _M_buf_unified.
(setp): Don't set _M_out_lim.
* testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc: Fix for
the new logic ('read', 'write' and 'uncommitted' modes): e.g.,
upon open the mode is 'uncommitted' and therefore the put area
pointers are null.
* testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc: Ditto.
* testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc: Ditto.
* testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc: Ditto.
* testsuite/27_io/basic_filebuf/setbuf/char/1.cc: Ditto.
* testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc: Ditto.
* testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc: Ditto.
* testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc: Ditto.
* testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc: Ditto.
* testsuite/27_io/basic_filebuf/snextc/char/1-io.cc: Ditto.
* testsuite/27_io/basic_filebuf/snextc/char/1-out.cc: Ditto.
* testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc: Ditto.
* testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc: Ditto.
* testsuite/27_io/basic_filebuf/sputc/char/1-io.cc: Ditto.
* testsuite/27_io/basic_filebuf/sputc/char/1-out.cc: Ditto.
* testsuite/27_io/basic_filebuf/sputc/char/9701-2.cc: Ditto.
* testsuite/27_io/basic_filebuf/sputn/char/1-io.cc: Ditto.
* testsuite/27_io/basic_filebuf/sputn/char/1-out.cc: Ditto.
* testsuite/27_io/basic_filebuf/sputn/char/9701-1.cc: Ditto.
* testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc: Ditto.
* testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc: Ditto.
* include/bits/fstream.tcc (showmanyc): Use only the
documented derivation interface to basic_streambuf (gptr(),
setg(), etc.) to work right with user specializations.
* include/bits/streambuf.tcc (sbumpc, sputbackc, sungetc,
sputc, xsgetn, xsputn, __copy_streambufs): Likewise.
* include/std/std_streambuf.h (in_avail, sgetc, uflow, stossc):
Likewise.
* include/std/std_fstream.h (_M_create_pback, _M_destroy_pback,
xsgetn): Likewise.
diff -cprN libstdc++-v3-orig/include/bits/fstream.tcc libstdc++-v3/include/bits/fstream.tcc
*** libstdc++-v3-orig/include/bits/fstream.tcc Wed Jun 18 21:13:18 2003
--- libstdc++-v3/include/bits/fstream.tcc Mon Jun 23 21:27:42 2003
*************** namespace std
*** 63,70 ****
delete [] this->_M_buf;
this->_M_buf = NULL;
_M_buf_allocated = false;
- this->setg(NULL, NULL, NULL);
- this->setp(NULL, NULL);
}
}
--- 63,68 ----
*************** namespace std
*** 73,82 ****
basic_filebuf() : __streambuf_type(), _M_file(&_M_lock),
_M_state_cur(__state_type()), _M_state_beg(__state_type()),
_M_buf(NULL), _M_buf_size(BUFSIZ), _M_buf_allocated(false),
! _M_last_overflowed(false), _M_filepos(0), _M_pback_cur_save(0),
! _M_pback_end_save(0), _M_pback_init(false), _M_codecvt(0)
{
- this->_M_buf_unified = true;
if (has_facet<__codecvt_type>(this->_M_buf_locale))
_M_codecvt = &use_facet<__codecvt_type>(this->_M_buf_locale);
}
--- 71,80 ----
basic_filebuf() : __streambuf_type(), _M_file(&_M_lock),
_M_state_cur(__state_type()), _M_state_beg(__state_type()),
_M_buf(NULL), _M_buf_size(BUFSIZ), _M_buf_allocated(false),
! _M_reading(false), _M_writing(false), _M_last_overflowed(false),
! _M_pback_cur_save(0), _M_pback_end_save(0), _M_pback_init(false),
! _M_codecvt(0)
{
if (has_facet<__codecvt_type>(this->_M_buf_locale))
_M_codecvt = &use_facet<__codecvt_type>(this->_M_buf_locale);
}
*************** namespace std
*** 95,102 ****
_M_allocate_internal_buffer();
this->_M_mode = __mode;
! // Setup initial position of buffer.
! _M_set_buffer(0);
if ((__mode & ios_base::ate)
&& this->seekoff(0, ios_base::end, __mode) < 0)
--- 93,102 ----
_M_allocate_internal_buffer();
this->_M_mode = __mode;
! // Setup initial buffer to 'uncommitted' mode.
! _M_reading = false;
! _M_writing = false;
! _M_set_buffer(-1);
if ((__mode & ios_base::ate)
&& this->seekoff(0, ios_base::end, __mode) < 0)
*************** namespace std
*** 120,128 ****
bool __testfail = false;
try
{
! const bool __testput = this->_M_out_beg < this->_M_out_lim;
!
! if (__testput
&& traits_type::eq_int_type(this->overflow(),
traits_type::eof()))
__testfail = true;
--- 120,126 ----
bool __testfail = false;
try
{
! if (this->pbase() < this->pptr()
&& traits_type::eq_int_type(this->overflow(),
traits_type::eof()))
__testfail = true;
*************** namespace std
*** 144,149 ****
--- 142,150 ----
this->_M_mode = ios_base::openmode(0);
this->_M_pback_init = false;
_M_destroy_internal_buffer();
+ _M_reading = false;
+ _M_writing = false;
+ _M_set_buffer(-1);
if (!_M_file.close())
__testfail = true;
*************** namespace std
*** 167,173 ****
{
// For a stateful encoding (-1) the pending sequence might be just
// shift and unshift prefixes with no actual character.
! __ret = this->_M_in_end - this->_M_in_cur;
if (__check_facet(_M_codecvt).encoding() >= 0)
__ret += _M_file.showmanyc() / _M_codecvt->max_length();
}
--- 168,174 ----
{
// For a stateful encoding (-1) the pending sequence might be just
// shift and unshift prefixes with no actual character.
! __ret = this->egptr() - this->gptr();
if (__check_facet(_M_codecvt).encoding() >= 0)
__ret += _M_file.showmanyc() / _M_codecvt->max_length();
}
*************** namespace std
*** 185,210 ****
const bool __testin = this->_M_mode & ios_base::in;
const bool __testout = this->_M_mode & ios_base::out;
! if (__testin)
{
// Check for pback madness, and if so swich back to the
// normal buffers and jet outta here before expensive
// fileops happen...
_M_destroy_pback();
! if (this->_M_in_cur < this->_M_in_end)
{
! __ret = traits_type::to_int_type(*this->_M_in_cur);
if (__bump)
! _M_move_in_cur(1);
return __ret;
}
- // Sync internal and external buffers.
- if (__testout && this->_M_out_beg < this->_M_out_lim
- && traits_type::eq_int_type(this->overflow(), __ret))
- return __ret;
-
// Get and convert input sequence.
const size_t __buflen = this->_M_buf_size > 1
? this->_M_buf_size - 1 : 1;
--- 186,206 ----
const bool __testin = this->_M_mode & ios_base::in;
const bool __testout = this->_M_mode & ios_base::out;
! if (__testin && !_M_writing)
{
// Check for pback madness, and if so swich back to the
// normal buffers and jet outta here before expensive
// fileops happen...
_M_destroy_pback();
! if (this->gptr() < this->egptr())
{
! __ret = traits_type::to_int_type(*this->gptr());
if (__bump)
! this->gbump(1);
return __ret;
}
// Get and convert input sequence.
const size_t __buflen = this->_M_buf_size > 1
? this->_M_buf_size - 1 : 1;
*************** namespace std
*** 212,218 ****
streamsize __ilen = 0;
if (__check_facet(_M_codecvt).always_noconv())
{
! __elen = _M_file.xsgetn(reinterpret_cast<char*>(this->_M_in_beg), __buflen);
__ilen = __elen;
}
else
--- 208,214 ----
streamsize __ilen = 0;
if (__check_facet(_M_codecvt).always_noconv())
{
! __elen = _M_file.xsgetn(reinterpret_cast<char*>(this->eback()), __buflen);
__ilen = __elen;
}
else
*************** namespace std
*** 224,236 ****
char_type* __iend;
codecvt_base::result __r;
__r = _M_codecvt->in(_M_state_cur, __buf, __buf + __elen,
! __eend, this->_M_in_beg,
! this->_M_in_beg + __buflen, __iend);
if (__r == codecvt_base::ok)
! __ilen = __iend - this->_M_in_beg;
else if (__r == codecvt_base::noconv)
{
! traits_type::copy(this->_M_in_beg,
reinterpret_cast<char_type*>(__buf),
__elen);
__ilen = __elen;
--- 220,232 ----
char_type* __iend;
codecvt_base::result __r;
__r = _M_codecvt->in(_M_state_cur, __buf, __buf + __elen,
! __eend, this->eback(),
! this->eback() + __buflen, __iend);
if (__r == codecvt_base::ok)
! __ilen = __iend - this->eback();
else if (__r == codecvt_base::noconv)
{
! traits_type::copy(this->eback(),
reinterpret_cast<char_type*>(__buf),
__elen);
__ilen = __elen;
*************** namespace std
*** 246,254 ****
if (__ilen > 0)
{
_M_set_buffer(__ilen);
! __ret = traits_type::to_int_type(*this->_M_in_cur);
if (__bump)
! _M_move_in_cur(1);
}
}
_M_last_overflowed = false;
--- 242,251 ----
if (__ilen > 0)
{
_M_set_buffer(__ilen);
! _M_reading = true;
! __ret = traits_type::to_int_type(*this->gptr());
if (__bump)
! this->gbump(1);
}
}
_M_last_overflowed = false;
*************** namespace std
*** 263,269 ****
int_type __ret = traits_type::eof();
const bool __testin = this->_M_mode & ios_base::in;
! if (__testin)
{
// Remember whether the pback buffer is active, otherwise below
// we may try to store in it a second char (libstdc++/9761).
--- 260,266 ----
int_type __ret = traits_type::eof();
const bool __testin = this->_M_mode & ios_base::in;
! if (__testin && !_M_writing)
{
// Remember whether the pback buffer is active, otherwise below
// we may try to store in it a second char (libstdc++/9761).
*************** namespace std
*** 271,280 ****
const bool __testeof = traits_type::eq_int_type(__i, __ret);
int_type __tmp;
! if (this->_M_in_beg < this->_M_in_cur)
{
! _M_move_in_cur(-1);
! __tmp = traits_type::to_int_type(*this->_M_in_cur);
}
else if (this->seekoff(-1, ios_base::cur) >= 0)
{
--- 268,277 ----
const bool __testeof = traits_type::eq_int_type(__i, __ret);
int_type __tmp;
! if (this->eback() < this->gptr())
{
! this->gbump(-1);
! __tmp = traits_type::to_int_type(*this->gptr());
}
else if (this->seekoff(-1, ios_base::cur) >= 0)
{
*************** namespace std
*** 301,307 ****
else if (!__testpb)
{
_M_create_pback();
! *this->_M_in_cur = traits_type::to_char_type(__i);
__ret = __i;
}
}
--- 298,305 ----
else if (!__testpb)
{
_M_create_pback();
! _M_reading = true;
! *this->gptr() = traits_type::to_char_type(__i);
__ret = __i;
}
}
*************** namespace std
*** 318,354 ****
const bool __testeof = traits_type::eq_int_type(__c, __ret);
const bool __testout = this->_M_mode & ios_base::out;
! if (__testout)
{
! if (this->_M_out_beg < this->_M_out_lim)
{
- // Need to restore current position. The position of the
- // external byte sequence (_M_file) corresponds to
- // _M_filepos, and we need to move it to _M_out_beg for
- // the write.
- if (_M_filepos != this->_M_out_beg)
- _M_file.seekoff(this->_M_out_beg - _M_filepos, ios_base::cur);
-
// If appropriate, append the overflow char.
if (!__testeof)
! *this->_M_out_lim++ = traits_type::to_char_type(__c);
// Convert pending sequence to external representation,
// output.
! if (_M_convert_to_external(this->_M_out_beg,
! this->_M_out_lim - this->_M_out_beg)
&& (!__testeof || (__testeof && !_M_file.sync())))
{
_M_set_buffer(0);
__ret = traits_type::not_eof(__c);
}
}
else
{
// Unbuffered.
char_type __conv = traits_type::to_char_type(__c);
if (__testeof || _M_convert_to_external(&__conv, 1))
! __ret = traits_type::not_eof(__c);
}
}
_M_last_overflowed = true;
--- 316,365 ----
const bool __testeof = traits_type::eq_int_type(__c, __ret);
const bool __testout = this->_M_mode & ios_base::out;
! if (__testout && !_M_reading)
{
! if (this->pbase() < this->pptr())
{
// If appropriate, append the overflow char.
if (!__testeof)
! {
! *this->pptr() = traits_type::to_char_type(__c);
! this->pbump(1);
! }
// Convert pending sequence to external representation,
// output.
! if (_M_convert_to_external(this->pbase(),
! this->pptr() - this->pbase())
&& (!__testeof || (__testeof && !_M_file.sync())))
{
_M_set_buffer(0);
__ret = traits_type::not_eof(__c);
}
}
+ else if (this->_M_buf_size > 1)
+ {
+ // Overflow in 'uncommitted' mode: set _M_writing, set
+ // the buffer to the initial 'write' mode, and put __c
+ // into the buffer.
+ _M_set_buffer(0);
+ _M_writing = true;
+ if (!__testeof)
+ {
+ *this->pptr() = traits_type::to_char_type(__c);
+ this->pbump(1);
+ }
+ __ret = traits_type::not_eof(__c);
+ }
else
{
// Unbuffered.
char_type __conv = traits_type::to_char_type(__c);
if (__testeof || _M_convert_to_external(&__conv, 1))
! {
! _M_writing = true;
! __ret = traits_type::not_eof(__c);
! }
}
}
_M_last_overflowed = true;
*************** namespace std
*** 393,399 ****
}
else
{
! // Result == error .
__blen = 0;
}
--- 404,410 ----
}
else
{
! // Result == error.
__blen = 0;
}
*************** namespace std
*** 407,413 ****
if (__r == codecvt_base::partial)
{
const char_type* __iresume = __iend;
! streamsize __rlen = this->_M_out_lim - __iend;
__r = _M_codecvt->out(_M_state_cur, __iresume,
__iresume + __rlen, __iend, __buf,
__buf + __blen, __bend);
--- 418,424 ----
if (__r == codecvt_base::partial)
{
const char_type* __iresume = __iend;
! streamsize __rlen = this->pptr() - __iend;
__r = _M_codecvt->out(_M_state_cur, __iresume,
__iresume + __rlen, __iend, __buf,
__buf + __blen, __bend);
*************** namespace std
*** 446,452 ****
// Step 2: Use the external array.
this->_M_buf = __s;
this->_M_buf_size = __n;
! _M_set_buffer(0);
}
_M_last_overflowed = false;
return this;
--- 457,465 ----
// Step 2: Use the external array.
this->_M_buf = __s;
this->_M_buf_size = __n;
! _M_reading = false;
! _M_writing = false;
! _M_set_buffer(-1);
}
_M_last_overflowed = false;
return this;
*************** namespace std
*** 473,513 ****
// Ditch any pback buffers to avoid confusion.
_M_destroy_pback();
! if (__way != ios_base::cur || __off != 0)
! {
! // Sync the internal and external streams.
! const bool __testget = this->_M_in_beg < this->_M_in_end;
! const bool __testput = this->_M_out_beg < this->_M_out_lim;
! off_type __computed_off = __width * __off;
!
! if (__testput || _M_last_overflowed)
! {
! // Part one: update the output sequence.
! this->sync();
!
! // Part two: output unshift sequence.
! _M_output_unshift();
! }
! else if (__testget && __way == ios_base::cur)
! __computed_off += this->_M_in_cur - _M_filepos;
!
! // Return pos_type(off_type(-1)) in case of failure.
! __ret = _M_file.seekoff(__computed_off, __way, __mode);
! _M_set_buffer(0);
! }
! else
{
! // NB: Need to do this in case _M_file in indeterminate
! // state, ie _M_file._offset == -1
! pos_type __tmp = _M_file.seekoff(__off, ios_base::cur, __mode);
! if (__tmp >= 0)
! {
! // Seek successful.
! __ret = __tmp;
! __ret += std::max(this->_M_out_cur, this->_M_in_cur)
! - _M_filepos;
! }
}
}
_M_last_overflowed = false;
return __ret;
--- 486,511 ----
// Ditch any pback buffers to avoid confusion.
_M_destroy_pback();
! // Sync the internal and external streams.
! off_type __computed_off = __width * __off;
!
! if (this->pbase() < this->pptr()
! || _M_last_overflowed)
{
! // Part one: update the output sequence.
! this->sync();
!
! // Part two: output unshift sequence.
! _M_output_unshift();
}
+ else if (_M_reading && __way == ios_base::cur)
+ __computed_off += this->gptr() - this->egptr();
+
+ // Return pos_type(off_type(-1)) in case of failure.
+ __ret = _M_file.seekoff(__computed_off, __way, __mode);
+ _M_reading = false;
+ _M_writing = false;
+ _M_set_buffer(-1);
}
_M_last_overflowed = false;
return __ret;
diff -cprN libstdc++-v3-orig/include/bits/streambuf.tcc libstdc++-v3/include/bits/streambuf.tcc
*** libstdc++-v3-orig/include/bits/streambuf.tcc Wed Jun 11 00:00:42 2003
--- libstdc++-v3/include/bits/streambuf.tcc Mon Jun 23 18:56:49 2003
*************** namespace std
*** 45,54 ****
sbumpc()
{
int_type __ret;
! if (_M_in_cur < _M_in_end)
{
! __ret = traits_type::to_int_type(*this->_M_in_cur);
! _M_move_in_cur(1);
}
else
__ret = this->uflow();
--- 45,54 ----
sbumpc()
{
int_type __ret;
! if (this->gptr() < this->egptr())
{
! __ret = traits_type::to_int_type(*this->gptr());
! this->gbump(1);
}
else
__ret = this->uflow();
*************** namespace std
*** 61,73 ****
sputbackc(char_type __c)
{
int_type __ret;
! const bool __testpos = _M_in_beg < _M_in_cur;
! if (!__testpos || !traits_type::eq(__c, this->_M_in_cur[-1]))
__ret = this->pbackfail(traits_type::to_int_type(__c));
else
{
! _M_move_in_cur(-1);
! __ret = traits_type::to_int_type(*this->_M_in_cur);
}
return __ret;
}
--- 61,73 ----
sputbackc(char_type __c)
{
int_type __ret;
! const bool __testpos = this->eback() < this->gptr();
! if (!__testpos || !traits_type::eq(__c, this->gptr()[-1]))
__ret = this->pbackfail(traits_type::to_int_type(__c));
else
{
! this->gbump(-1);
! __ret = traits_type::to_int_type(*this->gptr());
}
return __ret;
}
*************** namespace std
*** 78,87 ****
sungetc()
{
int_type __ret;
! if (_M_in_beg < _M_in_cur)
{
! _M_move_in_cur(-1);
! __ret = traits_type::to_int_type(*_M_in_cur);
}
else
__ret = this->pbackfail();
--- 78,87 ----
sungetc()
{
int_type __ret;
! if (this->eback() < this->gptr())
{
! this->gbump(-1);
! __ret = traits_type::to_int_type(*this->gptr());
}
else
__ret = this->pbackfail();
*************** namespace std
*** 94,103 ****
sputc(char_type __c)
{
int_type __ret;
! if (_M_out_cur < _M_out_end)
{
! *_M_out_cur = __c;
! _M_move_out_cur(1);
__ret = traits_type::to_int_type(__c);
}
else
--- 94,103 ----
sputc(char_type __c)
{
int_type __ret;
! if (this->pptr() < this->epptr())
{
! *this->pptr() = __c;
! this->pbump(1);
__ret = traits_type::to_int_type(__c);
}
else
*************** namespace std
*** 113,127 ****
streamsize __ret = 0;
while (__ret < __n)
{
! const size_t __buf_len = _M_in_end - _M_in_cur;
if (__buf_len)
{
const size_t __remaining = __n - __ret;
const size_t __len = std::min(__buf_len, __remaining);
! traits_type::copy(__s, _M_in_cur, __len);
__ret += __len;
__s += __len;
! _M_move_in_cur(__len);
}
if (__ret < __n)
--- 113,127 ----
streamsize __ret = 0;
while (__ret < __n)
{
! const size_t __buf_len = this->egptr() - this->gptr();
if (__buf_len)
{
const size_t __remaining = __n - __ret;
const size_t __len = std::min(__buf_len, __remaining);
! traits_type::copy(__s, this->gptr(), __len);
__ret += __len;
__s += __len;
! this->gbump(__len);
}
if (__ret < __n)
*************** namespace std
*** 147,161 ****
streamsize __ret = 0;
while (__ret < __n)
{
! const size_t __buf_len = _M_out_end - _M_out_cur;
if (__buf_len)
{
const size_t __remaining = __n - __ret;
const size_t __len = std::min(__buf_len, __remaining);
! traits_type::copy(_M_out_cur, __s, __len);
__ret += __len;
__s += __len;
! _M_move_out_cur(__len);
}
if (__ret < __n)
--- 147,161 ----
streamsize __ret = 0;
while (__ret < __n)
{
! const size_t __buf_len = this->epptr() - this->pptr();
if (__buf_len)
{
const size_t __remaining = __n - __ret;
const size_t __len = std::min(__buf_len, __remaining);
! traits_type::copy(this->pptr(), __s, __len);
__ret += __len;
__s += __len;
! this->pbump(__len);
}
if (__ret < __n)
*************** namespace std
*** 189,200 ****
typename _Traits::int_type __c = __sbin->sgetc();
while (!_Traits::eq_int_type(__c, _Traits::eof()))
{
! const size_t __n = __sbin->_M_in_end - __sbin->_M_in_cur;
if (__n > 1)
{
! const size_t __wrote = __sbout->sputn(__sbin->_M_in_cur,
__n);
! __sbin->_M_move_in_cur(__wrote);
__ret += __wrote;
if (__wrote < __n)
break;
--- 189,200 ----
typename _Traits::int_type __c = __sbin->sgetc();
while (!_Traits::eq_int_type(__c, _Traits::eof()))
{
! const size_t __n = __sbin->egptr() - __sbin->gptr();
if (__n > 1)
{
! const size_t __wrote = __sbout->sputn(__sbin->gptr(),
__n);
! __sbin->gbump(__wrote);
__ret += __wrote;
if (__wrote < __n)
break;
diff -cprN libstdc++-v3-orig/include/ext/stdio_filebuf.h libstdc++-v3/include/ext/stdio_filebuf.h
*** libstdc++-v3-orig/include/ext/stdio_filebuf.h Fri Jun 6 17:50:27 2003
--- libstdc++-v3/include/ext/stdio_filebuf.h Sun Jun 22 23:43:46 2003
*************** namespace __gnu_cxx
*** 127,133 ****
this->_M_mode = __mode;
this->_M_buf_size = __size;
_M_allocate_internal_buffer();
! _M_set_buffer(0);
}
}
--- 127,135 ----
this->_M_mode = __mode;
this->_M_buf_size = __size;
_M_allocate_internal_buffer();
! this->_M_reading = false;
! this->_M_writing = false;
! _M_set_buffer(-1);
}
}
*************** namespace __gnu_cxx
*** 142,148 ****
this->_M_mode = __mode;
this->_M_buf_size = __size;
_M_allocate_internal_buffer();
! _M_set_buffer(0);
}
}
} // namespace __gnu_cxx
--- 144,152 ----
this->_M_mode = __mode;
this->_M_buf_size = __size;
_M_allocate_internal_buffer();
! this->_M_reading = false;
! this->_M_writing = false;
! _M_set_buffer(-1);
}
}
} // namespace __gnu_cxx
diff -cprN libstdc++-v3-orig/include/std/std_fstream.h libstdc++-v3/include/std/std_fstream.h
*** libstdc++-v3-orig/include/std/std_fstream.h Wed Jun 11 00:00:43 2003
--- libstdc++-v3/include/std/std_fstream.h Mon Jun 23 21:25:04 2003
*************** namespace std
*** 137,155 ****
* @endif
*/
bool _M_buf_allocated;
!
// XXX Needed?
bool _M_last_overflowed;
- // The position in the buffer corresponding to the external file
- // pointer.
- /**
- * @if maint
- * @doctodo
- * @endif
- */
- char_type* _M_filepos;
-
//@{
/**
* @if maint
--- 137,154 ----
* @endif
*/
bool _M_buf_allocated;
!
! // _M_reading == false && _M_writing == false for 'uncommitted' mode;
! // _M_reading == true for 'read' mode;
! // _M_writing == true for 'write' mode;
! //
! // NB: _M_reading == true && _M_writing == true is unused.
! bool _M_reading;
! bool _M_writing;
!
// XXX Needed?
bool _M_last_overflowed;
//@{
/**
* @if maint
*************** namespace std
*** 175,182 ****
{
if (!_M_pback_init)
{
! _M_pback_cur_save = this->_M_in_cur;
! _M_pback_end_save = this->_M_in_end;
this->setg(&_M_pback, &_M_pback, &_M_pback + 1);
_M_pback_init = true;
}
--- 174,181 ----
{
if (!_M_pback_init)
{
! _M_pback_cur_save = this->gptr();
! _M_pback_end_save = this->egptr();
this->setg(&_M_pback, &_M_pback, &_M_pback + 1);
_M_pback_init = true;
}
*************** namespace std
*** 191,197 ****
if (_M_pback_init)
{
// Length _M_in_cur moved in the pback buffer.
! _M_pback_cur_save += this->_M_in_cur != this->_M_in_beg;
this->setg(this->_M_buf, _M_pback_cur_save, _M_pback_end_save);
_M_pback_init = false;
}
--- 190,196 ----
if (_M_pback_init)
{
// Length _M_in_cur moved in the pback buffer.
! _M_pback_cur_save += this->gptr() != this->eback();
this->setg(this->_M_buf, _M_pback_cur_save, _M_pback_end_save);
_M_pback_init = false;
}
*************** namespace std
*** 365,387 ****
sync()
{
int __ret = 0;
- const bool __testput = this->_M_out_beg < this->_M_out_lim;
// Make sure that the internal buffer resyncs its idea of
// the file position with the external file.
! if (__testput)
{
! // Need to restore current position after the write.
! const off_type __off = this->_M_out_cur - this->_M_out_lim;
!
! // _M_file.sync() will be called within.
! if (traits_type::eq_int_type(this->overflow(), traits_type::eof()))
__ret = -1;
! else if (__off)
! _M_file.seekoff(__off, ios_base::cur);
}
! else
! _M_file.sync();
_M_last_overflowed = false;
return __ret;
}
--- 364,386 ----
sync()
{
int __ret = 0;
// Make sure that the internal buffer resyncs its idea of
// the file position with the external file.
! // NB: _M_file.sync() will be called within.
! if (this->pbase() < this->pptr())
{
! int_type __tmp = this->overflow();
! if (traits_type::eq_int_type(__tmp, traits_type::eof()))
__ret = -1;
! else
! {
! _M_set_buffer(-1);
! _M_reading = false;
! _M_writing = false;
! }
}
!
_M_last_overflowed = false;
return __ret;
}
*************** namespace std
*** 398,406 ****
streamsize __ret = 0;
if (this->_M_pback_init)
{
! if (__n && this->_M_in_cur == this->_M_in_beg)
{
! *__s++ = *this->_M_in_cur++;
__ret = 1;
}
_M_destroy_pback();
--- 397,406 ----
streamsize __ret = 0;
if (this->_M_pback_init)
{
! if (__n && this->gptr() == this->eback())
{
! *__s++ = *this->gptr();
! this->gbump(1);
__ret = 1;
}
_M_destroy_pback();
*************** namespace std
*** 427,436 ****
_M_output_unshift();
// This function sets the pointers of the internal buffer, both get
! // and put areas. Typically, __off == _M_in_end - _M_in_beg upon
! // _M_underflow; __off == 0 upon overflow, seekoff, open, setbuf.
//
! // NB: _M_out_end - _M_out_beg == _M_buf_size - 1, since _M_buf_size
// reflects the actual allocated memory and the last cell is reserved
// for the overflow char of a full put area.
void
--- 427,439 ----
_M_output_unshift();
// This function sets the pointers of the internal buffer, both get
! // and put areas. Typically:
! //
! // __off == egptr() - eback() upon underflow/uflow ('read' mode);
! // __off == 0 upon overflow ('write' mode);
! // __off == -1 upon open, setbuf, seekoff/pos ('uncommitted' mode).
//
! // NB: epptr() - pbase() == _M_buf_size - 1, since _M_buf_size
// reflects the actual allocated memory and the last cell is reserved
// for the overflow char of a full put area.
void
*************** namespace std
*** 439,452 ****
const bool __testin = this->_M_mode & ios_base::in;
const bool __testout = this->_M_mode & ios_base::out;
! if (__testin)
this->setg(this->_M_buf, this->_M_buf, this->_M_buf + __off);
! if (__testout && this->_M_buf_size > 1)
! {
! this->setp(this->_M_buf, this->_M_buf + this->_M_buf_size - 1);
! this->_M_out_lim += __off;
! }
! _M_filepos = this->_M_buf + __off;
}
};
--- 442,456 ----
const bool __testin = this->_M_mode & ios_base::in;
const bool __testout = this->_M_mode & ios_base::out;
! if (__testin && __off > 0)
this->setg(this->_M_buf, this->_M_buf, this->_M_buf + __off);
! else
! this->setg(this->_M_buf, this->_M_buf, this->_M_buf);
!
! if (__testout && __off == 0 && this->_M_buf_size > 1 )
! this->setp(this->_M_buf, this->_M_buf + this->_M_buf_size - 1);
! else
! this->setp(NULL, NULL);
}
};
diff -cprN libstdc++-v3-orig/include/std/std_streambuf.h libstdc++-v3/include/std/std_streambuf.h
*** libstdc++-v3-orig/include/std/std_streambuf.h Fri Jun 20 00:02:29 2003
--- libstdc++-v3/include/std/std_streambuf.h Mon Jun 23 05:07:09 2003
*************** namespace std
*** 176,200 ****
char_type* _M_out_cur; // Current put area.
char_type* _M_out_end; // End of put area.
- //@{
- /**
- * @if maint
- * setp (and _M_set_buffer(0) in basic_filebuf) set it equal to
- * _M_out_beg, then at each put operation it may be moved
- * forward (toward _M_out_end) by _M_move_out_cur.
- * @endif
- */
- char_type* _M_out_lim; // End limit of used put area.
- //@}
-
- /**
- * @if maint
- * True iff _M_in_* and _M_out_* buffers should always point to
- * the same place. True for fstreams, false for sstreams.
- * @endif
- */
- bool _M_buf_unified;
-
/**
* @if maint
* Place to stash in || out || in | out settings for current streambuf.
--- 176,181 ----
*************** namespace std
*** 216,265 ****
*/
fpos<__state_type> _M_pos;
- // Correctly sets the _M_in_cur pointer, and bumps the
- // _M_out_cur pointer as well if necessary.
- void
- _M_move_in_cur(off_type __n) // argument needs to be +-
- {
- const bool __testout = _M_out_cur;
- _M_in_cur += __n;
- if (__testout && _M_buf_unified)
- _M_out_cur += __n;
- }
-
- // Correctly sets the _M_out_cur pointer, and bumps the
- // appropriate _M_out_lim and _M_in_end pointers as well. Necessary
- // for the un-tied stringbufs, in in|out mode.
- // Invariant:
- // __n + _M_out_[cur, lim] <= _M_out_end
- // Assuming all _M_out_[beg, cur, lim] pointers are operating on
- // the same range:
- // _M_out_beg <= _M_*_ <= _M_out_end
- void
- _M_move_out_cur(off_type __n) // argument needs to be +-
- {
- _M_out_cur += __n;
- if (__builtin_expect(_M_buf_unified, false))
- {
- const bool __testin = _M_in_cur;
- if (__testin)
- _M_in_cur += __n;
- if (_M_out_cur > _M_out_lim)
- {
- _M_out_lim = _M_out_cur;
- // NB: in | out buffers drag the _M_in_end pointer along...
- if (__testin)
- _M_in_end += __n;
- }
- }
- }
-
public:
/// Destructor deallocates no buffer space.
virtual
~basic_streambuf()
{
- _M_buf_unified = false;
_M_mode = ios_base::openmode(0);
}
--- 197,207 ----
*************** namespace std
*** 330,336 ****
streamsize
in_avail()
{
! const streamsize __ret = _M_in_end - _M_in_cur;
return __ret ? __ret : this->showmanyc();
}
--- 272,278 ----
streamsize
in_avail()
{
! const streamsize __ret = this->egptr() - this->gptr();
return __ret ? __ret : this->showmanyc();
}
*************** namespace std
*** 373,380 ****
sgetc()
{
int_type __ret;
! if (_M_in_cur < _M_in_end)
! __ret = traits_type::to_int_type(*this->_M_in_cur);
else
__ret = this->underflow();
return __ret;
--- 315,322 ----
sgetc()
{
int_type __ret;
! if (this->gptr() < this->egptr())
! __ret = traits_type::to_int_type(*this->gptr());
else
__ret = this->underflow();
return __ret;
*************** namespace std
*** 461,467 ****
basic_streambuf()
: _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_unified(false),
_M_mode(ios_base::openmode(0)),_M_buf_locale(locale())
{ }
--- 403,408 ----
*************** namespace std
*** 553,559 ****
void
setp(char_type* __pbeg, char_type* __pend)
{
! _M_out_beg = _M_out_cur = _M_out_lim = __pbeg;
_M_out_end = __pend;
}
--- 494,500 ----
void
setp(char_type* __pbeg, char_type* __pend)
{
! _M_out_beg = _M_out_cur = __pbeg;
_M_out_end = __pend;
}
*************** namespace std
*** 703,712 ****
int_type __ret = traits_type::eof();
const bool __testeof = traits_type::eq_int_type(this->underflow(),
__ret);
! if (!__testeof && _M_in_cur < _M_in_end)
{
! __ret = traits_type::to_int_type(*_M_in_cur);
! ++_M_in_cur;
}
return __ret;
}
--- 644,653 ----
int_type __ret = traits_type::eof();
const bool __testeof = traits_type::eq_int_type(this->underflow(),
__ret);
! if (!__testeof && this->gptr() < this->egptr())
{
! __ret = traits_type::to_int_type(*this->gptr());
! this->gbump(1);
}
return __ret;
}
*************** namespace std
*** 786,793 ****
void
stossc()
{
! if (_M_in_cur < _M_in_end)
! ++_M_in_cur;
else
this->uflow();
}
--- 727,734 ----
void
stossc()
{
! if (this->gptr() < this->egptr())
! this->gbump(1);
else
this->uflow();
}
diff -cprN libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc
*** libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc Fri Jun 6 02:19:16 2003
--- libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc Mon Jun 23 05:29:33 2003
*************** void test05()
*** 46,56 ****
{
constraint_filebuf fb_03;
fb_03.open(name_03, ios_base::out | ios_base::in | ios_base::trunc);
! VERIFY( fb_03.write_position() );
VERIFY( !fb_03.read_position() );
int_type c5 = fb_03.sbumpc();
VERIFY( c5 == traits_type::eof() );
! VERIFY( fb_03.write_position() );
VERIFY( !fb_03.read_position() );
}
--- 46,56 ----
{
constraint_filebuf fb_03;
fb_03.open(name_03, ios_base::out | ios_base::in | ios_base::trunc);
! VERIFY( !fb_03.write_position() );
VERIFY( !fb_03.read_position() );
int_type c5 = fb_03.sbumpc();
VERIFY( c5 == traits_type::eof() );
! VERIFY( !fb_03.write_position() );
VERIFY( !fb_03.read_position() );
}
*************** void test05()
*** 58,66 ****
{
constraint_filebuf fb_01;
fb_01.open(name_01, ios_base::in | ios_base::out);
! VERIFY( fb_01.write_position() );
! int_type c1 = fb_01.sbumpc();
VERIFY( c1 == '/' );
int_type c3 = fb_01.sbumpc();
VERIFY( c3 == '/' );
--- 58,66 ----
{
constraint_filebuf fb_01;
fb_01.open(name_01, ios_base::in | ios_base::out);
! VERIFY( !fb_01.write_position() );
! int_type c1 = fb_01.sbumpc();
VERIFY( c1 == '/' );
int_type c3 = fb_01.sbumpc();
VERIFY( c3 == '/' );
*************** void test05()
*** 80,86 ****
VERIFY( c2 == '9' );
VERIFY( c3 == '0' );
! VERIFY( fb_01.write_position() );
VERIFY( fb_01.read_position() );
}
}
--- 80,86 ----
VERIFY( c2 == '9' );
VERIFY( c3 == '0' );
! VERIFY( !fb_01.write_position() );
VERIFY( fb_01.read_position() );
}
}
diff -cprN libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc
*** libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc Fri Jun 6 02:19:16 2003
--- libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc Mon Jun 23 04:31:16 2003
*************** void test05()
*** 45,57 ****
{
constraint_filebuf fb_02;
fb_02.open(name_02, ios_base::out | ios_base::trunc);
! VERIFY( fb_02.write_position() );
VERIFY( !fb_02.read_position() );
int_type c2 = fb_02.sbumpc();
VERIFY( c2 == traits_type::eof() );
int_type c4 = fb_02.sbumpc();
VERIFY( c4 == traits_type::eof() );
! VERIFY( fb_02.write_position() );
VERIFY( !fb_02.read_position() );
}
}
--- 45,57 ----
{
constraint_filebuf fb_02;
fb_02.open(name_02, ios_base::out | ios_base::trunc);
! VERIFY( !fb_02.write_position() );
VERIFY( !fb_02.read_position() );
int_type c2 = fb_02.sbumpc();
VERIFY( c2 == traits_type::eof() );
int_type c4 = fb_02.sbumpc();
VERIFY( c4 == traits_type::eof() );
! VERIFY( !fb_02.write_position() );
VERIFY( !fb_02.read_position() );
}
}
diff -cprN libstdc++-v3-orig/testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc
*** libstdc++-v3-orig/testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc Fri Jun 13 23:06:37 2003
--- libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc Mon Jun 23 04:58:55 2003
*************** void test05()
*** 59,65 ****
{
constraint_filebuf fb_03;
fb_03.open(name_01, ios_base::out | ios_base::in);
! VERIFY( fb_03.write_position() );
VERIFY( !fb_03.read_position() );
// 27filebuf-3.txt = bd23456789:;<=>?...
//beg
--- 59,65 ----
{
constraint_filebuf fb_03;
fb_03.open(name_01, ios_base::out | ios_base::in);
! VERIFY( !fb_03.write_position() );
VERIFY( !fb_03.read_position() );
// 27filebuf-3.txt = bd23456789:;<=>?...
//beg
*************** void test05()
*** 111,117 ****
fb_03.pubsync();
c3 = fb_03.sgetc();
VERIFY( c1 == c3 );
! VERIFY( fb_03.write_position() );
VERIFY( fb_03.read_position() );
}
}
--- 111,117 ----
fb_03.pubsync();
c3 = fb_03.sgetc();
VERIFY( c1 == c3 );
! VERIFY( !fb_03.write_position() );
VERIFY( fb_03.read_position() );
}
}
diff -cprN libstdc++-v3-orig/testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc
*** libstdc++-v3-orig/testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc Fri Jun 13 23:06:37 2003
--- libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc Mon Jun 23 13:17:21 2003
*************** void test05()
*** 60,66 ****
{
constraint_filebuf fb_03;
fb_03.open(name_01, ios_base::out | ios_base::in);
! VERIFY( fb_03.write_position() );
VERIFY( !fb_03.read_position() );
pt_1 = fb_03.pubseekoff(78, ios_base::beg);
off_1 = pt_1;
--- 60,66 ----
{
constraint_filebuf fb_03;
fb_03.open(name_01, ios_base::out | ios_base::in);
! VERIFY( !fb_03.write_position() );
VERIFY( !fb_03.read_position() );
pt_1 = fb_03.pubseekoff(78, ios_base::beg);
off_1 = pt_1;
*************** void test05()
*** 84,90 ****
VERIFY( off_1 > off_2 );
fb_03.sputn("\nof the wonderful things he does!!\nok", 37);
fb_03.pubsync();
! VERIFY( fb_03.write_position() );
VERIFY( !fb_03.read_position() );
fb_03.close();
VERIFY( !fb_03.is_open() );
--- 84,90 ----
VERIFY( off_1 > off_2 );
fb_03.sputn("\nof the wonderful things he does!!\nok", 37);
fb_03.pubsync();
! VERIFY( !fb_03.write_position() );
VERIFY( !fb_03.read_position() );
fb_03.close();
VERIFY( !fb_03.is_open() );
diff -cprN libstdc++-v3-orig/testsuite/27_io/basic_filebuf/setbuf/char/1.cc libstdc++-v3/testsuite/27_io/basic_filebuf/setbuf/char/1.cc
*** libstdc++-v3-orig/testsuite/27_io/basic_filebuf/setbuf/char/1.cc Thu Apr 10 09:15:28 2003
--- libstdc++-v3/testsuite/27_io/basic_filebuf/setbuf/char/1.cc Mon Jun 23 12:41:59 2003
*************** void test05()
*** 79,85 ****
// setbuf
// pubsetbuf(char_type* s, streamsize n)
f_tmp.pubsetbuf(0, 0);
! VERIFY( !f_tmp.check_pointers() );
}
}
--- 79,85 ----
// setbuf
// pubsetbuf(char_type* s, streamsize n)
f_tmp.pubsetbuf(0, 0);
! VERIFY( f_tmp.check_pointers() );
}
}
diff -cprN libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc
*** libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc Fri Jun 6 02:19:16 2003
--- libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc Mon Jun 23 04:33:46 2003
*************** void test05()
*** 48,60 ****
{
constraint_filebuf fb_03; // in | out
fb_03.open(name_03, ios::out | ios::in | ios::trunc);
! VERIFY( fb_03.write_position() );
VERIFY( !fb_03.read_position() );
c1 = fb_03.sgetc();
c2 = fb_03.sbumpc();
VERIFY( c1 == traits_type::eof() );
VERIFY( c1 == c2 );
! VERIFY( fb_03.write_position() );
VERIFY( !fb_03.read_position() );
}
--- 48,60 ----
{
constraint_filebuf fb_03; // in | out
fb_03.open(name_03, ios::out | ios::in | ios::trunc);
! VERIFY( !fb_03.write_position() );
VERIFY( !fb_03.read_position() );
c1 = fb_03.sgetc();
c2 = fb_03.sbumpc();
VERIFY( c1 == traits_type::eof() );
VERIFY( c1 == c2 );
! VERIFY( !fb_03.write_position() );
VERIFY( !fb_03.read_position() );
}
*************** void test05()
*** 62,68 ****
{
constraint_filebuf fb_01; // in
fb_01.open(name_01, ios::in | ios::out);
! VERIFY( fb_01.write_position() );
c1 = fb_01.sgetc();
VERIFY( c1 == '/' );
c2 = fb_01.sgetc();
--- 62,68 ----
{
constraint_filebuf fb_01; // in
fb_01.open(name_01, ios::in | ios::out);
! VERIFY( !fb_01.write_position() );
c1 = fb_01.sgetc();
VERIFY( c1 == '/' );
c2 = fb_01.sgetc();
*************** void test05()
*** 74,80 ****
VERIFY( c1 == '/' );
VERIFY( c2 == ' ' );
VERIFY( c3 == ' ' );
! VERIFY( fb_01.write_position() );
VERIFY( fb_01.read_position() );
}
}
--- 74,80 ----
VERIFY( c1 == '/' );
VERIFY( c2 == ' ' );
VERIFY( c3 == ' ' );
! VERIFY( !fb_01.write_position() );
VERIFY( fb_01.read_position() );
}
}
diff -cprN libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc
*** libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc Fri Jun 6 02:19:16 2003
--- libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc Mon Jun 23 04:33:56 2003
*************** void test05()
*** 47,53 ****
{
constraint_filebuf fb_02; // out
fb_02.open(name_02, ios::out | ios::trunc);
! VERIFY( fb_02.write_position() );
VERIFY( !fb_02.read_position() );
c1 = fb_02.sgetc();
VERIFY( c1 == traits_type::eof() );
--- 47,53 ----
{
constraint_filebuf fb_02; // out
fb_02.open(name_02, ios::out | ios::trunc);
! VERIFY( !fb_02.write_position() );
VERIFY( !fb_02.read_position() );
c1 = fb_02.sgetc();
VERIFY( c1 == traits_type::eof() );
*************** void test05()
*** 57,63 ****
c1 = fb_02.sbumpc();
c2 = fb_02.sgetc();
VERIFY( c1 == c2 );
! VERIFY( fb_02.write_position() );
VERIFY( !fb_02.read_position() );
}
}
--- 57,63 ----
c1 = fb_02.sbumpc();
c2 = fb_02.sgetc();
VERIFY( c1 == c2 );
! VERIFY( !fb_02.write_position() );
VERIFY( !fb_02.read_position() );
}
}
diff -cprN libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc
*** libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc Mon Jun 16 23:24:40 2003
--- libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc Mon Jun 23 04:35:23 2003
*************** void test05()
*** 55,65 ****
{
constraint_filebuf fb_03;
fb_03.open(name_03, ios_base::out | ios_base::in | ios_base::trunc);
! VERIFY( fb_03.write_position() );
VERIFY( !fb_03.read_position() );
strmsz_1 = fb_03.sgetn(carray1, 10);
VERIFY( strmsz_1 == 0 );
! VERIFY( fb_03.write_position() );
VERIFY( !fb_03.read_position() );
}
--- 55,65 ----
{
constraint_filebuf fb_03;
fb_03.open(name_03, ios_base::out | ios_base::in | ios_base::trunc);
! VERIFY( !fb_03.write_position() );
VERIFY( !fb_03.read_position() );
strmsz_1 = fb_03.sgetn(carray1, 10);
VERIFY( strmsz_1 == 0 );
! VERIFY( !fb_03.write_position() );
VERIFY( !fb_03.read_position() );
}
*************** void test05()
*** 70,76 ****
// to trigger the same underflow situation everywhere.
fb_01.pubsetbuf(buffer, 8192);
fb_01.open(name_01, ios_base::in | ios_base::out);
! VERIFY( fb_01.write_position() );
strmsz_1 = fb_01.in_avail();
strmsz_2 = fb_01.sgetn(carray1, 10);
VERIFY( strmsz_2 == 10 );
--- 70,76 ----
// to trigger the same underflow situation everywhere.
fb_01.pubsetbuf(buffer, 8192);
fb_01.open(name_01, ios_base::in | ios_base::out);
! VERIFY( !fb_01.write_position() );
strmsz_1 = fb_01.in_avail();
strmsz_2 = fb_01.sgetn(carray1, 10);
VERIFY( strmsz_2 == 10 );
*************** void test05()
*** 87,93 ****
VERIFY( strmsz_1 > 0 );
strmsz_2 = fb_01.sgetn(carray2, strmsz_1 + 5);
VERIFY( strmsz_1 == strmsz_2 ); //at the end of the actual file
! VERIFY( fb_01.write_position() );
VERIFY( !fb_01.read_position() );
}
}
--- 87,93 ----
VERIFY( strmsz_1 > 0 );
strmsz_2 = fb_01.sgetn(carray2, strmsz_1 + 5);
VERIFY( strmsz_1 == strmsz_2 ); //at the end of the actual file
! VERIFY( !fb_01.write_position() );
VERIFY( !fb_01.read_position() );
}
}
diff -cprN libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc
*** libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc Mon Jun 16 23:24:40 2003
--- libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc Mon Jun 23 04:35:42 2003
*************** void test05()
*** 53,59 ****
{
constraint_filebuf fb_02;
fb_02.open(name_02, ios_base::out | ios_base::trunc);
! VERIFY( fb_02.write_position() );
VERIFY( !fb_02.read_position() );
strmsz_2 = fb_02.in_avail();
strmsz_2 = fb_02.sgetn(carray2, 10);
--- 53,59 ----
{
constraint_filebuf fb_02;
fb_02.open(name_02, ios_base::out | ios_base::trunc);
! VERIFY( !fb_02.write_position() );
VERIFY( !fb_02.read_position() );
strmsz_2 = fb_02.in_avail();
strmsz_2 = fb_02.sgetn(carray2, 10);
*************** void test05()
*** 66,72 ****
VERIFY( strmsz_2 == 0 );
c4 = fb_02.sgetc();
VERIFY( c4 == traits_type::eof() );
! VERIFY( fb_02.write_position() );
VERIFY( !fb_02.read_position() );
}
}
--- 66,72 ----
VERIFY( strmsz_2 == 0 );
c4 = fb_02.sgetc();
VERIFY( c4 == traits_type::eof() );
! VERIFY( !fb_02.write_position() );
VERIFY( !fb_02.read_position() );
}
}
diff -cprN libstdc++-v3-orig/testsuite/27_io/basic_filebuf/snextc/char/1-io.cc libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-io.cc
*** libstdc++-v3-orig/testsuite/27_io/basic_filebuf/snextc/char/1-io.cc Fri Jun 6 02:19:17 2003
--- libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-io.cc Mon Jun 23 04:36:07 2003
*************** void test05()
*** 48,58 ****
{
constraint_filebuf fb_03;
fb_03.open(name_03, ios_base::out | ios_base::in | ios_base::trunc);
! VERIFY( fb_03.write_position() );
VERIFY( !fb_03.read_position() );
c3 = fb_03.snextc();
VERIFY( c3 == traits_type::eof() );
! VERIFY( fb_03.write_position() );
VERIFY( !fb_03.read_position() );
}
--- 48,58 ----
{
constraint_filebuf fb_03;
fb_03.open(name_03, ios_base::out | ios_base::in | ios_base::trunc);
! VERIFY( !fb_03.write_position() );
VERIFY( !fb_03.read_position() );
c3 = fb_03.snextc();
VERIFY( c3 == traits_type::eof() );
! VERIFY( !fb_03.write_position() );
VERIFY( !fb_03.read_position() );
}
*************** void test05()
*** 60,66 ****
{
constraint_filebuf fb_01;
fb_01.open(name_01, ios_base::in | ios_base::out);
! VERIFY( fb_01.write_position() );
int_type c4 = fb_01.sbumpc();
VERIFY( c4 == '/' );
c4 = fb_01.sbumpc();
--- 60,66 ----
{
constraint_filebuf fb_01;
fb_01.open(name_01, ios_base::in | ios_base::out);
! VERIFY( !fb_01.write_position() );
int_type c4 = fb_01.sbumpc();
VERIFY( c4 == '/' );
c4 = fb_01.sbumpc();
*************** void test05()
*** 71,77 ****
VERIFY( c1 == '9' );
c4 = fb_01.sgetc();
VERIFY( c4 == '9' );
! VERIFY( fb_01.write_position() );
VERIFY( fb_01.read_position() );
}
}
--- 71,77 ----
VERIFY( c1 == '9' );
c4 = fb_01.sgetc();
VERIFY( c4 == '9' );
! VERIFY( !fb_01.write_position() );
VERIFY( fb_01.read_position() );
}
}
diff -cprN libstdc++-v3-orig/testsuite/27_io/basic_filebuf/snextc/char/1-out.cc libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-out.cc
*** libstdc++-v3-orig/testsuite/27_io/basic_filebuf/snextc/char/1-out.cc Fri Jun 6 02:19:17 2003
--- libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-out.cc Mon Jun 23 04:36:19 2003
*************** void test05()
*** 48,60 ****
{
constraint_filebuf fb_02;
fb_02.open(name_02, ios_base::out | ios_base::trunc);
! VERIFY( fb_02.write_position() );
VERIFY( !fb_02.read_position() );
c2 = fb_02.snextc();
VERIFY( c2 == traits_type::eof() );
c2 = fb_02.snextc();
VERIFY( c2 == traits_type::eof() );
! VERIFY( fb_02.write_position() );
VERIFY( !fb_02.read_position() );
}
}
--- 48,60 ----
{
constraint_filebuf fb_02;
fb_02.open(name_02, ios_base::out | ios_base::trunc);
! VERIFY( !fb_02.write_position() );
VERIFY( !fb_02.read_position() );
c2 = fb_02.snextc();
VERIFY( c2 == traits_type::eof() );
c2 = fb_02.snextc();
VERIFY( c2 == traits_type::eof() );
! VERIFY( !fb_02.write_position() );
VERIFY( !fb_02.read_position() );
}
}
diff -cprN libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc
*** libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc Fri Jun 13 23:06:37 2003
--- libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc Mon Jun 23 04:37:06 2003
*************** void test01()
*** 50,56 ****
{
constraint_filebuf fb_01;
fb_01.open(name_01, ios_base::out | ios_base::in | ios_base::trunc);
! VERIFY( fb_01.write_position() );
VERIFY( !fb_01.read_position() );
strmsz_1 = fb_01.sputn("racadabras", 10);//"abracadabras or what?"
strmsz_2 = fb_01.sputn(", i wanna reach out and", 10);
--- 50,56 ----
{
constraint_filebuf fb_01;
fb_01.open(name_01, ios_base::out | ios_base::in | ios_base::trunc);
! VERIFY( !fb_01.write_position() );
VERIFY( !fb_01.read_position() );
strmsz_1 = fb_01.sputn("racadabras", 10);//"abracadabras or what?"
strmsz_2 = fb_01.sputn(", i wanna reach out and", 10);
*************** void test01()
*** 90,96 ****
c3 = fb_01.sgetc();
VERIFY( c3 == c2 );
VERIFY( strmsz_1 + 1 == strmsz_2 );
! VERIFY( fb_01.write_position() );
VERIFY( fb_01.read_position() );
}
}
--- 90,96 ----
c3 = fb_01.sgetc();
VERIFY( c3 == c2 );
VERIFY( strmsz_1 + 1 == strmsz_2 );
! VERIFY( !fb_01.write_position() );
VERIFY( fb_01.read_position() );
}
}
diff -cprN libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc
*** libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc Tue Jun 10 02:05:49 2003
--- libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc Mon Jun 23 04:37:20 2003
*************** void test01()
*** 48,54 ****
{
constraint_filebuf fb_01; // out
fb_01.open(name_01, ios::out | ios::trunc);
! VERIFY( fb_01.write_position() );
VERIFY( !fb_01.read_position() );
c1 = fb_01.sgetc();
VERIFY( c1 == traits_type::eof() );
--- 48,54 ----
{
constraint_filebuf fb_01; // out
fb_01.open(name_01, ios::out | ios::trunc);
! VERIFY( !fb_01.write_position() );
VERIFY( !fb_01.read_position() );
c1 = fb_01.sgetc();
VERIFY( c1 == traits_type::eof() );
*************** void test01()
*** 58,64 ****
c1 = fb_01.sbumpc();
c2 = fb_01.sputbackc('a');
VERIFY( c1 == c2 );
! VERIFY( fb_01.write_position() );
VERIFY( !fb_01.read_position() );
}
}
--- 58,64 ----
c1 = fb_01.sbumpc();
c2 = fb_01.sputbackc('a');
VERIFY( c1 == c2 );
! VERIFY( !fb_01.write_position() );
VERIFY( !fb_01.read_position() );
}
}
diff -cprN libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sputc/char/1-io.cc libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-io.cc
*** libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sputc/char/1-io.cc Fri Jun 6 02:19:17 2003
--- libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-io.cc Mon Jun 23 04:38:31 2003
*************** void test05()
*** 52,58 ****
{
constraint_filebuf fb_03;
fb_03.open(name_03, ios_base::out | ios_base::in | ios_base::trunc);
! VERIFY( fb_03.write_position() );
VERIFY( !fb_03.read_position() );
c1 = fb_03.sputc('b');
VERIFY( c1 == 'b' );
--- 52,58 ----
{
constraint_filebuf fb_03;
fb_03.open(name_03, ios_base::out | ios_base::in | ios_base::trunc);
! VERIFY( !fb_03.write_position() );
VERIFY( !fb_03.read_position() );
c1 = fb_03.sputc('b');
VERIFY( c1 == 'b' );
diff -cprN libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sputc/char/1-out.cc libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-out.cc
*** libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sputc/char/1-out.cc Fri Jun 6 02:19:17 2003
--- libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-out.cc Mon Jun 23 04:38:42 2003
*************** void test05()
*** 51,57 ****
{
constraint_filebuf fb_02;
fb_02.open(name_02, ios_base::out | ios_base::trunc);
! VERIFY( fb_02.write_position() );
VERIFY( !fb_02.read_position() );
c1 = fb_02.sputc('a');
VERIFY( c1 == 'a' );
--- 51,57 ----
{
constraint_filebuf fb_02;
fb_02.open(name_02, ios_base::out | ios_base::trunc);
! VERIFY( !fb_02.write_position() );
VERIFY( !fb_02.read_position() );
c1 = fb_02.sputc('a');
VERIFY( c1 == 'a' );
diff -cprN libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sputc/char/9701-2.cc libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/9701-2.cc
*** libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sputc/char/9701-2.cc Thu Apr 10 09:15:28 2003
--- libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/9701-2.cc Mon Jun 23 00:53:02 2003
*************** void test11()
*** 55,61 ****
dfbuf_01.open(name_05, std::ios_base::out);
over_called = false;
dfbuf_01.sputc('i');
! VERIFY( !over_called );
over_expected = dfbuf_01.pub_epptr() == dfbuf_01.pub_pptr();
over_called = false;
dfbuf_01.sputc('v');
--- 55,61 ----
dfbuf_01.open(name_05, std::ios_base::out);
over_called = false;
dfbuf_01.sputc('i');
! VERIFY( over_called );
over_expected = dfbuf_01.pub_epptr() == dfbuf_01.pub_pptr();
over_called = false;
dfbuf_01.sputc('v');
diff -cprN libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sputn/char/1-io.cc libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-io.cc
*** libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sputn/char/1-io.cc Fri Jun 6 02:19:17 2003
--- libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-io.cc Mon Jun 23 04:39:05 2003
*************** void test05()
*** 50,56 ****
{
constraint_filebuf fb_03;
fb_03.open(name_03, ios_base::out | ios_base::in | ios_base::trunc);
! VERIFY( fb_03.write_position() );
VERIFY( !fb_03.read_position() );
strmsz_1 = fb_03.sputn("racadabras", 10);//"abracadabras or what?"
VERIFY( strmsz_1 == 10 );
--- 50,56 ----
{
constraint_filebuf fb_03;
fb_03.open(name_03, ios_base::out | ios_base::in | ios_base::trunc);
! VERIFY( !fb_03.write_position() );
VERIFY( !fb_03.read_position() );
strmsz_1 = fb_03.sputn("racadabras", 10);//"abracadabras or what?"
VERIFY( strmsz_1 == 10 );
diff -cprN libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sputn/char/1-out.cc libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-out.cc
*** libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sputn/char/1-out.cc Fri Jun 6 02:19:17 2003
--- libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-out.cc Mon Jun 23 04:39:15 2003
*************** void test05()
*** 49,55 ****
{
constraint_filebuf fb_02;
fb_02.open(name_02, ios_base::out | ios_base::trunc);
! VERIFY( fb_02.write_position() );
VERIFY( !fb_02.read_position() );
strmsz_1 = fb_02.sputn("racadabras", 10);
VERIFY( strmsz_1 == 10 );
--- 49,55 ----
{
constraint_filebuf fb_02;
fb_02.open(name_02, ios_base::out | ios_base::trunc);
! VERIFY( !fb_02.write_position() );
VERIFY( !fb_02.read_position() );
strmsz_1 = fb_02.sputn("racadabras", 10);
VERIFY( strmsz_1 == 10 );
diff -cprN libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sputn/char/9701-1.cc libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/9701-1.cc
*** libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sputn/char/9701-1.cc Thu Apr 10 09:15:28 2003
--- libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/9701-1.cc Mon Jun 23 00:52:48 2003
*************** void test11()
*** 59,65 ****
dfbuf_02.open(name_05, std::ios_base::out);
over_called = false;
dfbuf_02.sputn("sonne's", 7);
! VERIFY( !over_called );
over_expected = dfbuf_02.pub_epptr() == dfbuf_02.pub_pptr();
over_called = false;
dfbuf_02.sputn(" peak", 5);
--- 59,65 ----
dfbuf_02.open(name_05, std::ios_base::out);
over_called = false;
dfbuf_02.sputn("sonne's", 7);
! VERIFY( over_called );
over_expected = dfbuf_02.pub_epptr() == dfbuf_02.pub_pptr();
over_called = false;
dfbuf_02.sputn(" peak", 5);
diff -cprN libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc
*** libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc Mon Jun 16 18:20:28 2003
--- libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc Mon Jun 23 04:39:38 2003
*************** void test01()
*** 50,56 ****
{
constraint_filebuf fb_01;
fb_01.open(name_01, ios_base::out | ios_base::in | ios_base::trunc);
! VERIFY( fb_01.write_position() );
VERIFY( !fb_01.read_position() );
fb_01.sputc('u');
fb_01.sputc('v');
--- 50,56 ----
{
constraint_filebuf fb_01;
fb_01.open(name_01, ios_base::out | ios_base::in | ios_base::trunc);
! VERIFY( !fb_01.write_position() );
VERIFY( !fb_01.read_position() );
fb_01.sputc('u');
fb_01.sputc('v');
*************** void test01()
*** 71,77 ****
VERIFY( c1 != c2 );
VERIFY( strmsz_2 != strmsz_1 );
VERIFY( strmsz_2 == 1 );
! VERIFY( fb_01.write_position() );
VERIFY( fb_01.read_position() );
}
}
--- 71,77 ----
VERIFY( c1 != c2 );
VERIFY( strmsz_2 != strmsz_1 );
VERIFY( strmsz_2 == 1 );
! VERIFY( !fb_01.write_position() );
VERIFY( fb_01.read_position() );
}
}
diff -cprN libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc
*** libstdc++-v3-orig/testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc Mon Jun 16 18:20:28 2003
--- libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc Mon Jun 23 04:40:21 2003
*************** void test01()
*** 48,54 ****
{
constraint_filebuf fb_01; // out
fb_01.open(name_01, ios::out | ios::trunc);
! VERIFY( fb_01.write_position() );
VERIFY( !fb_01.read_position() );
c1 = fb_01.sgetc();
VERIFY( c1 == traits_type::eof() );
--- 48,54 ----
{
constraint_filebuf fb_01; // out
fb_01.open(name_01, ios::out | ios::trunc);
! VERIFY( !fb_01.write_position() );
VERIFY( !fb_01.read_position() );
c1 = fb_01.sgetc();
VERIFY( c1 == traits_type::eof() );
*************** void test01()
*** 58,64 ****
c1 = fb_01.sbumpc();
c2 = fb_01.sungetc();
VERIFY( c1 == c2 );
! VERIFY( fb_01.write_position() );
VERIFY( !fb_01.read_position() );
}
}
--- 58,64 ----
c1 = fb_01.sbumpc();
c2 = fb_01.sungetc();
VERIFY( c1 == c2 );
! VERIFY( !fb_01.write_position() );
VERIFY( !fb_01.read_position() );
}
}