[v3] formatting clarifications

Benjamin Kosnik bkoz@redhat.com
Mon Dec 1 18:20:00 GMT 2003


...actually, just did this, as discuessed.

tested x86/linux

2003-12-01  Benjamin Kosnik  <bkoz@redhat.com>

	* docs/html/17_intro/C++STYLE: Add exception bits.
	* include/bits/fstream.tcc: Add location to exception strings.

	* include/bits/stl_construct.h: Formatting tweaks.

Index: docs/html/17_intro/C++STYLE
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/docs/html/17_intro/C++STYLE,v
retrieving revision 1.8
diff -c -p -r1.8 C++STYLE
*** docs/html/17_intro/C++STYLE	23 Aug 2002 16:52:29 -0000	1.8
--- docs/html/17_intro/C++STYLE	1 Dec 2003 18:18:53 -0000
*************** Notable areas of divergence from what ma
*** 200,206 ****
--- 200,224 ----
     For more explanation and examples, see src/globals.cc.  All such
     variables should be contained in that file, for simplicity.
  
+ 15. Exception abstractions
+     Use the exception abstractions found in functexcept.h, which allow
+     C++ programmers to use this library with -fno-exceptions. (Even if
+     that is rarely advisable, it's a necessary evil for backwards
+     compatibility.)
  
+ 16. Exception error messages
+     All start with the name of the function where the exception is
+     thrown, and then (optional) descriptive text is added. Example:
+ 
+     __throw_logic_error("basic_string::_S_construct NULL not valid");
+ 
+     Reason: The verbose terminate handler prints out exception::what(),
+     as well as the typeinfo for the thrown exception. As this is the
+     default terminate handler, by putting location info into the
+     exception string, a very useful error message is printed out for
+     uncaught exceptions. So useful, in fact, that non-programmers can
+     give useful error messages, and programmers can intelligently
+     speculate what went wrong without even using a debugger.
  
  The library currently has a mixture of GNU-C and modern C++ coding
  styles.  The GNU C usages will be combed out gradually.
Index: include/bits/fstream.tcc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/fstream.tcc,v
retrieving revision 1.112
diff -c -p -r1.112 fstream.tcc
*** include/bits/fstream.tcc	29 Nov 2003 22:49:46 -0000	1.112
--- include/bits/fstream.tcc	1 Dec 2003 18:18:54 -0000
*************** namespace std
*** 254,260 ****
  		      // codecvt::max_length() is bogus.
  		      if (_M_ext_end - _M_ext_buf + __rlen > _M_ext_buf_size)
  			{
! 			  __throw_ios_failure("codecvt::max_length() "
  					      "is not valid");
  			}
  		      streamsize __elen = _M_file.xsgetn(_M_ext_end, __rlen);
--- 254,261 ----
  		      // codecvt::max_length() is bogus.
  		      if (_M_ext_end - _M_ext_buf + __rlen > _M_ext_buf_size)
  			{
! 			  __throw_ios_failure("basic_filebuf::underflow "
! 					      "codecvt::max_length() "
  					      "is not valid");
  			}
  		      streamsize __elen = _M_file.xsgetn(_M_ext_end, __rlen);
*************** namespace std
*** 305,314 ****
  	      // However, reaching it while looping on partial means that
  	      // the file has got an incomplete character.
  	      if (__r == codecvt_base::partial)
! 		__throw_ios_failure("incomplete character in file");
  	    }
  	  else
! 	    __throw_ios_failure("invalid byte sequence in file");
  	}
        return __ret;
      }
--- 306,317 ----
  	      // However, reaching it while looping on partial means that
  	      // the file has got an incomplete character.
  	      if (__r == codecvt_base::partial)
! 		__throw_ios_failure("basic_filebuf::underflow "
! 				    "incomplete character in file");
  	    }
  	  else
! 	    __throw_ios_failure("basic_filebuf::underflow "
! 				"invalid byte sequence in file");
  	}
        return __ret;
      }
Index: include/bits/stl_construct.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_construct.h,v
retrieving revision 1.14
diff -c -p -r1.14 stl_construct.h
*** include/bits/stl_construct.h	1 Dec 2003 15:34:06 -0000	1.14
--- include/bits/stl_construct.h	1 Dec 2003 18:18:54 -0000
***************
*** 1,6 ****
  // nonstandard construct and destroy functions -*- C++ -*-
  
! // Copyright (C) 2001, 2002 Free Software Foundation, Inc.
  //
  // This file is part of the GNU ISO C++ Library.  This library is free
  // software; you can redistribute it and/or modify it under the
--- 1,6 ----
  // nonstandard construct and destroy functions -*- C++ -*-
  
! // Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
  //
  // This file is part of the GNU ISO C++ Library.  This library is free
  // software; you can redistribute it and/or modify it under the
*************** namespace std
*** 72,84 ****
     * object's constructor with an initializer.
     * @endif
     */
!   template <class _T1, class _T2>
      inline void
      _Construct(_T1* __p, const _T2& __value)
      {
        // _GLIBCXX_RESOLVE_LIB_DEFECTS
        // 402. wrong new expression in [some_]allocator::construct
!       ::new (static_cast<void*>(__p)) _T1(__value); 
      }
    
    /**
--- 72,84 ----
     * object's constructor with an initializer.
     * @endif
     */
!   template<typename _T1, typename _T2>
      inline void
      _Construct(_T1* __p, const _T2& __value)
      {
        // _GLIBCXX_RESOLVE_LIB_DEFECTS
        // 402. wrong new expression in [some_]allocator::construct
!       ::new(static_cast<void*>(__p)) _T1(__value); 
      }
    
    /**
*************** namespace std
*** 87,99 ****
     * object's default constructor (no initializers).
     * @endif
     */
!   template <class _T1>
      inline void
      _Construct(_T1* __p)
      {
        // _GLIBCXX_RESOLVE_LIB_DEFECTS
        // 402. wrong new expression in [some_]allocator::construct     
!       ::new (static_cast<void*>(__p)) _T1();
      }
  
    /**
--- 87,99 ----
     * object's default constructor (no initializers).
     * @endif
     */
!   template<typename _T1>
      inline void
      _Construct(_T1* __p)
      {
        // _GLIBCXX_RESOLVE_LIB_DEFECTS
        // 402. wrong new expression in [some_]allocator::construct     
!       ::new(static_cast<void*>(__p)) _T1();
      }
  
    /**
*************** namespace std
*** 101,107 ****
     * Destroy the object pointed to by a pointer type.
     * @endif
     */
!   template <class _Tp>
      inline void
      _Destroy(_Tp* __pointer)
      { __pointer->~_Tp(); }
--- 101,107 ----
     * Destroy the object pointed to by a pointer type.
     * @endif
     */
!   template<typename _Tp>
      inline void
      _Destroy(_Tp* __pointer)
      { __pointer->~_Tp(); }
*************** namespace std
*** 113,119 ****
     * This is a helper function used only by _Destroy().
     * @endif
     */
!   template <class _ForwardIterator>
      inline void
      __destroy_aux(_ForwardIterator __first, _ForwardIterator __last, __false_type)
      { for ( ; __first != __last; ++__first) std::_Destroy(&*__first); }
--- 113,119 ----
     * This is a helper function used only by _Destroy().
     * @endif
     */
!   template<typename _ForwardIterator>
      inline void
      __destroy_aux(_ForwardIterator __first, _ForwardIterator __last, __false_type)
      { for ( ; __first != __last; ++__first) std::_Destroy(&*__first); }
*************** namespace std
*** 127,133 ****
     * This is a helper function used only by _Destroy().
     * @endif
     */
!   template <class _ForwardIterator> 
      inline void
      __destroy_aux(_ForwardIterator, _ForwardIterator, __true_type)
      { }
--- 127,133 ----
     * This is a helper function used only by _Destroy().
     * @endif
     */
!   template<typename _ForwardIterator> 
      inline void
      __destroy_aux(_ForwardIterator, _ForwardIterator, __true_type)
      { }
*************** namespace std
*** 139,145 ****
     * away, otherwise the objects' destructors must be invoked.
     * @endif
     */
!   template <class _ForwardIterator>
      inline void
      _Destroy(_ForwardIterator __first, _ForwardIterator __last)
      {
--- 139,145 ----
     * away, otherwise the objects' destructors must be invoked.
     * @endif
     */
!   template<typename _ForwardIterator>
      inline void
      _Destroy(_ForwardIterator __first, _ForwardIterator __last)
      {



More information about the Gcc-patches mailing list