This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [v3] 9371/9546/10093/10095


Benjamin Kosnik wrote:

Fixes for longstanding exception handling bugs.

Thanks!

I'm committing the following straightforward follow up for
a warning regression due to a now unused parameter and for
a now redundant try/catch.

Tested x86-linux.

Paolo.

////////////
2003-11-27  Paolo Carlini  <pcarlini@suse.de>

	* include/std/std_streambuf.h (__copy_streambufs): Remove
	the first, unused, basic_ios<> parameter.
	* src/streambuf-inst.cc: Likewise.
	* include/bits/streambuf.tcc: Likewise.
	* include/bits/istream.tcc (operator>>(__streambuf_type*)):
	Tweak accordingly the call.
	* include/bits/ostream.tcc (operator<<(__streambuf_type*)):
	Likewise.

	* include/bits/streambuf.tcc (__copy_streambufs): Remove
	redundant try/catch.
diff -prN libstdc++-v3-orig/include/bits/istream.tcc libstdc++-v3/include/bits/istream.tcc
*** libstdc++-v3-orig/include/bits/istream.tcc	Thu Nov 27 09:25:03 2003
--- libstdc++-v3/include/bits/istream.tcc	Thu Nov 27 13:24:27 2003
*************** namespace std 
*** 409,415 ****
  	{
  	  try
  	    {
! 	      if (!__copy_streambufs(*this, this->rdbuf(), __sbout))
  		__err |= ios_base::failbit;
  	    }
  	  catch(...)
--- 409,415 ----
  	{
  	  try
  	    {
! 	      if (!__copy_streambufs(this->rdbuf(), __sbout))
  		__err |= ios_base::failbit;
  	    }
  	  catch(...)
diff -prN libstdc++-v3-orig/include/bits/ostream.tcc libstdc++-v3/include/bits/ostream.tcc
*** libstdc++-v3-orig/include/bits/ostream.tcc	Thu Nov 27 09:25:03 2003
--- libstdc++-v3/include/bits/ostream.tcc	Thu Nov 27 13:25:00 2003
*************** namespace std 
*** 304,310 ****
  	{
  	  try
  	    {
! 	      if (!__copy_streambufs(*this, __sbin, this->rdbuf()))
  		__err |= ios_base::failbit;
  	    }
  	  catch(...)
--- 304,310 ----
  	{
  	  try
  	    {
! 	      if (!__copy_streambufs(__sbin, this->rdbuf()))
  		__err |= ios_base::failbit;
  	    }
  	  catch(...)
diff -prN libstdc++-v3-orig/include/bits/streambuf.tcc libstdc++-v3/include/bits/streambuf.tcc
*** libstdc++-v3-orig/include/bits/streambuf.tcc	Thu Nov 27 09:25:03 2003
--- libstdc++-v3/include/bits/streambuf.tcc	Thu Nov 27 13:25:50 2003
*************** namespace std 
*** 113,150 ****
    // necessary.
    template<typename _CharT, typename _Traits>
      streamsize
!     __copy_streambufs(basic_ios<_CharT, _Traits>& __ios,
! 		      basic_streambuf<_CharT, _Traits>* __sbin,
  		      basic_streambuf<_CharT, _Traits>* __sbout) 
      {
        streamsize __ret = 0;
!       try 
  	{
! 	  typename _Traits::int_type __c = __sbin->sgetc();
! 	  while (!_Traits::eq_int_type(__c, _Traits::eof()))
  	    {
! 	      const size_t __n = __sbin->egptr() - __sbin->gptr();
! 	      if (__n > 1)
! 		{
! 		  const size_t __wrote = __sbout->sputn(__sbin->gptr(), __n);
! 		  __sbin->gbump(__wrote);
! 		  __ret += __wrote;
! 		  if (__wrote < __n)
! 		    break;
! 		  __c = __sbin->underflow();
! 		}
! 	      else 
! 		{
! 		  __c = __sbout->sputc(_Traits::to_char_type(__c));
! 		  if (_Traits::eq_int_type(__c, _Traits::eof()))
! 		    break;
! 		  ++__ret;
! 		  __c = __sbin->snextc();
! 		}
  	    }
  	}
-       catch(...)
- 	{ __throw_exception_again; }
        return __ret;
      }
  
--- 113,144 ----
    // necessary.
    template<typename _CharT, typename _Traits>
      streamsize
!     __copy_streambufs(basic_streambuf<_CharT, _Traits>* __sbin,
  		      basic_streambuf<_CharT, _Traits>* __sbout) 
      {
        streamsize __ret = 0;
!       typename _Traits::int_type __c = __sbin->sgetc();
!       while (!_Traits::eq_int_type(__c, _Traits::eof()))
  	{
! 	  const size_t __n = __sbin->egptr() - __sbin->gptr();
! 	  if (__n > 1)
  	    {
! 	      const size_t __wrote = __sbout->sputn(__sbin->gptr(), __n);
! 	      __sbin->gbump(__wrote);
! 	      __ret += __wrote;
! 	      if (__wrote < __n)
! 		break;
! 	      __c = __sbin->underflow();
! 	    }
! 	  else 
! 	    {
! 	      __c = __sbout->sputc(_Traits::to_char_type(__c));
! 	      if (_Traits::eq_int_type(__c, _Traits::eof()))
! 		break;
! 	      ++__ret;
! 	      __c = __sbin->snextc();
  	    }
  	}
        return __ret;
      }
  
*************** namespace std 
*** 155,168 ****
    extern template class basic_streambuf<char>;
    extern template
      streamsize
!     __copy_streambufs(basic_ios<char>&, basic_streambuf<char>*,
  		      basic_streambuf<char>*); 
  
  #ifdef _GLIBCXX_USE_WCHAR_T
    extern template class basic_streambuf<wchar_t>;
    extern template
      streamsize
!     __copy_streambufs(basic_ios<wchar_t>&, basic_streambuf<wchar_t>*,
  		      basic_streambuf<wchar_t>*); 
  #endif
  #endif
--- 149,162 ----
    extern template class basic_streambuf<char>;
    extern template
      streamsize
!     __copy_streambufs(basic_streambuf<char>*,
  		      basic_streambuf<char>*); 
  
  #ifdef _GLIBCXX_USE_WCHAR_T
    extern template class basic_streambuf<wchar_t>;
    extern template
      streamsize
!     __copy_streambufs(basic_streambuf<wchar_t>*,
  		      basic_streambuf<wchar_t>*); 
  #endif
  #endif
diff -prN libstdc++-v3-orig/include/std/std_streambuf.h libstdc++-v3/include/std/std_streambuf.h
*** libstdc++-v3-orig/include/std/std_streambuf.h	Fri Nov 14 00:13:19 2003
--- libstdc++-v3/include/std/std_streambuf.h	Thu Nov 27 13:26:30 2003
*************** namespace std
*** 56,63 ****
    */
    template<typename _CharT, typename _Traits>
      streamsize
!     __copy_streambufs(basic_ios<_CharT, _Traits>& _ios,
! 		      basic_streambuf<_CharT, _Traits>* __sbin,
  		      basic_streambuf<_CharT, _Traits>* __sbout);
    
    /**
--- 56,62 ----
    */
    template<typename _CharT, typename _Traits>
      streamsize
!     __copy_streambufs(basic_streambuf<_CharT, _Traits>* __sbin,
  		      basic_streambuf<_CharT, _Traits>* __sbout);
    
    /**
*************** namespace std
*** 153,160 ****
        friend class ostreambuf_iterator<char_type, traits_type>;
  
        friend streamsize
!       __copy_streambufs<>(basic_ios<char_type, traits_type>& __ios,
! 			  __streambuf_type* __sbin,__streambuf_type* __sbout);
        
      protected:
        //@{
--- 152,159 ----
        friend class ostreambuf_iterator<char_type, traits_type>;
  
        friend streamsize
!       __copy_streambufs<>(__streambuf_type* __sbin,
! 			  __streambuf_type* __sbout);
        
      protected:
        //@{
diff -prN libstdc++-v3-orig/src/streambuf-inst.cc libstdc++-v3/src/streambuf-inst.cc
*** libstdc++-v3-orig/src/streambuf-inst.cc	Sat Jul  5 06:05:42 2003
--- libstdc++-v3/src/streambuf-inst.cc	Thu Nov 27 13:27:34 2003
*************** namespace std
*** 45,56 ****
  
    template
      streamsize
!     __copy_streambufs(basic_ios<char>&, basic_streambuf<char>*,
  		      basic_streambuf<char>*); 
  #ifdef _GLIBCXX_USE_WCHAR_T
    template
      streamsize
!     __copy_streambufs(basic_ios<wchar_t>&, basic_streambuf<wchar_t>*,
  		      basic_streambuf<wchar_t>*); 
  #endif
  } //std
--- 45,56 ----
  
    template
      streamsize
!     __copy_streambufs(basic_streambuf<char>*,
  		      basic_streambuf<char>*); 
  #ifdef _GLIBCXX_USE_WCHAR_T
    template
      streamsize
!     __copy_streambufs(basic_streambuf<wchar_t>*,
  		      basic_streambuf<wchar_t>*); 
  #endif
  } //std

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]