[multiple changes]
authorBenjamin Kosnik <bkoz@gcc.gnu.org>
Fri, 26 Oct 2001 05:32:06 +0000 (05:32 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Fri, 26 Oct 2001 05:32:06 +0000 (05:32 +0000)
2001-10-25  Benjamin Kosnik  <bkoz@redhat.com>

libstdc++/4545
* include/bits/ostream.tcc (ostream::operator<<(streambuf*)): Fix
exceptions.
* include/bits/istream.tcc (istream::operator>>(streambuf*): Make
consistent, where possible.
* include/bits/streambuf.tcc: Tweak.

2001-10-25  Brendan Kehoe  <brendan@zen.org>

libstdc++/4536
* bits/ostream.tcc (seekp): Scope use as ios_base::failbit.
  * bits/istream.tcc (seekg): Likewise.

From-SVN: r46528

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/istream.tcc
libstdc++-v3/include/bits/ostream.tcc
libstdc++-v3/include/bits/streambuf.tcc

index 65f391e65d20aba2beb9b10e89997d79c4132b70..1ce42b72e35b6ba6b56055d46b089e8a37803b55 100644 (file)
@@ -1,3 +1,18 @@
+2001-10-25  Benjamin Kosnik  <bkoz@redhat.com>
+
+       libstdc++/4545
+       * include/bits/ostream.tcc (ostream::operator<<(streambuf*)): Fix
+       exceptions.
+       * include/bits/istream.tcc (istream::operator>>(streambuf*): Make
+       consistent, where possible.
+       * include/bits/streambuf.tcc: Tweak.
+       
+2001-10-25  Brendan Kehoe  <brendan@zen.org>
+
+       libstdc++/4536
+       * bits/ostream.tcc (seekp): Scope use as ios_base::failbit.
+       * bits/istream.tcc (seekg): Likewise.
+
 2001-10-25  Benjamin Kosnik  <bkoz@redhat.com>
            Peter Schmid <schmid@snake.iap.physik.tu-darmstadt.de>
            Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
index e0014ea7e1cb8955539d92ba94eb29c21817a18e..47b01f6bae263e3c833e436bbc1cd68217d02a10 100644 (file)
@@ -454,14 +454,30 @@ namespace std
     basic_istream<_CharT, _Traits>::
     operator>>(__streambuf_type* __sbout)
     {
-      streamsize __xtrct = 0;
-      __streambuf_type* __sbin = this->rdbuf();
-      sentry __cerb(*this, false);
-      if (__sbout && __cerb)
-       __xtrct = __copy_streambufs(*this, __sbin, __sbout);
-      if (!__sbout || !__xtrct)
-       this->setstate(ios_base::failbit);
-      return *this;
+       sentry __cerb(*this, false);
+       if (__cerb)
+        {
+          try
+            {
+              streamsize __xtrct = 0;
+              if (__sbout)
+                {
+                  __streambuf_type* __sbin = this->rdbuf();
+                  __xtrct = __copy_streambufs(*this, __sbin, __sbout);
+                }
+              if (!__sbout || !__xtrct)
+                this->setstate(ios_base::failbit);
+            }
+          catch(exception& __fail)
+            {
+              // 27.6.2.5.1 Common requirements.
+              // Turn this on without causing an ios::failure to be thrown.
+              this->setstate(ios_base::badbit);
+              if ((this->exceptions() & ios_base::badbit) != 0)
+                __throw_exception_again;
+            }
+        }
+       return *this;
     }
 
   template<typename _CharT, typename _Traits>
@@ -963,7 +979,7 @@ namespace std
 
 // 129. Need error indication from seekp() and seekg()
              if (__err == pos_type(off_type(-1)))
-               this->setstate(failbit);
+               this->setstate(ios_base::failbit);
 #endif
            }
          catch(exception& __fail)
@@ -996,7 +1012,7 @@ namespace std
 
 // 129. Need error indication from seekp() and seekg()
              if (__err == pos_type(off_type(-1)))
-               this->setstate(failbit);
+               this->setstate(ios_base::failbit);
 #endif
            }
          catch(exception& __fail)
index 33182261e2c425c9d5ce350752453c2ebb4e5f48..ff9283dc70beda2e2173dfc4be4f8af193dafc9f 100644 (file)
@@ -109,6 +109,38 @@ namespace std
       return *this;
     }
 
+  template<typename _CharT, typename _Traits>
+    basic_ostream<_CharT, _Traits>& 
+    basic_ostream<_CharT, _Traits>::operator<<(__streambuf_type* __sbin)
+    {
+      sentry __cerb(*this);
+      if (__cerb)
+       {
+         try
+           {
+             streamsize __xtrct = 0;
+             if (__sbin)
+               {
+                 __streambuf_type* __sbout = this->rdbuf();
+                 __xtrct = __copy_streambufs(*this, __sbin, __sbout);
+               }
+             else
+               this->setstate(ios_base::badbit);
+             if (!__xtrct)
+               this->setstate(ios_base::failbit);
+           }
+         catch(exception& __fail)
+           {
+             // 27.6.2.5.1 Common requirements.
+             // Turn this on without causing an ios::failure to be thrown.
+             this->setstate(ios_base::badbit);
+             if ((this->exceptions() & ios_base::badbit) != 0)
+               __throw_exception_again;
+           }
+       }
+      return *this;
+    }
+
   template<typename _CharT, typename _Traits>
     basic_ostream<_CharT, _Traits>& 
     basic_ostream<_CharT, _Traits>::operator<<(bool __n)
@@ -336,20 +368,6 @@ namespace std
       return *this;
     }
 
-  template<typename _CharT, typename _Traits>
-    basic_ostream<_CharT, _Traits>& 
-    basic_ostream<_CharT, _Traits>::operator<<(__streambuf_type* __sbin)
-    {
-      streamsize __xtrct = 0;
-      __streambuf_type* __sbout = this->rdbuf();
-      sentry __cerb(*this);
-      if (__sbin && __cerb)
-       __xtrct = __copy_streambufs(*this, __sbin, __sbout);
-      if (!__sbin || !__xtrct)
-       this->setstate(ios_base::failbit);
-      return *this;
-    }
-
   template<typename _CharT, typename _Traits>
     basic_ostream<_CharT, _Traits>&
     basic_ostream<_CharT, _Traits>::put(char_type __c)
@@ -418,7 +436,7 @@ namespace std
 
 // 129. Need error indication from seekp() and seekg()
          if (__err == pos_type(off_type(-1)))
-           this->setstate(failbit);
+           this->setstate(ios_base::failbit);
 #endif
        }
       return *this;
@@ -440,7 +458,7 @@ namespace std
 
 // 129. Need error indication from seekp() and seekg()
          if (__err == pos_type(off_type(-1)))
-           this->setstate(failbit);
+           this->setstate(ios_base::failbit);
        }
 #endif
       return *this;
@@ -753,4 +771,3 @@ namespace std
 // Local Variables:
 // mode:C++
 // End:
-
index d928379918a4f335c3276939a3ce412a0101c9d1..9482c69c7adf223bfda10d9a487faebffde92d1a 100644 (file)
@@ -198,29 +198,31 @@ namespace std {
       streamsize __bufsize = __sbin->in_avail();
       streamsize __xtrct;
       bool __testput = __sbout->_M_mode & ios_base::out;
-      try {
-       while (__testput && __bufsize != -1)
-         {
-           __xtrct = __sbout->sputn(__sbin->gptr(), __bufsize);
-           __ret += __xtrct;
-           __sbin->_M_in_cur_move(__xtrct);
-           if (__xtrct == __bufsize)
-             {
-               if (__sbin->sgetc() == _Traits::eof())
-                 break;
-               __bufsize = __sbin->in_avail();
-             }
-           else
-             break;
-         }
-      }
-      catch(exception& __fail) {
-       if ((__ios.exceptions() & ios_base::failbit) != 0)
-         __throw_exception_again;
-      }
+      try 
+       {
+         while (__testput && __bufsize != -1)
+           {
+             __xtrct = __sbout->sputn(__sbin->gptr(), __bufsize);
+             __ret += __xtrct;
+             __sbin->_M_in_cur_move(__xtrct);
+             if (__xtrct == __bufsize)
+               {
+                 if (__sbin->sgetc() == _Traits::eof())
+                   break;
+                 __bufsize = __sbin->in_avail();
+               }
+             else
+               break;
+           }
+       }
+      catch(exception& __fail) 
+       {
+         __ios.setstate(ios_base::failbit);
+         if ((__ios.exceptions() & ios_base::failbit) != 0)
+           __throw_exception_again;
+       }
       return __ret;
     }
 } // namespace std
 
 #endif // _CPP_BITS_STREAMBUF_TCC
-