This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[Patch] Remove basic_filebuf::_M_last_overflowed
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: libstdc++ at gcc dot gnu dot org
- Cc: bkoz <bkoz at redhat dot com>
- Date: Sat, 03 May 2003 13:58:21 +0200
- Subject: [Patch] Remove basic_filebuf::_M_last_overflowed
Hi,
this was real fun!
In std_fstream.h we had this comment
// XXX Needed?
bool _M_last_overflowed;
so I had a look. The only place where it was used
was seekeoff():
// Sync the internal and external streams.
// out
if (__testput || _M_last_overflowed)
{
// Part one: update the output sequence.
And the only place where it was *apparently* set to true
was _M_overflow().
However, overflow(), just before returning, set it back
to false! And I went ahead: in all the other places where
_M_overflow() was called, before returning _M_last_overflowed
was also set back to false (*)!
Therefore, it could *never* happen that it was true in
that 'if' inside seekoff()! (QED ;)
Tested x86-linux, ok for trunk?
Paolo.
(*) And/or seekoff() was not called in the middle
(e.g., _M_underflow()).
2003-05-03 Paolo Carlini <pcarlini@unitus.it>
Remove basic_filebuf::_M_last_overflowed
* include/std/std_fstream.h (~basic_filebuf(), sync()): Don't
set _M_last_overflowed.
* include/bits/fstream.tcc (basic_filebuf(), close(),
showmanyc(), pbackfail(), overflow(), _M_overflow(), setbuf(),
imbue()): Likewise.
(seekoff): Remove from 'if' condition, don't set.
* src/fstream.cc (basic_filebuf<char/wchar_t>::_M_underflow):
Don't set _M_last_overflowed.
diff -urN libstdc++-v3-orig/include/bits/fstream.tcc libstdc++-v3/include/bits/fstream.tcc
--- libstdc++-v3-orig/include/bits/fstream.tcc 2003-04-29 21:46:07.000000000 +0200
+++ libstdc++-v3/include/bits/fstream.tcc 2003-05-03 13:39:32.000000000 +0200
@@ -77,8 +77,7 @@
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_pback_cur_save(0),
- _M_pback_end_save(0), _M_pback_init(false)
+ _M_pback_cur_save(0), _M_pback_end_save(0), _M_pback_init(false)
{ this->_M_buf_unified = true; }
template<typename _CharT, typename _Traits>
@@ -129,7 +128,7 @@
#if 0
// XXX not done
- if (_M_last_overflowed)
+ if (__testput)
{
_M_output_unshift();
_M_overflow(__eof);
@@ -152,7 +151,6 @@
if (!__testfail)
__ret = this;
}
- _M_last_overflowed = false;
return __ret;
}
@@ -177,7 +175,6 @@
__ret += _M_file.showmanyc_helper(__testsync) / __cvt.max_length();
}
- _M_last_overflowed = false;
return __ret;
}
@@ -240,7 +237,6 @@
}
}
}
- _M_last_overflowed = false;
return __ret;
}
@@ -267,7 +263,6 @@
__ret = this->_M_overflow(__c);
}
- _M_last_overflowed = false; // Set in _M_overflow, below.
return __ret;
}
@@ -396,7 +391,6 @@
}
}
}
- _M_last_overflowed = true;
return __ret;
}
@@ -422,7 +416,6 @@
this->_M_buf_size = __n;
_M_set_indeterminate();
}
- _M_last_overflowed = false;
return this;
}
@@ -456,7 +449,7 @@
const bool __testput = this->_M_out_beg < this->_M_out_lim;
// Sync the internal and external streams.
// out
- if (__testput || _M_last_overflowed)
+ if (__testput)
{
// Part one: update the output sequence.
this->sync();
@@ -487,7 +480,6 @@
}
}
}
- _M_last_overflowed = false;
return __ret;
}
@@ -523,7 +515,6 @@
// converted chars. This in turn may cause the reconstruction
// of the original file. YIKES!!
// XXX The part in the above comment is not done.
- _M_last_overflowed = false;
}
// Inhibit implicit instantiations for required instantiations,
diff -urN libstdc++-v3-orig/include/std/std_fstream.h libstdc++-v3/include/std/std_fstream.h
--- libstdc++-v3-orig/include/std/std_fstream.h 2003-04-29 01:51:36.000000000 +0200
+++ libstdc++-v3/include/std/std_fstream.h 2003-05-03 12:59:07.000000000 +0200
@@ -136,9 +136,6 @@
*/
bool _M_buf_allocated;
- // XXX Needed?
- bool _M_last_overflowed;
-
// The position in the buffer corresponding to the external file
// pointer.
/**
@@ -225,7 +222,6 @@
{
this->close();
_M_buf_size = 0;
- _M_last_overflowed = false;
}
// Members:
@@ -406,7 +402,6 @@
else
_M_file.sync();
- _M_last_overflowed = false;
return __ret;
}
diff -urN libstdc++-v3-orig/src/fstream.cc libstdc++-v3/src/fstream.cc
--- libstdc++-v3-orig/src/fstream.cc 2003-04-28 06:54:54.000000000 +0200
+++ libstdc++-v3/src/fstream.cc 2003-05-03 12:54:36.000000000 +0200
@@ -102,7 +102,6 @@
}
}
}
- _M_last_overflowed = false;
return __ret;
}
@@ -207,7 +206,6 @@
}
}
}
- _M_last_overflowed = false;
return __ret;
}