aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@unitus.it>2003-05-07 14:48:58 +0200
committerPaolo Carlini <paolo@gcc.gnu.org>2003-05-07 12:48:58 +0000
commitcd96b185c55c02d9a74755489deffd3e287e6060 (patch)
treed5347de6279f2d770da10bdb7d098bea9e9da6de
parentda635858a526e75936c13622baa93d2e23344daa (diff)
downloadgcc-cd96b185c55c02d9a74755489deffd3e287e6060.zip
gcc-cd96b185c55c02d9a74755489deffd3e287e6060.tar.gz
gcc-cd96b185c55c02d9a74755489deffd3e287e6060.tar.bz2
std_fstream.h (_M_is_indeterminate): Remove.
2003-05-07 Paolo Carlini <pcarlini@unitus.it> * include/std/std_fstream.h (_M_is_indeterminate): Remove. * src/fstream.cc (basic_filebuf<char/wchar_t>::_M_underflow): Simplify: either there is no buffer or __testget == !__testinit. * src/fstream.cc (basic_filebuf<char/wchar_t>::_M_underflow): _M_set_determinate() automatically sets, if appropriate, _M_out_cur == _M_in_cur. * include/std/std_fstream.h (_M_destroy_pback): Don't set unnecessarily _M_pback_cur_save and _M_pback_end_save. * include/std/std_fstream.h (_M_set_determinate): Minor tweak. * include/std/std_sstream.h (_M_sync): Minor tweak. * include/bits/fstream.tcc (close): No need to call _M_destroy_pback, setting _M_pback_init to false suffices to clean up. From-SVN: r66557
-rw-r--r--libstdc++-v3/ChangeLog22
-rw-r--r--libstdc++-v3/include/bits/fstream.tcc2
-rw-r--r--libstdc++-v3/include/std/std_fstream.h30
-rw-r--r--libstdc++-v3/include/std/std_sstream.h2
-rw-r--r--libstdc++-v3/src/fstream.cc10
5 files changed, 28 insertions, 38 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index bd8039a..6ee16c2 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,25 @@
+2003-05-07 Paolo Carlini <pcarlini@unitus.it>
+
+ * include/std/std_fstream.h (_M_is_indeterminate): Remove.
+ * src/fstream.cc
+ (basic_filebuf<char/wchar_t>::_M_underflow): Simplify: either
+ there is no buffer or __testget == !__testinit.
+
+ * src/fstream.cc
+ (basic_filebuf<char/wchar_t>::_M_underflow): _M_set_determinate()
+ automatically sets, if appropriate, _M_out_cur == _M_in_cur.
+
+ * include/std/std_fstream.h (_M_destroy_pback): Don't set
+ unnecessarily _M_pback_cur_save and _M_pback_end_save.
+
+ * include/std/std_fstream.h (_M_set_determinate): Minor tweak.
+
+ * include/std/std_sstream.h (_M_sync): Minor tweak.
+
+ * include/bits/fstream.tcc (close): No need to call
+ _M_destroy_pback, setting _M_pback_init to false suffices
+ to clean up.
+
2003-05-06 Benjamin Kosnik <bkoz@redhat.com>
* include/bits/stl_algo.h: Enums as _S_.
diff --git a/libstdc++-v3/include/bits/fstream.tcc b/libstdc++-v3/include/bits/fstream.tcc
index 0dba445..c15d6de 100644
--- a/libstdc++-v3/include/bits/fstream.tcc
+++ b/libstdc++-v3/include/bits/fstream.tcc
@@ -143,8 +143,8 @@ namespace std
// NB: Do this here so that re-opened filebufs will be cool...
this->_M_mode = ios_base::openmode(0);
+ this->_M_pback_init = false;
_M_destroy_internal_buffer();
- _M_destroy_pback();
if (!_M_file.close())
__testfail = true;
diff --git a/libstdc++-v3/include/std/std_fstream.h b/libstdc++-v3/include/std/std_fstream.h
index ffbf789..b8704f4 100644
--- a/libstdc++-v3/include/std/std_fstream.h
+++ b/libstdc++-v3/include/std/std_fstream.h
@@ -201,8 +201,6 @@ namespace std
this->setg(this->_M_buf, _M_pback_cur_save + __off_cur,
_M_pback_end_save + __off_end);
- _M_pback_cur_save = NULL;
- _M_pback_end_save = NULL;
_M_pback_init = false;
}
}
@@ -452,7 +450,7 @@ namespace std
void
_M_output_unshift();
- // These three functions are used to clarify internal buffer
+ // These two functions are used to clarify internal buffer
// maintenance. After an overflow, or after a seekoff call that
// started at beg or end, or possibly when the stream becomes
// unbuffered, and a myrid other obscure corner cases, the
@@ -483,34 +481,10 @@ namespace std
if (__testout)
{
this->setp(this->_M_buf, this->_M_buf + this->_M_buf_size);
- this->_M_out_lim = this->_M_buf + __off;
+ this->_M_out_lim += __off;
}
_M_filepos = this->_M_buf + __off;
}
-
- /**
- * @if maint
- * @doctodo
- * @endif
- */
- bool
- _M_is_indeterminate(void)
- {
- const bool __testin = this->_M_mode & ios_base::in;
- const bool __testout = this->_M_mode & ios_base::out;
- bool __ret = false;
- // Don't return true if unbuffered.
- if (this->_M_buf)
- {
- if (__testin)
- __ret = this->_M_in_beg == this->_M_in_cur
- && this->_M_in_cur == this->_M_in_end;
- if (__testout)
- __ret = this->_M_out_beg == this->_M_out_cur
- && this->_M_out_cur == this->_M_out_lim;
- }
- return __ret;
- }
};
// Explicit specialization declarations, defined in src/fstream.cc.
diff --git a/libstdc++-v3/include/std/std_sstream.h b/libstdc++-v3/include/std/std_sstream.h
index e917079..ca7b1e5 100644
--- a/libstdc++-v3/include/std/std_sstream.h
+++ b/libstdc++-v3/include/std/std_sstream.h
@@ -258,7 +258,7 @@ namespace std
{
this->setp(__base, __base + _M_string.capacity());
// _M_out_lim points to the string end.
- this->_M_out_lim = __base + __len;
+ this->_M_out_lim += __len;
this->_M_out_cur += __o;
}
}
diff --git a/libstdc++-v3/src/fstream.cc b/libstdc++-v3/src/fstream.cc
index 1f2a000..41ca770 100644
--- a/libstdc++-v3/src/fstream.cc
+++ b/libstdc++-v3/src/fstream.cc
@@ -64,7 +64,6 @@ namespace std
// Sync internal and external buffers.
// NB: __testget -> __testput as _M_buf_unified here.
const bool __testget = _M_in_beg < _M_in_cur;
- const bool __testinit = _M_is_indeterminate();
if (__testget)
{
if (__testout)
@@ -74,7 +73,7 @@ namespace std
ios_base::cur, __testsync, ios_base::in);
}
- if (__testinit || __testget)
+ if (_M_buf_size)
{
streamsize __elen = 0;
streamsize __ilen = 0;
@@ -86,8 +85,6 @@ namespace std
if (0 < __ilen)
{
_M_set_determinate(__ilen);
- if (__testout)
- _M_out_cur = _M_in_cur;
__ret = traits_type::to_int_type(*_M_in_cur);
if (__bump)
_M_move_in_cur(1);
@@ -145,7 +142,6 @@ namespace std
// Sync internal and external buffers.
// NB: __testget -> __testput as _M_buf_unified here.
const bool __testget = _M_in_beg < _M_in_cur;
- const bool __testinit = _M_is_indeterminate();
if (__testget)
{
if (__testout)
@@ -155,7 +151,7 @@ namespace std
ios_base::cur, __testsync, ios_base::in);
}
- if (__testinit || __testget)
+ if (_M_buf_size)
{
streamsize __elen = 0;
streamsize __ilen = 0;
@@ -191,8 +187,6 @@ namespace std
if (0 < __ilen)
{
_M_set_determinate(__ilen);
- if (__testout)
- _M_out_cur = _M_in_cur;
__ret = traits_type::to_int_type(*_M_in_cur);
if (__bump)
_M_move_in_cur(1);