]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ios.cc: (ios_base::Init::_S_ios_destroy): Remove flush calls.
authorBenjamin Kosnik <bkoz@redhat.com>
Wed, 3 Apr 2002 02:32:52 +0000 (02:32 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Wed, 3 Apr 2002 02:32:52 +0000 (02:32 +0000)
2002-04-02  Benjamin Kosnik  <bkoz@redhat.com>

libstdc++/5268
* src/ios.cc: (ios_base::Init::_S_ios_destroy): Remove flush calls.
* testsuite/27_io/ios_init.cc (tests04): Add test.

libstdc++/3983
* include/bits/basic_ios.h (basic_ios::_M_get_fctype_ios): Remove.
(basic_ios::_M_ios_fctype): Consistently name to _M_fctype.
* include/bits/basic_ios.tcc: Same. Remove outdated comments.
* include/bits/istream.tcc: Use _M_fctype, make consistent with
ostream.
* testsuite/27_io/ios_init.cc (tests03): Add test.

From-SVN: r51777

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/basic_ios.h
libstdc++-v3/include/bits/basic_ios.tcc
libstdc++-v3/include/bits/istream.tcc
libstdc++-v3/src/ios.cc
libstdc++-v3/testsuite/27_io/ios_init.cc

index b61a6997c8153e6f53d30bc063df1be2dfdb0c28..bbb282d26100182eb506b19e3a8057409e9f89f7 100644 (file)
@@ -1,3 +1,17 @@
+2002-04-02  Benjamin Kosnik  <bkoz@redhat.com>
+       
+       libstdc++/5268
+       * src/ios.cc: (ios_base::Init::_S_ios_destroy): Remove flush calls.
+       * testsuite/27_io/ios_init.cc (tests04): Add test.
+
+       libstdc++/3983
+       * include/bits/basic_ios.h (basic_ios::_M_get_fctype_ios): Remove.
+       (basic_ios::_M_ios_fctype): Consistently name to _M_fctype.
+       * include/bits/basic_ios.tcc: Same. Remove outdated comments.
+       * include/bits/istream.tcc: Use _M_fctype, make consistent with
+       ostream.
+       * testsuite/27_io/ios_init.cc (tests03): Add test.
+       
 2002-04-02  Phil Edwards  <pme@gcc.gnu.org>
 
        * include/Makefile.am (install-data-local):  Use mkinstalldirs.
index cc8617f986f15ba94fd1d665416bd1679ee71d98..13ad0f82e99064feb361f392abf1751b451cd11a 100644 (file)
@@ -69,17 +69,13 @@ namespace std
       basic_streambuf<_CharT, _Traits>* _M_streambuf;
 
       // Cached use_facet<ctype>, which is based on the current locale info.
-      const __ctype_type*              _M_ios_fctype;      
+      const __ctype_type*              _M_fctype;      
       // From ostream.
       const __numput_type*             _M_fnumput;
       // From istream.
       const __numget_type*             _M_fnumget;
 
     public:
-      const __ctype_type*      
-      _M_get_fctype_ios(void)
-      { return _M_ios_fctype; }
-
       operator void*() const 
       { return this->fail() ? 0 : const_cast<basic_ios*>(this); }
 
index 7dba1222cfb03b04708beeff47506965b4a5b3b3..1e345dc2117205d9394cf744a348547c05f08abd 100644 (file)
@@ -67,12 +67,6 @@ namespace std
       _Words* __words = (__rhs._M_word_size <= _S_local_word_size) ?
        _M_local_word : new _Words[__rhs._M_word_size];
 
-      // XXX This is the only reason _Callback_list was defined
-      // inline. The suspicion is that this increased compilation
-      // times dramatically for functions that use this member
-      // function (inserters_extractors, ios_manip_fmtflags). FIX ME,
-      // clean this stuff up. Callbacks are broken right now, anyway.
-
       // Bump refs before doing callbacks, for safety.
       _Callback_list* __cb = __rhs._M_callbacks;
       if (__cb) 
@@ -113,8 +107,8 @@ namespace std
     basic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const
     { 
       char __ret = __dfault;
-      if (_M_check_facet(_M_ios_fctype))
-       __ret = _M_ios_fctype->narrow(__c, __dfault); 
+      if (_M_check_facet(_M_fctype))
+       __ret = _M_fctype->narrow(__c, __dfault); 
       return __ret;
     }
 
@@ -123,8 +117,8 @@ namespace std
     basic_ios<_CharT, _Traits>::widen(char __c) const
     {
       char_type __ret = char_type();
-      if (_M_check_facet(_M_ios_fctype))
-       __ret = _M_ios_fctype->widen(__c); 
+      if (_M_check_facet(_M_fctype))
+       __ret = _M_fctype->widen(__c); 
       return __ret;
     }
 
@@ -175,9 +169,9 @@ namespace std
     basic_ios<_CharT, _Traits>::_M_cache_facets(const locale& __loc)
     {
       if (has_facet<__ctype_type>(__loc))
-       _M_ios_fctype = &use_facet<__ctype_type>(__loc);
+       _M_fctype = &use_facet<__ctype_type>(__loc);
       else
-       _M_ios_fctype = 0;
+       _M_fctype = 0;
       // Should be filled in by ostream and istream, respectively.
       if (has_facet<__numput_type>(__loc))
        _M_fnumput = &use_facet<__numput_type>(__loc); 
index 4a32c659be4e8dda2d6a834ba267158c1f0d7c28..7f985594f9b531dc288d58485be52046c49f0530 100644 (file)
@@ -50,12 +50,13 @@ namespace std
          if (!__noskipws && (__in.flags() & ios_base::skipws))
            {     
              const __int_type __eof = traits_type::eof();
-             const __ctype_type* __ctype = __in._M_get_fctype_ios();
              __streambuf_type* __sb = __in.rdbuf();
              __int_type __c = __sb->sgetc();
-             
-             while (__c != __eof && __ctype->is(ctype_base::space, __c))
-               __c = __sb->snextc();
+
+             if (__in._M_check_facet(__in._M_fctype))
+               while (__c != __eof
+                      && __in._M_fctype->is(ctype_base::space, __c))
+                 __c = __sb->snextc();
 
 #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
 //195.  Should basic_istream::sentry's constructor ever set eofbit? 
@@ -1098,12 +1099,12 @@ namespace std
              if (__num == 0)
                __num = numeric_limits<streamsize>::max();
              
+             const __ctype_type& __ctype = use_facet<__ctype_type>(__in.getloc());
+             const int_type __eof = _Traits::eof();
              __streambuf_type* __sb = __in.rdbuf();
-             const __ctype_type* __ctype = __in._M_get_fctype_ios();
              int_type __c = __sb->sbumpc();
-             const int_type __eof = _Traits::eof();
-             bool __testsp = __ctype->is(ctype_base::space, __c);
              bool __testeof =  __c == __eof;
+             bool __testsp = __ctype.is(ctype_base::space, __c);
              
              while (__extracted < __num - 1 && !__testeof && !__testsp)
                {
@@ -1111,7 +1112,7 @@ namespace std
                  ++__extracted;
                  __c = __sb->sbumpc();
                  __testeof = __c == __eof;
-                 __testsp = __ctype->is(ctype_base::space, __c);
+                 __testsp = __ctype.is(ctype_base::space, __c);
                }
              
              if (!__testeof)
@@ -1150,8 +1151,8 @@ namespace std
       typedef typename __istream_type::int_type        __int_type;
       typedef typename __istream_type::char_type       __char_type;
 
+      const __ctype_type& __ctype = use_facet<__ctype_type>(__in.getloc());
       __streambuf_type* __sb = __in.rdbuf();
-      const __ctype_type* __ctype = __in._M_get_fctype_ios();
       const __int_type __eof = _Traits::eof();       
       __int_type __c;
       bool __testeof;
@@ -1160,8 +1161,8 @@ namespace std
       do 
        {
          __c = __sb->sbumpc();
-         __testeof = __c == __eof;
-         __testsp = __ctype->is(ctype_base::space, __c);
+         __testeof = __c == __eof;       
+         __testsp = __ctype.is(ctype_base::space, __c);
        }
       while (!__testeof && __testsp);
 
@@ -1195,12 +1196,12 @@ namespace std
          __size_type __n;
          __n = __w > 0 ? static_cast<__size_type>(__w) : __str.max_size();
 
+         const __ctype_type& __ctype = use_facet<__ctype_type>(__in.getloc());
+         const __int_type __eof = _Traits::eof();
          __streambuf_type* __sb = __in.rdbuf();
-         const __ctype_type* __ctype = __in._M_get_fctype_ios();
          __int_type __c = __sb->sbumpc();
-         const __int_type __eof = _Traits::eof();
-         bool __testsp = __ctype->is(ctype_base::space, __c);
          bool __testeof =  __c == __eof;
+         bool __testsp = __ctype.is(ctype_base::space, __c);
 
          while (__extracted < __n && !__testeof && !__testsp)
            {
@@ -1208,7 +1209,7 @@ namespace std
              ++__extracted;
              __c = __sb->sbumpc();
              __testeof = __c == __eof;
-             __testsp = __ctype->is(ctype_base::space, __c);
+             __testsp = __ctype.is(ctype_base::space, __c);
            }
          if (!__testeof)
            __sb->sputbackc(__c);
index d13ff0e73cf5856d2de0e69cd3cf404bb37509af..0aab0a25a3a007d99282e3975a404ee35f376059 100644 (file)
@@ -190,16 +190,10 @@ namespace std
     // Explicitly call dtors to free any memory that is dynamically
     // allocated by filebuf ctor or member functions, but don't
     // deallocate all memory by calling operator delete.
-    cout.flush();
-    cerr.flush();
-    clog.flush();
     buf_cout.~filebuf();
     buf_cin.~filebuf();
     buf_cerr.~filebuf();
 #ifdef _GLIBCPP_USE_WCHAR_T
-    wcout.flush();
-    wcerr.flush();
-    wclog.flush();
     buf_wcout.~wfilebuf();
     buf_wcin.~wfilebuf();
     buf_wcerr.~wfilebuf();
index 38d2e522822caefcde58a34f4991827549c3c580..72b9fb4cc85698856181a57cac4906202cbaf789 100644 (file)
@@ -132,6 +132,80 @@ void test02()
   VERIFY( test );
 }
 
+// libstdc++/3983
+void test03()
+{
+  using namespace std;
+  bool test = true;
+
+  // input streams
+  basic_istringstream<unsigned char> iss_uc;
+  unsigned char arr[6] = { 'a', 'b', 'c', 'd', 'e' };
+
+  // Sentry uses locale info, so have to try one formatted input.
+  try 
+    { 
+      int i;
+      iss_uc >> i;
+    }
+  catch (bad_cast& obj)
+    { }
+  catch (exception& obj)
+    { test = false; }
+  
+  try 
+    { 
+      iss_uc >> arr;
+    }
+  catch (bad_cast& obj)
+    { }
+  catch (exception& obj)
+    { test = false; }
+  
+  try 
+    { 
+      iss_uc >> ws;
+    }
+  catch (bad_cast& obj)
+    { }
+  catch (exception& obj)
+    { test = false; }
+  try 
+    { 
+      basic_string<unsigned char> s_uc(arr);
+      iss_uc >> s_uc;
+    }
+  catch (bad_cast& obj)
+    { }
+  catch (exception& obj)
+    { test = false; }
+
+  // output streams
+  basic_ostringstream<unsigned char> oss_uc;
+
+  try 
+    { 
+      bool b = true;
+      oss_uc << b;
+    }
+  catch (bad_cast& obj)
+    { }
+  catch (exception& obj)
+    { test = false; }
+   
+  VERIFY( test );
+}
+
+// libstdc++/5268
+int test04()
+{
+  std::stringbuf b1;
+  std::cout.rdbuf( &b1 );
+  std::cout << "hello\n";
+  return 0;
+}
+
 #if !__GXX_WEAK__
 // Explicitly instantiate for systems with no COMDAT or weak support.
 template 
@@ -147,5 +221,7 @@ int main()
 {
   test01();
   test02();
+  test03();
+  test04();
   return 0;
 }