From: Benjamin Kosnik Date: Sat, 24 Jun 2000 00:56:05 +0000 (+0000) Subject: fstream.tcc (basic_filebuf::basic_filebuf(fd)): Use it. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=81ef1479590b169b10a93e7e7d4fbaaa4af2b4a4;p=platform%2Fupstream%2Fgcc.git fstream.tcc (basic_filebuf::basic_filebuf(fd)): Use it. 2000-06-23 Benjamin Kosnik * bits/fstream.tcc (basic_filebuf::basic_filebuf(fd)): Use it. (basic_filebuf::close): Use it. * bits/std_fstream.h (basic_filebuf): Remove default arguments for filebuf ctor. (basic_filebuf): Add _M_fileno_based data member. As reported by brent verner * testsuite/27_io/filebuf_members.cc: New file. * testsuite/27_io/filebuf_members-1.tst: New file. From-SVN: r34673 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 0c20b3d..1b283126 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,14 @@ 2000-06-23 Benjamin Kosnik + * bits/fstream.tcc (basic_filebuf::basic_filebuf(fd)): Use it. + (basic_filebuf::close): Use it. + * bits/std_fstream.h (basic_filebuf): Remove default arguments for + filebuf ctor. + (basic_filebuf): Add _M_fileno_based data member. + As reported by brent verner + * testsuite/27_io/filebuf_members.cc: New file. + * testsuite/27_io/filebuf_members-1.tst: New file. + * bits/std_fstream.h: Formatting tweaks. * testsuite/27_io/ofstream_members.cc: New file. * testsuite/27_io/ofstream_members-1.tst: New file. diff --git a/libstdc++-v3/bits/fstream.tcc b/libstdc++-v3/bits/fstream.tcc index 44cfb19..d5a5e97 100644 --- a/libstdc++-v3/bits/fstream.tcc +++ b/libstdc++-v3/bits/fstream.tcc @@ -55,19 +55,20 @@ namespace std template basic_filebuf<_CharT, _Traits>:: basic_filebuf() - : __streambuf_type(), _M_file(NULL), _M_last_overflowed(false), - _M_state_cur(), _M_state_beg() + : __streambuf_type(), _M_file(NULL), _M_state_cur(), _M_state_beg(), + _M_last_overflowed(false), _M_fileno_based(false) { _M_fcvt = &use_facet<__codecvt_type>(this->getloc()); } template basic_filebuf<_CharT, _Traits>:: basic_filebuf(int __fd, const char* /*__name*/, ios_base::openmode __mode) - : __streambuf_type(), _M_last_overflowed(false), - _M_state_cur(), _M_state_beg() + : __streambuf_type(), _M_state_cur(), _M_state_beg(), + _M_last_overflowed(false) { _M_fcvt = &use_facet<__codecvt_type>(this->getloc()); _M_init_filebuf(); + _M_fileno_based = true; _M_file->sys_open(__fd, __mode); if (this->is_open() && _M_buf_size) { @@ -142,8 +143,14 @@ namespace std _M_really_overflow(traits_type::eof()); } #endif - - if (_M_file->close()) + + bool __testclosed; + if (_M_fileno_based) + __testclosed = _M_file->sys_close(); + else + __testclosed = _M_file->close(); + + if (__testclosed) { _M_mode = ios_base::openmode(0); if (_M_buf_size) diff --git a/libstdc++-v3/bits/std_fstream.h b/libstdc++-v3/bits/std_fstream.h index 158623e..063f1df 100644 --- a/libstdc++-v3/bits/std_fstream.h +++ b/libstdc++-v3/bits/std_fstream.h @@ -66,19 +66,19 @@ namespace std { private: // Data Members: __file_type* _M_file; - bool _M_last_overflowed; // XXX Needed? __state_type _M_state_cur;// Current state type for codecvt. __state_type _M_state_beg; const __codecvt_type* _M_fcvt; // Cached value from use_facet. __mutext_type _M_lock; - + bool _M_last_overflowed; // XXX Needed? + bool _M_fileno_based; // Open/closed via filenos. + public: // Constructors/destructor: basic_filebuf(); // Non-standard ctor: - basic_filebuf(int __fd, const char* __name = "unknown", - ios_base::openmode __mode = ios_base::in | ios_base::out); + basic_filebuf(int __fd, const char* __name, ios_base::openmode __mode); virtual ~basic_filebuf()