]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
std_streambuf.h (_M_out_buf_size()): Remove.
authorPaolo Carlini <pcarlini@unitus.it>
Mon, 31 Mar 2003 18:24:13 +0000 (20:24 +0200)
committerPaolo Carlini <paolo@gcc.gnu.org>
Mon, 31 Mar 2003 18:24:13 +0000 (18:24 +0000)
2003-03-31  Paolo Carlini  <pcarlini@unitus.it>

* include/std/std_streambuf.h (_M_out_buf_size()): Remove.
* include/bits/fstream.tcc (_M_allocate_internal_buffer):
Don't set _M_out_end.
(basic_filebuf::overflow): Replace _M_out_buf_size() with
this->_M_out_cur && this->_M_out_cur < this->_M_out_end.
* include/bits/sstream.tcc (basic_stringbuf::overflow):
Replace _M_out_buf_size() with this->_M_out_cur < this->_M_out_end;
* include/bits/streambuf.tcc (basic_streambuf::sputc):
Replace _M_out_buf_size() with _M_out_cur && _M_out_cur < _M_out_end.
(basic_streambuf::xsputn): Replace _M_out_buf_size() with
_M_out_end - _M_out_cur.
(__copy_streambufs): Likewise.
* include/std/std_fstream.h (_M_set_determinate): Set
_M_out_end here.

From-SVN: r65093

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/fstream.tcc
libstdc++-v3/include/bits/sstream.tcc
libstdc++-v3/include/bits/streambuf.tcc
libstdc++-v3/include/std/std_fstream.h
libstdc++-v3/include/std/std_streambuf.h

index 09ef061d96ff04d3698eb1e6c2ae9ced53584cbb..833755a8f38450b3574c01576e8752e05c482d9b 100644 (file)
@@ -1,3 +1,20 @@
+2003-03-31  Paolo Carlini  <pcarlini@unitus.it>
+
+       * include/std/std_streambuf.h (_M_out_buf_size()): Remove.
+       * include/bits/fstream.tcc (_M_allocate_internal_buffer):
+       Don't set _M_out_end.
+       (basic_filebuf::overflow): Replace _M_out_buf_size() with
+       this->_M_out_cur && this->_M_out_cur < this->_M_out_end.
+       * include/bits/sstream.tcc (basic_stringbuf::overflow):
+       Replace _M_out_buf_size() with this->_M_out_cur < this->_M_out_end;
+       * include/bits/streambuf.tcc (basic_streambuf::sputc):
+       Replace _M_out_buf_size() with _M_out_cur && _M_out_cur < _M_out_end.
+       (basic_streambuf::xsputn): Replace _M_out_buf_size() with
+       _M_out_end - _M_out_cur.
+       (__copy_streambufs): Likewise.
+       * include/std/std_fstream.h (_M_set_determinate): Set
+       _M_out_end here.
+       
 2003-03-30  Paolo Carlini  <pcarlini@unitus.it>
 
        * include/bits/fstream.tcc (basic_filebuf::showmanyc,
index f1b65a1a5580f6f4f089f9dec1f0a899377deeae..64f5d1d7703356167f435ac46f4e9e188b5bba97 100644 (file)
@@ -48,10 +48,8 @@ namespace std
        {
          this->_M_buf_size = this->_M_buf_size_opt;
 
-         // Allocate internal buffer...
+         // Allocate internal buffer.
          this->_M_buf = new char_type[this->_M_buf_size];
-         // ... and consistently set the end of buffer pointer.
-         this->_M_out_end = this->_M_buf + this->_M_buf_size;
          _M_buf_allocated = true;
        }
     }
@@ -255,7 +253,8 @@ namespace std
     overflow(int_type __c)
     {
       int_type __ret = traits_type::eof();
-      bool __testput = _M_out_buf_size();
+      bool __testput =
+       this->_M_out_cur && this->_M_out_cur < this->_M_out_end;
       bool __testout = this->_M_mode & ios_base::out;
       
       if (__testout)
index 5f9f62e93427deada42a3077e7a28cb2ec869e50..991cb13ef98250a36fb83641a230f92836c486fd 100644 (file)
@@ -92,7 +92,7 @@ namespace std
       __size_type __len =
        std::max(_M_string.capacity() + 1, this->_M_buf_size_opt);
 
-      bool __testwrite = _M_out_buf_size();
+      bool __testwrite = this->_M_out_cur < this->_M_out_end;
       if (__builtin_expect(!__testwrite && __len > _M_string.max_size(), false))
        return traits_type::eof();
 
index 6e9d192f34557e6249c0dfc775eac6496cb41afe..47fc4ece18440cc30e9e970768a6e7e59b76af7a 100644 (file)
@@ -99,7 +99,7 @@ namespace std
     sputc(char_type __c)
     {
       int_type __ret;
-      if (_M_out_buf_size())
+      if (_M_out_cur && _M_out_cur < _M_out_end)
        {
          *_M_out_cur = __c;
          _M_out_cur_move(1);
@@ -152,7 +152,7 @@ namespace std
       streamsize __ret = 0;
       while (__ret < __n)
        {
-         off_type __buf_len = _M_out_buf_size();
+         off_type __buf_len = _M_out_end - _M_out_cur;
          if (__buf_len > 0)
            {
              off_type __remaining = __n - __ret;
@@ -189,11 +189,12 @@ namespace std
                      basic_streambuf<_CharT, _Traits>* __sbout) 
   {
       typedef typename _Traits::int_type       int_type;
+      typedef typename _Traits::off_type       off_type;
 
       streamsize __ret = 0;
       streamsize __bufsize = __sbin->in_avail();
       streamsize __xtrct;
-      const typename _Traits::off_type __size_opt =
+      const off_type __size_opt =
        __sbin->_M_buf_size_opt > 0 ? __sbin->_M_buf_size_opt : 1;
 
       try 
@@ -213,7 +214,8 @@ namespace std
                {
                  streamsize __charsread;
                  const streamsize __size =
-                   std::min(__size_opt, __sbout->_M_out_buf_size());
+                   std::min(__size_opt, off_type(__sbout->_M_out_end -
+                                                 __sbout->_M_out_cur));
                  if (__size > 1)
                    {
                      _CharT* __buf =
index ecbaba4c510a340c6c8452023aff2626f1c5b5ae..c5e34808d16a8b7ee3004e44e86e3a9b88b8218c 100644 (file)
@@ -409,13 +409,10 @@ namespace std
        bool __testin = this->_M_mode & ios_base::in;
        bool __testout = this->_M_mode & ios_base::out;
        if (__testin)
-         {
-           this->_M_in_beg = this->_M_in_cur = this->_M_buf;
-           this->_M_in_end = this->_M_buf + __off;
-         }
+         this->setg(this->_M_buf, this->_M_buf, this->_M_buf + __off);
        if (__testout)
          {
-           this->_M_out_beg = this->_M_out_cur = this->_M_buf;
+           this->setp(this->_M_buf, this->_M_buf + this->_M_buf_size);
            this->_M_out_lim = this->_M_buf + __off;
          }
        _M_filepos = this->_M_buf + __off;
index 850f2015530056e10bcca1686ced6aa66762f632..10687d2975198fb1900705f85e608a9ebd27160d 100644 (file)
@@ -333,16 +333,6 @@ namespace std
          }
       }
 
-      // Returns zero if the output buffer is full (-> overflow).
-      off_type
-      _M_out_buf_size()
-      {
-       if (_M_out_cur)
-         return _M_out_end - _M_out_cur;
-       else
-         return off_type(0);
-      }
-
   public:
       /// Destructor deallocates no buffer space.
       virtual