]> gcc.gnu.org Git - gcc.git/commitdiff
filebuf.cc: Tweak.
authorBenjamin Kosnik <bkoz@gcc.gnu.org>
Thu, 29 Jun 2000 18:20:55 +0000 (18:20 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Thu, 29 Jun 2000 18:20:55 +0000 (18:20 +0000)
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

libstdc++-v3/ChangeLog
libstdc++-v3/bits/fstream.tcc
libstdc++-v3/bits/std_fstream.h
libstdc++-v3/config/c_io_libio.cc
libstdc++-v3/testsuite/27_io/filebuf.cc
libstdc++-v3/testsuite/27_io/filebuf_members.cc

index 2eb0351d0dd8dc9e084e4df59d1609a6db69b7a2..605040a8777112feb550980cf80037a5b343db9d 100644 (file)
@@ -1,3 +1,18 @@
+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
@@ -30,7 +45,7 @@
 
        * 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.
index d5a5e97eff0248e9771fb3631f680f5a688191c4..8380abc077aff19d828b72477ee6ec9bb069a17e 100644 (file)
@@ -56,10 +56,9 @@ namespace std
     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)
@@ -68,7 +67,6 @@ namespace std
     {
       _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)
        {
@@ -144,14 +142,10 @@ namespace std
            }
 #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;
index 063f1df50ee8484281126288d3430f70fbb0fbb4..f372100efc97f9ca13d9a3b036be0185bfe76dcb 100644 (file)
@@ -71,7 +71,6 @@ namespace std {
       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:
@@ -85,8 +84,6 @@ namespace std {
       { 
        this->close();
        _M_fcvt = NULL;
-       delete _M_file;
-       _M_file = NULL;
        _M_last_overflowed = false;
       }
 
index 22fa70220197379982f66391689318a4056cccbb..7bc4a990bf9ea015302d45aaa6c66bf278619a0a 100644 (file)
@@ -39,9 +39,10 @@ namespace std {
   
   __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 
@@ -50,14 +51,13 @@ namespace std {
  
   __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*
@@ -89,13 +89,12 @@ namespace std {
 
     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;
   }
 
@@ -148,22 +147,22 @@ namespace std {
     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;
@@ -174,10 +173,7 @@ namespace std {
   
   __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 
index a04215e7d22a5b858c2f52f6919c0e40a6a40690..ce51a5915ea3759d3846996ca48f466daabff42e 100644 (file)
@@ -46,6 +46,7 @@ derived_filebuf fb_03; // in | out
 
 const int buffer_size = 8192;
 
+
 // initialize filebufs to be the same size regardless of platform
 void test00()
 {
@@ -54,6 +55,7 @@ void test00()
   fb_03.set_size(buffer_size);
 }
 
+
 // test the filebuf/stringbuf locale settings
 bool test01() {
   std::locale loc_tmp;
@@ -75,7 +77,7 @@ bool test02() {
   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.
index 5057074529bb2c8fa9297bd0a936caeb5e9ad6c4..5933bfd8607a31d25a5a02862f4d52f66069df92 100644 (file)
@@ -60,7 +60,7 @@ test_01()
 
   // read (standard)
   FILE* f = fopen(name_01, "r");
-  test &= !f;
+  test &= f != NULL;
 
   {
     std::ifstream ifstream1(name_01);
This page took 0.074743 seconds and 5 git commands to generate.