This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[Patch] Basic_streambuf::setg() and setp() (2nd take)
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: libstdc++ at gcc dot gnu dot org
- Cc: Benjamin Kosnik <bkoz at redhat dot com>
- Date: Thu, 08 May 2003 06:10:24 +0200
- Subject: [Patch] Basic_streambuf::setg() and setp() (2nd take)
Hi all, hi Benjamin,
if an issue with trying to simplify setg and setp is the
implementation defined behaviour of pubsetbuf,
basic_filebuf::setbuf, that is, why not changing the
latter, adding there _M_mode changing bits?
This allows much less complex _M_pback_destroy/create and
_M_set_indeterminate/determinate: perhaps we even inline
them with the default parameters (not really tried, yet).
Tested x86-linux, as usual.
Ok?
Paolo.
///////
2003-05-07 Paolo Carlini <pcarlini@unitus.it>
* include/std/std_streambuf.h (setg, setp): Don't change _M_mode...
* include/bits/fstream.tcc (setbuf): ... do it here.
diff -urN libstdc++-v3-orig/include/bits/fstream.tcc libstdc++-v3/include/bits/fstream.tcc
--- libstdc++-v3-orig/include/bits/fstream.tcc 2003-05-07 14:31:20.000000000 +0200
+++ libstdc++-v3/include/bits/fstream.tcc 2003-05-08 05:54:03.000000000 +0200
@@ -420,6 +420,10 @@
// Step 2: Use the external array.
this->_M_buf = __s;
this->_M_buf_size = __n;
+ if (!(this->_M_mode & ios_base::in))
+ this->_M_mode = this->_M_mode | ios_base::in;
+ if (!(this->_M_mode & ios_base::out))
+ this->_M_mode = this->_M_mode | ios_base::out;
_M_set_indeterminate();
}
_M_last_overflowed = false;
diff -urN libstdc++-v3-orig/include/std/std_streambuf.h libstdc++-v3/include/std/std_streambuf.h
--- libstdc++-v3-orig/include/std/std_streambuf.h 2003-04-29 01:51:36.000000000 +0200
+++ libstdc++-v3/include/std/std_streambuf.h 2003-05-08 05:54:21.000000000 +0200
@@ -508,8 +508,6 @@
_M_in_beg = __gbeg;
_M_in_cur = __gnext;
_M_in_end = __gend;
- if (!(_M_mode & ios_base::in) && __gbeg && __gnext && __gend)
- _M_mode = _M_mode | ios_base::in;
}
// [27.5.2.3.2] put area access
@@ -555,8 +553,6 @@
{
_M_out_beg = _M_out_cur = _M_out_lim = __pbeg;
_M_out_end = __pend;
- if (!(_M_mode & ios_base::out) && __pbeg && __pend)
- _M_mode = _M_mode | ios_base::out;
}
// [27.5.2.4] virtual functions