This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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]

[libstdc++] Re: Indentation fixes for stl_alloc.h


On Wed, Aug 21, 2002 at 04:51:30PM -0700, Benjamin Kosnik wrote:
> >     int
> >     two_lines(const char* arg)
> >       { return strchr(arg, 'a'); }
> 
> Well then C++STYLE is wrong... please feel free to correct it. Also,
> probably add the return bits...

Here's what I've checked in.  (For those following along at home:  I had
formatted chunks of STL code according to a style rule that turns out to
have been a typo in the original document, unspotted for years.)

Also, one of the allocator adaptor specializations was for some reason
declared as a class instead of a struct (as its primary template is),
but then never had any public access specifiers.


2002-08-23  Phil Edwards  <pme@gcc.gnu.org>

	* config/linker-map.gnu:  Verbose comments, clean up spacing.
	* include/bits/stl_alloc.h:  Fix indentation of 'if' bodies, return
	statements.
	__allocator:  Change class declaration to struct.
	* docs/html/17_intro/C++STYLE:  Fix typo.
	* include/bits/stl_deque.h, include/bits/stl_list.h,
	include/bits/stl_map.h, include/bits/stl_multimap.h,
	include/bits/stl_vector.h:  Fix fallout from typo.


Index: config/linker-map.gnu
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/config/linker-map.gnu,v
retrieving revision 1.16
diff -u -3 -p -r1.16 linker-map.gnu
--- config/linker-map.gnu	1 Aug 2002 17:25:56 -0000	1.16
+++ config/linker-map.gnu	23 Aug 2002 16:49:04 -0000
@@ -42,6 +42,8 @@ GLIBCPP_3.2 {
     };
 
     # Names not in an 'extern' block are mangled names.
+
+    # std::has_facet*
     _ZSt9has_facet*;
 
     # operator new(unsigned)
@@ -72,8 +74,8 @@ GLIBCPP_3.2 {
     # operator delete[](void*, std::nothrow_t const&)
     _ZdaPvRKSt9nothrow_t;
 
-    # vtable	
-    _ZTV*;  
+    # vtable
+    _ZTV*;
     _ZTT*;
 
     # typeinfo
Index: docs/html/17_intro/C++STYLE
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/docs/html/17_intro/C++STYLE,v
retrieving revision 1.7
diff -u -3 -p -r1.7 C++STYLE
--- docs/html/17_intro/C++STYLE	23 Nov 2001 16:29:00 -0000	1.7
+++ docs/html/17_intro/C++STYLE	23 Aug 2002 16:49:04 -0000
@@ -173,7 +173,7 @@ Notable areas of divergence from what ma
      int foo;
 
 13. Spacing WRT return statements.
-   no extra spacing before returns
+   no extra spacing before returns, no parenthesis
    ie
 
    }
@@ -184,6 +184,12 @@ Notable areas of divergence from what ma
 
    return __ret;
 
+   -NOT-
+
+   }
+   return (__ret);
+
+
 14. Location of global variables.
    All global variables of class type, whether in the "user visable"
    space (e.g., cin) or the implementation namespace, must be defined
@@ -264,7 +270,7 @@ namespace std
 
     int 
     two_lines(const char* arg) 
-      { return strchr(arg, 'a'); }
+    { return strchr(arg, 'a'); }
 
     inline int 
     three_lines();  // inline, but defined below.
@@ -359,8 +365,4 @@ namespace std 
     // doesn't fit in one line.
   }
 } // namespace std
-
-
-
-
 
Index: include/bits/stl_alloc.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_alloc.h,v
retrieving revision 1.23
diff -u -3 -p -r1.23 stl_alloc.h
--- include/bits/stl_alloc.h	20 Jul 2002 06:26:26 -0000	1.23
+++ include/bits/stl_alloc.h	23 Aug 2002 16:49:05 -0000
@@ -111,6 +111,7 @@ namespace std
     { ::operator delete(__p); }
   };
 
+
   /**
    *  @if maint
    *  A malloc-based allocator.  Typically slower than the
@@ -159,7 +160,7 @@ namespace std
       {
         void (* __old)() = __malloc_alloc_oom_handler;
         __malloc_alloc_oom_handler = __f;
-        return(__old);
+        return __old;
       }
     };
 
@@ -179,11 +180,11 @@ namespace std
         {
           __my_malloc_handler = __malloc_alloc_oom_handler;
           if (0 == __my_malloc_handler)
-          std::__throw_bad_alloc();
+            std::__throw_bad_alloc();
           (*__my_malloc_handler)();
           __result = malloc(__n);
           if (__result)
-            return(__result);
+            return __result;
         }
     }
 
@@ -204,7 +205,7 @@ namespace std
           (*__my_malloc_handler)();
           __result = realloc(__p, __n);
           if (__result)
-            return(__result);
+            return __result;
         }
     }
 #endif
@@ -230,25 +231,25 @@ namespace std
    *  (See @link Allocators allocators info @endlink for more.)
    */
   template<typename _Tp, typename _Alloc>
-  class __simple_alloc
-  {
-  public:
-    static _Tp*
-    allocate(size_t __n)
-    { return 0 == __n ? 0 : (_Tp*) _Alloc::allocate(__n * sizeof (_Tp)); }
-
-    static _Tp*
-    allocate()
-    { return (_Tp*) _Alloc::allocate(sizeof (_Tp)); }
-
-    static void
-    deallocate(_Tp* __p, size_t __n)
-    { if (0 != __n) _Alloc::deallocate(__p, __n * sizeof (_Tp)); }
-
-    static void
-    deallocate(_Tp* __p)
-    { _Alloc::deallocate(__p, sizeof (_Tp)); }
-  };
+    class __simple_alloc
+    {
+    public:
+      static _Tp*
+      allocate(size_t __n)
+      { return 0 == __n ? 0 : (_Tp*) _Alloc::allocate(__n * sizeof (_Tp)); }
+  
+      static _Tp*
+      allocate()
+      { return (_Tp*) _Alloc::allocate(sizeof (_Tp)); }
+  
+      static void
+      deallocate(_Tp* __p, size_t __n)
+      { if (0 != __n) _Alloc::deallocate(__p, __n * sizeof (_Tp)); }
+  
+      static void
+      deallocate(_Tp* __p)
+      { _Alloc::deallocate(__p, sizeof (_Tp)); }
+    };
 
 
   /**
@@ -479,7 +480,7 @@ namespace std
         {
           __result = _S_start_free;
           _S_start_free += __total_bytes;
-          return(__result);
+          return __result ;
         }
       else if (__bytes_left >= __size)
         {
@@ -487,7 +488,7 @@ namespace std
           __total_bytes = __size * __nobjs;
           __result = _S_start_free;
           _S_start_free += __total_bytes;
-          return(__result);
+          return __result;
         }
       else
         {
@@ -521,7 +522,7 @@ namespace std
                       *__my_free_list = __p -> _M_free_list_link;
                       _S_start_free = (char*)__p;
                       _S_end_free = _S_start_free + __i;
-                      return(_S_chunk_alloc(__size, __nobjs));
+                      return _S_chunk_alloc(__size, __nobjs);
                       // Any leftover piece will eventually make it to the
                       // right free list.
                     }
@@ -533,7 +534,7 @@ namespace std
             }
           _S_heap_size += __bytes_to_get;
           _S_end_free = _S_start_free + __bytes_to_get;
-          return(_S_chunk_alloc(__size, __nobjs));
+          return _S_chunk_alloc(__size, __nobjs);
         }
     }
 
@@ -554,7 +555,7 @@ namespace std
       int __i;
 
       if (1 == __nobjs)
-        return(__chunk);
+        return __chunk;
       __my_free_list = _S_free_list + _S_freelist_index(__n);
 
       // Build free list in chunk.
@@ -784,7 +785,7 @@ namespace std
   };
 
   template<typename _Alloc>
-    class __allocator<void, _Alloc>
+    struct __allocator<void, _Alloc>
     {
       typedef size_t      size_type;
       typedef ptrdiff_t   difference_type;
Index: include/bits/stl_deque.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_deque.h,v
retrieving revision 1.27
diff -u -3 -p -r1.27 stl_deque.h
--- include/bits/stl_deque.h	9 Aug 2002 16:51:15 -0000	1.27
+++ include/bits/stl_deque.h	23 Aug 2002 16:49:05 -0000
@@ -81,7 +81,7 @@ namespace std
   */
   inline size_t 
   __deque_buf_size(size_t __size) 
-    { return __size < 512 ? size_t(512 / __size) : size_t(1); }
+  { return __size < 512 ? size_t(512 / __size) : size_t(1); }
   
   
   /**
@@ -1160,7 +1160,7 @@ namespace std
     */
     iterator
     insert(iterator __position)
-      { return insert(__position, value_type()); }
+    { return insert(__position, value_type()); }
   #endif
   
     /**
@@ -1174,7 +1174,7 @@ namespace std
     */
     void
     insert(iterator __position, size_type __n, const value_type& __x)
-      { _M_fill_insert(__position, __n, __x); }
+    { _M_fill_insert(__position, __n, __x); }
   
     /**
      *  @brief  Inserts a range into the %deque.
Index: include/bits/stl_list.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_list.h,v
retrieving revision 1.18
diff -u -3 -p -r1.18 stl_list.h
--- include/bits/stl_list.h	9 Aug 2002 16:51:15 -0000	1.18
+++ include/bits/stl_list.h	23 Aug 2002 16:49:05 -0000
@@ -113,20 +113,20 @@ namespace std
     /// Walk the %list forward.
     void
     _M_incr()
-      { _M_node = _M_node->_M_next; }
+    { _M_node = _M_node->_M_next; }
   
     /// Walk the %list backward.
     void
     _M_decr()
-      { _M_node = _M_node->_M_prev; }
+    { _M_node = _M_node->_M_prev; }
   
     bool
     operator==(const _List_iterator_base& __x) const
-      { return _M_node == __x._M_node; }
+    { return _M_node == __x._M_node; }
   
     bool
     operator!=(const _List_iterator_base& __x) const
-      { return _M_node != __x._M_node; }
+    { return _M_node != __x._M_node; }
   };
   
   /**
@@ -164,12 +164,12 @@ namespace std
   
     reference
     operator*() const
-      { return static_cast<_Node*>(_M_node)->_M_data; }
-      // Must downcast from List_node_base to _List_node to get to _M_data.
+    { return static_cast<_Node*>(_M_node)->_M_data; }
+    // Must downcast from List_node_base to _List_node to get to _M_data.
   
     pointer
     operator->() const
-      { return &(operator*()); }
+    { return &(operator*()); }
   
     _Self&
     operator++()
@@ -226,11 +226,11 @@ namespace std
   protected:
     _List_node<_Tp>*
     _M_get_node()
-      { return _M_node_allocator.allocate(1); }
+    { return _M_node_allocator.allocate(1); }
   
     void
     _M_put_node(_List_node<_Tp>* __p)
-      { _M_node_allocator.deallocate(__p, 1); }
+    { _M_node_allocator.deallocate(__p, 1); }
   
     // NOTA BENE
     // The stored instance is not actually of "allocator_type"'s type.  Instead
@@ -272,11 +272,11 @@ namespace std
   
     _List_node<_Tp>*
     _M_get_node()
-      { return _Alloc_type::allocate(1); }
+    { return _Alloc_type::allocate(1); }
   
     void
     _M_put_node(_List_node<_Tp>* __p)
-      { _Alloc_type::deallocate(__p, 1); }
+    { _Alloc_type::deallocate(__p, 1); }
   
     _List_node<_Tp>* _M_node;
   };
@@ -828,7 +828,7 @@ namespace std
     */
     void
     insert(iterator __pos, size_type __n, const value_type& __x)
-      { _M_fill_insert(__pos, __n, __x); }
+    { _M_fill_insert(__pos, __n, __x); }
   
     /**
      *  @brief  Inserts a range into the %list.
Index: include/bits/stl_map.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_map.h,v
retrieving revision 1.14
diff -u -3 -p -r1.14 stl_map.h
--- include/bits/stl_map.h	9 Aug 2002 16:51:15 -0000	1.14
+++ include/bits/stl_map.h	23 Aug 2002 16:49:05 -0000
@@ -109,7 +109,7 @@ namespace std
         value_compare(_Compare __c) : comp(__c) {}
       public:
         bool operator()(const value_type& __x, const value_type& __y) const
-          { return comp(__x.first, __y.first); }
+        { return comp(__x.first, __y.first); }
       };
   
   private:
@@ -337,7 +337,7 @@ namespace std
     */
     pair<iterator,bool>
     insert(const value_type& __x)
-      { return _M_t.insert_unique(__x); }
+    { return _M_t.insert_unique(__x); }
   
     /**
      *  @brief Attempts to insert a std::pair into the %map.
@@ -361,7 +361,7 @@ namespace std
     */
     iterator
     insert(iterator position, const value_type& __x)
-      { return _M_t.insert_unique(position, __x); }
+    { return _M_t.insert_unique(position, __x); }
   
     /**
      *  @brief A template function that attemps to insert a range of elements.
@@ -374,7 +374,7 @@ namespace std
     template <typename _InputIterator>
       void
       insert(_InputIterator __first, _InputIterator __last)
-        { _M_t.insert_unique(__first, __last); }
+      { _M_t.insert_unique(__first, __last); }
   
     /**
      *  @brief Erases an element from a %map.
@@ -491,7 +491,7 @@ namespace std
     */
     size_type
     count(const key_type& __x) const
-      { return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
+    { return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
   
     /**
      *  @brief Finds the beginning of a subsequence matching given key.
@@ -541,7 +541,7 @@ namespace std
     */
     const_iterator
     upper_bound(const key_type& __x) const
-      { return _M_t.upper_bound(__x); }
+    { return _M_t.upper_bound(__x); }
   
     /**
      *  @brief Finds a subsequence matching given key.
@@ -560,7 +560,7 @@ namespace std
     */
     pair<iterator,iterator>
     equal_range(const key_type& __x)
-      { return _M_t.equal_range(__x); }
+    { return _M_t.equal_range(__x); }
   
     /**
      *  @brief Finds a subsequence matching given key.
@@ -579,7 +579,7 @@ namespace std
     */
     pair<const_iterator,const_iterator>
     equal_range(const key_type& __x) const
-      { return _M_t.equal_range(__x); }
+    { return _M_t.equal_range(__x); }
   
     template <typename _K1, typename _T1, typename _C1, typename _A1>
     friend bool operator== (const map<_K1,_T1,_C1,_A1>&,
Index: include/bits/stl_multimap.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_multimap.h,v
retrieving revision 1.14
diff -u -3 -p -r1.14 stl_multimap.h
--- include/bits/stl_multimap.h	9 Aug 2002 16:51:15 -0000	1.14
+++ include/bits/stl_multimap.h	23 Aug 2002 16:49:05 -0000
@@ -123,7 +123,7 @@ namespace std
         value_compare(_Compare __c) : comp(__c) {}
       public:
         bool operator()(const value_type& __x, const value_type& __y) const
-          { return comp(__x.first, __y.first); }
+        { return comp(__x.first, __y.first); }
     };
   
   private:
@@ -347,7 +347,7 @@ namespace std
     */
     iterator
     insert(iterator __position, const value_type& __x)
-      { return _M_t.insert_equal(__position, __x); }
+    { return _M_t.insert_equal(__position, __x); }
   
     /**
      *  @brief A template function that attemps to insert a range of elements.
@@ -360,7 +360,7 @@ namespace std
     template <typename _InputIterator>
       void
       insert(_InputIterator __first, _InputIterator __last)
-        { _M_t.insert_equal(__first, __last); }
+      { _M_t.insert_equal(__first, __last); }
   
     /**
      *  @brief Erases an element from a %multimap.
Index: include/bits/stl_vector.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_vector.h,v
retrieving revision 1.27
diff -u -3 -p -r1.27 stl_vector.h
--- include/bits/stl_vector.h	9 Aug 2002 16:51:15 -0000	1.27
+++ include/bits/stl_vector.h	23 Aug 2002 16:49:06 -0000
@@ -98,7 +98,7 @@ namespace std
   
     void
     _M_deallocate(_Tp* __p, size_t __n)
-      { if (__p) _M_data_allocator.deallocate(__p, __n); }
+    { if (__p) _M_data_allocator.deallocate(__p, __n); }
   };
   
   /// @if maint Specialization for instanceless allocators.  @endif
@@ -447,7 +447,7 @@ namespace std
     */
     size_type
     capacity() const
-      { return size_type(const_iterator(_M_end_of_storage) - begin()); }
+    { return size_type(const_iterator(_M_end_of_storage) - begin()); }
   
     /**
      *  Returns true if the %vector is empty.  (Thus begin() would equal end().)
@@ -631,7 +631,7 @@ namespace std
     */
     iterator
     insert(iterator __position)
-      { return insert(__position, value_type()); }
+    { return insert(__position, value_type()); }
   #endif
   
     /**
@@ -648,7 +648,7 @@ namespace std
     */
     void
     insert (iterator __pos, size_type __n, const value_type& __x)
-      { _M_fill_insert(__pos, __n, __x); }
+    { _M_fill_insert(__pos, __n, __x); }
   
     /**
      *  @brief  Inserts a range into the %vector.


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