]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Remove _M_buf_size_opt, use directly _M_buf_size instead.
authorPaolo Carlini <pcarlini@unitus.it>
Sat, 12 Apr 2003 19:21:35 +0000 (21:21 +0200)
committerPaolo Carlini <paolo@gcc.gnu.org>
Sat, 12 Apr 2003 19:21:35 +0000 (19:21 +0000)
2003-04-12  Paolo Carlini  <pcarlini@unitus.it>

Remove _M_buf_size_opt, use directly _M_buf_size instead.
* include/bits/fstream.tcc
(basic_filebuf::_M_allocate_internal_buffer, setbuf): Remove
references to _M_buf_size_opt.
* include/bits/sstream.tcc (basic_stringbuf::overflow): Likewise.
* include/bits/streambuf.tcc (__copy_streambufs): Likewise, rename
__bufsize to __in_avail and __size_opt to __buf_size.
* include/ext/stdio_filebuf.h (stdio_filebuf::stdio_filebuf): Likewise.
* include/std/std_sstream.h (_M_stringbuf_init, setbuf): Likewise.
* include/std/std_streambuf.h (~basic_streambuf(),
basic_streambuf()): Likewise, remove _M_buf_size_opt member.
* testsuite/27_io/basic_filebuf/close/char/3.cc: Set _M_buf_size.
* testsuite/27_io/basic_filebuf/in_avail/char/1.cc: Likewise.
* testsuite/27_io/basic_filebuf/sbumpc/char/1.cc: Likewise.
* testsuite/27_io/basic_filebuf/seekoff/char/1.cc: Likewise.
* testsuite/27_io/basic_filebuf/seekpos/char/1.cc: Likewise.
* testsuite/27_io/basic_filebuf/sgetc/char/1.cc: Likewise.
* testsuite/27_io/basic_filebuf/sgetn/char/1.cc: Likewise.
* testsuite/27_io/basic_filebuf/snextc/char/1.cc: Likewise.
* testsuite/27_io/basic_filebuf/sputbackc/char/1.cc: Likewise.
* testsuite/27_io/basic_filebuf/sputc/char/1.cc: Likewise.
* testsuite/27_io/basic_filebuf/sputn/char/1.cc: Likewise.
* testsuite/27_io/basic_filebuf/sungetc/char/1.cc: Likewise.

From-SVN: r65518

19 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/fstream.tcc
libstdc++-v3/include/bits/sstream.tcc
libstdc++-v3/include/bits/streambuf.tcc
libstdc++-v3/include/ext/stdio_filebuf.h
libstdc++-v3/include/std/std_sstream.h
libstdc++-v3/include/std/std_streambuf.h
libstdc++-v3/testsuite/27_io/basic_filebuf/close/char/3.cc
libstdc++-v3/testsuite/27_io/basic_filebuf/in_avail/char/1.cc
libstdc++-v3/testsuite/27_io/basic_filebuf/sbumpc/char/1.cc
libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/1.cc
libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1.cc
libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1.cc
libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1.cc
libstdc++-v3/testsuite/27_io/basic_filebuf/snextc/char/1.cc
libstdc++-v3/testsuite/27_io/basic_filebuf/sputbackc/char/1.cc
libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1.cc
libstdc++-v3/testsuite/27_io/basic_filebuf/sputn/char/1.cc
libstdc++-v3/testsuite/27_io/basic_filebuf/sungetc/char/1.cc

index 65197a2e7eb5260dccf0947ce6126f799104d41c..10791e4e6b855f4b6dd18dd11d36253d12594909 100644 (file)
@@ -1,3 +1,29 @@
+2003-04-12  Paolo Carlini  <pcarlini@unitus.it>
+
+       Remove _M_buf_size_opt, use directly _M_buf_size instead.
+       * include/bits/fstream.tcc
+       (basic_filebuf::_M_allocate_internal_buffer, setbuf): Remove
+       references to _M_buf_size_opt. 
+       * include/bits/sstream.tcc (basic_stringbuf::overflow): Likewise.
+       * include/bits/streambuf.tcc (__copy_streambufs): Likewise, rename
+       __bufsize to __in_avail and __size_opt to __buf_size.
+       * include/ext/stdio_filebuf.h (stdio_filebuf::stdio_filebuf): Likewise.
+       * include/std/std_sstream.h (_M_stringbuf_init, setbuf): Likewise.
+       * include/std/std_streambuf.h (~basic_streambuf(),
+       basic_streambuf()): Likewise, remove _M_buf_size_opt member.
+       * testsuite/27_io/basic_filebuf/close/char/3.cc: Set _M_buf_size.
+       * testsuite/27_io/basic_filebuf/in_avail/char/1.cc: Likewise.
+       * testsuite/27_io/basic_filebuf/sbumpc/char/1.cc: Likewise.
+       * testsuite/27_io/basic_filebuf/seekoff/char/1.cc: Likewise.
+       * testsuite/27_io/basic_filebuf/seekpos/char/1.cc: Likewise.
+       * testsuite/27_io/basic_filebuf/sgetc/char/1.cc: Likewise.
+       * testsuite/27_io/basic_filebuf/sgetn/char/1.cc: Likewise.
+       * testsuite/27_io/basic_filebuf/snextc/char/1.cc: Likewise.
+       * testsuite/27_io/basic_filebuf/sputbackc/char/1.cc: Likewise.
+       * testsuite/27_io/basic_filebuf/sputc/char/1.cc: Likewise.
+       * testsuite/27_io/basic_filebuf/sputn/char/1.cc: Likewise.
+       * testsuite/27_io/basic_filebuf/sungetc/char/1.cc: Likewise.
+
 2003-04-12  Paolo Carlini  <pcarlini at unitus dot it>
 
        * include/ext/stdio_filebuf.h
index c4481bab4f895ea3335875ba819643a162074864..360b907336bfeb2da3803462fbe440591f9d7c13 100644 (file)
@@ -44,10 +44,8 @@ namespace std
     basic_filebuf<_CharT, _Traits>::
     _M_allocate_internal_buffer()
     {
-      if (!this->_M_buf && this->_M_buf_size_opt)
+      if (!this->_M_buf && this->_M_buf_size)
        {
-         this->_M_buf_size = this->_M_buf_size_opt;
-
          // Allocate internal buffer.
          this->_M_buf = new char_type[this->_M_buf_size];
          _M_buf_allocated = true;
@@ -416,7 +414,7 @@ namespace std
     setbuf(char_type* __s, streamsize __n)
     {
       if (!this->is_open() && __s == 0 && __n == 0)
-       this->_M_buf_size_opt = 0;
+       this->_M_buf_size = 0;
       else if (__s && __n)
        {
          // This is implementation-defined behavior, and assumes
@@ -429,7 +427,7 @@ namespace std
          
          // Step 2: Use the external array.
          this->_M_buf = __s;
-         this->_M_buf_size_opt = this->_M_buf_size = __n;
+         this->_M_buf_size = __n;
          // Consistently set the end of buffer pointer.
          this->_M_out_end = this->_M_buf + this->_M_buf_size;
          _M_set_indeterminate();
index d41b3cfeb9732dddb9a137042b2333acfcd2f600..ab3298c102259af948caa7f5957ff9ca19b5678d 100644 (file)
@@ -88,10 +88,12 @@ namespace std
       if (__builtin_expect(__testeof, false))
        return traits_type::not_eof(__c);
 
-      // In virtue of DR 169 (TC) we are allowed to grow more than
-      // one char the first time and also...
-      __size_type __len = std::max(__size_type(_M_string.capacity() + 1), 
-                                  this->_M_buf_size_opt);
+      // NB: Start ostringstream buffers at 512 chars. This is an
+      // experimental value (pronounced "arbitrary" in some of the
+      // hipper english-speaking countries), and can be changed to
+      // suit particular needs.
+      __size_type __len = std::max(__size_type(_M_string.capacity() + 1),
+                                  __size_type(512));
       bool __testput = this->_M_out_cur < this->_M_out_end;
       if (__builtin_expect(!__testput && __len > _M_string.max_size(), false))
        return traits_type::eof();
@@ -102,8 +104,9 @@ namespace std
        {
          // Force-allocate, re-sync.
          _M_string = this->str();
-         // ... the next time. That's easy to implement thanks to the
-         // exponential growth policy builtin into basic_string.
+         // In virtue of DR 169 (TC) we are allowed to grow more than
+         // one char. That's easy to implement thanks to the exponential
+         // growth policy builtin into basic_string.
          _M_string.reserve(__len);
          _M_really_sync(const_cast<char_type*>(_M_string.data()),
                         this->_M_in_cur - this->_M_in_beg, 
index 47fc4ece18440cc30e9e970768a6e7e59b76af7a..75ef5182c409df8a457efa2b48dbdc2fd8e09372 100644 (file)
@@ -192,29 +192,29 @@ namespace std
       typedef typename _Traits::off_type       off_type;
 
       streamsize __ret = 0;
-      streamsize __bufsize = __sbin->in_avail();
+      streamsize __in_avail = __sbin->in_avail();
       streamsize __xtrct;
-      const off_type __size_opt =
-       __sbin->_M_buf_size_opt > 0 ? __sbin->_M_buf_size_opt : 1;
+      const off_type __buf_size =
+       __sbin->_M_buf_size > 0 ? __sbin->_M_buf_size : 1;
 
       try 
        {
-         while (__bufsize != -1)
+         while (__in_avail != -1)
            {
-             if (__bufsize != 0 && __sbin->gptr() != NULL
-                 && __sbin->gptr() + __bufsize <= __sbin->egptr()) 
+             if (__in_avail != 0 && __sbin->gptr()
+                 && __sbin->gptr() + __in_avail <= __sbin->egptr()) 
                {
-                 __xtrct = __sbout->sputn(__sbin->gptr(), __bufsize);
+                 __xtrct = __sbout->sputn(__sbin->gptr(), __in_avail);
                  __ret += __xtrct;
                  __sbin->_M_in_cur_move(__xtrct);
-                 if (__xtrct != __bufsize)
+                 if (__xtrct != __in_avail)
                    break;
                }
              else 
                {
                  streamsize __charsread;
                  const streamsize __size =
-                   std::min(__size_opt, off_type(__sbout->_M_out_end -
+                   std::min(__buf_size, off_type(__sbout->_M_out_end -
                                                  __sbout->_M_out_cur));
                  if (__size > 1)
                    {
@@ -246,7 +246,7 @@ namespace std
                }
              if (_Traits::eq_int_type(__sbin->sgetc(), _Traits::eof()))
                break;
-             __bufsize = __sbin->in_avail();
+             __in_avail = __sbin->in_avail();
            }
        }
       catch(exception& __fail) 
index b15d8d88a6885a9071d46b9215cb2b582fda94fb..c2cfa2c143f3aa7454c728b29af0f628a555734f 100644 (file)
@@ -129,11 +129,10 @@ namespace __gnu_cxx
              // Specify not to use an allocated buffer.
              this->_M_buf = _M_unbuf;
              this->_M_buf_size = __size;
-             this->_M_buf_size_opt = 0;
            }
          else
            {
-             this->_M_buf_size_opt = __size;
+             this->_M_buf_size = __size;
              _M_allocate_internal_buffer();
            }
          _M_set_indeterminate();
@@ -154,11 +153,10 @@ namespace __gnu_cxx
              // Specify not to use an allocated buffer.
              this->_M_buf = _M_unbuf;
              this->_M_buf_size = __size;
-             this->_M_buf_size_opt = 0;
            }
          else
            {
-             this->_M_buf_size_opt = __size;
+             this->_M_buf_size = __size;
              _M_allocate_internal_buffer();
            }
          _M_set_indeterminate();
index 96fc6f009fa736e82c35e6c04f6517fc0004f458..635e8ed61fb7ebf2217ef6df11f00b3e33874de8 100644 (file)
@@ -177,13 +177,8 @@ namespace std
       void
       _M_stringbuf_init(ios_base::openmode __mode)
       {
-       // NB: Start ostringstream buffers at 512 bytes. This is an
-       // experimental value (pronounced "arbitrary" in some of the
-       // hipper english-speaking countries), and can be changed to
-       // suit particular needs.
-       this->_M_buf_size_opt = 512;
        this->_M_mode = __mode;
-       
+
        __size_type __len = 0;
        if (this->_M_mode & (ios_base::ate | ios_base::app))
          __len = _M_string.size();
@@ -235,7 +230,7 @@ namespace std
            
            // Step 2: Use the external array.
            this->_M_buf = __s;
-           this->_M_buf_size_opt = this->_M_buf_size = __n;
+           this->_M_buf_size = __n;
            _M_really_sync(__s, 0, 0);
          }
        return this;
index 81fe656c0d403c5df1f64a70ee5170ad3c940bb3..f6a31ac7c26a9ac1efda9706b177b8046bb7804a 100644 (file)
@@ -172,19 +172,12 @@ namespace std
 
       /**
        *  @if maint
-       *  Actual size of allocated internal buffer, in bytes. Unused
-       *  for sstreams, which have readily available _M_string.capacity().
+       *  Actual size of allocated internal buffer. Unused for sstreams,
+       *  which have readily available _M_string.capacity().
        *  @endif
       */
       size_t                   _M_buf_size;
 
-      /**
-       *  @if maint
-       *  Optimal or preferred size of internal buffer, in bytes.
-       *  @endif
-      */
-      size_t                   _M_buf_size_opt;
-
       /**
        *  @if maint
        *  True iff _M_in_* and _M_out_* buffers should always point to
@@ -340,7 +333,6 @@ namespace std
       {
        _M_buf_unified = false;
        _M_buf_size = 0;
-       _M_buf_size_opt = 0;
        _M_mode = ios_base::openmode(0);
       }
 
@@ -552,9 +544,9 @@ namespace std
        *  - this is not an error
       */
       basic_streambuf()
-      : _M_buf(NULL), _M_buf_size(0), _M_buf_size_opt(BUFSIZ), 
-      _M_buf_unified(false), _M_in_beg(0), _M_in_cur(0), _M_in_end(0),
-      _M_out_beg(0), _M_out_cur(0), _M_out_end(0), _M_out_lim(0),
+      : _M_buf(NULL), _M_buf_size(BUFSIZ), _M_buf_unified(false),
+      _M_in_beg(0), _M_in_cur(0), _M_in_end(0), _M_out_beg(0),
+      _M_out_cur(0), _M_out_end(0), _M_out_lim(0),
       _M_mode(ios_base::openmode(0)), _M_buf_locale(locale()), 
       _M_pback_cur_save(0), _M_pback_end_save(0), 
       _M_pback_init(false)
index d7c1286f0ff40fa95b67f690e168010e76b0a707..94059d0ee59bd64cd97611de5087402be07447f6 100644 (file)
@@ -54,7 +54,7 @@ class derived_filebuf: public std::filebuf
 {
  public:
   void
-  set_size(int_type __size) { _M_buf_size_opt = __size; }
+  set_size(int_type __size) { _M_buf_size = __size; }
 };
 
 derived_filebuf fb_01; // in 
index eca4951004f475328cdb3e283346d51da551dd86..479ff7ba7078f3997388d53a54871aea66aefa0c 100644 (file)
@@ -54,7 +54,7 @@ class derived_filebuf: public std::filebuf
 {
  public:
   void
-  set_size(int_type __size) { _M_buf_size_opt = __size; }
+  set_size(int_type __size) { _M_buf_size = __size; }
 };
 
 derived_filebuf fb_01; // in 
index 5a27cdd592cbe9a0c0d80a3dcf77c1e4ee84bff1..d2c7ccd53b471291576e9f432e2262074d66d7c8 100644 (file)
@@ -41,7 +41,7 @@ class derived_filebuf: public std::filebuf
 {
  public:
   void
-  set_size(int_type __size) { _M_buf_size_opt = __size; }
+  set_size(int_type __size) { _M_buf_size = __size; }
 };
 
 derived_filebuf fb_01; // in 
index cb64d106bb5faf8b6f11f2d9b4cb7af1160ffd5c..e448326d76b8e1df533f3e4fc3f5485eddc6849f 100644 (file)
@@ -39,7 +39,7 @@ class derived_filebuf: public std::filebuf
 {
  public:
   void
-  set_size(int_type __size) { _M_buf_size_opt = __size; }
+  set_size(int_type __size) { _M_buf_size = __size; }
 };
 
 derived_filebuf fb_03; // in | out
index 65a91c458f0f64a4426f04ea4a548b12b0d73d17..cd4084fc85e12ad76ca07071365a402f8f002f5e 100644 (file)
@@ -39,7 +39,7 @@ class derived_filebuf: public std::filebuf
 {
  public:
   void
-  set_size(int_type __size) { _M_buf_size_opt = __size; }
+  set_size(int_type __size) { _M_buf_size = __size; }
 };
 
 derived_filebuf fb_03; // in | out
index 34f535539497a735b5a325f9d2bff56b0e822c60..f5a194c32124d687c867e66dcfe00465264b056f 100644 (file)
@@ -54,7 +54,7 @@ class derived_filebuf: public std::filebuf
 {
  public:
   void
-  set_size(int_type __size) { _M_buf_size_opt = __size; }
+  set_size(int_type __size) { _M_buf_size = __size; }
 };
 
 derived_filebuf fb_01; // in 
index 1f0fd4c1d8e2691ecc8ceda31fb314bda0e139fd..634d41bec399a9f8e7550dc3e138feed70bea9b7 100644 (file)
@@ -41,7 +41,7 @@ class derived_filebuf: public std::filebuf
 {
  public:
   void
-  set_size(int_type __size) { _M_buf_size_opt = __size; }
+  set_size(int_type __size) { _M_buf_size = __size; }
 };
 
 derived_filebuf fb_01; // in 
index 9dcfcb5ac477ba315fd11e7e7d185dc22a6a336d..fb205bd701f01bfe435cf9b58ad757a7838ee8c3 100644 (file)
@@ -41,7 +41,7 @@ class derived_filebuf: public std::filebuf
 {
  public:
   void
-  set_size(int_type __size) { _M_buf_size_opt = __size; }
+  set_size(int_type __size) { _M_buf_size = __size; }
 };
 
 derived_filebuf fb_01; // in 
index 62dc70ee191ca3688c2f12608090ab849b859430..0f2eb896f5b7f3765528b1b4dbb86b78975a1dfd 100644 (file)
@@ -54,7 +54,7 @@ class derived_filebuf: public std::filebuf
 {
  public:
   void
-  set_size(int_type __size) { _M_buf_size_opt = __size; }
+  set_size(int_type __size) { _M_buf_size = __size; }
 };
 
 derived_filebuf fb_01; // in 
index db386f72212647f4821b1e9be62a2043481bd01f..875f37e8ae18ee1df99b055e30e5a52e68879be5 100644 (file)
@@ -54,7 +54,7 @@ class derived_filebuf: public std::filebuf
 {
  public:
   void
-  set_size(int_type __size) { _M_buf_size_opt = __size; }
+  set_size(int_type __size) { _M_buf_size = __size; }
 };
 
 derived_filebuf fb_01; // in 
index 38acef66baa4220e245cf44169a2410adbdbe75b..a8bafd50788bab47ca01d8939e4f3107858ae4b1 100644 (file)
@@ -54,7 +54,7 @@ class derived_filebuf: public std::filebuf
 {
  public:
   void
-  set_size(int_type __size) { _M_buf_size_opt = __size; }
+  set_size(int_type __size) { _M_buf_size = __size; }
 };
 
 derived_filebuf fb_01; // in 
index 92af72810b2caf7f86d7d21fdd5049333627dfa7..c0f2520c7d106e7b123c89fb9051c4e9a133f843 100644 (file)
@@ -54,7 +54,7 @@ class derived_filebuf: public std::filebuf
 {
  public:
   void
-  set_size(int_type __size) { _M_buf_size_opt = __size; }
+  set_size(int_type __size) { _M_buf_size = __size; }
 };
 
 derived_filebuf fb_01; // in