Internal consistency checks.....
authorBenjamin Kosnik <bkoz@gcc.gnu.org>
Wed, 19 Jul 2000 08:04:38 +0000 (08:04 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Wed, 19 Jul 2000 08:04:38 +0000 (08:04 +0000)
2000-07-19  Benjamin Kosnik  <bkoz@milou.soma.redhat.com>

Internal consistency checks.....
* bits/ios_base.h: Change _M_locale_ios to _M_ios_locale.
* src/ios.cc: Same.

* bits/basic_ios.h: Change _M_fctype_ios to _M_ios_fctype.
* bits/basic_ios.tcc: Same.

* bits/std_streambuf.h: Change _M_locale_buf to _M_buf_locale.
Change _M_fctype_buf to _M_buf_fctype.
* bits/fstream.tcc: Same.

* bits/std_streambuf.h: Change _M_buf_bump to _M_out_cur_move.
Change _M_locale_set to _M_buf_locale_init.
* bits/streambuf.tcc: Same.
* bits/sstream.tcc: Same.
* bits/fstream.tcc: Same.

* bits/std_streambuf.h: Make typedefs consistent.
(_M_buf_bump): Be more careful with input sequence.

* bits/std_sstream.h: Same.
* bits/std_fstream.h: Same.

From-SVN: r35129

libstdc++-v3/ChangeLog
libstdc++-v3/bits/basic_ios.h
libstdc++-v3/bits/basic_ios.tcc
libstdc++-v3/bits/fstream.tcc
libstdc++-v3/bits/ios_base.h
libstdc++-v3/bits/sstream.tcc
libstdc++-v3/bits/std_fstream.h
libstdc++-v3/bits/std_sstream.h
libstdc++-v3/bits/std_streambuf.h
libstdc++-v3/bits/streambuf.tcc
libstdc++-v3/src/ios.cc

index 83299da..4dd8eae 100644 (file)
@@ -1,4 +1,29 @@
-2000-07-18  Benjamin Kosnik  <bkoz@soma.redhat.com>
+2000-07-19  Benjamin Kosnik  <bkoz@milou.soma.redhat.com>
+
+       Internal consistency checks.....
+       * bits/ios_base.h: Change _M_locale_ios to _M_ios_locale.
+       * src/ios.cc: Same.
+       
+       * bits/basic_ios.h: Change _M_fctype_ios to _M_ios_fctype.
+       * bits/basic_ios.tcc: Same.
+       
+       * bits/std_streambuf.h: Change _M_locale_buf to _M_buf_locale.
+       Change _M_fctype_buf to _M_buf_fctype.
+       * bits/fstream.tcc: Same.
+
+       * bits/std_streambuf.h: Change _M_buf_bump to _M_out_cur_move.
+       Change _M_locale_set to _M_buf_locale_init.
+       * bits/streambuf.tcc: Same.
+       * bits/sstream.tcc: Same.
+       * bits/fstream.tcc: Same.
+
+       * bits/std_streambuf.h: Make typedefs consistent.
+       (_M_buf_bump): Be more careful with input sequence.
+
+       * bits/std_sstream.h: Same.
+       * bits/std_fstream.h: Same.
+
+2000-07-18  Benjamin Kosnik  <bkoz@purist.soma.redhat.com>
 
        * acinclude.m4: Tweaks.
        * config/c_io_libio.cc: Tweaks.
index 8168ec0..7cac68b 100644 (file)
@@ -66,7 +66,7 @@ namespace std {
       iostate                          _M_streambuf_state;
 
       // Cached use_facet<ctype>, which is based on the current locale info.
-      const __ctype_type*              _M_fctype_ios;      
+      const __ctype_type*              _M_ios_fctype;      
       // From ostream.
       const __numput_type*             _M_fnumput;
       // From istream.
@@ -76,7 +76,7 @@ namespace std {
 
       inline const __ctype_type*       
       _M_get_fctype_ios(void)
-      { return _M_fctype_ios; }
+      { return _M_ios_fctype; }
 
       inline const __numget_type* 
       _M_get_fnumget(void)
index 3c24e24..54d5efd 100644 (file)
@@ -91,12 +91,12 @@ namespace std {
   template<typename _CharT, typename _Traits>
     char
     basic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const
-    { return _M_fctype_ios->narrow(__c, __dfault); }
+    { return _M_ios_fctype->narrow(__c, __dfault); }
 
   template<typename _CharT, typename _Traits>
     _CharT
     basic_ios<_CharT, _Traits>::widen(char __c) const
-    { return _M_fctype_ios->widen(__c); }
+    { return _M_ios_fctype->widen(__c); }
 
   // Locales:
   template<typename _CharT, typename _Traits>
@@ -105,7 +105,7 @@ namespace std {
     {
       locale __old(this->getloc());
       ios_base::imbue(__loc);
-      _M_fctype_ios = &use_facet<__ctype_type>(__loc);
+      _M_ios_fctype = &use_facet<__ctype_type>(__loc);
       _M_fnumput = &use_facet<__numput_type>(__loc); 
       _M_fnumget = &use_facet<__numget_type>(__loc); 
       if (this->rdbuf() != 0)
@@ -120,7 +120,7 @@ namespace std {
       // NB: This may be called more than once on the same object.
       ios_base::_M_init();
       locale __loc = this->getloc();
-      _M_fctype_ios = &use_facet<__ctype_type>(__loc);
+      _M_ios_fctype = &use_facet<__ctype_type>(__loc);
       // Should be filled in by ostream and istream, respectively.
       _M_fnumput = &use_facet<__numput_type>(__loc); 
       _M_fnumget = &use_facet<__numget_type>(__loc); 
index 8380abc..556c110 100644 (file)
@@ -329,7 +329,7 @@ namespace std
          if (!__testpos)
            {
              *_M_out_cur = traits_type::to_char_type(__c);
-             _M_buf_bump(1);
+             _M_out_cur_move(1);
              __retval = traits_type::not_eof(__c);
            }
          else 
@@ -535,14 +535,14 @@ namespace std
       bool __testbeg = gptr() == eback() && pptr() == pbase();
       bool __teststate = _M_fcvt->encoding() == -1;
       
-      _M_locale_set = true;
-      if (__testbeg && !__teststate && _M_locale_buf != __loc)
+      _M_buf_locale_init = true;
+      if (__testbeg && !__teststate && _M_buf_locale != __loc)
        {
          // XXX Will need to save these older values.
-         _M_locale_buf = __loc;
-         _M_fcvt = &use_facet<__codecvt_type>(_M_locale_buf);
+         _M_buf_locale = __loc;
+         _M_fcvt = &use_facet<__codecvt_type>(_M_buf_locale);
          // XXX Necessary?
-         _M_fctype_buf = &use_facet<__ctype_type>(_M_locale_buf); 
+         _M_buf_fctype = &use_facet<__ctype_type>(_M_buf_locale); 
        }
       // NB this may require the reconversion of previously
       // converted chars. This in turn may cause the reconstruction
index ee257c6..f7b8ca9 100644 (file)
@@ -276,7 +276,7 @@ namespace std {
     _M_grow_words(int __index);
 
     // Members for locale and locale caching.
-    locale             _M_locale_ios;
+    locale             _M_ios_locale;
 
     void 
     _M_init();
@@ -367,7 +367,7 @@ namespace std {
     imbue(const locale& __loc);
 
     inline locale 
-    getloc() const { return _M_locale_ios; }
+    getloc() const { return _M_ios_locale; }
 
     // Storage:
     static int 
index 949c263..e87e6d1 100644 (file)
@@ -102,7 +102,7 @@ namespace std {
                  _M_really_sync(_M_in_cur - _M_in_beg, 
                                 _M_out_cur - _M_out_beg);
                  *_M_out_cur = traits_type::to_char_type(__c);
-                 _M_buf_bump(1);
+                 _M_out_cur_move(1);
                  __retval = __c;
                }
            }
@@ -163,7 +163,7 @@ namespace std {
          if (__testout
              && __newoffo + __off >= 0 && __endo - __beg >= __newoffo + __off)
            {
-             _M_buf_bump(__newoffo + __off - (_M_out_cur - __beg));
+             _M_out_cur_move(__newoffo + __off - (_M_out_cur - __beg));
              __retval = pos_type(__newoffo);
            }
        }
@@ -199,7 +199,7 @@ namespace std {
          if (__testin)
            _M_in_cur = _M_in_beg + __pos;
          if (__testout)
-           _M_buf_bump((__pos) - (_M_out_cur - __beg));
+           _M_out_cur_move((__pos) - (_M_out_cur - __beg));
          __retval = pos_type(off_type(__pos));
        }
       
index 997d377..045bb60 100644 (file)
@@ -47,20 +47,19 @@ namespace std {
     {
     public:
       // Types:
-      typedef _CharT                                     char_type;
-      typedef _Traits                                    traits_type;
-      typedef typename _Traits::int_type                 int_type;
-      typedef typename _Traits::pos_type                 pos_type;
-      typedef typename _Traits::off_type                 off_type;
-
+      typedef _CharT                                   char_type;
+      typedef _Traits                                  traits_type;
+      typedef typename traits_type::int_type           int_type;
+      typedef typename traits_type::pos_type           pos_type;
+      typedef typename traits_type::off_type           off_type;
 
       // Non-standard Types:
-      typedef basic_streambuf<_CharT, _Traits>                   __streambuf_type;
-      typedef basic_filebuf<_CharT, _Traits>             __filebuf_type;
-      typedef __basic_file                               __file_type;
-      typedef typename _Traits::state_type                __state_type;
-      typedef codecvt<_CharT, char, __state_type>         __codecvt_type;
-      typedef typename __codecvt_type::result            __res_type;
+      typedef basic_streambuf<char_type, traits_type>          __streambuf_type;
+      typedef basic_filebuf<char_type, traits_type>     __filebuf_type;
+      typedef __basic_file                             __file_type;
+      typedef typename traits_type::state_type          __state_type;
+      typedef codecvt<char_type, char, __state_type>    __codecvt_type;
+      typedef typename __codecvt_type::result          __res_type;
       
       friend ios_base; // For sync_with_stdio.
 
@@ -197,15 +196,15 @@ namespace std {
     {
     public:
       // Types:
-      typedef _CharT                           char_type;
-      typedef typename _Traits::int_type       int_type;
-      typedef typename _Traits::pos_type       pos_type;
-      typedef typename _Traits::off_type       off_type;
-      typedef _Traits                          traits_type;
+      typedef _CharT                                   char_type;
+      typedef _Traits                                  traits_type;
+      typedef typename traits_type::int_type           int_type;
+      typedef typename traits_type::pos_type           pos_type;
+      typedef typename traits_type::off_type           off_type;
 
       // Non-standard types:
-      typedef basic_filebuf<_CharT, _Traits>   __filebuf_type;
-      typedef basic_istream<_CharT, _Traits>   __istream_type;
+      typedef basic_filebuf<char_type, traits_type>    __filebuf_type;
+      typedef basic_istream<char_type, traits_type>    __istream_type;
     
       // Constructors/Destructors:
       basic_ifstream()
@@ -251,17 +250,17 @@ namespace std {
     class basic_ofstream : public basic_ostream<_CharT,_Traits>
     {
     public:
-       // Types:
-      typedef _CharT                           char_type;
-      typedef typename _Traits::int_type       int_type;
-      typedef typename _Traits::pos_type       pos_type;
-      typedef typename _Traits::off_type       off_type;
-      typedef _Traits                          traits_type;
+      // Types:
+      typedef _CharT                                   char_type;
+      typedef _Traits                                  traits_type;
+      typedef typename traits_type::int_type           int_type;
+      typedef typename traits_type::pos_type           pos_type;
+      typedef typename traits_type::off_type           off_type;
 
       // Non-standard types:
-      typedef basic_filebuf<_CharT, _Traits>   __filebuf_type;
-      typedef basic_ostream<_CharT, _Traits>   __ostream_type;
-     
+      typedef basic_filebuf<char_type, traits_type>    __filebuf_type;
+      typedef basic_ostream<char_type, traits_type>    __ostream_type;
+      
       // Constructors:
       basic_ofstream()
       : __ostream_type(new __filebuf_type())
@@ -312,17 +311,17 @@ namespace std {
     class basic_fstream : public basic_iostream<_CharT, _Traits>
     {
     public:
-       // Types:
-      typedef _CharT                           char_type;
-      typedef typename _Traits::int_type       int_type;
-      typedef typename _Traits::pos_type       pos_type;
-      typedef typename _Traits::off_type       off_type;
-      typedef _Traits                          traits_type;
+      // Types:
+      typedef _CharT                                   char_type;
+      typedef _Traits                                  traits_type;
+      typedef typename traits_type::int_type           int_type;
+      typedef typename traits_type::pos_type           pos_type;
+      typedef typename traits_type::off_type           off_type;
 
       // Non-standard types:
-      typedef basic_filebuf<_CharT, _Traits>   __filebuf_type;
-      typedef basic_ios<_CharT, _Traits>       __ios_type;
-      typedef basic_iostream<_CharT, _Traits>  __iostream_type;
+      typedef basic_filebuf<char_type, traits_type>    __filebuf_type;
+      typedef basic_ios<char_type, traits_type>                __ios_type;
+      typedef basic_iostream<char_type, traits_type>   __iostream_type;
 
       // Constructors/destructor:
       basic_fstream()
index 939d6c0..4394dc9 100644 (file)
@@ -45,13 +45,14 @@ namespace std {
     public:
       // Types:
       typedef _CharT                                   char_type;
-      typedef typename _Traits::int_type               int_type;
-      typedef typename _Traits::pos_type               pos_type;
-      typedef typename _Traits::off_type               off_type;
-      typedef _Traits                                  traits_type;
-      // Non-standard types:
-      typedef basic_streambuf<_CharT, _Traits>                 __streambuf_type;
-      typedef basic_string<_CharT, _Traits, _Alloc>    __string_type;
+      typedef _Traits                                  traits_type;
+      typedef typename traits_type::int_type           int_type;
+      typedef typename traits_type::pos_type           pos_type;
+      typedef typename traits_type::off_type           off_type;
+
+      // Non-standard Types:
+      typedef basic_streambuf<char_type, traits_type>          __streambuf_type;
+      typedef basic_string<char_type, _Traits, _Alloc>         __string_type;
       typedef typename __string_type::size_type                __size_type;
 
     private:
@@ -192,16 +193,16 @@ namespace std {
     {
     public:
       // Types:
-      typedef _CharT char_type;
-      typedef typename _Traits::int_type               int_type;
-      typedef typename _Traits::pos_type               pos_type;
-      typedef typename _Traits::off_type               off_type;
-      typedef _Traits                                  traits_type;
+      typedef _CharT                                   char_type;
+      typedef _Traits                                  traits_type;
+      typedef typename traits_type::int_type           int_type;
+      typedef typename traits_type::pos_type           pos_type;
+      typedef typename traits_type::off_type           off_type;
 
       // Non-standard types:
       typedef basic_string<_CharT, _Traits, _Alloc>    __string_type;
       typedef basic_stringbuf<_CharT, _Traits, _Alloc>         __stringbuf_type;
-      typedef basic_istream<_CharT, _Traits>           __istream_type;
+      typedef basic_istream<char_type, traits_type>    __istream_type;
 
       // Constructors:
       explicit 
@@ -245,15 +246,16 @@ namespace std {
     {
     public:
       // Types:
-      typedef _CharT char_type;
-      typedef typename _Traits::int_type int_type;
-      typedef typename _Traits::pos_type pos_type;
-      typedef typename _Traits::off_type off_type;
-      typedef _Traits                    traits_type;
+      typedef _CharT                                   char_type;
+      typedef _Traits                                  traits_type;
+      typedef typename traits_type::int_type           int_type;
+      typedef typename traits_type::pos_type           pos_type;
+      typedef typename traits_type::off_type           off_type;
+
       // Non-standard types:
       typedef basic_string<_CharT, _Traits, _Alloc>    __string_type;
       typedef basic_stringbuf<_CharT, _Traits, _Alloc>         __stringbuf_type;
-      typedef basic_ostream<_CharT, _Traits>           __ostream_type;
+      typedef basic_ostream<char_type, traits_type>    __ostream_type;
 
       // Constructors/destructor:
       explicit 
@@ -296,16 +298,17 @@ namespace std {
     class basic_stringstream : public basic_iostream<_CharT, _Traits>
     {
     public:
-      // Types
-      typedef _CharT char_type;
-      typedef typename _Traits::int_type int_type;
-      typedef typename _Traits::pos_type pos_type;
-      typedef typename _Traits::off_type off_type;
-      typedef _Traits                    traits_type;
-       // Non-standard types:
+      // Types:
+      typedef _CharT                                   char_type;
+      typedef _Traits                                  traits_type;
+      typedef typename traits_type::int_type           int_type;
+      typedef typename traits_type::pos_type           pos_type;
+      typedef typename traits_type::off_type           off_type;
+
+      // Non-standard Types:
       typedef basic_string<_CharT, _Traits, _Alloc>    __string_type;
       typedef basic_stringbuf<_CharT, _Traits, _Alloc>         __stringbuf_type;
-      typedef basic_iostream<_CharT, _Traits>          __iostream_type;
+      typedef basic_iostream<char_type, traits_type>   __iostream_type;
      
       // Constructors/destructors
       explicit 
index 5798ba1..23bdd5c 100644 (file)
@@ -55,14 +55,14 @@ namespace std {
     public:
       // Types:
       typedef _CharT                                   char_type;
-      typedef typename _Traits::int_type               int_type;
-      typedef typename _Traits::pos_type               pos_type;
-      typedef typename _Traits::off_type               off_type;
       typedef _Traits                                  traits_type;
+      typedef typename traits_type::int_type           int_type;
+      typedef typename traits_type::pos_type           pos_type;
+      typedef typename traits_type::off_type           off_type;
 
       // Non-standard Types:
-      typedef ctype<_CharT>                            __ctype_type;
-      typedef basic_streambuf<_CharT, _Traits>                 __streambuf_type;
+      typedef ctype<char_type>                         __ctype_type;
+      typedef basic_streambuf<char_type, traits_type>          __streambuf_type;
       
       friend class basic_ios<char_type, traits_type>;
       friend class basic_istream<char_type, traits_type>;
@@ -71,9 +71,8 @@ namespace std {
       friend class ostreambuf_iterator<char_type, traits_type>;
 
       friend streamsize
-      _S_copy_streambufs<>(basic_ios<_CharT, _Traits>& __ios,
-                        basic_streambuf<_CharT, _Traits>* __sbin,
-                        basic_streambuf<_CharT, _Traits>* __sbout);
+      _S_copy_streambufs<>(basic_ios<char_type, traits_type>& __ios,
+                          __streambuf_type* __sbin,__streambuf_type* __sbout);
       
     protected:
 
@@ -110,13 +109,13 @@ namespace std {
       ios_base::openmode       _M_mode;        
 
       // Current locale setting.
-      locale                   _M_locale_buf;  
+      locale                   _M_buf_locale;  
 
       // True iff locale is initialized.
-      bool                     _M_locale_set;
+      bool                     _M_buf_locale_init;
 
       // Cached use_facet<ctype>, which is based on the current locale info.
-      const __ctype_type*      _M_fctype_buf;      
+      const __ctype_type*      _M_buf_fctype;      
 
       // Correctly sets the _M_out_cur pointer, and bumps the
       // appropriate _M_*_end pointers as well. Necessary for the
@@ -127,23 +126,24 @@ namespace std {
       // the same range:
       // _M_buf <= _M_*_ <= _M_buf + _M_buf_size
       void 
-      _M_buf_bump(off_type __n) // argument needs to be +-
+      _M_out_cur_move(off_type __n) // argument needs to be +-
       {
        bool __testin = _M_mode & ios_base::in;
-       bool __testout = _M_mode & ios_base::out;
+
        _M_out_cur += __n;
-       if (_M_buf_unified && __testin)
-         _M_in_cur = _M_out_cur;
+       if (__testin && _M_buf_unified)
+         _M_in_cur += __n;
        if (_M_out_cur > _M_out_end)
          {
            _M_out_end = _M_out_cur;
-           if (__testin && __testout && _M_out_end > _M_in_end)
-             _M_in_end = _M_out_cur;
+           // NB: in | out buffers drag the _M_in_end pointer along...
+           if (__testin)
+             _M_in_end += __n;
          }
       }
 
       // These three functions are used to clarify internal buffer
-      // maintance. After an overflow, or after a seekoff call that
+      // maintenance. After an overflow, or after a seekoff call that
       // started at beg or end, or possibly when the stream becomes
       // unbuffered, and a myrid other obscure corner cases, the
       // internal buffer does not truly reflect the contents of the
@@ -193,8 +193,8 @@ namespace std {
        _M_buf_size = 0;
        _M_buf_size_opt = 0;
        _M_mode = ios_base::openmode(0);
-       _M_fctype_buf = NULL;
-       _M_locale_set = false;
+       _M_buf_fctype = NULL;
+       _M_buf_locale_init = false;
       }
 
       // Locales:
@@ -209,8 +209,8 @@ namespace std {
       locale   
       getloc() const
       {
-       if (_M_locale_set)
-         return _M_locale_buf
+       if (_M_buf_locale_init)
+         return _M_buf_locale
        else 
          return locale();
       } 
@@ -292,10 +292,10 @@ namespace std {
        _M_buf_size_opt(static_cast<int_type>(BUFSIZ * sizeof(char_type))),
        _M_buf_unified(false), _M_in_cur(0), _M_in_beg(0), _M_in_end(0), 
        _M_out_cur(0), _M_out_beg(0), _M_out_end(0), 
-       _M_mode(ios_base::openmode(0)), _M_locale_buf(locale()), 
-       _M_locale_set(false) 
+       _M_mode(ios_base::openmode(0)), _M_buf_locale(locale()), 
+       _M_buf_locale_init(false) 
 
-      { _M_fctype_buf =  &use_facet<__ctype_type>(this->getloc()); }
+      { _M_buf_fctype =  &use_facet<__ctype_type>(this->getloc()); }
 
       // Get area:
       char_type* 
@@ -353,11 +353,11 @@ namespace std {
       virtual void 
       imbue(const locale& __loc) 
       { 
-       _M_locale_set = true;
-       if (_M_locale_buf != __loc)
+       _M_buf_locale_init = true;
+       if (_M_buf_locale != __loc)
         {
-          _M_locale_buf = __loc;
-          _M_fctype_buf = &use_facet<__ctype_type>(_M_locale_buf); 
+          _M_buf_locale = __loc;
+          _M_buf_fctype = &use_facet<__ctype_type>(_M_buf_locale); 
         }      
       }
 
index d5ed76d..aca0a20 100644 (file)
@@ -108,7 +108,7 @@ namespace std {
       if (_M_out_cur && _M_out_cur < _M_out_beg + _M_buf_size)
        {
          *_M_out_cur = __c;
-         _M_buf_bump(1);
+         _M_out_cur_move(1);
          __retval = traits_type::to_int_type(__c);
        }
       else
@@ -198,7 +198,7 @@ namespace std {
                  traits_type::copy(_M_out_cur, __s, __len);
                  __retval += __len;
                  __s += __len;
-                 _M_buf_bump(__len);
+                 _M_out_cur_move(__len);
                }
            }
        }
index 6598842..d8b46f0 100644 (file)
@@ -201,7 +201,7 @@ namespace std {
     _M_callbacks = 0;
     _M_words = 0;
     _M_word_limit = 0;
-    _M_locale_ios = locale();
+    _M_ios_locale = locale();
     // No init needed for _M_word_array or _M_dummy.
   }  
   
@@ -209,8 +209,8 @@ namespace std {
   locale
   ios_base::imbue(const locale& __loc)
   {
-    locale __old = _M_locale_ios;
-    _M_locale_ios = __loc;
+    locale __old = _M_ios_locale;
+    _M_ios_locale = __loc;
     // Make sure there's a callback for the format caches so they will be
     // marked dirty.
     _Format_cache<char>::_S_get(*this);