+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>
Update to SGI STL 3.3
* 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.
* testsuite/21_strings/rfind.cc: New file.
basic_filebuf<_CharT, _Traits>::
basic_filebuf()
: __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()); }
-
template<typename _CharT, typename _Traits>
basic_filebuf<_CharT, _Traits>::
basic_filebuf(int __fd, const char* /*__name*/, ios_base::openmode __mode)
{
_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)
{
}
#endif
- bool __testclosed;
- if (_M_fileno_based)
- __testclosed = _M_file->sys_close();
- else
- __testclosed = _M_file->close();
-
- if (__testclosed)
+ if (_M_file)
{
+ delete _M_file;
+ _M_file = NULL;
_M_mode = ios_base::openmode(0);
if (_M_buf_size)
delete [] _M_buf;
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:
{
this->close();
_M_fcvt = NULL;
- delete _M_file;
- _M_file = NULL;
_M_last_overflowed = false;
}
__basic_file::__basic_file(__c_lock* __lock)
{
- this->_lock = __lock;
- _IO_init(this, 0);
+ _lock = __lock;
+ _IO_init(this, 0);
_IO_file_init(this);
+ _IO_file_attach(this, -1);
}
int
__basic_file::~__basic_file()
{
- if (_IO_file_is_open(this))
+ if (this->is_open())
{
_IO_do_flush(this);
- if (!(_IO_file_flags & _IO_DELETE_DONT_CLOSE))
+ if (!(_flags & _IO_DELETE_DONT_CLOSE))
_IO_SYSCLOSE(this);
}
- else
- _IO_un_link(this);
+ _IO_default_finish(this, 0);
}
__basic_file*
if (__fd >= 0)
{
- __retval = this;
_fileno = __fd;
+ int __mask = _IO_NO_READS + _IO_NO_WRITES + _IO_IS_APPENDING;
+ _flags = (_flags & ~__mask) | (__rw_mode & __mask);
+ _IO_link_in(this);
+ __retval = this;
}
-
- int __mask = _IO_NO_READS + _IO_NO_WRITES + _IO_IS_APPENDING;
- _IO_file_flags = (_IO_file_flags & ~__mask) | (__rw_mode & __mask);
- _IO_link_in(this);
return __retval;
}
if (__testb)
__p_mode |= O_BINARY;
#endif
- if ( !_IO_file_is_open(this))
+ if (!_IO_file_is_open(this))
{
#if _G_HAVE_IO_FILE_OPEN
__c_file_type* __f;
__f = _IO_file_open(this, __name, __p_mode, __prot, __rw_mode, 0);
__retval = __f ? this: NULL;
#else
- int __i = ::open(__name, __p_mode, __prot);
- if (__i >= 0)
+ int __fd = ::open(__name, __p_mode, __prot);
+ if (__fd >= 0)
{
+ _fileno = __fd;
+ int __mask = _IO_NO_READS + _IO_NO_WRITES + _IO_IS_APPENDING;
+ _flags = (_flags & ~__mask) | (__rw_mode & __mask);
+ _IO_link_in(this);
__retval = this;
- _fileno = __i;
}
- int __mask = _IO_NO_READS + _IO_NO_WRITES + _IO_IS_APPENDING;
- _IO_file_flags = (_IO_file_flags & ~__mask) | (__rw_mode & __mask);
- _IO_link_in(this);
#endif
}
return __retval;
__basic_file*
__basic_file::close()
- {
- bool __testopen = _IO_file_close_it(this);
- return __testopen ? static_cast<__basic_file*>(NULL) : this;
- }
+ { return _IO_file_close_it(this) ? static_cast<__basic_file*>(NULL) : this; }
// NB: Unused.
int
const int buffer_size = 8192;
+
// initialize filebufs to be the same size regardless of platform
void test00()
{
fb_03.set_size(buffer_size);
}
+
// test the filebuf/stringbuf locale settings
bool test01() {
std::locale loc_tmp;
test &= !fb_03.is_open();
// filebuf_type* open(const char* __s, ios_base::openmode __mode)
- fb_01.open(name_01, std::ios_base::in | std::ios_base::ate);
+ fb_01.open(name_01, std::ios_base::in | std::ios_base::ate);
fb_02.open(name_02, std::ios_base::in | std::ios_base::out | std::ios_base::trunc);
// Try to open two different files without closing the first:
// Should keep the old file attached, and disregard attempt to overthrow.
// read (standard)
FILE* f = fopen(name_01, "r");
- test &= !f;
+ test &= f != NULL;
{
std::ifstream ifstream1(name_01);