summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@unitus.it>2003-06-24 15:48:11 +0200
committerPaolo Carlini <paolo@gcc.gnu.org>2003-06-24 13:48:11 +0000
commit71b460210af83307df263fc57eb2603ca314eb59 (patch)
tree4181362da88e74433fa135cb0546217d62cdae22
parentcebebe72b1f06a31668a8efb9a5f2d6be590b20d (diff)
downloadgcc-71b460210af83307df263fc57eb2603ca314eb59.tar.gz
Nathan C.
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. Co-Authored-By: Nathan C. Myers <ncm-nospam@cantrip.org> From-SVN: r68420
-rw-r--r--libstdc++-v3/ChangeLog64
-rw-r--r--libstdc++-v3/include/bits/fstream.tcc160
-rw-r--r--libstdc++-v3/include/bits/streambuf.tcc44
-rw-r--r--libstdc++-v3/include/ext/stdio_filebuf.h8
-rw-r--r--libstdc++-v3/include/std/std_fstream.h76
-rw-r--r--libstdc++-v3/include/std/std_streambuf.h77
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc10
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc4
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc4
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc4
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/setbuf/char/1.cc2
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc8
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc4
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc8
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc4
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-io.cc8
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-out.cc4
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc4
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc4
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-io.cc2
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-out.cc2
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/9701-2.cc2
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-io.cc2
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-out.cc2
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/9701-1.cc2
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc4
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc4
27 files changed, 264 insertions, 253 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 3f7f5d8df9c..bf9cd5cb2ba 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,67 @@
+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.
+
2003-06-23 Loren J. Rittle <ljrittle@acm.org>
* configure.host (freebsd*): Set abi_baseline_pair.
diff --git a/libstdc++-v3/include/bits/fstream.tcc b/libstdc++-v3/include/bits/fstream.tcc
index 13275882c47..22a24dcee69 100644
--- a/libstdc++-v3/include/bits/fstream.tcc
+++ b/libstdc++-v3/include/bits/fstream.tcc
@@ -63,8 +63,6 @@ namespace std
delete [] this->_M_buf;
this->_M_buf = NULL;
_M_buf_allocated = false;
- this->setg(NULL, NULL, NULL);
- this->setp(NULL, NULL);
}
}
@@ -73,10 +71,10 @@ namespace std
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)
+ _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)
{
- this->_M_buf_unified = true;
if (has_facet<__codecvt_type>(this->_M_buf_locale))
_M_codecvt = &use_facet<__codecvt_type>(this->_M_buf_locale);
}
@@ -95,8 +93,10 @@ namespace std
_M_allocate_internal_buffer();
this->_M_mode = __mode;
- // Setup initial position of buffer.
- _M_set_buffer(0);
+ // 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)
@@ -120,9 +120,7 @@ namespace std
bool __testfail = false;
try
{
- const bool __testput = this->_M_out_beg < this->_M_out_lim;
-
- if (__testput
+ if (this->pbase() < this->pptr()
&& traits_type::eq_int_type(this->overflow(),
traits_type::eof()))
__testfail = true;
@@ -144,6 +142,9 @@ namespace std
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;
@@ -167,7 +168,7 @@ namespace std
{
// 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;
+ __ret = this->egptr() - this->gptr();
if (__check_facet(_M_codecvt).encoding() >= 0)
__ret += _M_file.showmanyc() / _M_codecvt->max_length();
}
@@ -185,26 +186,21 @@ namespace std
const bool __testin = this->_M_mode & ios_base::in;
const bool __testout = this->_M_mode & ios_base::out;
- if (__testin)
+ 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->_M_in_cur < this->_M_in_end)
+ if (this->gptr() < this->egptr())
{
- __ret = traits_type::to_int_type(*this->_M_in_cur);
+ __ret = traits_type::to_int_type(*this->gptr());
if (__bump)
- _M_move_in_cur(1);
+ this->gbump(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;
@@ -212,7 +208,7 @@ namespace std
streamsize __ilen = 0;
if (__check_facet(_M_codecvt).always_noconv())
{
- __elen = _M_file.xsgetn(reinterpret_cast<char*>(this->_M_in_beg), __buflen);
+ __elen = _M_file.xsgetn(reinterpret_cast<char*>(this->eback()), __buflen);
__ilen = __elen;
}
else
@@ -224,13 +220,13 @@ namespace std
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);
+ __eend, this->eback(),
+ this->eback() + __buflen, __iend);
if (__r == codecvt_base::ok)
- __ilen = __iend - this->_M_in_beg;
+ __ilen = __iend - this->eback();
else if (__r == codecvt_base::noconv)
{
- traits_type::copy(this->_M_in_beg,
+ traits_type::copy(this->eback(),
reinterpret_cast<char_type*>(__buf),
__elen);
__ilen = __elen;
@@ -246,9 +242,10 @@ namespace std
if (__ilen > 0)
{
_M_set_buffer(__ilen);
- __ret = traits_type::to_int_type(*this->_M_in_cur);
+ _M_reading = true;
+ __ret = traits_type::to_int_type(*this->gptr());
if (__bump)
- _M_move_in_cur(1);
+ this->gbump(1);
}
}
_M_last_overflowed = false;
@@ -263,7 +260,7 @@ namespace std
int_type __ret = traits_type::eof();
const bool __testin = this->_M_mode & ios_base::in;
- if (__testin)
+ 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).
@@ -271,10 +268,10 @@ namespace std
const bool __testeof = traits_type::eq_int_type(__i, __ret);
int_type __tmp;
- if (this->_M_in_beg < this->_M_in_cur)
+ if (this->eback() < this->gptr())
{
- _M_move_in_cur(-1);
- __tmp = traits_type::to_int_type(*this->_M_in_cur);
+ this->gbump(-1);
+ __tmp = traits_type::to_int_type(*this->gptr());
}
else if (this->seekoff(-1, ios_base::cur) >= 0)
{
@@ -301,7 +298,8 @@ namespace std
else if (!__testpb)
{
_M_create_pback();
- *this->_M_in_cur = traits_type::to_char_type(__i);
+ _M_reading = true;
+ *this->gptr() = traits_type::to_char_type(__i);
__ret = __i;
}
}
@@ -318,37 +316,50 @@ namespace std
const bool __testeof = traits_type::eq_int_type(__c, __ret);
const bool __testout = this->_M_mode & ios_base::out;
- if (__testout)
+ if (__testout && !_M_reading)
{
- if (this->_M_out_beg < this->_M_out_lim)
+ if (this->pbase() < this->pptr())
{
- // 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);
+ {
+ *this->pptr() = traits_type::to_char_type(__c);
+ this->pbump(1);
+ }
// Convert pending sequence to external representation,
// output.
- if (_M_convert_to_external(this->_M_out_beg,
- this->_M_out_lim - this->_M_out_beg)
+ 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))
- __ret = traits_type::not_eof(__c);
+ {
+ _M_writing = true;
+ __ret = traits_type::not_eof(__c);
+ }
}
}
_M_last_overflowed = true;
@@ -393,7 +404,7 @@ namespace std
}
else
{
- // Result == error .
+ // Result == error.
__blen = 0;
}
@@ -407,7 +418,7 @@ namespace std
if (__r == codecvt_base::partial)
{
const char_type* __iresume = __iend;
- streamsize __rlen = this->_M_out_lim - __iend;
+ streamsize __rlen = this->pptr() - __iend;
__r = _M_codecvt->out(_M_state_cur, __iresume,
__iresume + __rlen, __iend, __buf,
__buf + __blen, __bend);
@@ -446,7 +457,9 @@ namespace std
// Step 2: Use the external array.
this->_M_buf = __s;
this->_M_buf_size = __n;
- _M_set_buffer(0);
+ _M_reading = false;
+ _M_writing = false;
+ _M_set_buffer(-1);
}
_M_last_overflowed = false;
return this;
@@ -473,41 +486,26 @@ namespace std
// 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
+ // Sync the internal and external streams.
+ off_type __computed_off = __width * __off;
+
+ if (this->pbase() < this->pptr()
+ || _M_last_overflowed)
{
- // 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;
- }
+ // 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 --git a/libstdc++-v3/include/bits/streambuf.tcc b/libstdc++-v3/include/bits/streambuf.tcc
index f6a96e85581..d78d8ea45d9 100644
--- a/libstdc++-v3/include/bits/streambuf.tcc
+++ b/libstdc++-v3/include/bits/streambuf.tcc
@@ -45,10 +45,10 @@ namespace std
sbumpc()
{
int_type __ret;
- if (_M_in_cur < _M_in_end)
+ if (this->gptr() < this->egptr())
{
- __ret = traits_type::to_int_type(*this->_M_in_cur);
- _M_move_in_cur(1);
+ __ret = traits_type::to_int_type(*this->gptr());
+ this->gbump(1);
}
else
__ret = this->uflow();
@@ -61,13 +61,13 @@ namespace std
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]))
+ 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
{
- _M_move_in_cur(-1);
- __ret = traits_type::to_int_type(*this->_M_in_cur);
+ this->gbump(-1);
+ __ret = traits_type::to_int_type(*this->gptr());
}
return __ret;
}
@@ -78,10 +78,10 @@ namespace std
sungetc()
{
int_type __ret;
- if (_M_in_beg < _M_in_cur)
+ if (this->eback() < this->gptr())
{
- _M_move_in_cur(-1);
- __ret = traits_type::to_int_type(*_M_in_cur);
+ this->gbump(-1);
+ __ret = traits_type::to_int_type(*this->gptr());
}
else
__ret = this->pbackfail();
@@ -94,10 +94,10 @@ namespace std
sputc(char_type __c)
{
int_type __ret;
- if (_M_out_cur < _M_out_end)
+ if (this->pptr() < this->epptr())
{
- *_M_out_cur = __c;
- _M_move_out_cur(1);
+ *this->pptr() = __c;
+ this->pbump(1);
__ret = traits_type::to_int_type(__c);
}
else
@@ -113,15 +113,15 @@ namespace std
streamsize __ret = 0;
while (__ret < __n)
{
- const size_t __buf_len = _M_in_end - _M_in_cur;
+ 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, _M_in_cur, __len);
+ traits_type::copy(__s, this->gptr(), __len);
__ret += __len;
__s += __len;
- _M_move_in_cur(__len);
+ this->gbump(__len);
}
if (__ret < __n)
@@ -147,15 +147,15 @@ namespace std
streamsize __ret = 0;
while (__ret < __n)
{
- const size_t __buf_len = _M_out_end - _M_out_cur;
+ 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(_M_out_cur, __s, __len);
+ traits_type::copy(this->pptr(), __s, __len);
__ret += __len;
__s += __len;
- _M_move_out_cur(__len);
+ this->pbump(__len);
}
if (__ret < __n)
@@ -189,12 +189,12 @@ namespace std
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;
+ const size_t __n = __sbin->egptr() - __sbin->gptr();
if (__n > 1)
{
- const size_t __wrote = __sbout->sputn(__sbin->_M_in_cur,
+ const size_t __wrote = __sbout->sputn(__sbin->gptr(),
__n);
- __sbin->_M_move_in_cur(__wrote);
+ __sbin->gbump(__wrote);
__ret += __wrote;
if (__wrote < __n)
break;
diff --git a/libstdc++-v3/include/ext/stdio_filebuf.h b/libstdc++-v3/include/ext/stdio_filebuf.h
index 43ef34dec72..574a62b8160 100644
--- a/libstdc++-v3/include/ext/stdio_filebuf.h
+++ b/libstdc++-v3/include/ext/stdio_filebuf.h
@@ -127,7 +127,9 @@ namespace __gnu_cxx
this->_M_mode = __mode;
this->_M_buf_size = __size;
_M_allocate_internal_buffer();
- _M_set_buffer(0);
+ this->_M_reading = false;
+ this->_M_writing = false;
+ _M_set_buffer(-1);
}
}
@@ -142,7 +144,9 @@ namespace __gnu_cxx
this->_M_mode = __mode;
this->_M_buf_size = __size;
_M_allocate_internal_buffer();
- _M_set_buffer(0);
+ this->_M_reading = false;
+ this->_M_writing = false;
+ _M_set_buffer(-1);
}
}
} // namespace __gnu_cxx
diff --git a/libstdc++-v3/include/std/std_fstream.h b/libstdc++-v3/include/std/std_fstream.h
index 7cc0dbd8e1f..605fad22b3e 100644
--- a/libstdc++-v3/include/std/std_fstream.h
+++ b/libstdc++-v3/include/std/std_fstream.h
@@ -137,19 +137,18 @@ namespace std
* @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;
- // The position in the buffer corresponding to the external file
- // pointer.
- /**
- * @if maint
- * @doctodo
- * @endif
- */
- char_type* _M_filepos;
-
//@{
/**
* @if maint
@@ -175,8 +174,8 @@ namespace std
{
if (!_M_pback_init)
{
- _M_pback_cur_save = this->_M_in_cur;
- _M_pback_end_save = this->_M_in_end;
+ _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;
}
@@ -191,7 +190,7 @@ namespace std
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;
+ _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;
}
@@ -365,23 +364,23 @@ namespace std
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)
+ // NB: _M_file.sync() will be called within.
+ if (this->pbase() < this->pptr())
{
- // 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()))
+ int_type __tmp = this->overflow();
+ if (traits_type::eq_int_type(__tmp, traits_type::eof()))
__ret = -1;
- else if (__off)
- _M_file.seekoff(__off, ios_base::cur);
+ else
+ {
+ _M_set_buffer(-1);
+ _M_reading = false;
+ _M_writing = false;
+ }
}
- else
- _M_file.sync();
+
_M_last_overflowed = false;
return __ret;
}
@@ -398,9 +397,10 @@ namespace std
streamsize __ret = 0;
if (this->_M_pback_init)
{
- if (__n && this->_M_in_cur == this->_M_in_beg)
+ if (__n && this->gptr() == this->eback())
{
- *__s++ = *this->_M_in_cur++;
+ *__s++ = *this->gptr();
+ this->gbump(1);
__ret = 1;
}
_M_destroy_pback();
@@ -427,10 +427,13 @@ namespace std
_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.
+ // 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: _M_out_end - _M_out_beg == _M_buf_size - 1, since _M_buf_size
+ // 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
@@ -439,14 +442,15 @@ namespace std
const bool __testin = this->_M_mode & ios_base::in;
const bool __testout = this->_M_mode & ios_base::out;
- if (__testin)
+ if (__testin && __off > 0)
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;
+ 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 --git a/libstdc++-v3/include/std/std_streambuf.h b/libstdc++-v3/include/std/std_streambuf.h
index fa85bf4641e..b69de0313a8 100644
--- a/libstdc++-v3/include/std/std_streambuf.h
+++ b/libstdc++-v3/include/std/std_streambuf.h
@@ -176,25 +176,6 @@ namespace std
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.
@@ -216,50 +197,11 @@ namespace std
*/
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);
}
@@ -330,7 +272,7 @@ namespace std
streamsize
in_avail()
{
- const streamsize __ret = _M_in_end - _M_in_cur;
+ const streamsize __ret = this->egptr() - this->gptr();
return __ret ? __ret : this->showmanyc();
}
@@ -373,8 +315,8 @@ namespace std
sgetc()
{
int_type __ret;
- if (_M_in_cur < _M_in_end)
- __ret = traits_type::to_int_type(*this->_M_in_cur);
+ if (this->gptr() < this->egptr())
+ __ret = traits_type::to_int_type(*this->gptr());
else
__ret = this->underflow();
return __ret;
@@ -461,7 +403,6 @@ namespace std
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())
{ }
@@ -553,7 +494,7 @@ namespace std
void
setp(char_type* __pbeg, char_type* __pend)
{
- _M_out_beg = _M_out_cur = _M_out_lim = __pbeg;
+ _M_out_beg = _M_out_cur = __pbeg;
_M_out_end = __pend;
}
@@ -703,10 +644,10 @@ namespace std
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)
+ if (!__testeof && this->gptr() < this->egptr())
{
- __ret = traits_type::to_int_type(*_M_in_cur);
- ++_M_in_cur;
+ __ret = traits_type::to_int_type(*this->gptr());
+ this->gbump(1);
}
return __ret;
}
@@ -786,8 +727,8 @@ namespace std
void
stossc()
{
- if (_M_in_cur < _M_in_end)
- ++_M_in_cur;
+ if (this->gptr() < this->egptr())
+ this->gbump(1);
else
this->uflow();
}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc
index 9098a2083e7..451518c1f23 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc
@@ -46,11 +46,11 @@ void test05()
{
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.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.write_position() );
VERIFY( !fb_03.read_position() );
}
@@ -58,9 +58,9 @@ void test05()
{
constraint_filebuf fb_01;
fb_01.open(name_01, ios_base::in | ios_base::out);
- VERIFY( fb_01.write_position() );
+ VERIFY( !fb_01.write_position() );
- int_type c1 = fb_01.sbumpc();
+ int_type c1 = fb_01.sbumpc();
VERIFY( c1 == '/' );
int_type c3 = fb_01.sbumpc();
VERIFY( c3 == '/' );
@@ -80,7 +80,7 @@ void test05()
VERIFY( c2 == '9' );
VERIFY( c3 == '0' );
- VERIFY( fb_01.write_position() );
+ VERIFY( !fb_01.write_position() );
VERIFY( fb_01.read_position() );
}
}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc
index ff0cb97dd5d..69559a9a69c 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc
@@ -45,13 +45,13 @@ void test05()
{
constraint_filebuf fb_02;
fb_02.open(name_02, ios_base::out | ios_base::trunc);
- VERIFY( fb_02.write_position() );
+ 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.write_position() );
VERIFY( !fb_02.read_position() );
}
}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc
index 7552d889eb6..d310d513871 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc
@@ -59,7 +59,7 @@ void test05()
{
constraint_filebuf fb_03;
fb_03.open(name_01, ios_base::out | ios_base::in);
- VERIFY( fb_03.write_position() );
+ VERIFY( !fb_03.write_position() );
VERIFY( !fb_03.read_position() );
// 27filebuf-3.txt = bd23456789:;<=>?...
//beg
@@ -111,7 +111,7 @@ void test05()
fb_03.pubsync();
c3 = fb_03.sgetc();
VERIFY( c1 == c3 );
- VERIFY( fb_03.write_position() );
+ VERIFY( !fb_03.write_position() );
VERIFY( fb_03.read_position() );
}
}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc
index 097edb76b2a..6efbb9512ae 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc
@@ -60,7 +60,7 @@ void test05()
{
constraint_filebuf fb_03;
fb_03.open(name_01, ios_base::out | ios_base::in);
- VERIFY( fb_03.write_position() );
+ VERIFY( !fb_03.write_position() );
VERIFY( !fb_03.read_position() );
pt_1 = fb_03.pubseekoff(78, ios_base::beg);
off_1 = pt_1;
@@ -84,7 +84,7 @@ void test05()
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.write_position() );
VERIFY( !fb_03.read_position() );
fb_03.close();
VERIFY( !fb_03.is_open() );
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/setbuf/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/setbuf/char/1.cc
index d4f9e4c15dc..25511d93ea6 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/setbuf/char/1.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/setbuf/char/1.cc
@@ -79,7 +79,7 @@ void test05()
// setbuf
// pubsetbuf(char_type* s, streamsize n)
f_tmp.pubsetbuf(0, 0);
- VERIFY( !f_tmp.check_pointers() );
+ VERIFY( f_tmp.check_pointers() );
}
}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc
index 6882234f1d5..7a754768002 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc
@@ -48,13 +48,13 @@ void test05()
{
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.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.write_position() );
VERIFY( !fb_03.read_position() );
}
@@ -62,7 +62,7 @@ void test05()
{
constraint_filebuf fb_01; // in
fb_01.open(name_01, ios::in | ios::out);
- VERIFY( fb_01.write_position() );
+ VERIFY( !fb_01.write_position() );
c1 = fb_01.sgetc();
VERIFY( c1 == '/' );
c2 = fb_01.sgetc();
@@ -74,7 +74,7 @@ void test05()
VERIFY( c1 == '/' );
VERIFY( c2 == ' ' );
VERIFY( c3 == ' ' );
- VERIFY( fb_01.write_position() );
+ VERIFY( !fb_01.write_position() );
VERIFY( fb_01.read_position() );
}
}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc
index 30d4d1b5e40..41e18e435e4 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc
@@ -47,7 +47,7 @@ void test05()
{
constraint_filebuf fb_02; // out
fb_02.open(name_02, ios::out | ios::trunc);
- VERIFY( fb_02.write_position() );
+ VERIFY( !fb_02.write_position() );
VERIFY( !fb_02.read_position() );
c1 = fb_02.sgetc();
VERIFY( c1 == traits_type::eof() );
@@ -57,7 +57,7 @@ void test05()
c1 = fb_02.sbumpc();
c2 = fb_02.sgetc();
VERIFY( c1 == c2 );
- VERIFY( fb_02.write_position() );
+ VERIFY( !fb_02.write_position() );
VERIFY( !fb_02.read_position() );
}
}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc
index ff2663ef911..e1d9a38f75e 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc
@@ -55,11 +55,11 @@ void test05()
{
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.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.write_position() );
VERIFY( !fb_03.read_position() );
}
@@ -70,7 +70,7 @@ void test05()
// 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() );
+ VERIFY( !fb_01.write_position() );
strmsz_1 = fb_01.in_avail();
strmsz_2 = fb_01.sgetn(carray1, 10);
VERIFY( strmsz_2 == 10 );
@@ -87,7 +87,7 @@ void test05()
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.write_position() );
VERIFY( !fb_01.read_position() );
}
}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc
index 7bd5e37e440..eb710f2d056 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc
@@ -53,7 +53,7 @@ void test05()
{
constraint_filebuf fb_02;
fb_02.open(name_02, ios_base::out | ios_base::trunc);
- VERIFY( fb_02.write_position() );
+ VERIFY( !fb_02.write_position() );
VERIFY( !fb_02.read_position() );
strmsz_2 = fb_02.in_avail();
strmsz_2 = fb_02.sgetn(carray2, 10);
@@ -66,7 +66,7 @@ void test05()
VERIFY( strmsz_2 == 0 );
c4 = fb_02.sgetc();
VERIFY( c4 == traits_type::eof() );
- VERIFY( fb_02.write_position() );
+ VERIFY( !fb_02.write_position() );
VERIFY( !fb_02.read_position() );
}
}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-io.cc
index 0627648cc7b..aa5000d987a 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-io.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-io.cc
@@ -48,11 +48,11 @@ void test05()
{
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.write_position() );
VERIFY( !fb_03.read_position() );
c3 = fb_03.snextc();
VERIFY( c3 == traits_type::eof() );
- VERIFY( fb_03.write_position() );
+ VERIFY( !fb_03.write_position() );
VERIFY( !fb_03.read_position() );
}
@@ -60,7 +60,7 @@ void test05()
{
constraint_filebuf fb_01;
fb_01.open(name_01, ios_base::in | ios_base::out);
- VERIFY( fb_01.write_position() );
+ VERIFY( !fb_01.write_position() );
int_type c4 = fb_01.sbumpc();
VERIFY( c4 == '/' );
c4 = fb_01.sbumpc();
@@ -71,7 +71,7 @@ void test05()
VERIFY( c1 == '9' );
c4 = fb_01.sgetc();
VERIFY( c4 == '9' );
- VERIFY( fb_01.write_position() );
+ VERIFY( !fb_01.write_position() );
VERIFY( fb_01.read_position() );
}
}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-out.cc
index d226ac29699..118383a978e 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-out.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1-out.cc
@@ -48,13 +48,13 @@ void test05()
{
constraint_filebuf fb_02;
fb_02.open(name_02, ios_base::out | ios_base::trunc);
- VERIFY( fb_02.write_position() );
+ 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.write_position() );
VERIFY( !fb_02.read_position() );
}
}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc
index ca300cedbd1..f43191cc730 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc
@@ -50,7 +50,7 @@ void test01()
{
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.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);
@@ -90,7 +90,7 @@ void test01()
c3 = fb_01.sgetc();
VERIFY( c3 == c2 );
VERIFY( strmsz_1 + 1 == strmsz_2 );
- VERIFY( fb_01.write_position() );
+ VERIFY( !fb_01.write_position() );
VERIFY( fb_01.read_position() );
}
}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc
index 78d3b790df6..83d57e2fc61 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc
@@ -48,7 +48,7 @@ void test01()
{
constraint_filebuf fb_01; // out
fb_01.open(name_01, ios::out | ios::trunc);
- VERIFY( fb_01.write_position() );
+ VERIFY( !fb_01.write_position() );
VERIFY( !fb_01.read_position() );
c1 = fb_01.sgetc();
VERIFY( c1 == traits_type::eof() );
@@ -58,7 +58,7 @@ void test01()
c1 = fb_01.sbumpc();
c2 = fb_01.sputbackc('a');
VERIFY( c1 == c2 );
- VERIFY( fb_01.write_position() );
+ VERIFY( !fb_01.write_position() );
VERIFY( !fb_01.read_position() );
}
}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-io.cc
index c1717612b6c..72350c0a8b8 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-io.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-io.cc
@@ -52,7 +52,7 @@ void test05()
{
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.write_position() );
VERIFY( !fb_03.read_position() );
c1 = fb_03.sputc('b');
VERIFY( c1 == 'b' );
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-out.cc
index 987b4e26217..f4b5b73f0e7 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-out.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-out.cc
@@ -51,7 +51,7 @@ void test05()
{
constraint_filebuf fb_02;
fb_02.open(name_02, ios_base::out | ios_base::trunc);
- VERIFY( fb_02.write_position() );
+ VERIFY( !fb_02.write_position() );
VERIFY( !fb_02.read_position() );
c1 = fb_02.sputc('a');
VERIFY( c1 == 'a' );
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/9701-2.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/9701-2.cc
index e0358ef5252..1d100dd3ede 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/9701-2.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/9701-2.cc
@@ -55,7 +55,7 @@ void test11()
dfbuf_01.open(name_05, std::ios_base::out);
over_called = false;
dfbuf_01.sputc('i');
- VERIFY( !over_called );
+ VERIFY( over_called );
over_expected = dfbuf_01.pub_epptr() == dfbuf_01.pub_pptr();
over_called = false;
dfbuf_01.sputc('v');
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-io.cc
index 37509601427..9ec3d259ca8 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-io.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-io.cc
@@ -50,7 +50,7 @@ void test05()
{
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.write_position() );
VERIFY( !fb_03.read_position() );
strmsz_1 = fb_03.sputn("racadabras", 10);//"abracadabras or what?"
VERIFY( strmsz_1 == 10 );
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-out.cc
index 647f310d87f..f98bcd745b1 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-out.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1-out.cc
@@ -49,7 +49,7 @@ void test05()
{
constraint_filebuf fb_02;
fb_02.open(name_02, ios_base::out | ios_base::trunc);
- VERIFY( fb_02.write_position() );
+ VERIFY( !fb_02.write_position() );
VERIFY( !fb_02.read_position() );
strmsz_1 = fb_02.sputn("racadabras", 10);
VERIFY( strmsz_1 == 10 );
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/9701-1.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/9701-1.cc
index 3c350a4d360..b675d79d0bb 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/9701-1.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/9701-1.cc
@@ -59,7 +59,7 @@ void test11()
dfbuf_02.open(name_05, std::ios_base::out);
over_called = false;
dfbuf_02.sputn("sonne's", 7);
- VERIFY( !over_called );
+ VERIFY( over_called );
over_expected = dfbuf_02.pub_epptr() == dfbuf_02.pub_pptr();
over_called = false;
dfbuf_02.sputn(" peak", 5);
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc
index 38819b6ba19..78464834bec 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc
@@ -50,7 +50,7 @@ void test01()
{
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.write_position() );
VERIFY( !fb_01.read_position() );
fb_01.sputc('u');
fb_01.sputc('v');
@@ -71,7 +71,7 @@ void test01()
VERIFY( c1 != c2 );
VERIFY( strmsz_2 != strmsz_1 );
VERIFY( strmsz_2 == 1 );
- VERIFY( fb_01.write_position() );
+ VERIFY( !fb_01.write_position() );
VERIFY( fb_01.read_position() );
}
}
diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc
index f7d78312420..99cf7ed383c 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc
@@ -48,7 +48,7 @@ void test01()
{
constraint_filebuf fb_01; // out
fb_01.open(name_01, ios::out | ios::trunc);
- VERIFY( fb_01.write_position() );
+ VERIFY( !fb_01.write_position() );
VERIFY( !fb_01.read_position() );
c1 = fb_01.sgetc();
VERIFY( c1 == traits_type::eof() );
@@ -58,7 +58,7 @@ void test01()
c1 = fb_01.sbumpc();
c2 = fb_01.sungetc();
VERIFY( c1 == c2 );
- VERIFY( fb_01.write_position() );
+ VERIFY( !fb_01.write_position() );
VERIFY( !fb_01.read_position() );
}
}