2012-06-27  Benjamin Kosnik  <bkoz@redhat.com>

	* include/bits/c++config: Remove __regex nested namespace.
	* include/bits/regex_compiler.h: Change __regex to
	__detail. Adjust doxygen markup, add regex-details group.
	* include/bits/regex_constants.h: Same.
	* include/bits/regex_cursor.h: Same.
	* include/bits/regex_error.h: Same.
	* include/bits/regex_grep_matcher.h: Same.
	* include/bits/regex_grep_matcher.tcc: Same.
	* include/bits/regex_nfa.h: Same.
	* include/bits/regex_nfa.tcc: Same.
	* include/bits/regex.h: Same. Remove static from global constants.

	* testsuite/ext/profile/mutex_extensions_neg.cc: Adjust line numbers.

	* include/bits/locale_classes.tcc: Add use_facet, has_facet to
	locales group.

diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index e76e742..1806151 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -1,7 +1,7 @@
 // Predefined symbols and macros -*- C++ -*-
 
 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-// 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+// 2006, 2007, 2008, 2009, 2010, 2011, 2012 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
@@ -210,7 +210,6 @@ namespace std
   namespace this_thread { inline namespace __7 { } }
 
   namespace __detail { inline namespace __7 { } }
-  namespace __regex { inline namespace __7 { } }
 }
 
 namespace __gnu_cxx
diff --git a/libstdc++-v3/include/bits/locale_classes.tcc b/libstdc++-v3/include/bits/locale_classes.tcc
index c796e0e..306fe46 100644
--- a/libstdc++-v3/include/bits/locale_classes.tcc
+++ b/libstdc++-v3/include/bits/locale_classes.tcc
@@ -1,6 +1,7 @@
 // Locale support -*- C++ -*-
 
-// Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
+// 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
@@ -89,6 +90,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   /**
    *  @brief  Test for the presence of a facet.
+   *  @ingroup locales
    *
    *  has_facet tests the locale argument for the presence of the facet type
    *  provided as the template parameter.  Facets derived from the facet
@@ -114,6 +116,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   /**
    *  @brief  Return a facet.
+   *  @ingroup locales
    *
    *  use_facet looks for and returns a reference to a facet of type Facet
    *  where Facet is the template parameter.  If has_facet(locale) is true,
diff --git a/libstdc++-v3/include/bits/regex.h b/libstdc++-v3/include/bits/regex.h
index 4c49665..897b8a4 100644
--- a/libstdc++-v3/include/bits/regex.h
+++ b/libstdc++-v3/include/bits/regex.h
@@ -1,6 +1,6 @@
 // class template regex -*- C++ -*-
 
-// Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+// Copyright (C) 2010, 2011, 2012 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
@@ -32,15 +32,13 @@ namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
-/**
- * @defgroup regex Regular Expressions
- * A facility for performing regular expression pattern matching.
- */
- //@{
+  /**
+   * @addtogroup regex
+   * @{
+   */
 
-  // [7.7] Class regex_traits
   /**
-   * @brief Describes aspects of a regular expression.
+   * @brief Class regex_traits. Describes aspects of a regular expression.
    *
    * A regular expression traits class that satisfies the requirements of 
    * section [28.7].
@@ -53,17 +51,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     struct regex_traits
     {
     public:
-      typedef _Ch_type                     char_type;
-      typedef std::basic_string<char_type> string_type;
-      typedef std::locale                  locale_type;
-      typedef std::ctype_base::mask        char_class_type;
+      typedef _Ch_type                     	char_type;
+      typedef std::basic_string<char_type> 	string_type;
+      typedef std::locale                  	locale_type;
+      typedef std::ctype_base::mask        	char_class_type;
 
     public:
       /**
        * @brief Constructs a default traits object.
        */
-      regex_traits()
-      { }
+      regex_traits() { }
       
       /**
        * @brief Gives the length of a C-style string starting at @p __p.
@@ -101,10 +98,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        */
       char_type
       translate_nocase(char_type __c) const
-      {
-	using std::ctype;
-	using std::use_facet;
-	return use_facet<ctype<char_type> >(_M_locale).tolower(__c);
+      { 
+	typedef std::ctype<char_type> __ctype_type;
+	const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale));
+	return __fctyp.tolower(__c); 
       }
       
       /**
@@ -131,12 +128,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
         string_type
         transform(_Fwd_iter __first, _Fwd_iter __last) const
         {
-	  using std::collate;
-	  using std::use_facet;
-	  const collate<_Ch_type>& __c(use_facet<
-				       collate<_Ch_type> >(_M_locale));
+	  typedef std::collate<char_type> __collate_type;
+	  const __collate_type& __fclt(use_facet<__collate_type>(_M_locale));
 	  string_type __s(__first, __last);
-	  return __c.transform(__s.data(), __s.data() + __s.size());
+	  return __fclt.transform(__s.data(), __s.data() + __s.size());
 	}
 
       /**
@@ -284,16 +279,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     regex_traits<_Ch_type>::
     isctype(_Ch_type __c, char_class_type __f) const
     {
-      using std::ctype;
-      using std::use_facet;
-      const ctype<_Ch_type>& __ctype(use_facet<
-				     ctype<_Ch_type> >(_M_locale));
+      typedef std::ctype<char_type> __ctype_type;
+      const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale));
       
-      if (__ctype.is(__f, __c))
+      if (__fctyp.is(__f, __c))
 	return true;
       
       // special case of underscore in [[:w:]]
-      if (__c == __ctype.widen('_'))
+      if (__c == __fctyp.widen('_'))
 	{
 	  const char __wb[] = "w";
 	  char_class_type __wt = this->lookup_classname(__wb,
@@ -303,7 +296,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	}
     
       // special case of [[:space:]] in [[:blank:]]
-      if (__ctype.is(std::ctype_base::space, __c))
+      if (__fctyp.is(std::ctype_base::space, __c))
 	{
 	  const char __bb[] = "blank";
 	  char_class_type __bt = this->lookup_classname(__bb,
@@ -320,7 +313,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     regex_traits<_Ch_type>::
     value(_Ch_type __ch, int __radix) const
     {
-      std::basic_istringstream<_Ch_type> __is(string_type(1, __ch));
+      std::basic_istringstream<char_type> __is(string_type(1, __ch));
       int __v;
       if (__radix == 8)
 	__is >> std::oct;
@@ -354,26 +347,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        * std [28.8.1](1)
        */
       //@{
-      static constexpr regex_constants::syntax_option_type icase
-        = regex_constants::icase;
-      static constexpr regex_constants::syntax_option_type nosubs
-        = regex_constants::nosubs;
-      static constexpr regex_constants::syntax_option_type optimize
-        = regex_constants::optimize;
-      static constexpr regex_constants::syntax_option_type collate
-        = regex_constants::collate;
-      static constexpr regex_constants::syntax_option_type ECMAScript
-        = regex_constants::ECMAScript;
-      static constexpr regex_constants::syntax_option_type basic
-        = regex_constants::basic;
-      static constexpr regex_constants::syntax_option_type extended
-        = regex_constants::extended;
-      static constexpr regex_constants::syntax_option_type awk
-        = regex_constants::awk;
-      static constexpr regex_constants::syntax_option_type grep
-        = regex_constants::grep;
-      static constexpr regex_constants::syntax_option_type egrep
-        = regex_constants::egrep;
+      static constexpr flag_type icase = regex_constants::icase;
+      static constexpr flag_type nosubs = regex_constants::nosubs;
+      static constexpr flag_type optimize = regex_constants::optimize;
+      static constexpr flag_type collate = regex_constants::collate;
+      static constexpr flag_type ECMAScript = regex_constants::ECMAScript;
+      static constexpr flag_type basic = regex_constants::basic;
+      static constexpr flag_type extended = regex_constants::extended;
+      static constexpr flag_type awk = regex_constants::awk;
+      static constexpr flag_type grep = regex_constants::grep;
+      static constexpr flag_type egrep = regex_constants::egrep;
       //@}
 
       // [7.8.2] construct/copy/destroy
@@ -382,8 +365,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        * character sequence.
        */
       basic_regex()
-      : _M_flags(regex_constants::ECMAScript),
-        _M_automaton(__regex::__compile<const _Ch_type*, _Rx_traits>(0, 0,
+      : _M_flags(ECMAScript),
+        _M_automaton(__detail::__compile<const _Ch_type*, _Rx_traits>(0, 0,
                      _M_traits, _M_flags))
       { }
 
@@ -399,10 +382,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        * @throws regex_error if @p __p is not a valid regular expression.
        */
       explicit
-      basic_regex(const _Ch_type* __p,
-		  flag_type __f = regex_constants::ECMAScript)
+      basic_regex(const _Ch_type* __p, flag_type __f = ECMAScript)
       : _M_flags(__f),
-        _M_automaton(__regex::__compile(__p, __p + _Rx_traits::length(__p),
+        _M_automaton(__detail::__compile(__p, __p + _Rx_traits::length(__p),
         				_M_traits, _M_flags))
       { }
 
@@ -420,7 +402,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        */
       basic_regex(const _Ch_type* __p, std::size_t __len, flag_type __f)
       : _M_flags(__f),
-        _M_automaton(__regex::__compile(__p, __p + __len, _M_traits, _M_flags))
+        _M_automaton(__detail::__compile(__p, __p + __len, _M_traits, _M_flags))
       { }
 
       /**
@@ -454,11 +436,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        */
       template<typename _Ch_traits, typename _Ch_alloc>
         explicit
-        basic_regex(const std::basic_string<_Ch_type, _Ch_traits,
-		    _Ch_alloc>& __s,
-		    flag_type __f = regex_constants::ECMAScript)
+        basic_regex(const std::basic_string<_Ch_type, _Ch_traits, 
+					    _Ch_alloc>& __s,
+		    flag_type __f = ECMAScript)
 	: _M_flags(__f),
-	  _M_automaton(__regex::__compile(__s.begin(), __s.end(),
+	  _M_automaton(__detail::__compile(__s.begin(), __s.end(),
 	  				  _M_traits, _M_flags))
         { }
 
@@ -477,9 +459,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        */
       template<typename _InputIterator>
         basic_regex(_InputIterator __first, _InputIterator __last, 
-		    flag_type __f = regex_constants::ECMAScript)
+		    flag_type __f = ECMAScript)
 	: _M_flags(__f),
-	  _M_automaton(__regex::__compile(__first, __last, _M_traits, _M_flags))
+	  _M_automaton(__detail::__compile(__first, __last, _M_traits, _M_flags))
         { }
 
       /**
@@ -491,9 +473,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        * @throws regex_error if @p __l is not a valid regular expression.
        */
       basic_regex(initializer_list<_Ch_type> __l,
-		  flag_type __f = regex_constants::ECMAScript)
+		  flag_type __f = ECMAScript)
       : _M_flags(__f),
-        _M_automaton(__regex::__compile(__l.begin(), __l.end(),
+        _M_automaton(__detail::__compile(__l.begin(), __l.end(),
         				_M_traits, _M_flags))
       { }
 
@@ -534,9 +516,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        *
        * @param __s A pointer to a string containing a regular expression.
        */
-      template<typename _Ch_typeraits, typename _Allocator>
+      template<typename _Ch_typeraits, typename _Alloc>
         basic_regex&
-        operator=(const basic_string<_Ch_type, _Ch_typeraits, _Allocator>& __s)
+        operator=(const basic_string<_Ch_type, _Ch_typeraits, _Alloc>& __s)
         { return this->assign(__s, flags()); }
 
       // [7.8.3] assign
@@ -580,8 +562,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        * regex_error is thrown, *this remains unchanged.
        */
       basic_regex&
-      assign(const _Ch_type* __p,
-	     flag_type __flags = regex_constants::ECMAScript)
+      assign(const _Ch_type* __p, flag_type __flags = ECMAScript)
       { return this->assign(string_type(__p), __flags); }
 
       /**
@@ -612,10 +593,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        * expression pattern interpreted according to @p __flags.  If
        * regex_error is thrown, *this remains unchanged.
        */
-      template<typename _Ch_typeraits, typename _Allocator>
+      template<typename _Ch_typeraits, typename _Alloc>
         basic_regex&
-        assign(const basic_string<_Ch_type, _Ch_typeraits, _Allocator>& __s,
-	       flag_type __flags = regex_constants::ECMAScript)
+        assign(const basic_string<_Ch_type, _Ch_typeraits, _Alloc>& __s,
+	       flag_type __flags = ECMAScript)
         { 
 	  basic_regex __tmp(__s, __flags);
 	  this->swap(__tmp);
@@ -638,7 +619,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       template<typename _InputIterator>
         basic_regex&
         assign(_InputIterator __first, _InputIterator __last,
-	       flag_type __flags = regex_constants::ECMAScript)
+	       flag_type __flags = ECMAScript)
         { return this->assign(string_type(__first, __last), __flags); }
 
       /**
@@ -653,8 +634,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        * unchanged.
        */
       basic_regex&
-      assign(initializer_list<_Ch_type> __l,
-	     flag_type __flags = regex_constants::ECMAScript)
+      assign(initializer_list<_Ch_type> __l, flag_type __flags = ECMAScript)
       { return this->assign(__l.begin(), __l.end(), __flags); }
 
       // [7.8.4] const operations
@@ -701,8 +681,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       void
       swap(basic_regex& __rhs)
       {
-	std::swap(_M_flags,     __rhs._M_flags);
-	std::swap(_M_traits,    __rhs._M_traits);
+	std::swap(_M_flags, __rhs._M_flags);
+	std::swap(_M_traits, __rhs._M_traits);
 	std::swap(_M_automaton, __rhs._M_automaton);
       }
 
@@ -712,18 +692,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       { _M_automaton->_M_dot(__ostr); }
 #endif
       
-      const __regex::_AutomatonPtr&
+      const __detail::_AutomatonPtr&
       _M_get_automaton() const
       { return _M_automaton; }
 
     protected:
       flag_type              _M_flags;
       _Rx_traits             _M_traits;
-      __regex::_AutomatonPtr _M_automaton;
+      __detail::_AutomatonPtr _M_automaton;
     };
   
   /** @brief Standard regular expressions. */
   typedef basic_regex<char>    regex;
+
 #ifdef _GLIBCXX_USE_WCHAR_T
   /** @brief Standard wide-character regular expressions. */
   typedef basic_regex<wchar_t> wregex;
@@ -759,14 +740,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _BiIter>
     class sub_match : public std::pair<_BiIter, _BiIter>
     {
+      typedef iterator_traits<_BiIter>			__iter_traits;
+	
     public:
-      typedef typename iterator_traits<_BiIter>::value_type      value_type;
-      typedef typename iterator_traits<_BiIter>::difference_type
-                                                            difference_type;
-      typedef _BiIter                                              iterator;
-      typedef std::basic_string<value_type>                     string_type;
+      typedef typename __iter_traits::value_type      	value_type;
+      typedef typename __iter_traits::difference_type 	difference_type;
+      typedef _BiIter                                   iterator;
+      typedef std::basic_string<value_type>             string_type;
 
-    public:
       bool matched;
       
       constexpr sub_match() : matched() { }
@@ -851,11 +832,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   
   /** @brief Standard regex submatch over a C-style null-terminated string. */
   typedef sub_match<const char*>             csub_match;
+
   /** @brief Standard regex submatch over a standard string. */
   typedef sub_match<string::const_iterator>  ssub_match;
+
 #ifdef _GLIBCXX_USE_WCHAR_T
   /** @brief Regex submatch over a C-style null-terminated wide string. */
   typedef sub_match<const wchar_t*>          wcsub_match;
+
   /** @brief Regex submatch over a standard wide string. */
   typedef sub_match<wstring::const_iterator> wssub_match;
 #endif
@@ -870,8 +854,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    */
   template<typename _BiIter>
     inline bool
-    operator==(const sub_match<_BiIter>& __lhs,
-	       const sub_match<_BiIter>& __rhs)
+    operator==(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
     { return __lhs.compare(__rhs) == 0; }
 
   /**
@@ -882,8 +865,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    */
   template<typename _BiIter>
     inline bool
-    operator!=(const sub_match<_BiIter>& __lhs,
-	       const sub_match<_BiIter>& __rhs)
+    operator!=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
     { return __lhs.compare(__rhs) != 0; }
 
   /**
@@ -894,8 +876,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    */
   template<typename _BiIter>
     inline bool
-    operator<(const sub_match<_BiIter>& __lhs,
-	      const sub_match<_BiIter>& __rhs)
+    operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
     { return __lhs.compare(__rhs) < 0; }
 
   /**
@@ -906,8 +887,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    */
   template<typename _BiIter>
     inline bool
-    operator<=(const sub_match<_BiIter>& __lhs,
-	       const sub_match<_BiIter>& __rhs)
+    operator<=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
     { return __lhs.compare(__rhs) <= 0; }
 
   /**
@@ -918,8 +898,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    */
   template<typename _BiIter>
     inline bool
-    operator>=(const sub_match<_BiIter>& __lhs,
-	       const sub_match<_BiIter>& __rhs)
+    operator>=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
     { return __lhs.compare(__rhs) >= 0; }
 
   /**
@@ -930,10 +909,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    */
   template<typename _BiIter>
     inline bool
-    operator>(const sub_match<_BiIter>& __lhs,
-	      const sub_match<_BiIter>& __rhs)
+    operator>(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
     { return __lhs.compare(__rhs) > 0; }
 
+  // Alias for sub_match'd string.
+  template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
+    using __sub_match_string = basic_string<
+                              typename iterator_traits<_Bi_iter>::value_type,
+                              _Ch_traits, _Ch_alloc>;
+
   /**
    * @brief Tests the equivalence of a string and a regular expression
    *        submatch.
@@ -943,9 +927,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    */
   template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
     inline bool
-    operator==(const basic_string<
-	       typename iterator_traits<_Bi_iter>::value_type,
-	       _Ch_traits, _Ch_alloc>& __lhs,
+    operator==(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
 	       const sub_match<_Bi_iter>& __rhs)
     { return __rhs.compare(__lhs.c_str()) == 0; }
 
@@ -958,9 +940,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    */
   template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
     inline bool
-    operator!=(const basic_string<
-	       typename iterator_traits<_Bi_iter>::value_type,
-	       _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
+    operator!=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
+	       const sub_match<_Bi_iter>& __rhs)
     { return !(__lhs == __rhs); }
 
   /**
@@ -971,9 +952,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    */
   template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
     inline bool
-    operator<(const basic_string<
-	      typename iterator_traits<_Bi_iter>::value_type,
-	      _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
+    operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
+	      const sub_match<_Bi_iter>& __rhs)
      { return __rhs.compare(__lhs.c_str()) > 0; }
 
   /**
@@ -984,9 +964,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    */
   template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
     inline bool
-    operator>(const basic_string<
-	      typename iterator_traits<_Bi_iter>::value_type, 
-	      _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
+    operator>(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
+	      const sub_match<_Bi_iter>& __rhs)
     { return __rhs < __lhs; }
 
   /**
@@ -997,9 +976,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    */
   template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
     inline bool
-    operator>=(const basic_string<
-	       typename iterator_traits<_Bi_iter>::value_type,
-	       _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
+    operator>=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
+	       const sub_match<_Bi_iter>& __rhs)
     { return !(__lhs < __rhs); }
 
   /**
@@ -1010,9 +988,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    */
   template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
     inline bool
-    operator<=(const basic_string<
-	       typename iterator_traits<_Bi_iter>::value_type,
-	       _Ch_traits, _Ch_alloc>& __lhs, const sub_match<_Bi_iter>& __rhs)
+    operator<=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
+	       const sub_match<_Bi_iter>& __rhs)
     { return !(__rhs < __lhs); }
 
   /**
@@ -1025,9 +1002,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
     inline bool
     operator==(const sub_match<_Bi_iter>& __lhs,
-	       const basic_string<
-	       typename iterator_traits<_Bi_iter>::value_type,
-	       _Ch_traits, _Ch_alloc>& __rhs)
+	       const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
     { return __lhs.compare(__rhs.c_str()) == 0; }
 
   /**
@@ -1040,9 +1015,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
     inline bool
     operator!=(const sub_match<_Bi_iter>& __lhs,
-	       const basic_string<
-	       typename iterator_traits<_Bi_iter>::value_type,
-	       _Ch_traits, _Ch_alloc>& __rhs)
+	       const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
     { return !(__lhs == __rhs); }
 
   /**
@@ -1054,9 +1027,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc>
     inline bool
     operator<(const sub_match<_Bi_iter>& __lhs,
-	      const basic_string<
-	      typename iterator_traits<_Bi_iter>::value_type,
-	      _Ch_traits, _Ch_alloc>& __rhs)
+	      const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
     { return __lhs.compare(__rhs.c_str()) < 0; }
 
   /**
@@ -1068,9 +1039,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc>
     inline bool
     operator>(const sub_match<_Bi_iter>& __lhs,
-	      const basic_string<
-	      typename iterator_traits<_Bi_iter>::value_type,
-	      _Ch_traits, _Ch_alloc>& __rhs)
+	      const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
     { return __rhs < __lhs; }
 
   /**
@@ -1082,9 +1051,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc>
     inline bool
     operator>=(const sub_match<_Bi_iter>& __lhs,
-	       const basic_string<
-	       typename iterator_traits<_Bi_iter>::value_type,
-	       _Ch_traits, _Ch_alloc>& __rhs)
+	       const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
     { return !(__lhs < __rhs); }
 
   /**
@@ -1096,9 +1063,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Bi_iter, class _Ch_traits, class _Ch_alloc>
     inline bool
     operator<=(const sub_match<_Bi_iter>& __lhs,
-	       const basic_string<
-	       typename iterator_traits<_Bi_iter>::value_type,
-	       _Ch_traits, _Ch_alloc>& __rhs)
+	       const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __rhs)
     { return !(__rhs < __lhs); }
 
   /**
@@ -1261,8 +1226,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
 	       const sub_match<_Bi_iter>& __rhs)
     {
-      return __rhs.compare(typename sub_match<_Bi_iter>::string_type(1, __lhs))
-             == 0;
+      typedef typename sub_match<_Bi_iter>::string_type string_type;
+      return __rhs.compare(string_type(1, __lhs)) == 0;
     }
 
   /**
@@ -1289,8 +1254,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
 	      const sub_match<_Bi_iter>& __rhs)
     {
-      return __rhs.compare(typename sub_match<_Bi_iter>::string_type(1, __lhs))
-             > 0;
+      typedef typename sub_match<_Bi_iter>::string_type string_type;
+      return __rhs.compare(string_type(1, __lhs)) > 0;
     }
 
   /**
@@ -1341,8 +1306,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     operator==(const sub_match<_Bi_iter>& __lhs,
 	       typename iterator_traits<_Bi_iter>::value_type const& __rhs)
     {
-      return __lhs.compare(typename sub_match<_Bi_iter>::string_type(1, __rhs))
-             == 0;
+      typedef typename sub_match<_Bi_iter>::string_type string_type;
+      return __lhs.compare(string_type(1, __rhs)) == 0;
     }
 
   /**
@@ -1369,8 +1334,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     operator<(const sub_match<_Bi_iter>& __lhs,
 	      typename iterator_traits<_Bi_iter>::value_type const& __rhs)
     {
-      return __lhs.compare(typename sub_match<_Bi_iter>::string_type(1, __rhs))
-             < 0;
+      typedef typename sub_match<_Bi_iter>::string_type string_type;
+      return __lhs.compare(string_type(1, __rhs)) < 0;
     }
 
   /**
@@ -1460,9 +1425,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    * @nosubgrouping
    */
   template<typename _Bi_iter,
-	   typename _Allocator = allocator<sub_match<_Bi_iter> > >
+	   typename _Alloc = allocator<sub_match<_Bi_iter> > >
     class match_results
-    : private std::vector<sub_match<_Bi_iter>, _Allocator>
+    : private std::vector<sub_match<_Bi_iter>, _Alloc>
     {
     private:
       /*
@@ -1476,26 +1441,27 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        * [n+1] prefix
        * [n+2] suffix
        */
-      typedef std::vector<sub_match<_Bi_iter>, _Allocator>    _Base_type;
+      typedef std::vector<sub_match<_Bi_iter>, _Alloc>     _Base_type;
+      typedef std::iterator_traits<_Bi_iter>   	   	   __iter_traits;
+      typedef regex_constants::match_flag_type		   match_flag_type;
 
     public:
       /**
        * @name 10.? Public Types
        */
       //@{
-      typedef sub_match<_Bi_iter>                             value_type;
-      typedef const value_type&                               const_reference;
-      typedef const_reference                                 reference;
-      typedef typename _Base_type::const_iterator             const_iterator;
-      typedef const_iterator                                  iterator;
-      typedef typename std::iterator_traits<_Bi_iter>::difference_type
-                                                              difference_type;
-      typedef typename allocator_traits<_Allocator>::size_type
-                                                              size_type;
-      typedef _Allocator                                      allocator_type;
-      typedef typename std::iterator_traits<_Bi_iter>::value_type
-                                                              char_type;
-      typedef std::basic_string<char_type>                    string_type;
+      typedef _Alloc                                       allocator_type;
+      typedef sub_match<_Bi_iter>                          value_type;
+      typedef const value_type&                            const_reference;
+      typedef const_reference                              reference;
+      typedef typename _Base_type::const_iterator          const_iterator;
+      typedef const_iterator                               iterator;
+      typedef typename __iter_traits::difference_type	   difference_type;
+      typedef typename __iter_traits::value_type 	   char_type;
+      typedef typename allocator_traits<_Alloc>::size_type size_type;
+
+
+      typedef std::basic_string<char_type>                 string_type;
       //@}
   
     public:
@@ -1509,7 +1475,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        * @post size() returns 0 and str() returns an empty string.
        */
       explicit
-      match_results(const _Allocator& __a = _Allocator())
+      match_results(const _Alloc& __a = _Alloc())
       : _Base_type(__a)
       { }
 
@@ -1751,8 +1717,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
         _Out_iter
         format(_Out_iter __out, const char_type* __fmt_first,
 	       const char_type* __fmt_last,
-	       regex_constants::match_flag_type __flags
-	       = regex_constants::format_default) const
+	       match_flag_type __flags = regex_constants::format_default) const
         { return __out; }
 
       /**
@@ -1761,8 +1726,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       template<typename _Out_iter, typename _St, typename _Sa>
         _Out_iter
         format(_Out_iter __out, const basic_string<char_type, _St, _Sa>& __fmt,
-	       regex_constants::match_flag_type __flags
-	       = regex_constants::format_default) const
+	       match_flag_type __flags = regex_constants::format_default) const
         {
           return format(__out, __fmt.data(), __fmt.data() + __fmt.size(),
                         __flags);
@@ -1774,8 +1738,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       template<typename _Out_iter, typename _St, typename _Sa>
         basic_string<char_type, _St, _Sa>
         format(const basic_string<char_type, _St, _Sa>& __fmt,
-	       regex_constants::match_flag_type __flags
-	       = regex_constants::format_default) const
+	       match_flag_type __flags = regex_constants::format_default) const
         {
           basic_string<char_type, _St, _Sa> __result;
           format(std::back_inserter(__result), __fmt, __flags);
@@ -1787,8 +1750,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        */
       string_type
       format(const char_type* __fmt,
-	     regex_constants::match_flag_type __flags
-	     = regex_constants::format_default) const
+	     match_flag_type __flags = regex_constants::format_default) const
       {
         string_type __result;
         format(std::back_inserter(__result),
@@ -1827,7 +1789,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       //@} 
       
     private:
-      friend class __regex::_SpecializedResults<_Bi_iter, _Allocator>;
+      friend class __detail::_SpecializedResults<_Bi_iter, _Alloc>;
     };
   
   typedef match_results<const char*>             cmatch;
@@ -1843,10 +1805,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    * @returns true if the two objects refer to the same match,
    * false otherwise.
    */
-  template<typename _Bi_iter, typename _Allocator>
+  template<typename _Bi_iter, typename _Alloc>
     inline bool
-    operator==(const match_results<_Bi_iter, _Allocator>& __m1,
-	       const match_results<_Bi_iter, _Allocator>& __m2)
+    operator==(const match_results<_Bi_iter, _Alloc>& __m1,
+	       const match_results<_Bi_iter, _Alloc>& __m2)
     {
       if (__m1.ready() != __m2.ready())
         return false;
@@ -1867,10 +1829,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    * @returns true if the two objects do not refer to the same match,
    * false otherwise.
    */
-  template<typename _Bi_iter, class _Allocator>
+  template<typename _Bi_iter, class _Alloc>
     inline bool
-    operator!=(const match_results<_Bi_iter, _Allocator>& __m1,
-	       const match_results<_Bi_iter, _Allocator>& __m2)
+    operator!=(const match_results<_Bi_iter, _Alloc>& __m1,
+	       const match_results<_Bi_iter, _Alloc>& __m2)
     { return !(__m1 == __m2); }
 
   // [7.10.6] match_results swap
@@ -1881,10 +1843,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *
    * The contents of the two match_results objects are swapped.
    */
-  template<typename _Bi_iter, typename _Allocator>
+  template<typename _Bi_iter, typename _Alloc>
     inline void
-    swap(match_results<_Bi_iter, _Allocator>& __lhs,
-	 match_results<_Bi_iter, _Allocator>& __rhs)
+    swap(match_results<_Bi_iter, _Alloc>& __lhs,
+	 match_results<_Bi_iter, _Alloc>& __rhs)
     { __lhs.swap(__rhs); }
 
   // [7.11.2] Function template regex_match
@@ -1910,21 +1872,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *
    * @todo Implement this function.
    */
-  template<typename _Bi_iter, typename _Allocator,
+  template<typename _Bi_iter, typename _Alloc,
 	   typename _Ch_type, typename _Rx_traits>
     bool
     regex_match(_Bi_iter                                 __s,
                 _Bi_iter                                 __e,
-                match_results<_Bi_iter, _Allocator>&     __m,
+                match_results<_Bi_iter, _Alloc>&     __m,
                 const basic_regex<_Ch_type, _Rx_traits>& __re,
                 regex_constants::match_flag_type         __flags
                                = regex_constants::match_default)
     {
-      __regex::_AutomatonPtr __a = __re._M_get_automaton();
-      __regex::_Automaton::_SizeT __sz = __a->_M_sub_count();
-      __regex::_SpecializedCursor<_Bi_iter> __cs(__s, __e);
-      __regex::_SpecializedResults<_Bi_iter, _Allocator> __r(__sz, __cs, __m);
-      __regex::_Grep_matcher __matcher(__cs, __r, __a, __flags);
+      __detail::_AutomatonPtr __a = __re._M_get_automaton();
+      __detail::_Automaton::_SizeT __sz = __a->_M_sub_count();
+      __detail::_SpecializedCursor<_Bi_iter> __cs(__s, __e);
+      __detail::_SpecializedResults<_Bi_iter, _Alloc> __r(__sz, __cs, __m);
+      __detail::_Grep_matcher __matcher(__cs, __r, __a, __flags);
       return __m[0].matched;
     }
 
@@ -1967,10 +1929,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *
    * @throws an exception of type regex_error.
    */
-  template<typename _Ch_type, typename _Allocator, typename _Rx_traits>
+  template<typename _Ch_type, typename _Alloc, typename _Rx_traits>
     inline bool
     regex_match(const _Ch_type* __s,
-		match_results<const _Ch_type*, _Allocator>& __m,
+		match_results<const _Ch_type*, _Alloc>& __m,
 		const basic_regex<_Ch_type, _Rx_traits>& __re,
 		regex_constants::match_flag_type __f
 		= regex_constants::match_default)
@@ -1991,11 +1953,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    * @throws an exception of type regex_error.
    */
   template<typename _Ch_traits, typename _Ch_alloc,
-	   typename _Allocator, typename _Ch_type, typename _Rx_traits>
+	   typename _Alloc, typename _Ch_type, typename _Rx_traits>
     inline bool
     regex_match(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s,
 		match_results<typename basic_string<_Ch_type, 
-		_Ch_traits, _Ch_alloc>::const_iterator, _Allocator>& __m,
+		_Ch_traits, _Ch_alloc>::const_iterator, _Alloc>& __m,
 		const basic_regex<_Ch_type, _Rx_traits>& __re,
 		regex_constants::match_flag_type __flags
 		= regex_constants::match_default)
@@ -2060,11 +2022,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *
    * @todo Implement this function.
    */
-  template<typename _Bi_iter, typename _Allocator,
+  template<typename _Bi_iter, typename _Alloc,
 	   typename _Ch_type, typename _Rx_traits>
     inline bool
     regex_search(_Bi_iter __first, _Bi_iter __last,
-		 match_results<_Bi_iter, _Allocator>& __m,
+		 match_results<_Bi_iter, _Alloc>& __m,
 		 const basic_regex<_Ch_type, _Rx_traits>& __re,
 		 regex_constants::match_flag_type __flags
 		 = regex_constants::match_default)
@@ -2106,10 +2068,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *
    * @throws an exception of type regex_error.
    */
-  template<typename _Ch_type, class _Allocator, class _Rx_traits>
+  template<typename _Ch_type, class _Alloc, class _Rx_traits>
     inline bool
     regex_search(const _Ch_type* __s,
-		 match_results<const _Ch_type*, _Allocator>& __m,
+		 match_results<const _Ch_type*, _Alloc>& __m,
 		 const basic_regex<_Ch_type, _Rx_traits>& __e,
 		 regex_constants::match_flag_type __f
 		 = regex_constants::match_default)
@@ -2168,12 +2130,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    * @throws an exception of type regex_error.
    */
   template<typename _Ch_traits, typename _Ch_alloc,
-	   typename _Allocator, typename _Ch_type,
+	   typename _Alloc, typename _Ch_type,
 	   typename _Rx_traits>
     inline bool
     regex_search(const basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s,
 		 match_results<typename basic_string<_Ch_type,
-		 _Ch_traits, _Ch_alloc>::const_iterator, _Allocator>& __m,
+		 _Ch_traits, _Ch_alloc>::const_iterator, _Alloc>& __m,
 		 const basic_regex<_Ch_type, _Rx_traits>& __e,
 		 regex_constants::match_flag_type __f
 		 = regex_constants::match_default)
@@ -2249,7 +2211,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       typedef const value_type&                  reference;
       typedef std::forward_iterator_tag          iterator_category;
 
-    public:
       /**
        * @brief Provides a singular iterator, useful for indicating
        * one-past-the-end of a range.
@@ -2506,11 +2467,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   /** @brief Token iterator for C-style NULL-terminated strings. */
   typedef regex_token_iterator<const char*>             cregex_token_iterator;
+
   /** @brief Token iterator for standard strings. */
   typedef regex_token_iterator<string::const_iterator>  sregex_token_iterator;
+
 #ifdef _GLIBCXX_USE_WCHAR_T
   /** @brief Token iterator for C-style NULL-terminated wide strings. */
   typedef regex_token_iterator<const wchar_t*>          wcregex_token_iterator;
+
   /** @brief Token iterator for standard wide-character strings. */
   typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
 #endif
diff --git a/libstdc++-v3/include/bits/regex_compiler.h b/libstdc++-v3/include/bits/regex_compiler.h
index 025c4fa..5b1aaa1 100644
--- a/libstdc++-v3/include/bits/regex_compiler.h
+++ b/libstdc++-v3/include/bits/regex_compiler.h
@@ -1,6 +1,6 @@
 // class template regex -*- C++ -*-
 
-// Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+// Copyright (C) 2010, 2011, 2012 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
@@ -30,10 +30,16 @@
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
-namespace __regex
+namespace __detail
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+  /**
+   * @addtogroup regex-detail
+   * @{
+   */
+
+  /// Base class for scanner.
   struct _Scanner_base
   {
     typedef unsigned int _StateT;
@@ -45,16 +51,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     virtual ~_Scanner_base() { };
   };
 
-  //
-  // @brief Scans an input range for regex tokens.
-  //
-  // The %_Scanner class interprets the regular expression pattern in the input
-  // range passed to its constructor as a sequence of parse tokens passed to
-  // the regular expression compiler.  The sequence of tokens provided depends
-  // on the flag settings passed to the constructor:  different regular
-  // expression grammars will interpret the same input pattern in
-  // syntactically different ways.
-  //
+  /**
+   * @brief struct _Scanner. Scans an input range for regex tokens.
+   *
+   * The %_Scanner class interprets the regular expression pattern in
+   * the input range passed to its constructor as a sequence of parse
+   * tokens passed to the regular expression compiler.  The sequence
+   * of tokens provided depends on the flag settings passed to the
+   * constructor: different regular expression grammars will interpret
+   * the same input pattern in syntactically different ways.
+   */
   template<typename _InputIterator>
     class _Scanner: public _Scanner_base
     {
@@ -65,7 +71,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       typedef regex_constants::syntax_option_type                   _FlagT;
       typedef const std::ctype<_CharT>                              _CtypeT;
 
-      // Token types returned from the scanner.
+      /// Token types returned from the scanner.
       enum _TokenT
       {
 	_S_token_anychar,
@@ -99,7 +105,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	_S_token_unknown
       };
 
-    public:
       _Scanner(_IteratorT __begin, _IteratorT __end, _FlagT __flags,
 	       std::locale __loc)
       : _M_current(__begin) , _M_end(__end) , _M_flags(__flags),
@@ -141,7 +146,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       void
       _M_eat_collsymbol();
 
-    private:
       _IteratorT  _M_current;
       _IteratorT  _M_end;
       _FlagT      _M_flags;
@@ -625,7 +629,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     }
 #endif
 
-  // Builds an NFA from an input iterator interval.
+  /// Builds an NFA from an input iterator interval.
   template<typename _InIter, typename _TraitsT>
     class _Compiler
     {
@@ -635,7 +639,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       typedef std::basic_string<_CharT>                          _StringT;
       typedef regex_constants::syntax_option_type                _FlagT;
 
-    public:
       _Compiler(const _InIter& __b, const _InIter& __e,
 		_TraitsT& __traits, _FlagT __flags);
 
@@ -704,7 +707,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       int
       _M_cur_int_value(int __radix);
 
-    private:
       _TraitsT&      _M_traits;
       _ScannerT      _M_scanner;
       _StringT       _M_cur_value;
@@ -1102,8 +1104,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return _AutomatonPtr(new _Nfa(_Compiler<_InIter, _TraitsT>(__b, __e, __t,
                                         __f)._M_nfa())); }
 
+ //@} regex-detail
 _GLIBCXX_END_NAMESPACE_VERSION
-} // namespace __regex
+} // namespace __detail
 } // namespace std
-
-/* vim: set ts=8 sw=2 sts=2: */
diff --git a/libstdc++-v3/include/bits/regex_constants.h b/libstdc++-v3/include/bits/regex_constants.h
index bddef3a..61052e9 100644
--- a/libstdc++-v3/include/bits/regex_constants.h
+++ b/libstdc++-v3/include/bits/regex_constants.h
@@ -1,6 +1,6 @@
 // class template regex -*- C++ -*-
 
-// Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+// Copyright (C) 2010, 2011, 2012 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
@@ -33,6 +33,13 @@
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 /**
+ * @defgroup regex Regular Expressions
+ *
+ * A facility for performing regular expression pattern matching.
+ * @{
+ */
+
+/**
  * @namespace std::regex_constants
  * @brief ISO C++-0x entities sub namespace for regex.
  */
@@ -76,14 +83,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    * Specifies that the matching of regular expressions against a character
    * sequence shall be performed without regard to case.
    */
-  static constexpr syntax_option_type icase      = 1 << _S_icase;
+  constexpr syntax_option_type icase      = 1 << _S_icase;
 
   /**
    * Specifies that when a regular expression is matched against a character
    * container sequence, no sub-expression matches are to be stored in the
    * supplied match_results structure.
    */
-  static constexpr syntax_option_type nosubs     = 1 << _S_nosubs;
+  constexpr syntax_option_type nosubs     = 1 << _S_nosubs;
 
   /**
    * Specifies that the regular expression engine should pay more attention to
@@ -91,13 +98,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    * speed with which regular expression objects are constructed. Otherwise
    * it has no detectable effect on the program output.
    */
-  static constexpr syntax_option_type optimize   = 1 << _S_optimize;
+  constexpr syntax_option_type optimize   = 1 << _S_optimize;
 
   /**
    * Specifies that character ranges of the form [a-b] should be locale
    * sensitive.
    */
-  static constexpr syntax_option_type collate    = 1 << _S_collate;
+  constexpr syntax_option_type collate    = 1 << _S_collate;
 
   /**
    * Specifies that the grammar recognized by the regular expression engine is
@@ -107,7 +114,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    * in the PERL scripting language but extended with elements found in the
    * POSIX regular expression grammar.
    */
-  static constexpr syntax_option_type ECMAScript = 1 << _S_ECMAScript;
+  constexpr syntax_option_type ECMAScript = 1 << _S_ECMAScript;
 
   /**
    * Specifies that the grammar recognized by the regular expression engine is
@@ -116,7 +123,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    * Headers, Section 9, Regular Expressions [IEEE, Information Technology --
    * Portable Operating System Interface (POSIX), IEEE Standard 1003.1-2001].
    */
-  static constexpr syntax_option_type basic      = 1 << _S_basic;
+  constexpr syntax_option_type basic      = 1 << _S_basic;
 
   /**
    * Specifies that the grammar recognized by the regular expression engine is
@@ -124,7 +131,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    * Portable Operating System Interface (POSIX), Base Definitions and Headers,
    * Section 9, Regular Expressions.
    */
-  static constexpr syntax_option_type extended   = 1 << _S_extended;
+  constexpr syntax_option_type extended   = 1 << _S_extended;
 
   /**
    * Specifies that the grammar recognized by the regular expression engine is
@@ -134,7 +141,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    * \\\\, \\a, \\b, \\f, \\n, \\r, \\t , \\v, \\&apos;, &apos;,
    * and \\ddd (where ddd is one, two, or three octal digits).  
    */
-  static constexpr syntax_option_type awk        = 1 << _S_awk;
+  constexpr syntax_option_type awk        = 1 << _S_awk;
 
   /**
    * Specifies that the grammar recognized by the regular expression engine is
@@ -142,7 +149,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    * identical to syntax_option_type basic, except that newlines are treated
    * as whitespace.
    */
-  static constexpr syntax_option_type grep       = 1 << _S_grep;
+  constexpr syntax_option_type grep       = 1 << _S_grep;
 
   /**
    * Specifies that the grammar recognized by the regular expression engine is
@@ -150,7 +157,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    * IEEE Std 1003.1-2001.  This option is identical to syntax_option_type 
    * extended, except that newlines are treated as whitespace.
    */
-  static constexpr syntax_option_type egrep      = 1 << _S_egrep;
+  constexpr syntax_option_type egrep      = 1 << _S_egrep;
 
   //@}
 
@@ -193,56 +200,56 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   /**
    * The default matching rules.
    */
-  static constexpr match_flag_type match_default     = 0;
+  constexpr match_flag_type match_default     = 0;
 
   /**
    * The first character in the sequence [first, last) is treated as though it
    * is not at the beginning of a line, so the character (^) in the regular
    * expression shall not match [first, first).
    */
-  static constexpr match_flag_type match_not_bol     = 1 << _S_not_bol;
+  constexpr match_flag_type match_not_bol     = 1 << _S_not_bol;
 
   /**
    * The last character in the sequence [first, last) is treated as though it
    * is not at the end of a line, so the character ($) in the regular
    * expression shall not match [last, last).
    */
-  static constexpr match_flag_type match_not_eol     = 1 << _S_not_eol;
+  constexpr match_flag_type match_not_eol     = 1 << _S_not_eol;
    
   /**
    * The expression \\b is not matched against the sub-sequence
    * [first,first).
    */
-  static constexpr match_flag_type match_not_bow     = 1 << _S_not_bow;
+  constexpr match_flag_type match_not_bow     = 1 << _S_not_bow;
    
   /**
    * The expression \\b should not be matched against the sub-sequence
    * [last,last).
    */
-  static constexpr match_flag_type match_not_eow     = 1 << _S_not_eow;
+  constexpr match_flag_type match_not_eow     = 1 << _S_not_eow;
    
   /**
    * If more than one match is possible then any match is an acceptable
    * result.
    */
-  static constexpr match_flag_type match_any         = 1 << _S_any;
+  constexpr match_flag_type match_any         = 1 << _S_any;
    
   /**
    * The expression does not match an empty sequence.
    */
-  static constexpr match_flag_type match_not_null    = 1 << _S_not_null;
+  constexpr match_flag_type match_not_null    = 1 << _S_not_null;
    
   /**
    * The expression only matches a sub-sequence that begins at first .
    */
-  static constexpr match_flag_type match_continuous  = 1 << _S_continuous;
+  constexpr match_flag_type match_continuous  = 1 << _S_continuous;
    
   /**
    * --first is a valid iterator position.  When this flag is set then the
    * flags match_not_bol and match_not_bow are ignored by the regular
    * expression algorithms 28.11 and iterators 28.12.
    */
-  static constexpr match_flag_type match_prev_avail  = 1 << _S_prev_avail;
+  constexpr match_flag_type match_prev_avail  = 1 << _S_prev_avail;
 
   /**
    * When a regular expression match is to be replaced by a new string, the
@@ -270,7 +277,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *         undefined, use the empty string instead. If
    *         nn > match_results::size(), the result is implementation-defined.
    */
-  static constexpr match_flag_type format_default    = 0;
+  constexpr match_flag_type format_default    = 0;
 
   /**
    * When a regular expression match is to be replaced by a new string, the
@@ -278,24 +285,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    * in IEEE Std 1003.1- 2001 [IEEE, Information Technology -- Portable
    * Operating System Interface (POSIX), IEEE Standard 1003.1-2001].
    */
-  static constexpr match_flag_type format_sed        = 1 << _S_sed;
+  constexpr match_flag_type format_sed        = 1 << _S_sed;
 
   /**
    * During a search and replace operation, sections of the character
    * container sequence being searched that do not match the regular
    * expression shall not be copied to the output string.
    */
-  static constexpr match_flag_type format_no_copy    = 1 << _S_no_copy;
+  constexpr match_flag_type format_no_copy    = 1 << _S_no_copy;
 
   /**
    * When specified during a search and replace operation, only the first
    * occurrence of the regular expression shall be replaced.
    */
-  static constexpr match_flag_type format_first_only = 1 << _S_first_only;
+  constexpr match_flag_type format_first_only = 1 << _S_first_only;
 
   //@}
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace regex_constants
-} // namespace
+
+/* @} */ // group regex
+} // namespace std
 
diff --git a/libstdc++-v3/include/bits/regex_cursor.h b/libstdc++-v3/include/bits/regex_cursor.h
index 9feac1d..281f3c1 100644
--- a/libstdc++-v3/include/bits/regex_cursor.h
+++ b/libstdc++-v3/include/bits/regex_cursor.h
@@ -1,6 +1,6 @@
 // class template regex -*- C++ -*-
 
-// Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+// Copyright (C) 2010, 2011, 2012 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
@@ -30,11 +30,17 @@
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
-namespace __regex
+namespace __detail
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
-  // ABC for pattern matching
+  /**
+   *  @defgroup regex-detail Base and Implementation Classes
+   *  @ingroup regex
+   *  @{
+   */
+
+  /// ABC for pattern matching
   struct _PatternCursor
   {
     virtual ~_PatternCursor() { };
@@ -42,7 +48,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     virtual bool _M_at_end() const = 0;
   };
 
-  // Provides a cursor into the specific target string.
+  /// Provides a cursor into the specific target string.
   template<typename _FwdIterT>
     class _SpecializedCursor
     : public _PatternCursor
@@ -88,6 +94,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     __cursor(const _FwdIterT& __b, const _FwdIterT __e)
     { return _SpecializedCursor<_FwdIterT>(__b, __e); }
 
+ //@} regex-detail
 _GLIBCXX_END_NAMESPACE_VERSION
-} // namespace __regex
+} // namespace __detail
 } // namespace
diff --git a/libstdc++-v3/include/bits/regex_error.h b/libstdc++-v3/include/bits/regex_error.h
index 567c08e..eec6212 100644
--- a/libstdc++-v3/include/bits/regex_error.h
+++ b/libstdc++-v3/include/bits/regex_error.h
@@ -1,6 +1,6 @@
 // class template regex -*- C++ -*-
 
-// Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+// Copyright (C) 2010, 2011, 2012 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
@@ -32,6 +32,11 @@
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
+/**
+ * @addtogroup regex
+ * @{
+ */
+
 namespace regex_constants
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -60,60 +65,60 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     };
 
   /** The expression contained an invalid collating element name. */
-  static constexpr error_type error_collate(_S_error_collate);
+  constexpr error_type error_collate(_S_error_collate);
 
   /** The expression contained an invalid character class name. */
-  static constexpr error_type error_ctype(_S_error_ctype);
+  constexpr error_type error_ctype(_S_error_ctype);
 
   /**
    * The expression contained an invalid escaped character, or a trailing
    * escape.
    */
-  static constexpr error_type error_escape(_S_error_escape);
+  constexpr error_type error_escape(_S_error_escape);
 
   /** The expression contained an invalid back reference. */
-  static constexpr error_type error_backref(_S_error_backref);
+  constexpr error_type error_backref(_S_error_backref);
 
   /** The expression contained mismatched [ and ]. */
-  static constexpr error_type error_brack(_S_error_brack);
+  constexpr error_type error_brack(_S_error_brack);
 
   /** The expression contained mismatched ( and ). */
-  static constexpr error_type error_paren(_S_error_paren);
+  constexpr error_type error_paren(_S_error_paren);
 
   /** The expression contained mismatched { and } */
-  static constexpr error_type error_brace(_S_error_brace);
+  constexpr error_type error_brace(_S_error_brace);
 
   /** The expression contained an invalid range in a {} expression. */
-  static constexpr error_type error_badbrace(_S_error_badbrace);
+  constexpr error_type error_badbrace(_S_error_badbrace);
 
   /**
    * The expression contained an invalid character range,
    * such as [b-a] in most encodings.
    */
-  static constexpr error_type error_range(_S_error_range);
+  constexpr error_type error_range(_S_error_range);
 
   /**
    * There was insufficient memory to convert the expression into a
    * finite state machine.
    */
-  static constexpr error_type error_space(_S_error_space);
+  constexpr error_type error_space(_S_error_space);
 
   /**
    * One of <em>*?+{</em> was not preceded by a valid regular expression.
    */
-  static constexpr error_type error_badrepeat(_S_error_badrepeat);
+  constexpr error_type error_badrepeat(_S_error_badrepeat);
 
   /**
    * The complexity of an attempted match against a regular expression
    * exceeded a pre-set level.
    */
-  static constexpr error_type error_complexity(_S_error_complexity);
+  constexpr error_type error_complexity(_S_error_complexity);
 
   /**
    * There was insufficient memory to determine whether the
    * regular expression could match the specified character sequence.
    */
-  static constexpr error_type error_stack(_S_error_stack);
+  constexpr error_type error_stack(_S_error_stack);
 
   //@}
 _GLIBCXX_END_NAMESPACE_VERSION
@@ -153,6 +158,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return _M_code; }
   };
 
+  //@} // group regex
 
   void
   __throw_regex_error(regex_constants::error_type __ecode);
diff --git a/libstdc++-v3/include/bits/regex_grep_matcher.h b/libstdc++-v3/include/bits/regex_grep_matcher.h
index 9312bb3..9cade17 100644
--- a/libstdc++-v3/include/bits/regex_grep_matcher.h
+++ b/libstdc++-v3/include/bits/regex_grep_matcher.h
@@ -1,6 +1,6 @@
 // class template regex -*- C++ -*-
 
-// Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+// Copyright (C) 2010, 2011, 2012 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
@@ -40,11 +40,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 _GLIBCXX_END_NAMESPACE_VERSION
   
-namespace __regex
+namespace __detail
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
-  // A _Results facade specialized for wrapping a templated match_results.
+  /**
+   *  @defgroup regex-detail Base and Implementation Classes
+   *  @ingroup regex
+   *  @{
+   */
+
+  /// A _Results facade specialized for wrapping a templated match_results.
   template<typename _FwdIterT, typename _Alloc>
     class _SpecializedResults
     : public _Results
@@ -95,12 +101,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	_M_results.at(__i).second = __c._M_pos()+1;
     }
 
-  // A stack of states used in evaluating the NFA.
+  /// A stack of states used in evaluating the NFA.
   typedef std::stack<_StateIdT, std::vector<_StateIdT> > _StateStack;
 
-  // Executes a regular expression NFA/DFA over a range using a variant of
-  // the parallel execution algorithm featured in the grep utility, modified
-  // to use Laurikari tags.
+  /// Executes a regular expression NFA/DFA over a range using a
+  /// variant of the parallel execution algorithm featured in the grep
+  /// utility, modified to use Laurikari tags.
   class _Grep_matcher
   {
   public:
@@ -119,14 +125,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     _StateSet
     _M_e_closure(_StateStack& __stack, const _StateSet& __s);
 
-  private:
     const std::shared_ptr<_Nfa>        _M_nfa;
     _PatternCursor&                    _M_pattern;
     _Results&                          _M_results;
   };
 
+ //@} regex-detail
 _GLIBCXX_END_NAMESPACE_VERSION
-} // namespace __regex
-} // namespace
+} // namespace __detail
+} // namespace std
 
 #include <bits/regex_grep_matcher.tcc>
diff --git a/libstdc++-v3/include/bits/regex_grep_matcher.tcc b/libstdc++-v3/include/bits/regex_grep_matcher.tcc
index ae28f6f..5323046 100644
--- a/libstdc++-v3/include/bits/regex_grep_matcher.tcc
+++ b/libstdc++-v3/include/bits/regex_grep_matcher.tcc
@@ -1,6 +1,6 @@
 // class template regex -*- C++ -*-
 
-// Copyright (C) 2010 Free Software Foundation, Inc.
+// Copyright (C) 2010, 2012 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
@@ -35,26 +35,26 @@ namespace std _GLIBCXX_VISIBILITY(default)
 namespace
 {
   // A stack of states used in evaluating the NFA.
-  typedef std::stack<std::__regex::_StateIdT,
-                     std::vector<std::__regex::_StateIdT>
+  typedef std::stack<std::__detail::_StateIdT,
+                     std::vector<std::__detail::_StateIdT>
 		     > _StateStack;
 
   // Obtains the next state set given the current state set __s and the current
   // input character.
-  inline std::__regex::_StateSet
-  __move(const std::__regex::_PatternCursor& __p,
-         const std::__regex::_Nfa& __nfa,
-         const std::__regex::_StateSet& __s)
+  inline std::__detail::_StateSet
+  __move(const std::__detail::_PatternCursor& __p,
+         const std::__detail::_Nfa& __nfa,
+         const std::__detail::_StateSet& __s)
   {
-    std::__regex::_StateSet __m;
-    for (std::__regex::_StateSet::const_iterator __i = __s.begin();
+    std::__detail::_StateSet __m;
+    for (std::__detail::_StateSet::const_iterator __i = __s.begin();
 	 __i != __s.end(); ++__i)
       {
-	if (*__i == std::__regex::_S_invalid_state_id)
+	if (*__i == std::__detail::_S_invalid_state_id)
 	  continue;
 
-	const std::__regex::_State& __state = __nfa[*__i];
-	if (__state._M_opcode == std::__regex::_S_opcode_match
+	const std::__detail::_State& __state = __nfa[*__i];
+	if (__state._M_opcode == std::__detail::_S_opcode_match
 	    && __state._M_matches(__p))
 	  __m.insert(__state._M_next);
       }
@@ -63,13 +63,13 @@ namespace
 
   // returns true if (__s intersect __t) is not empty
   inline bool
-  __includes_some(const std::__regex::_StateSet& __s,
-                  const std::__regex::_StateSet& __t)
+  __includes_some(const std::__detail::_StateSet& __s,
+                  const std::__detail::_StateSet& __t)
   {
     if (__s.size() > 0 && __t.size() > 0)
       {
-	std::__regex::_StateSet::const_iterator __first = __s.begin();
-	std::__regex::_StateSet::const_iterator __second = __t.begin();
+	std::__detail::_StateSet::const_iterator __first = __s.begin();
+	std::__detail::_StateSet::const_iterator __second = __t.begin();
 	while (__first != __s.end() && __second != __t.end())
 	  {
 	    if (*__first < *__second)
@@ -86,9 +86,9 @@ namespace
   // If an identified state __u is not already in the current state set __e,
   // insert it and push it on the current state stack __s.
   inline void
-  __add_visited_state(const std::__regex::_StateIdT __u,
+  __add_visited_state(const std::__detail::_StateIdT __u,
                       _StateStack&                  __s,
-                      std::__regex::_StateSet&      __e)
+                      std::__detail::_StateSet&      __e)
   {
     if (__e.count(__u) == 0)
       {
@@ -99,7 +99,7 @@ namespace
 
 } // anonymous namespace
 
-namespace __regex
+namespace __detail
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
@@ -109,7 +109,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 		regex_constants::match_flag_type __flags)
   : _M_nfa(static_pointer_cast<_Nfa>(__nfa)), _M_pattern(__p), _M_results(__r)
   {
-    __regex::_StateSet __t = this->_M_e_closure(_M_nfa->_M_start());
+    __detail::_StateSet __t = this->_M_e_closure(_M_nfa->_M_start());
     for (; !_M_pattern._M_at_end(); _M_pattern._M_next())
       __t = this->_M_e_closure(__move(_M_pattern, *_M_nfa, __t));
 
@@ -175,5 +175,5 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   }
 
 _GLIBCXX_END_NAMESPACE_VERSION
-} // namespace __regex
+} // namespace __detail
 } // namespace
diff --git a/libstdc++-v3/include/bits/regex_nfa.h b/libstdc++-v3/include/bits/regex_nfa.h
index c4a65e6..234fa20 100644
--- a/libstdc++-v3/include/bits/regex_nfa.h
+++ b/libstdc++-v3/include/bits/regex_nfa.h
@@ -1,6 +1,6 @@
 // class template regex -*- C++ -*-
 
-// Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+// Copyright (C) 2010, 2011, 2012 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
@@ -30,11 +30,16 @@
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
-namespace __regex
+namespace __detail
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
-  // Base class for, um, automata.  Could be an NFA or a DFA.  Your choice.
+  /**
+   * @addtogroup regex-detail
+   * @{
+   */
+
+  /// Base class for, um, automata.  Could be an NFA or a DFA.  Your choice.
   class _Automaton
   {
   public:
@@ -53,11 +58,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
   };
 
-  // Generic shared pointer to an automaton.  
+  /// Generic shared pointer to an automaton.  
   typedef std::shared_ptr<_Automaton> _AutomatonPtr;
 
-  // Operation codes that define the type of transitions within the base NFA
-  // that represents the regular expression.
+  /// Operation codes that define the type of transitions within the base NFA
+  /// that represents the regular expression.
   enum _Opcode
   {
       _S_opcode_unknown       =   0,
@@ -68,16 +73,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       _S_opcode_accept        = 255
   };
 
-  // Provides a generic facade for a templated match_results.
+  /// Provides a generic facade for a templated match_results.
   struct _Results
   {
     virtual void _M_set_pos(int __i, int __j, const _PatternCursor& __p) = 0;
     virtual void _M_set_matched(int __i, bool __is_matched) = 0;
   };
 
-  // Tags current state (for subexpr begin/end).
+  /// Tags current state (for subexpr begin/end).
   typedef std::function<void (const _PatternCursor&, _Results&)> _Tagger;
 
+  /// Start state tag.
   template<typename _FwdIterT, typename _TraitsT>
     struct _StartTagger
     {
@@ -93,6 +99,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       int       _M_index;
     };
 
+  /// End state tag.
   template<typename _FwdIterT, typename _TraitsT>
     struct _EndTagger
     {
@@ -108,15 +115,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       int       _M_index;
       _FwdIterT _M_pos;
     };
-  // Indicates if current state matches cursor current.
+
+  /// Indicates if current state matches cursor current.
   typedef std::function<bool (const _PatternCursor&)> _Matcher;
 
-  // Matches any character
+  /// Matches any character
   inline bool
   _AnyMatcher(const _PatternCursor&)
   { return true; }
 
-  // Matches a single character
+  /// Matches a single character
   template<typename _InIterT, typename _TraitsT>
     struct _CharMatcher
     {
@@ -139,7 +147,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       char_type       _M_c;
     };
 
-  // Matches a character range (bracket expression)
+  /// Matches a character range (bracket expression)
   template<typename _InIterT, typename _TraitsT>
     struct _RangeMatcher
     {
@@ -183,20 +191,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       bool            _M_is_non_matching;
     };
 
-  // Identifies a state in the NFA.
+  /// Identifies a state in the NFA.
   typedef int _StateIdT;
 
-  // The special case in which a state identifier is not an index.
+  /// The special case in which a state identifier is not an index.
   static const _StateIdT _S_invalid_state_id  = -1;
 
 
-  // An individual state in an NFA
-  //
-  // In this case a "state" is an entry in the NFA definition coupled with its
-  // outgoing transition(s).  All states have a single outgoing transition,
-  // except for accepting states (which have no outgoing transitions) and alt
-  // states, which have two outgoing transitions.
-  //
+  /**
+   * @brief struct _State
+   *
+   * An individual state in an NFA
+   *
+   * In this case a "state" is an entry in the NFA definition coupled
+   * with its outgoing transition(s).  All states have a single outgoing
+   * transition, except for accepting states (which have no outgoing
+   * transitions) and alt states, which have two outgoing transitions.
+   */
   struct _State
   {
     typedef int  _OpcodeT;
@@ -236,22 +247,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   };
 
   
-  // The Grep Matcher works on sets of states.  Here are sets of states.
+  /// The Grep Matcher works on sets of states.  Here are sets of states.
   typedef std::set<_StateIdT> _StateSet;
 
- // A collection of all states making up an NFA
-  //
-  // An NFA is a 4-tuple M = (K, S, s, F), where
-  //    K is a finite set of states,
-  //    S is the alphabet of the NFA,
-  //    s is the initial state,
-  //    F is a set of final (accepting) states.
-  //
-  // This NFA class is templated on S, a type that will hold values of the
-  // underlying alphabet (without regard to semantics of that alphabet).  The
-  // other elements of the tuple are generated during construction of the NFA
-  // and are available through accessor member functions.
-  //
+  /**
+   * @brief struct _Nfa
+   *
+   * A collection of all states making up an NFA.
+   *
+   * An NFA is a 4-tuple M = (K, S, s, F), where
+   *    K is a finite set of states,
+   *    S is the alphabet of the NFA,
+   *    s is the initial state,
+   *    F is a set of final (accepting) states.
+   *
+   * This NFA class is templated on S, a type that will hold values of the
+   * underlying alphabet (without regard to semantics of that alphabet).  The
+   * other elements of the tuple are generated during construction of the NFA
+   * and are available through accessor member functions.
+   */
   class _Nfa
   : public _Automaton, public std::vector<_State>
   {
@@ -260,7 +274,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     typedef unsigned int                        _SizeT;
     typedef regex_constants::syntax_option_type _FlagT;
 
-  public:
     _Nfa(_FlagT __f)
     : _M_flags(__f), _M_start_state(0), _M_subexpr_count(0)
     { }
@@ -309,7 +322,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     _StateIdT
     _M_insert_subexpr_begin(const _Tagger& __t)
     {
-      this->push_back(_StateT(_S_opcode_subexpr_begin, _M_subexpr_count++, __t));
+      this->push_back(_StateT(_S_opcode_subexpr_begin, _M_subexpr_count++,
+			      __t));
       return this->size()-1;
     }
 
@@ -332,9 +346,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     _SizeT     _M_subexpr_count;
   };
 
-  // Describes a sequence of one or more %_State, its current start and end(s).
-  //
-  // This structure contains fragments of an NFA during construction.
+  /// Describes a sequence of one or more %_State, its current start
+  /// and end(s).  This structure contains fragments of an NFA during
+  /// construction.
   class _StateSeq
   {
   public:
@@ -392,8 +406,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   };
 
+ //@} regex-detail
 _GLIBCXX_END_NAMESPACE_VERSION
-} // namespace __regex
+} // namespace __detail
 } // namespace std
 
 #include <bits/regex_nfa.tcc>
diff --git a/libstdc++-v3/include/bits/regex_nfa.tcc b/libstdc++-v3/include/bits/regex_nfa.tcc
index 9e4a6ce..c48ebe3 100644
--- a/libstdc++-v3/include/bits/regex_nfa.tcc
+++ b/libstdc++-v3/include/bits/regex_nfa.tcc
@@ -1,6 +1,6 @@
 // class template regex -*- C++ -*-
 
-// Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+// Copyright (C) 2010, 2011, 2012 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
@@ -31,7 +31,7 @@
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
-namespace __regex
+namespace __detail
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
@@ -170,5 +170,5 @@ _M_clone()
 { return 0; }
 
 _GLIBCXX_END_NAMESPACE_VERSION
-} // namespace __regex
+} // namespace __detail
 } // namespace
diff --git a/libstdc++-v3/testsuite/ext/profile/mutex_extensions_neg.cc b/libstdc++-v3/testsuite/ext/profile/mutex_extensions_neg.cc
index c6e6fea..104fc4b 100644
--- a/libstdc++-v3/testsuite/ext/profile/mutex_extensions_neg.cc
+++ b/libstdc++-v3/testsuite/ext/profile/mutex_extensions_neg.cc
@@ -25,4 +25,4 @@
 
 #include <vector>
 
-// { dg-error "multiple inlined namespaces" "" { target *-*-* } 263 }
+// { dg-error "multiple inlined namespaces" "" { target *-*-* } 262 }
