2000-06-23 Benjamin Kosnik <bkoz@purist.soma.redhat.com>
+ * 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 <brent@rcfile.org>
+ * 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.
template<typename _CharT, typename _Traits>
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<typename _CharT, typename _Traits>
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)
{
_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)
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()