]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libstdc++-v3/include/bits/regex_compiler.tcc
Update copyright years in libstdc++-v3/
[thirdparty/gcc.git] / libstdc++-v3 / include / bits / regex_compiler.tcc
index 94f3d5ea86cb44eea7d522d53afb595c62bffff2..0d90681bde7862bc14e9598425de6fcdc6ec6a95 100644 (file)
@@ -1,6 +1,6 @@
 // class template regex -*- C++ -*-
 
-// Copyright (C) 2013 Free Software Foundation, Inc.
+// Copyright (C) 2013-2014 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
@@ -59,8 +59,8 @@ namespace __detail
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
-  template<typename _FwdIter, typename _CharT, typename _TraitsT>
-    _Compiler<_FwdIter, _CharT, _TraitsT>::
+  template<typename _FwdIter, typename _TraitsT>
+    _Compiler<_FwdIter, _TraitsT>::
     _Compiler(_FwdIter __b, _FwdIter __e,
              const _TraitsT& __traits, _FlagT __flags)
     : _M_flags((__flags
@@ -73,8 +73,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
               ? __flags
               : __flags | regex_constants::ECMAScript),
     _M_traits(__traits),
+    _M_ctype(std::use_facet<_CtypeT>(_M_traits.getloc())),
     _M_scanner(__b, __e, _M_flags, _M_traits.getloc()),
-    _M_ctype(std::use_facet<std::ctype<_CharT>>(_M_traits.getloc())),
     _M_nfa(_M_flags)
     {
       _StateSeqT __r(_M_nfa, _M_nfa._M_start());
@@ -89,9 +89,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       _M_nfa._M_eliminate_dummy();
     }
 
-  template<typename _FwdIter, typename _CharT, typename _TraitsT>
+  template<typename _FwdIter, typename _TraitsT>
     void
-    _Compiler<_FwdIter, _CharT, _TraitsT>::
+    _Compiler<_FwdIter, _TraitsT>::
     _M_disjunction()
     {
       this->_M_alternative();
@@ -110,9 +110,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        }
     }
 
-  template<typename _FwdIter, typename _CharT, typename _TraitsT>
+  template<typename _FwdIter, typename _TraitsT>
     void
-    _Compiler<_FwdIter, _CharT, _TraitsT>::
+    _Compiler<_FwdIter, _TraitsT>::
     _M_alternative()
     {
       if (this->_M_term())
@@ -126,9 +126,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        _M_stack.push(_StateSeqT(_M_nfa, _M_nfa._M_insert_dummy()));
     }
 
-  template<typename _FwdIter, typename _CharT, typename _TraitsT>
+  template<typename _FwdIter, typename _TraitsT>
     bool
-    _Compiler<_FwdIter, _CharT, _TraitsT>::
+    _Compiler<_FwdIter, _TraitsT>::
     _M_term()
     {
       if (this->_M_assertion())
@@ -141,17 +141,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return false;
     }
 
-  template<typename _FwdIter, typename _CharT, typename _TraitsT>
+  template<typename _FwdIter, typename _TraitsT>
     bool
-    _Compiler<_FwdIter, _CharT, _TraitsT>::
+    _Compiler<_FwdIter, _TraitsT>::
     _M_assertion()
     {
       if (_M_match_token(_ScannerT::_S_token_line_begin))
-       _M_stack.push(_StateSeqT(_M_nfa, _M_nfa.
-             _M_insert_line_begin()));
+       _M_stack.push(_StateSeqT(_M_nfa, _M_nfa._M_insert_line_begin()));
       else if (_M_match_token(_ScannerT::_S_token_line_end))
-       _M_stack.push(_StateSeqT(_M_nfa, _M_nfa.
-             _M_insert_line_end()));
+       _M_stack.push(_StateSeqT(_M_nfa, _M_nfa._M_insert_line_end()));
       else if (_M_match_token(_ScannerT::_S_token_word_bound))
        // _M_value[0] == 'n' means it's negtive, say "not word boundary".
        _M_stack.push(_StateSeqT(_M_nfa, _M_nfa.
@@ -174,9 +172,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return true;
     }
 
-  template<typename _FwdIter, typename _CharT, typename _TraitsT>
+  template<typename _FwdIter, typename _TraitsT>
     void
-    _Compiler<_FwdIter, _CharT, _TraitsT>::
+    _Compiler<_FwdIter, _TraitsT>::
     _M_quantifier()
     {
       bool __neg = (_M_flags & regex_constants::ECMAScript);
@@ -222,9 +220,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
            __throw_regex_error(regex_constants::error_badbrace);
          _StateSeqT __r(_M_pop());
          _StateSeqT __e(_M_nfa, _M_nfa._M_insert_dummy());
-         int __min_rep = _M_cur_int_value(10);
+         long __min_rep = _M_cur_int_value(10);
          bool __infi = false;
-         int __n;
+         long __n;
 
          // {3
          if (_M_match_token(_ScannerT::_S_token_comma))
@@ -239,7 +237,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
          __neg = __neg && _M_match_token(_ScannerT::_S_token_opt);
 
-         for (int __i = 0; __i < __min_rep; ++__i)
+         for (long __i = 0; __i < __min_rep; ++__i)
            __e._M_append(__r._M_clone());
 
          if (__infi)
@@ -260,7 +258,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
              // "match less" one. Switch _M_alt and _M_next of all created
              // nodes. This is a hacking but IMO works well.
              std::stack<_StateIdT> __stack;
-             for (int __i = 0; __i < __n; ++__i)
+             for (long __i = 0; __i < __n; ++__i)
                {
                  auto __tmp = __r._M_clone();
                  auto __alt = _M_nfa._M_insert_alt(__tmp._M_start,
@@ -280,19 +278,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        }
     }
 
-  template<typename _FwdIter, typename _CharT, typename _TraitsT>
+  template<typename _FwdIter, typename _TraitsT>
     bool
-    _Compiler<_FwdIter, _CharT, _TraitsT>::
+    _Compiler<_FwdIter, _TraitsT>::
     _M_atom()
     {
       if (_M_match_token(_ScannerT::_S_token_anychar))
        _M_stack.push(_StateSeqT(_M_nfa,
                                _M_nfa._M_insert_matcher
-                               (_AnyMatcher<_CharT, _TraitsT>(_M_traits))));
+                               (_AnyMatcher<_TraitsT>(_M_traits))));
       else if (_M_try_char())
        _M_stack.push(_StateSeqT(_M_nfa,
                                 _M_nfa._M_insert_matcher
-                                (_CharMatcher<_CharT, _TraitsT>(_M_value[0],
+                                (_CharMatcher<_TraitsT>(_M_value[0],
                                                                 _M_traits,
                                                                 _M_flags))));
       else if (_M_match_token(_ScannerT::_S_token_backref))
@@ -305,7 +303,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                               _M_traits, _M_flags);
          __matcher._M_add_character_class(_M_value);
          _M_stack.push(_StateSeqT(_M_nfa,
-               _M_nfa._M_insert_matcher(__matcher)));
+               _M_nfa._M_insert_matcher(std::move(__matcher))));
        }
       else if (_M_match_token(_ScannerT::_S_token_subexpr_no_group_begin))
        {
@@ -318,7 +316,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        }
       else if (_M_match_token(_ScannerT::_S_token_subexpr_begin))
        {
-         int __mark = _M_nfa._M_sub_count();
          _StateSeqT __r(_M_nfa, _M_nfa._M_insert_subexpr_begin());
          this->_M_disjunction();
          if (!_M_match_token(_ScannerT::_S_token_subexpr_end))
@@ -332,9 +329,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return true;
     }
 
-  template<typename _FwdIter, typename _CharT, typename _TraitsT>
+  template<typename _FwdIter, typename _TraitsT>
     bool
-    _Compiler<_FwdIter, _CharT, _TraitsT>::
+    _Compiler<_FwdIter, _TraitsT>::
     _M_bracket_expression()
     {
       bool __neg =
@@ -344,13 +341,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       _BMatcherT __matcher(__neg, _M_traits, _M_flags);
       while (!_M_match_token(_ScannerT::_S_token_bracket_end))
        _M_expression_term(__matcher);
-      _M_stack.push(_StateSeqT(_M_nfa, _M_nfa._M_insert_matcher(__matcher)));
+      _M_stack.push(_StateSeqT(_M_nfa,
+                              _M_nfa._M_insert_matcher(std::move(__matcher))));
       return true;
     }
 
-  template<typename _FwdIter, typename _CharT, typename _TraitsT>
+  template<typename _FwdIter, typename _TraitsT>
     void
-    _Compiler<_FwdIter, _CharT, _TraitsT>::
+    _Compiler<_FwdIter, _TraitsT>::
     _M_expression_term(_BMatcherT& __matcher)
     {
       if (_M_match_token(_ScannerT::_S_token_collsymbol))
@@ -385,9 +383,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        __throw_regex_error(regex_constants::error_brack);
     }
 
-  template<typename _FwdIter, typename _CharT, typename _TraitsT>
+  template<typename _FwdIter, typename _TraitsT>
     bool
-    _Compiler<_FwdIter, _CharT, _TraitsT>::
+    _Compiler<_FwdIter, _TraitsT>::
     _M_try_char()
     {
       bool __is_char = false;
@@ -406,9 +404,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return __is_char;
     }
 
-  template<typename _FwdIter, typename _CharT, typename _TraitsT>
+  template<typename _FwdIter, typename _TraitsT>
     bool
-    _Compiler<_FwdIter, _CharT, _TraitsT>::
+    _Compiler<_FwdIter, _TraitsT>::
     _M_match_token(_TokenT token)
     {
       if (token == _M_scanner._M_get_token())
@@ -420,26 +418,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return false;
     }
 
-  template<typename _FwdIter, typename _CharT, typename _TraitsT>
+  template<typename _FwdIter, typename _TraitsT>
     int
-    _Compiler<_FwdIter, _CharT, _TraitsT>::
+    _Compiler<_FwdIter, _TraitsT>::
     _M_cur_int_value(int __radix)
     {
-      int __v = 0;
+      long __v = 0;
       for (typename _StringT::size_type __i = 0;
           __i < _M_value.length(); ++__i)
        __v =__v * __radix + _M_traits.value(_M_value[__i], __radix);
       return __v;
     }
 
-  template<typename _CharT, typename _TraitsT>
-    bool _BracketMatcher<_CharT, _TraitsT>::
-    operator()(_CharT __ch) const
+  template<typename _TraitsT>
+    bool
+    _BracketMatcher<_TraitsT>::operator()(_CharT __ch) const
     {
       bool __ret = false;
-      if (_M_traits.isctype(__ch, _M_class_set))
-       __ret = true;
-      else if (_M_char_set.count(_M_translate(__ch)))
+      if (_M_traits.isctype(__ch, _M_class_set)
+         || _M_char_set.count(_M_translate(__ch))
+         || _M_equiv_set.count(_M_traits.transform_primary(&__ch, &__ch+1)))
        __ret = true;
       else
        {