summaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/bits/streambuf.tcc
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 /libstdc++-v3/include/bits/streambuf.tcc
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
Diffstat (limited to 'libstdc++-v3/include/bits/streambuf.tcc')
-rw-r--r--libstdc++-v3/include/bits/streambuf.tcc44
1 files changed, 22 insertions, 22 deletions
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;