This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[Patch] Move streambuf::_M_mode to filebuf and stringbuf
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: libstdc++ at gcc dot gnu dot org
- Cc: bkoz <bkoz at redhat dot com>
- Date: Sun, 29 Jun 2003 18:37:44 +0200
- Subject: [Patch] Move streambuf::_M_mode to filebuf and stringbuf
Hi,
the below, as per Nathan's private indication, moves streambuf::_M_mode
to its proper places (where it's actually used, that is).
Tested x86-linux, seems almost trivial but will wait 24 hours...
Paolo.
////////
2003-06-29 Paolo Carlini <pcarlini@unitus.it>
* include/std/std_streambuf.h (_M_mode): Move from here to
filebuf and stringbuf.
(~basic_streambuf()): Don't set _M_mode.
(basic_streambuf()): Don't set _M_mode.
* include/std/std_fstream.h (_M_mode): Move here, from streambuf.
(~basic_filebuf()): Set _M_mode.
* include/bits/fstream.tcc (basic_filebuf()): Set _M_mode.
* include/std/std_sstream.h (_M_mode): Move here, from streambuf.
* testsuite/27_io/basic_streambuf/cons/char/1.cc: Don't set _M_mode.
* testsuite/27_io/basic_streambuf/overflow/char/1.cc: Likewise.
* testsuite/27_io/basic_streambuf/sgetc/char/1.cc: Likewise.
* testsuite/27_io/basic_streambuf/sgetn/char/1.cc: Likewise.
* testsuite/27_io/basic_streambuf/sputn/char/1.cc: Likewise.
diff -urN libstdc++-v3-curr/include/bits/fstream.tcc libstdc++-v3/include/bits/fstream.tcc
--- libstdc++-v3-curr/include/bits/fstream.tcc 2003-06-28 22:18:41.000000000 +0200
+++ libstdc++-v3/include/bits/fstream.tcc 2003-06-29 17:28:55.000000000 +0200
@@ -69,11 +69,11 @@
template<typename _CharT, typename _Traits>
basic_filebuf<_CharT, _Traits>::
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_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)
+ _M_mode(ios_base::openmode(0)), _M_state_cur(__state_type()),
+ _M_state_beg(__state_type()), _M_buf(NULL), _M_buf_size(BUFSIZ),
+ _M_buf_allocated(false), _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)
{
if (has_facet<__codecvt_type>(this->_M_buf_locale))
_M_codecvt = &use_facet<__codecvt_type>(this->_M_buf_locale);
diff -urN libstdc++-v3-curr/include/std/std_fstream.h libstdc++-v3/include/std/std_fstream.h
--- libstdc++-v3-curr/include/std/std_fstream.h 2003-06-28 22:22:47.000000000 +0200
+++ libstdc++-v3/include/std/std_fstream.h 2003-06-29 17:27:28.000000000 +0200
@@ -105,6 +105,13 @@
*/
__file_type _M_file;
+ /**
+ * @if maint
+ * Place to stash in || out || in | out settings for current filebuf.
+ * @endif
+ */
+ ios_base::openmode _M_mode;
+
// Current and beginning state type for codecvt.
/**
* @if maint
@@ -214,6 +221,7 @@
{
this->close();
_M_buf_size = 0;
+ _M_mode = ios_base::openmode(0);
_M_last_overflowed = false;
}
diff -urN libstdc++-v3-curr/include/std/std_sstream.h libstdc++-v3/include/std/std_sstream.h
--- libstdc++-v3-curr/include/std/std_sstream.h 2003-06-28 22:22:35.000000000 +0200
+++ libstdc++-v3/include/std/std_sstream.h 2003-06-29 18:20:15.000000000 +0200
@@ -85,6 +85,13 @@
//@}
protected:
+ /**
+ * @if maint
+ * Place to stash in || out || in | out settings for current stringbuf.
+ * @endif
+ */
+ ios_base::openmode _M_mode;
+
// Data Members:
/**
* @if maint
diff -urN libstdc++-v3-curr/include/std/std_streambuf.h libstdc++-v3/include/std/std_streambuf.h
--- libstdc++-v3-curr/include/std/std_streambuf.h 2003-06-28 23:21:29.000000000 +0200
+++ libstdc++-v3/include/std/std_streambuf.h 2003-06-29 17:35:28.000000000 +0200
@@ -178,13 +178,6 @@
/**
* @if maint
- * Place to stash in || out || in | out settings for current streambuf.
- * @endif
- */
- ios_base::openmode _M_mode;
-
- /**
- * @if maint
* Current locale setting.
* @endif
*/
@@ -201,9 +194,7 @@
/// Destructor deallocates no buffer space.
virtual
~basic_streambuf()
- {
- _M_mode = ios_base::openmode(0);
- }
+ { }
// [27.5.2.2.1] locales
/**
@@ -451,7 +442,7 @@
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_mode(ios_base::openmode(0)),_M_buf_locale(locale())
+ _M_buf_locale(locale())
{ }
// [27.5.2.3.1] get area access
diff -urN libstdc++-v3-curr/testsuite/27_io/basic_streambuf/cons/char/1.cc libstdc++-v3/testsuite/27_io/basic_streambuf/cons/char/1.cc
--- libstdc++-v3-curr/testsuite/27_io/basic_streambuf/cons/char/1.cc 2003-04-10 09:15:35.000000000 +0200
+++ libstdc++-v3/testsuite/27_io/basic_streambuf/cons/char/1.cc 2003-06-29 17:54:02.000000000 +0200
@@ -41,7 +41,7 @@
typedef std::streambuf::char_type char_type;
testbuf(): std::streambuf()
- { _M_mode = (std::ios_base::in | std::ios_base::out); }
+ { }
bool
check_pointers()
diff -urN libstdc++-v3-curr/testsuite/27_io/basic_streambuf/overflow/char/1.cc libstdc++-v3/testsuite/27_io/basic_streambuf/overflow/char/1.cc
--- libstdc++-v3-curr/testsuite/27_io/basic_streambuf/overflow/char/1.cc 2003-04-10 09:15:35.000000000 +0200
+++ libstdc++-v3/testsuite/27_io/basic_streambuf/overflow/char/1.cc 2003-06-29 17:53:41.000000000 +0200
@@ -41,7 +41,7 @@
typedef std::streambuf::char_type char_type;
testbuf(): std::streambuf()
- { _M_mode = (std::ios_base::in | std::ios_base::out); }
+ { }
bool
check_pointers()
diff -urN libstdc++-v3-curr/testsuite/27_io/basic_streambuf/sgetc/char/1.cc libstdc++-v3/testsuite/27_io/basic_streambuf/sgetc/char/1.cc
--- libstdc++-v3-curr/testsuite/27_io/basic_streambuf/sgetc/char/1.cc 2003-04-10 09:15:35.000000000 +0200
+++ libstdc++-v3/testsuite/27_io/basic_streambuf/sgetc/char/1.cc 2003-06-29 17:54:27.000000000 +0200
@@ -41,7 +41,7 @@
typedef std::streambuf::char_type char_type;
testbuf(): std::streambuf()
- { _M_mode = (std::ios_base::in | std::ios_base::out); }
+ { }
bool
check_pointers()
diff -urN libstdc++-v3-curr/testsuite/27_io/basic_streambuf/sgetn/char/1.cc libstdc++-v3/testsuite/27_io/basic_streambuf/sgetn/char/1.cc
--- libstdc++-v3-curr/testsuite/27_io/basic_streambuf/sgetn/char/1.cc 2003-04-10 09:15:35.000000000 +0200
+++ libstdc++-v3/testsuite/27_io/basic_streambuf/sgetn/char/1.cc 2003-06-29 17:54:52.000000000 +0200
@@ -41,7 +41,7 @@
typedef std::streambuf::char_type char_type;
testbuf(): std::streambuf()
- { _M_mode = (std::ios_base::in | std::ios_base::out); }
+ { }
bool
check_pointers()
diff -urN libstdc++-v3-curr/testsuite/27_io/basic_streambuf/sputn/char/1.cc libstdc++-v3/testsuite/27_io/basic_streambuf/sputn/char/1.cc
--- libstdc++-v3-curr/testsuite/27_io/basic_streambuf/sputn/char/1.cc 2003-04-10 09:15:36.000000000 +0200
+++ libstdc++-v3/testsuite/27_io/basic_streambuf/sputn/char/1.cc 2003-06-29 17:55:09.000000000 +0200
@@ -41,7 +41,7 @@
typedef std::streambuf::char_type char_type;
testbuf(): std::streambuf()
- { _M_mode = (std::ios_base::in | std::ios_base::out); }
+ { }
bool
check_pointers()