Commit ab30ba5c by Benjamin Kosnik

filebuf.cc: Tweak.


2000-06-28  Benjamin Kosnik  <bkoz@purist.soma.redhat.com>

	* testsuite/27_io/filebuf.cc: Tweak.
	* testsuite/27_io/filebuf_members.cc (test_01): Fix.
	* config/c_io_libio.cc (__basic_file::~__basic_file): Match libio
	filebuf dtor.
	(__basic_file::basic_file): Clean, add calls similar to
	_IO_file_attach.
	(__basic_file::open): Clean.
	(__basic_file::sys_open): Clean.

	* bits/std_fstream.h: Revert.
	* bits/fstream.tcc (filebuf::close()): Revert.
	(filebuf::basic_filebuf()): Revert.

From-SVN: r34786
parent 993c790e
2000-06-28 Benjamin Kosnik <bkoz@purist.soma.redhat.com>
* testsuite/27_io/filebuf.cc: Tweak.
* testsuite/27_io/filebuf_members.cc (test_01): Fix.
* config/c_io_libio.cc (__basic_file::~__basic_file): Match libio
filebuf dtor.
(__basic_file::basic_file): Clean, add calls similar to
_IO_file_attach.
(__basic_file::open): Clean.
(__basic_file::sys_open): Clean.
* bits/std_fstream.h: Revert.
* bits/fstream.tcc (filebuf::close()): Revert.
(filebuf::basic_filebuf()): Revert.
2000-06-27 Benjamin Kosnik <bkoz@purist.soma.redhat.com> 2000-06-27 Benjamin Kosnik <bkoz@purist.soma.redhat.com>
Update to SGI STL 3.3 Update to SGI STL 3.3
...@@ -30,7 +45,7 @@ ...@@ -30,7 +45,7 @@
* docs/install.html: Fix minor typo as reported. * docs/install.html: Fix minor typo as reported.
2000-06-13 Brent Verner <brent@rcfile.org> 2000-06-26 Brent Verner <brent@rcfile.org>
* bits/string.tcc (string::rfind): Fix. * bits/string.tcc (string::rfind): Fix.
* testsuite/21_strings/rfind.cc: New file. * testsuite/21_strings/rfind.cc: New file.
......
...@@ -56,10 +56,9 @@ namespace std ...@@ -56,10 +56,9 @@ namespace std
basic_filebuf<_CharT, _Traits>:: basic_filebuf<_CharT, _Traits>::
basic_filebuf() basic_filebuf()
: __streambuf_type(), _M_file(NULL), _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_last_overflowed(false)
{ _M_fcvt = &use_facet<__codecvt_type>(this->getloc()); } { _M_fcvt = &use_facet<__codecvt_type>(this->getloc()); }
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
basic_filebuf<_CharT, _Traits>:: basic_filebuf<_CharT, _Traits>::
basic_filebuf(int __fd, const char* /*__name*/, ios_base::openmode __mode) basic_filebuf(int __fd, const char* /*__name*/, ios_base::openmode __mode)
...@@ -68,7 +67,6 @@ namespace std ...@@ -68,7 +67,6 @@ namespace std
{ {
_M_fcvt = &use_facet<__codecvt_type>(this->getloc()); _M_fcvt = &use_facet<__codecvt_type>(this->getloc());
_M_init_filebuf(); _M_init_filebuf();
_M_fileno_based = true;
_M_file->sys_open(__fd, __mode); _M_file->sys_open(__fd, __mode);
if (this->is_open() && _M_buf_size) if (this->is_open() && _M_buf_size)
{ {
...@@ -144,14 +142,10 @@ namespace std ...@@ -144,14 +142,10 @@ namespace std
} }
#endif #endif
bool __testclosed; if (_M_file)
if (_M_fileno_based)
__testclosed = _M_file->sys_close();
else
__testclosed = _M_file->close();
if (__testclosed)
{ {
delete _M_file;
_M_file = NULL;
_M_mode = ios_base::openmode(0); _M_mode = ios_base::openmode(0);
if (_M_buf_size) if (_M_buf_size)
delete [] _M_buf; delete [] _M_buf;
......
...@@ -71,7 +71,6 @@ namespace std { ...@@ -71,7 +71,6 @@ namespace std {
const __codecvt_type* _M_fcvt; // Cached value from use_facet. const __codecvt_type* _M_fcvt; // Cached value from use_facet.
__mutext_type _M_lock; __mutext_type _M_lock;
bool _M_last_overflowed; // XXX Needed? bool _M_last_overflowed; // XXX Needed?
bool _M_fileno_based; // Open/closed via filenos.
public: public:
// Constructors/destructor: // Constructors/destructor:
...@@ -85,8 +84,6 @@ namespace std { ...@@ -85,8 +84,6 @@ namespace std {
{ {
this->close(); this->close();
_M_fcvt = NULL; _M_fcvt = NULL;
delete _M_file;
_M_file = NULL;
_M_last_overflowed = false; _M_last_overflowed = false;
} }
......
...@@ -39,9 +39,10 @@ namespace std { ...@@ -39,9 +39,10 @@ namespace std {
__basic_file::__basic_file(__c_lock* __lock) __basic_file::__basic_file(__c_lock* __lock)
{ {
this->_lock = __lock; _lock = __lock;
_IO_init(this, 0); _IO_init(this, 0);
_IO_file_init(this); _IO_file_init(this);
_IO_file_attach(this, -1);
} }
int int
...@@ -50,14 +51,13 @@ namespace std { ...@@ -50,14 +51,13 @@ namespace std {
__basic_file::~__basic_file() __basic_file::~__basic_file()
{ {
if (_IO_file_is_open(this)) if (this->is_open())
{ {
_IO_do_flush(this); _IO_do_flush(this);
if (!(_IO_file_flags & _IO_DELETE_DONT_CLOSE)) if (!(_flags & _IO_DELETE_DONT_CLOSE))
_IO_SYSCLOSE(this); _IO_SYSCLOSE(this);
} }
else _IO_default_finish(this, 0);
_IO_un_link(this);
} }
__basic_file* __basic_file*
...@@ -89,13 +89,12 @@ namespace std { ...@@ -89,13 +89,12 @@ namespace std {
if (__fd >= 0) if (__fd >= 0)
{ {
__retval = this;
_fileno = __fd; _fileno = __fd;
}
int __mask = _IO_NO_READS + _IO_NO_WRITES + _IO_IS_APPENDING; int __mask = _IO_NO_READS + _IO_NO_WRITES + _IO_IS_APPENDING;
_IO_file_flags = (_IO_file_flags & ~__mask) | (__rw_mode & __mask); _flags = (_flags & ~__mask) | (__rw_mode & __mask);
_IO_link_in(this); _IO_link_in(this);
__retval = this;
}
return __retval; return __retval;
} }
...@@ -148,22 +147,22 @@ namespace std { ...@@ -148,22 +147,22 @@ namespace std {
if (__testb) if (__testb)
__p_mode |= O_BINARY; __p_mode |= O_BINARY;
#endif #endif
if ( !_IO_file_is_open(this)) if (!_IO_file_is_open(this))
{ {
#if _G_HAVE_IO_FILE_OPEN #if _G_HAVE_IO_FILE_OPEN
__c_file_type* __f; __c_file_type* __f;
__f = _IO_file_open(this, __name, __p_mode, __prot, __rw_mode, 0); __f = _IO_file_open(this, __name, __p_mode, __prot, __rw_mode, 0);
__retval = __f ? this: NULL; __retval = __f ? this: NULL;
#else #else
int __i = ::open(__name, __p_mode, __prot); int __fd = ::open(__name, __p_mode, __prot);
if (__i >= 0) if (__fd >= 0)
{ {
__retval = this; _fileno = __fd;
_fileno = __i;
}
int __mask = _IO_NO_READS + _IO_NO_WRITES + _IO_IS_APPENDING; int __mask = _IO_NO_READS + _IO_NO_WRITES + _IO_IS_APPENDING;
_IO_file_flags = (_IO_file_flags & ~__mask) | (__rw_mode & __mask); _flags = (_flags & ~__mask) | (__rw_mode & __mask);
_IO_link_in(this); _IO_link_in(this);
__retval = this;
}
#endif #endif
} }
return __retval; return __retval;
...@@ -174,10 +173,7 @@ namespace std { ...@@ -174,10 +173,7 @@ namespace std {
__basic_file* __basic_file*
__basic_file::close() __basic_file::close()
{ { return _IO_file_close_it(this) ? static_cast<__basic_file*>(NULL) : this; }
bool __testopen = _IO_file_close_it(this);
return __testopen ? static_cast<__basic_file*>(NULL) : this;
}
// NB: Unused. // NB: Unused.
int int
......
...@@ -46,6 +46,7 @@ derived_filebuf fb_03; // in | out ...@@ -46,6 +46,7 @@ derived_filebuf fb_03; // in | out
const int buffer_size = 8192; const int buffer_size = 8192;
// initialize filebufs to be the same size regardless of platform // initialize filebufs to be the same size regardless of platform
void test00() void test00()
{ {
...@@ -54,6 +55,7 @@ void test00() ...@@ -54,6 +55,7 @@ void test00()
fb_03.set_size(buffer_size); fb_03.set_size(buffer_size);
} }
// test the filebuf/stringbuf locale settings // test the filebuf/stringbuf locale settings
bool test01() { bool test01() {
std::locale loc_tmp; std::locale loc_tmp;
......
...@@ -60,7 +60,7 @@ test_01() ...@@ -60,7 +60,7 @@ test_01()
// read (standard) // read (standard)
FILE* f = fopen(name_01, "r"); FILE* f = fopen(name_01, "r");
test &= !f; test &= f != NULL;
{ {
std::ifstream ifstream1(name_01); std::ifstream ifstream1(name_01);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment