]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
regex.h: (regex_token_iterator<>::regex_token_iterator): Fix compile error.
authorTim Shen <timshen91@gmail.com>
Sun, 6 Oct 2013 17:53:14 +0000 (17:53 +0000)
committerTim Shen <timshen@gcc.gnu.org>
Sun, 6 Oct 2013 17:53:14 +0000 (17:53 +0000)
2013-10-06  Tim Shen  <timshen91@gmail.com>

* include/bits/regex.h: (regex_token_iterator<>::regex_token_iterator):
Fix compile error.
* include/bits/regex.tcc: (regex_replace<>): Remove default parameter.

2013-10-06  Tim Shen  <timshen91@gmail.com>

* include/bits/regex.h (__regex_algo_impl<>, regex_match<>,
regex_search<>): New abstract function for regex_match and regex_search.
* include/bits/regex.tcc (__regex_algo_impl<>): Implement.
* include/bits/regex_executor.h
(_Executor<>::_M_lookahead,
 _DFSExecutor<>::_M_clone,
 _BFSExecutor<>::_M_clone): Let _M_clone to choose which executor to
use.
* include/bits/regex_executor.tcc (__get_executor<>): Update the
definition to support __policy.
* testsuite/28_regex/algorithms/regex_match/awk/cstring_01.cc: Use
*_debug.
* testsuite/28_regex/algorithms/regex_match/basic/empty_range.cc: Same.
* testsuite/28_regex/algorithms/regex_match/basic/string_01.cc: Same.
* testsuite/28_regex/algorithms/regex_match/basic/string_range_00_03.cc:
Same.
* testsuite/28_regex/algorithms/regex_match/basic/string_range_01_03.cc:
Same.
* testsuite/28_regex/algorithms/regex_match/basic/string_range_02_03.cc:
Same.
* testsuite/28_regex/algorithms/regex_match/ecma/char/53622.cc: Same.
* testsuite/28_regex/algorithms/regex_match/ecma/char/57173.cc: Same.
* testsuite/28_regex/algorithms/regex_match/ecma/char/58576.cc: Same.
* testsuite/28_regex/algorithms/regex_match/ecma/char/anymatcher.cc:
Same.
* testsuite/28_regex/algorithms/regex_match/ecma/char/backref.cc: Same.
* testsuite/28_regex/algorithms/regex_match/ecma/char/empty_range.cc:
Same.
* testsuite/28_regex/algorithms/regex_match/ecma/char/emptygroup.cc:
Same.
* testsuite/28_regex/algorithms/regex_match/ecma/char/hex.cc: Same.
* testsuite/28_regex/algorithms/regex_match/ecma/char/quoted_char.cc:
Same.
* testsuite/28_regex/algorithms/regex_match/ecma/wchar_t/anymatcher.cc:
Same.
* testsuite/28_regex/algorithms/regex_match/ecma/wchar_t/hex.cc: Same.
* testsuite/28_regex/algorithms/regex_match/extended/
string_bracket_01.cc: Same.
* testsuite/28_regex/algorithms/regex_match/extended/cstring_plus.cc:
Same.
* testsuite/28_regex/algorithms/regex_match/extended/
string_questionmark.cc: Same.
* testsuite/28_regex/algorithms/regex_match/extended/cstring_range.cc:
Same.
* testsuite/28_regex/algorithms/regex_match/extended/string_any.cc:
Same.
* testsuite/28_regex/algorithms/regex_match/extended/
string_dispatch_01.cc: Same.
* testsuite/28_regex/algorithms/regex_match/extended/
string_range_00_03.cc: Same.
* testsuite/28_regex/algorithms/regex_match/extended/
string_range_01_03.cc: Same.
* testsuite/28_regex/algorithms/regex_match/extended/
string_range_02_03.cc: Same.
* testsuite/28_regex/algorithms/regex_match/extended/wstring_locale.cc:
Same.
* testsuite/28_regex/algorithms/regex_search/basic/string_01.cc: Same.
* testsuite/28_regex/algorithms/regex_search/ecma/assertion.cc: Same.
* testsuite/28_regex/algorithms/regex_search/ecma/flags.cc: Same.
* testsuite/28_regex/algorithms/regex_search/ecma/greedy.cc: Same.
* testsuite/28_regex/algorithms/regex_search/ecma/string_01.cc: Same.
* testsuite/28_regex/match_results/format.cc: Same.
* testsuite/util/testsuite_regex.h
(regex_match_debug<>, regex_search_debug<>): Implement.

From-SVN: r203231

42 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/regex.h
libstdc++-v3/include/bits/regex.tcc
libstdc++-v3/include/bits/regex_automaton.h
libstdc++-v3/include/bits/regex_automaton.tcc
libstdc++-v3/include/bits/regex_compiler.tcc
libstdc++-v3/include/bits/regex_executor.h
libstdc++-v3/include/bits/regex_executor.tcc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/awk/cstring_01.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/basic/empty_range.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/basic/string_01.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/basic/string_range_00_03.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/basic/string_range_01_03.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/basic/string_range_02_03.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/char/53622.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/char/57173.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/char/58576.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/char/anymatcher.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/char/backref.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/char/empty_range.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/char/emptygroup.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/char/hex.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/char/quoted_char.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/wchar_t/anymatcher.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/wchar_t/hex.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/cstring_bracket_01.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/cstring_plus.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/cstring_questionmark.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/cstring_range.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/string_any.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/string_dispatch_01.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/string_range_00_03.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/string_range_01_03.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/string_range_02_03.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/wstring_locale.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_search/basic/string_01.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_search/ecma/assertion.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_search/ecma/flags.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_search/ecma/greedy.cc
libstdc++-v3/testsuite/28_regex/algorithms/regex_search/ecma/string_01.cc
libstdc++-v3/testsuite/28_regex/match_results/format.cc
libstdc++-v3/testsuite/util/testsuite_regex.h

index 4a00019bae08e12870a223b6c0e33159b05832b3..377ac0e7e9fd634df9d32993fa4f817d1d799fe4 100644 (file)
@@ -1,3 +1,76 @@
+2013-10-06  Tim Shen  <timshen91@gmail.com>
+
+       * include/bits/regex.h: (regex_token_iterator<>::regex_token_iterator):
+       Fix compile error.
+       * include/bits/regex.tcc: (regex_replace<>): Remove default parameter.
+
+2013-10-06  Tim Shen  <timshen91@gmail.com>
+
+       * include/bits/regex.h (__regex_algo_impl<>, regex_match<>,
+       regex_search<>): New abstract function for regex_match and regex_search.
+       * include/bits/regex.tcc (__regex_algo_impl<>): Implement.
+       * include/bits/regex_executor.h
+       (_Executor<>::_M_lookahead,
+        _DFSExecutor<>::_M_clone,
+        _BFSExecutor<>::_M_clone): Let _M_clone to choose which executor to
+       use.
+       * include/bits/regex_executor.tcc (__get_executor<>): Update the
+       definition to support __policy.
+       * testsuite/28_regex/algorithms/regex_match/awk/cstring_01.cc: Use
+       *_debug.
+       * testsuite/28_regex/algorithms/regex_match/basic/empty_range.cc: Same.
+       * testsuite/28_regex/algorithms/regex_match/basic/string_01.cc: Same.
+       * testsuite/28_regex/algorithms/regex_match/basic/string_range_00_03.cc:
+       Same.
+       * testsuite/28_regex/algorithms/regex_match/basic/string_range_01_03.cc:
+       Same.
+       * testsuite/28_regex/algorithms/regex_match/basic/string_range_02_03.cc:
+       Same.
+       * testsuite/28_regex/algorithms/regex_match/ecma/char/53622.cc: Same.
+       * testsuite/28_regex/algorithms/regex_match/ecma/char/57173.cc: Same.
+       * testsuite/28_regex/algorithms/regex_match/ecma/char/58576.cc: Same.
+       * testsuite/28_regex/algorithms/regex_match/ecma/char/anymatcher.cc:
+       Same.
+       * testsuite/28_regex/algorithms/regex_match/ecma/char/backref.cc: Same.
+       * testsuite/28_regex/algorithms/regex_match/ecma/char/empty_range.cc:
+       Same.
+       * testsuite/28_regex/algorithms/regex_match/ecma/char/emptygroup.cc:
+       Same.
+       * testsuite/28_regex/algorithms/regex_match/ecma/char/hex.cc: Same.
+       * testsuite/28_regex/algorithms/regex_match/ecma/char/quoted_char.cc:
+       Same.
+       * testsuite/28_regex/algorithms/regex_match/ecma/wchar_t/anymatcher.cc:
+       Same.
+       * testsuite/28_regex/algorithms/regex_match/ecma/wchar_t/hex.cc: Same.
+       * testsuite/28_regex/algorithms/regex_match/extended/
+       string_bracket_01.cc: Same.
+       * testsuite/28_regex/algorithms/regex_match/extended/cstring_plus.cc:
+       Same.
+       * testsuite/28_regex/algorithms/regex_match/extended/
+       string_questionmark.cc: Same.
+       * testsuite/28_regex/algorithms/regex_match/extended/cstring_range.cc:
+       Same.
+       * testsuite/28_regex/algorithms/regex_match/extended/string_any.cc:
+       Same.
+       * testsuite/28_regex/algorithms/regex_match/extended/
+       string_dispatch_01.cc: Same.
+       * testsuite/28_regex/algorithms/regex_match/extended/
+       string_range_00_03.cc: Same.
+       * testsuite/28_regex/algorithms/regex_match/extended/
+       string_range_01_03.cc: Same.
+       * testsuite/28_regex/algorithms/regex_match/extended/
+       string_range_02_03.cc: Same.
+       * testsuite/28_regex/algorithms/regex_match/extended/wstring_locale.cc:
+       Same.
+       * testsuite/28_regex/algorithms/regex_search/basic/string_01.cc: Same.
+       * testsuite/28_regex/algorithms/regex_search/ecma/assertion.cc: Same.
+       * testsuite/28_regex/algorithms/regex_search/ecma/flags.cc: Same.
+       * testsuite/28_regex/algorithms/regex_search/ecma/greedy.cc: Same.
+       * testsuite/28_regex/algorithms/regex_search/ecma/string_01.cc: Same.
+       * testsuite/28_regex/match_results/format.cc: Same.
+       * testsuite/util/testsuite_regex.h
+       (regex_match_debug<>, regex_search_debug<>): Implement.
+
 2013-10-06  Oleg Endo  <olegendo@gcc.gnu.org>
            Paolo Carlini  <paolo.carlini@oracle.com>
 
index 4d7e7d7ff3634337fa50924d9e7f4afb2fd8745e..3420f10b18b7aa43708fcac7e7be874c7bedffc7 100644 (file)
@@ -32,6 +32,24 @@ namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+namespace __detail
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+  template<typename _BiIter, typename _Alloc,
+          typename _CharT, typename _TraitsT,
+          _RegexExecutorPolicy __policy,
+          bool __match_mode>
+    bool
+    __regex_algo_impl(_BiIter                              __s,
+                     _BiIter                              __e,
+                     match_results<_BiIter, _Alloc>&      __m,
+                     const basic_regex<_CharT, _TraitsT>& __re,
+                     regex_constants::match_flag_type     __flags);
+
+_GLIBCXX_END_NAMESPACE_VERSION
+}
+
   /**
    * @addtogroup regex
    * @{
@@ -713,7 +731,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        _AutomatonPtr;
 
       template<typename _BiIter, typename _Alloc,
-       typename _CharT, typename _TraitsT>
+       typename _CharT, typename _TraitsT,
+       __detail::_RegexExecutorPolicy __policy>
        friend std::unique_ptr<
          __detail::_Executor<_BiIter, _Alloc, _CharT, _TraitsT>>
        __detail::__get_executor(_BiIter,
@@ -722,19 +741,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                                 const basic_regex<_CharT, _TraitsT>&,
                                 regex_constants::match_flag_type);
 
-      template<typename _Bp, typename _Ap, typename _Cp, typename _Rp>
-       friend bool
-       regex_match(_Bp, _Bp,
-                   match_results<_Bp, _Ap>&,
-                   const basic_regex<_Cp, _Rp>&,
-                   regex_constants::match_flag_type);
-
-      template<typename _Bp, typename _Ap, typename _Cp, typename _Rp>
+      template<typename _Bp, typename _Ap, typename _Cp, typename _Rp,
+       __detail::_RegexExecutorPolicy, bool>
        friend bool
-       regex_search(_Bp, _Bp,
-                    match_results<_Bp, _Ap>&,
-                    const basic_regex<_Cp, _Rp>&,
-                    regex_constants::match_flag_type);
+       __detail::__regex_algo_impl(_Bp, _Bp, match_results<_Bp, _Ap>&,
+                                   const basic_regex<_Cp, _Rp>&,
+                                   regex_constants::match_flag_type);
 
       template<typename, typename, typename, typename>
        friend class __detail::_Executor;
@@ -1851,21 +1863,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       template<typename, typename, typename>
        friend class regex_iterator;
 
-      template<typename _Bp, typename _Ap,
-       typename _Ch_type, typename _Rx_traits>
-       friend bool
-       regex_match(_Bp, _Bp, match_results<_Bp, _Ap>&,
-                   const basic_regex<_Ch_type,
-                   _Rx_traits>&,
-                   regex_constants::match_flag_type);
-
-      template<typename _Bp, typename _Ap,
-       typename _Ch_type, typename _Rx_traits>
+      template<typename _Bp, typename _Ap, typename _Cp, typename _Rp,
+       __detail::_RegexExecutorPolicy, bool>
        friend bool
-       regex_search(_Bp, _Bp, match_results<_Bp, _Ap>&,
-                    const basic_regex<_Ch_type,
-                    _Rx_traits>&,
-                    regex_constants::match_flag_type);
+       __detail::__regex_algo_impl(_Bp, _Bp, match_results<_Bp, _Ap>&,
+                                   const basic_regex<_Cp, _Rp>&,
+                                   regex_constants::match_flag_type);
 
       _Bi_iter _M_begin;
       bool     _M_in_iterator;
@@ -1951,13 +1954,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    */
   template<typename _Bi_iter, typename _Alloc,
           typename _Ch_type, typename _Rx_traits>
-    bool
+    inline bool
     regex_match(_Bi_iter                                 __s,
                _Bi_iter                                 __e,
                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_constants::match_default)
+    {
+      return __detail::__regex_algo_impl<_Bi_iter, _Alloc, _Ch_type, _Rx_traits,
+       __detail::_RegexExecutorPolicy::_S_auto, true>
+         (__s, __e, __m, __re, __flags);
+    }
 
   /**
    * @brief Indicates if there is a match between the regular expression @p e
@@ -2091,12 +2099,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    */
   template<typename _Bi_iter, typename _Alloc,
           typename _Ch_type, typename _Rx_traits>
-    bool
-    regex_search(_Bi_iter __first, _Bi_iter __last,
+    inline bool
+    regex_search(_Bi_iter __s, _Bi_iter __e,
                 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_constants::match_default)
+    {
+      return __detail::__regex_algo_impl<_Bi_iter, _Alloc, _Ch_type, _Rx_traits,
+       __detail::_RegexExecutorPolicy::_S_auto, false>
+         (__s, __e, __m, __re, __flags);
+    }
 
   /**
    * Searches for a regular expression within a range.
@@ -2586,8 +2599,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        * @param __rhs [IN] A %regex_token_iterator to copy.
        */
       regex_token_iterator(const regex_token_iterator& __rhs)
-      : _M_position(__rhs.position), _M_subs(__rhs.subs), _M_n(__rhs.N),
-      _M_result(__rhs.result), _M_suffix(__rhs.suffix),
+      : _M_position(__rhs._M_position), _M_subs(__rhs._M_subs),
+      _M_n(__rhs._M_n), _M_result(__rhs._M_result), _M_suffix(__rhs._M_suffix),
       _M_has_m1(__rhs._M_has_m1)
       {
        if (__rhs._M_result == &__rhs._M_suffix)
index 24316d26616f96f56dd56e560a990c705024f550..128a92c2f0d8c5a79598712908d4c149cd9f7204 100644 (file)
@@ -32,6 +32,83 @@ namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+namespace __detail
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+  // Result of merging regex_match and regex_search.
+  //
+  // __policy now can be _S_auto(auto dispatch by checking back-references)
+  // and _S_force_dfs(just use _DFSExecutor).
+  //
+  // That __match_mode is true means regex_match, else regex_search.
+  template<typename _BiIter, typename _Alloc,
+          typename _CharT, typename _TraitsT,
+          _RegexExecutorPolicy __policy,
+          bool __match_mode>
+    bool
+    __regex_algo_impl(_BiIter                              __s,
+                     _BiIter                              __e,
+                     match_results<_BiIter, _Alloc>&      __m,
+                     const basic_regex<_CharT, _TraitsT>& __re,
+                     regex_constants::match_flag_type     __flags)
+    {
+      if (__re._M_automaton == nullptr)
+       return false;
+
+      typename match_results<_BiIter, _Alloc>::_Base_type& __res = __m;
+      __res.resize(__re._M_automaton->_M_sub_count() + 2);
+      for (auto& __it : __res)
+       __it.matched = false;
+
+      typedef std::unique_ptr<_Executor<_BiIter, _Alloc, _CharT, _TraitsT>>
+       _ExecutorPtr;
+      typedef _DFSExecutor<_BiIter, _Alloc, _CharT, _TraitsT> _DFSExecutorT;
+      typedef _BFSExecutor<_BiIter, _Alloc, _CharT, _TraitsT> _BFSExecutorT;
+
+      _ExecutorPtr __executor =
+       __get_executor<_BiIter, _Alloc, _CharT, _TraitsT,
+         __policy>(__s, __e, __res, __re, __flags);
+
+      bool __ret;
+      if (__match_mode)
+       __ret = __executor->_M_match();
+      else
+       __ret = __executor->_M_search();
+      if (__ret)
+       {
+         for (auto __it : __res)
+           if (!__it.matched)
+             __it.first = __it.second = __e;
+         auto& __pre = __res[__res.size()-2];
+         auto& __suf = __res[__res.size()-1];
+         if (__match_mode)
+           {
+             __pre.matched = false;
+             __pre.first = __s;
+             __pre.second = __s;
+             __suf.matched = false;
+             __suf.first = __e;
+             __suf.second = __e;
+           }
+         else
+           {
+             __pre.first = __s;
+             __pre.second = __res[0].first;
+             __pre.matched = (__pre.first != __pre.second);
+             __suf.first = __res[0].second;
+             __suf.second = __e;
+             __suf.matched = (__suf.first != __suf.second);
+           }
+         if (__re.flags() & regex_constants::nosubs)
+           __res.resize(3);
+       }
+      return __ret;
+    }
+
+_GLIBCXX_END_NAMESPACE_VERSION
+}
+
   template<typename _Ch_type>
   template<typename _Fwd_iter>
     typename regex_traits<_Ch_type>::string_type
@@ -295,7 +372,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     value(_Ch_type __ch, int __radix) const
     {
       std::basic_istringstream<char_type> __is(string_type(1, __ch));
-      int __v;
+      long __v;
       if (__radix == 8)
        __is >> std::oct;
       else if (__radix == 16)
@@ -318,7 +395,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       const __ctype_type&
        __fctyp(use_facet<__ctype_type>(__traits.getloc()));
 
-      auto __output = [&](int __idx)
+      auto __output = [&](size_t __idx)
        {
          auto& __sub = _Base_type::operator[](__idx);
          if (__sub.matched)
@@ -376,7 +453,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                __output(_Base_type::size()-1);
              else if (__fctyp.is(__ctype_type::digit, *__next))
                {
-                 int __num = __traits.value(*__next, 10);
+                 long __num = __traits.value(*__next, 10);
                  if (++__next != __fmt_last
                      && __fctyp.is(__ctype_type::digit, *__next))
                    {
@@ -395,90 +472,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return __out;
     }
 
-  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, _Alloc>&         __m,
-               const basic_regex<_Ch_type, _Rx_traits>& __re,
-               regex_constants::match_flag_type         __flags
-                              = regex_constants::match_default)
-    {
-      if (__re._M_automaton == nullptr)
-       return false;
-
-      typename match_results<_Bi_iter, _Alloc>::_Base_type& __res = __m;
-      auto __size = __re._M_automaton->_M_sub_count();
-      __size += 2;
-      __res.resize(__size);
-      for (decltype(__size) __i = 0; __i < __size; ++__i)
-       __res[__i].matched = false;
-
-      if (__detail::__get_executor(__s, __e, __res, __re, __flags)->_M_match())
-       {
-         for (auto __it : __res)
-           if (!__it.matched)
-             __it.first = __it.second = __e;
-         auto& __pre = __res[__res.size()-2];
-         auto& __suf = __res[__res.size()-1];
-         __pre.matched = false;
-         __pre.first = __s;
-         __pre.second = __s;
-         __suf.matched = false;
-         __suf.first = __e;
-         __suf.second = __e;
-         return true;
-       }
-      return false;
-    }
-
-  template<typename _Bi_iter, typename _Alloc,
-          typename _Ch_type, typename _Rx_traits>
-    bool
-    regex_search(_Bi_iter __first, _Bi_iter __last,
-                match_results<_Bi_iter, _Alloc>& __m,
-                const basic_regex<_Ch_type, _Rx_traits>& __re,
-                regex_constants::match_flag_type __flags
-                = regex_constants::match_default)
-    {
-      if (__re._M_automaton == nullptr)
-       return false;
-
-      typename match_results<_Bi_iter, _Alloc>::_Base_type& __res = __m;
-      auto __size = __re._M_automaton->_M_sub_count();
-      __size += 2;
-      __res.resize(__size);
-      for (decltype(__size) __i = 0; __i < __size; ++__i)
-       __res[__i].matched = false;
-
-      if (__detail::__get_executor(__first, __last, __res, __re, __flags)
-         ->_M_search())
-       {
-         for (auto __it : __res)
-           if (!__it.matched)
-             __it.first = __it.second = __last;
-         auto& __pre = __res[__res.size()-2];
-         auto& __suf = __res[__res.size()-1];
-         __pre.first = __first;
-         __pre.second = __res[0].first;
-         __pre.matched = (__pre.first != __pre.second);
-         __suf.first = __res[0].second;
-         __suf.second = __last;
-         __suf.matched = (__suf.first != __suf.second);
-         return true;
-       }
-      return false;
-    }
-
   template<typename _Out_iter, typename _Bi_iter,
           typename _Rx_traits, typename _Ch_type>
     _Out_iter
     regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
                  const basic_regex<_Ch_type, _Rx_traits>& __e,
                  const _Ch_type* __fmt,
-                 regex_constants::match_flag_type __flags
-                 = regex_constants::match_default)
+                 regex_constants::match_flag_type __flags)
     {
       typedef regex_iterator<_Bi_iter, _Ch_type, _Rx_traits> _IterT;
       _IterT __i(__first, __last, __e, __flags);
index 94a14ce96aa0b16a0b12cf58bc5e3dcbb44f3d1d..60744b206625991e96824114060f4deb579e68ed 100644 (file)
@@ -40,7 +40,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  @{
    */
 
-  typedef int _StateIdT;
+  typedef long _StateIdT;
   typedef std::set<_StateIdT> _StateSet;
   static const _StateIdT _S_invalid_state_id  = -1;
 
@@ -49,7 +49,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   /// Operation codes that define the type of transitions within the base NFA
   /// that represents the regular expression.
-  enum _Opcode
+  enum _Opcode : int
   {
       _S_opcode_unknown,
       _S_opcode_alternative,
@@ -69,15 +69,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     class _State
     {
     public:
-      typedef int                        _OpcodeT;
       typedef _Matcher<_CharT>           _MatcherT;
 
-      _OpcodeT     _M_opcode;           // type of outgoing transition
+      _Opcode      _M_opcode;           // type of outgoing transition
       _StateIdT    _M_next;             // outgoing transition
       union // Since they are mutually exclusive.
       {
-       unsigned int _M_subexpr;        // for _S_opcode_subexpr_*
-       unsigned int _M_backref_index;  // for _S_opcode_backref
+       size_t _M_subexpr;        // for _S_opcode_subexpr_*
+       size_t _M_backref_index;  // for _S_opcode_backref
        struct
        {
          // for _S_opcode_alternative.
@@ -91,7 +90,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       };
       _MatcherT      _M_matches;        // for _S_opcode_match
 
-      explicit _State(_OpcodeT __opcode)
+      explicit _State(_Opcode  __opcode)
       : _M_opcode(__opcode), _M_next(_S_invalid_state_id)
       { }
 
@@ -110,7 +109,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     class _Automaton
     {
     public:
-      typedef unsigned int _SizeT;
+      typedef size_t _SizeT;
 
     public:
       virtual _SizeT
@@ -130,7 +129,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     public:
       typedef _State<_CharT, _TraitsT>            _StateT;
       typedef const _Matcher<_CharT>&             _MatcherT;
-      typedef unsigned int                        _SizeT;
+      typedef size_t                              _SizeT;
       typedef regex_constants::syntax_option_type _FlagT;
 
       _NFA(_FlagT __f)
@@ -203,7 +202,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       }
 
       _StateIdT
-      _M_insert_backref(unsigned int __index);
+      _M_insert_backref(size_t __index);
 
       _StateIdT
       _M_insert_line_begin()
@@ -250,7 +249,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       _M_dot(std::ostream& __ostr) const;
 #endif
 
-      std::vector<unsigned int> _M_paren_stack;
+      std::vector<size_t>       _M_paren_stack;
       _StateSet                 _M_accepting_states;
       _FlagT                    _M_flags;
       _StateIdT                 _M_start_state;
index 3402ef33d398e0d0a0e9f0b824269cad6973ea2d..c15e3e99545f75eb39fa4cab092fb305afbcb6e4 100644 (file)
@@ -137,7 +137,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     {
       __ostr << "digraph _Nfa {\n"
        << "  rankdir=LR;\n";
-      for (unsigned int __i = 0; __i < this->size(); ++__i)
+      for (size_t __i = 0; __i < this->size(); ++__i)
       { this->at(__i)._M_dot(__ostr, __i); }
       __ostr << "}\n";
       return __ostr;
@@ -146,7 +146,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   template<typename _CharT, typename _TraitsT>
     _StateIdT _NFA<_CharT, _TraitsT>::
-    _M_insert_backref(unsigned int __index)
+    _M_insert_backref(size_t __index)
     {
       // To figure out whether a backref is valid, a stack is used to store
       // unfinished sub-expressions. For example, when parsing
index 5225bc1ee6ce9fe1095c16655e6052b3fd2d2ac3..52386ce4e6450546cf618fff8eed4f9fa5f689d7 100644 (file)
@@ -222,9 +222,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 +239,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 +260,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,
@@ -318,7 +318,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        }
       else if (_M_match_token(_ScannerT::_S_token_subexpr_begin))
        {
-         int __mark = _M_nfa._M_sub_count();
+         auto __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))
@@ -425,7 +425,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     _Compiler<_FwdIter, _CharT, _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);
index a0149d2a54867cc1c29499f913b43fdfd57ec81e..2770098152b8dc64e971d37bede0a184a6c0a382 100644 (file)
@@ -145,8 +145,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       bool
       _M_word_boundry(_State<_CharT, _TraitsT> __state) const;
 
+      virtual std::unique_ptr<_Executor>
+      _M_clone() const = 0;
+
+      // Return whether now match the given sub-NFA.
       bool
-      _M_lookahead(_State<_CharT, _TraitsT> __state) const;
+      _M_lookahead(_State<_CharT, _TraitsT> __state) const
+      {
+       auto __sub = this->_M_clone();
+       __sub->_M_set_start(__state._M_alt);
+       return __sub->_M_search_from_first();
+      }
 
       void
       _M_set_results(_ResultsVec& __cur_results);
@@ -226,6 +235,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       bool
       _M_dfs(_StateIdT __start);
 
+      std::unique_ptr<_BaseT>
+      _M_clone() const
+      {
+       return std::unique_ptr<_BaseT>(new _DFSExecutor(this->_M_current,
+                                                       this->_M_end,
+                                                       this->_M_results,
+                                                       this->_M_re,
+                                                       this->_M_flags));
+      }
+
       // To record current solution.
       _ResultsVec     _M_cur_results;
       const _NFAT&    _M_nfa;
@@ -268,8 +287,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       // greedy policy.
       //
       // The definition of `greedy`:
-      // For the sequence of quantifiers in NFA sorted by there start position,
-      // now maintain a vector in every matching state, with equal length to
+      // For the sequence of quantifiers in NFA sorted by their start positions,
+      // now maintain a vector in every matching state, with length equal to
       // quantifier seq, recording repeating times of every quantifier. Now to
       // compare two matching states, we just lexically compare these two
       // vectors. To win the compare(to survive), one matching state needs to
@@ -281,26 +300,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       // operator<() for lexicographical_compare will emit the answer.
       //
       // When two vectors equal, it means the `where`, `when` and quantifier
-      // counts are identical, and indicates the same solution; so just return
-      // false.
+      // counts are identical, and indicates the same solution; so
+      // _ResultsEntry::operator<() just return false.
       struct _ResultsEntry
       : private _ResultsVec
       {
       public:
-       _ResultsEntry(unsigned int __res_sz, unsigned int __sz)
+       _ResultsEntry(size_t __res_sz, size_t __sz)
        : _ResultsVec(__res_sz), _M_quant_keys(__sz)
        { }
 
        void
-       resize(unsigned int __n)
+       resize(size_t __n)
        { _ResultsVec::resize(__n); }
 
-       unsigned int
+       size_t
        size()
        { return _ResultsVec::size(); }
 
        sub_match<_BiIter>&
-       operator[](unsigned int __idx)
+       operator[](size_t __idx)
        { return _ResultsVec::operator[](__idx); }
 
        bool
@@ -315,7 +334,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        }
 
        void
-       _M_inc(unsigned int __idx, bool __neg)
+       _M_inc(size_t __idx, bool __neg)
        { _M_quant_keys[__idx] += __neg ? 1 : -1; }
 
        _ResultsVec&
@@ -369,6 +388,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       bool
       _M_includes_some();
 
+      std::unique_ptr<_BaseT>
+      _M_clone() const
+      {
+       return std::unique_ptr<_BaseT>(new _BFSExecutor(this->_M_current,
+                                                       this->_M_end,
+                                                       this->_M_results,
+                                                       this->_M_re,
+                                                       this->_M_flags));
+      }
+
       std::map<_StateIdT, _ResultsPtr> _M_covered;
       // To record global optimal solution.
       _ResultsPtr                      _M_cur_results;
@@ -376,15 +405,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       _StateIdT                        _M_start_state;
     };
 
-  template<typename _BiIter, typename _Alloc,
-    typename _CharT, typename _TraitsT>
-    std::unique_ptr<_Executor<_BiIter, _Alloc, _CharT, _TraitsT>>
-    __get_executor(_BiIter __b,
-                  _BiIter __e,
-                  std::vector<sub_match<_BiIter>, _Alloc>& __m,
-                  const basic_regex<_CharT, _TraitsT>& __re,
-                  regex_constants::match_flag_type __flags);
-
  //@} regex-detail
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace __detail
index 60ba9527c64d9412ed08e082e9d672830469625c..3b1fcbc9e38f489ac85f27b5e11f88e9a15fa7d5 100644 (file)
@@ -365,39 +365,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return __ans;
     }
 
-  // Return whether now match the given sub-NFA.
-  template<typename _BiIter, typename _Alloc,
-    typename _CharT, typename _TraitsT>
-    bool _Executor<_BiIter, _Alloc, _CharT, _TraitsT>::
-    _M_lookahead(_State<_CharT, _TraitsT> __state) const
-    {
-      auto __sub = __get_executor(this->_M_current,
-                                 this->_M_end,
-                                 this->_M_results,
-                                 this->_M_re,
-                                 this->_M_flags);
-      __sub->_M_set_start(__state._M_alt);
-      return __sub->_M_search_from_first();
-    }
-
   template<typename _BiIter, typename _Alloc,
     typename _CharT, typename _TraitsT>
     void _Executor<_BiIter, _Alloc, _CharT, _TraitsT>::
     _M_set_results(_ResultsVec& __cur_results)
     {
-      if (_M_re.flags() & regex_constants::nosubs)
-       {
-         // truncate
-         __cur_results.resize(3);
-         _M_results.resize(3);
-       }
-      for (unsigned int __i = 0; __i < __cur_results.size(); ++__i)
+      for (size_t __i = 0; __i < __cur_results.size(); ++__i)
        if (__cur_results[__i].matched)
          _M_results[__i] = __cur_results[__i];
     }
 
+  enum class _RegexExecutorPolicy : int
+    { _S_auto, _S_force_dfs };
+
   template<typename _BiIter, typename _Alloc,
-    typename _CharT, typename _TraitsT>
+    typename _CharT, typename _TraitsT,
+    _RegexExecutorPolicy __policy>
     std::unique_ptr<_Executor<_BiIter, _Alloc, _CharT, _TraitsT>>
     __get_executor(_BiIter __b,
                   _BiIter __e,
@@ -411,7 +394,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       typedef _BFSExecutor<_BiIter, _Alloc, _CharT, _TraitsT> _BFSExecutorT;
       auto __p = std::static_pointer_cast<_NFA<_CharT, _TraitsT>>
        (__re._M_automaton);
-      if (__p->_M_has_backref)
+      if (__policy == _RegexExecutorPolicy::_S_force_dfs
+         || (__policy == _RegexExecutorPolicy::_S_auto && __p->_M_has_backref))
        return _ExecutorPtr(new _DFSExecutorT(__b, __e, __m, __re, __flags));
       return _ExecutorPtr(new _BFSExecutorT(__b, __e, __m, __re, __flags));
     }
index d4edf123e97e90ce1147a612305f1d30d5baee9c..e2bde2216dfcb4eda43812d4299186d572f0e196 100644 (file)
@@ -25,7 +25,9 @@
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
 
+using namespace __gnu_test;
 using namespace std;
 
 void
@@ -34,12 +36,12 @@ test01()
   bool test __attribute__((unused)) = true;
 
   regex("\\[", regex_constants::awk);
-  VERIFY(regex_match("\"", regex("[\\\"]", regex_constants::awk)));
-  VERIFY(regex_match("/", regex("/", regex_constants::awk)));
-  VERIFY(regex_match("\a", regex("\\a", regex_constants::awk)));
-  VERIFY(regex_match("\"", regex("\\\"", regex_constants::awk)));
-  VERIFY(regex_match("5", regex("\\65", regex_constants::awk)));
-  VERIFY(regex_match("53", regex("\\0653", regex_constants::awk)));
+  VERIFY(regex_match_debug("\"", regex("[\\\"]", regex_constants::awk)));
+  VERIFY(regex_match_debug("/", regex("/", regex_constants::awk)));
+  VERIFY(regex_match_debug("\a", regex("\\a", regex_constants::awk)));
+  VERIFY(regex_match_debug("\"", regex("\\\"", regex_constants::awk)));
+  VERIFY(regex_match_debug("5", regex("\\65", regex_constants::awk)));
+  VERIFY(regex_match_debug("53", regex("\\0653", regex_constants::awk)));
 }
 
 int
index eb22569f337725e0fc2f18b66c49898ccd4763ee..dd0dac4392f2c9a1d114a654a0f3cc38df4fb42c 100644 (file)
@@ -25,7 +25,9 @@
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
 
+using namespace __gnu_test;
 using namespace std;
 
 void
@@ -45,8 +47,8 @@ test01()
     }
   FAIL("[]");
   FAIL("[^]");
-  VERIFY(regex_match("]", regex("[]]", regex_constants::basic)));
-  VERIFY(!regex_match("]", regex("[^]]", regex_constants::basic)));
+  VERIFY(regex_match_debug ("]", regex("[]]", regex_constants::basic)));
+  VERIFY(!regex_match_debug ("]", regex("[^]]", regex_constants::basic)));
 }
 
 int
index 668309d8cbf4bc80775af089126664c2481d6cf1..34cfa557f016d823de2e13a61e27933ea059c627 100644 (file)
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
+
+using namespace __gnu_test;
+using namespace std;
 
 void
 test01()
@@ -35,7 +39,7 @@ test01()
        std::string target("aaba");
        std::smatch m;
 
-       VERIFY( std::regex_match(target, m, re) );
+       VERIFY( regex_match_debug(target, m, re) );
 
        VERIFY( m.size()  == re.mark_count()+1 );
        VERIFY( m.empty() == false );
index 18783866f5e9b83c3f36fe734469582af8396171..36f032d7024c4a32db052f75d9b4a8c554537961 100644 (file)
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
+
+using namespace __gnu_test;
+using namespace std;
 
 void
 test01()
@@ -35,7 +39,7 @@ test01()
        std::string target("aa");
        std::smatch m;
 
-       VERIFY( std::regex_match(target, m, re) );
+       VERIFY( regex_match_debug(target, m, re) );
 
        VERIFY( m.size()  == re.mark_count()+1 );
        VERIFY( m.empty() == false );
index 93826a78fb3c0d405f7b5f0c98ace62c727bc88f..812e3efa4d31804ce3143054c6ed0afe5bb23ca8 100644 (file)
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
+
+using namespace __gnu_test;
+using namespace std;
 
 void
 test01()
@@ -35,7 +39,7 @@ test01()
        std::string target("aa");
        std::smatch m;
 
-       VERIFY( std::regex_match(target, m, re) );
+       VERIFY( regex_match_debug(target, m, re) );
 
        VERIFY( m.size()  == re.mark_count()+1 );
        VERIFY( m.empty() == false );
index 91bc101392b1eecc6f8c02a2b735c903ede663cb..0924ed0014b61f1e3b47732288e129fa5eaa17e6 100644 (file)
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
+
+using namespace __gnu_test;
+using namespace std;
 
 void
 test01()
@@ -35,7 +39,7 @@ test01()
        std::string target("aa");
        std::smatch m;
 
-       VERIFY( std::regex_match(target, m, re) );
+       VERIFY( regex_match_debug(target, m, re) );
 
        VERIFY( m.size()  == re.mark_count()+1 );
        VERIFY( m.empty() == false );
index 5f4b1d1b894fd139ea1cc9c5adb3d6d55488a3df..5a762ab6eb4c31b1309b1b45bfd320bd48307d01 100644 (file)
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
+
+using namespace __gnu_test;
+using namespace std;
 
 // libstdc++/53622
 void
@@ -36,7 +40,7 @@ test01()
     std::string target("zxcv/onetwoabc");
     std::smatch m;
 
-    VERIFY( std::regex_match(target, m, re) );
+    VERIFY( regex_match_debug(target, m, re) );
     VERIFY( m.size() == 2 );
     VERIFY( m[0].matched == true );
     VERIFY( std::string(m[0].first, m[0].second) == "zxcv/onetwoabc" );
@@ -49,7 +53,7 @@ test01()
     std::string target("zxcv/onetwoabc");
     std::smatch m;
 
-    VERIFY( std::regex_match(target, m, re) );
+    VERIFY( regex_match_debug(target, m, re) );
     VERIFY( m.size() == 3 );
     VERIFY( m[0].matched == true );
     VERIFY( std::string(m[0].first, m[0].second) == "zxcv/onetwoabc" );
index b9a72c93f017c595b2378e9121f59b60504dbad7..dc177e54274ef4708b7ccaabe76c98fe0dac2b95 100644 (file)
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
+
+using namespace __gnu_test;
+using namespace std;
 #include <iostream>
 
 // libstdc++/57173
@@ -37,7 +41,7 @@ test01()
     std::string target("/asdf/qwerty");
     std::smatch m;
 
-    VERIFY( std::regex_match(target, m, re) );
+    VERIFY( regex_match_debug(target, m, re) );
     VERIFY( m.size() == 2 );
     VERIFY( std::string(m[1].first, m[1].second) == "/qwerty");
   }
@@ -46,7 +50,7 @@ test01()
     std::string target("/asdf/qwerty");
     std::smatch m;
 
-    VERIFY( std::regex_match(target, m, re) );
+    VERIFY( regex_match_debug(target, m, re) );
     VERIFY( m.size() == 3 );
     VERIFY( std::string(m[1].first, m[1].second) == "/qwerty");
   }
index 1a1365ceea2fd10c918fe9765f34a99deb539438..f745ef34e379e5cbc166af46f5b09d358ca7867a 100644 (file)
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
+
+using namespace __gnu_test;
+using namespace std;
 
 // libstdc++/58576
 void
 test01()
 {
-  using namespace std;
-
   bool test __attribute__((unused)) = true;
 
   string domain_name = "valid.hostname.org";
@@ -74,9 +76,9 @@ test01()
   };
   try
     {
-      VERIFY(regex_match( domain_name, m, fqdn_regex ));
+      VERIFY(regex_match_debug( domain_name, m, fqdn_regex ));
       VERIFY(m.size() == sizeof(sol) / sizeof(*sol));
-      for (int i = 0; i < (int)m.size(); i++) {
+      for (size_t i = 0; i < m.size(); i++) {
          string s(m[i].first, m[i].second);
          VERIFY(s == sol[i]);
       }
index 6e6095b8f249a9ece3daccebcd00be5179f96d04..866ff7fead8ce7c15d65888c158bed5e4165850d 100644 (file)
@@ -25,7 +25,9 @@
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
 
+using namespace __gnu_test;
 using namespace std;
 
 void
@@ -37,7 +39,7 @@ test01()
   {\
     regex re(res);\
     string st(s);\
-    VERIFY(!regex_match(st, re));\
+    VERIFY(!regex_match_debug(st, re));\
   }
   TEST(".", "\0");
   TEST(".", "\n");
index 321ce35a0389a90b44c65584f71f280674c72e78..05a57725d04b00204af37bcc658bbbc3e45e7732 100644 (file)
@@ -25,7 +25,9 @@
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
 
+using namespace __gnu_test;
 using namespace std;
 
 void
index 3c48d3521a5e2cc804a4cfbbc1ddcf8de8ffc95d..9f09c7463e8fde2c38e8f1b66d01eede4cb32f2a 100644 (file)
@@ -25,7 +25,9 @@
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
 
+using namespace __gnu_test;
 using namespace std;
 
 void
@@ -33,10 +35,10 @@ test01()
 {
   bool test __attribute__((unused)) = true;
 
-  VERIFY(!regex_match("x", regex("[]")));
-  VERIFY(regex_match("x", regex("[^]")));
-  VERIFY(!regex_match("]", regex("[]]")));
-  VERIFY(!regex_match("]", regex("[^]]")));
+  VERIFY(!regex_match_debug("x", regex("[]")));
+  VERIFY(regex_match_debug("x", regex("[^]")));
+  VERIFY(!regex_match_debug("]", regex("[]]")));
+  VERIFY(!regex_match_debug("]", regex("[^]]")));
 }
 
 int
index 1dc8f63f7891c0d60fb16a5fbc0c82fdfd99bb51..77fd43c0acbd357607c10a5052459f780cb633d8 100644 (file)
@@ -25,7 +25,9 @@
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
 
+using namespace __gnu_test;
 using namespace std;
 
 void
@@ -37,7 +39,7 @@ test01()
     regex re("()*\\1");
     cmatch m;
     const char s[] = "";
-    VERIFY( regex_match(s, m, re) );
+    VERIFY( regex_match_debug(s, m, re) );
     VERIFY( m.size() == 2 );
     VERIFY( m[0].matched );
     VERIFY( m[1].matched );
@@ -46,7 +48,7 @@ test01()
     regex re("()*");
     cmatch m;
     const char s[] = "";
-    VERIFY( regex_match(s, m, re) );
+    VERIFY( regex_match_debug(s, m, re) );
   }
 }
 
index a73b742a5e43dfdafe61a8a98910f2b9a350383a..b1030615ec360a612cf9f7d5aa73ea7e83957c40 100644 (file)
@@ -25,7 +25,9 @@
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
 
+using namespace __gnu_test;
 using namespace std;
 
 void
@@ -33,7 +35,7 @@ test01()
 {
   bool test __attribute__((unused)) = true;
 
-  VERIFY(regex_match(":", regex("\\x3a")));
+  VERIFY(regex_match_debug(":", regex("\\x3a")));
   try
     {
       regex("\\u400x");
index b54f5619a24c361779ca6d26fce6af2ab32b71ed..118c47226770048c6b0d3d30f4835c3f4e7ae4ec 100644 (file)
@@ -25,7 +25,9 @@
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
 
+using namespace __gnu_test;
 using namespace std;
 
 void
@@ -33,15 +35,15 @@ test01()
 {
   bool test __attribute__((unused)) = true;
 
-  VERIFY(regex_match("01", regex("\\d*")));
-  VERIFY(regex_match("asdfjkl", regex("\\D*")));
-  VERIFY(!regex_match("asdfjkl0", regex("\\D*")));
-  VERIFY(regex_match("\r\t\v\f ", regex("\\s*")));
-  VERIFY(regex_match("asdfjkl", regex("\\S*")));
-  VERIFY(!regex_match("asdfjkl\r", regex("\\S*")));
-  VERIFY(regex_match("_az", regex("\\w*")));
-  VERIFY(regex_match("!@#$%", regex("\\W*")));
-  VERIFY(!regex_match("_01234", regex("\\W*")));
+  VERIFY(regex_match_debug("01", regex("\\d*")));
+  VERIFY(regex_match_debug("asdfjkl", regex("\\D*")));
+  VERIFY(!regex_match_debug("asdfjkl0", regex("\\D*")));
+  VERIFY(regex_match_debug("\r\t\v\f ", regex("\\s*")));
+  VERIFY(regex_match_debug("asdfjkl", regex("\\S*")));
+  VERIFY(!regex_match_debug("asdfjkl\r", regex("\\S*")));
+  VERIFY(regex_match_debug("_az", regex("\\w*")));
+  VERIFY(regex_match_debug("!@#$%", regex("\\W*")));
+  VERIFY(!regex_match_debug("_01234", regex("\\W*")));
 }
 
 int
index c574908d6a9c51035bfb29217c815bec0db79d43..323a2ff4ed612c7a28eaf623ed5e24a3227a5126 100644 (file)
@@ -25,7 +25,9 @@
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
 
+using namespace __gnu_test;
 using namespace std;
 
 void
@@ -37,7 +39,7 @@ test01()
   {\
     wregex re(res);\
     wstring st(s);\
-    VERIFY(!regex_match(st, re));\
+    VERIFY(!regex_match_debug(st, re));\
   }
   TESTL(L".", L"\u2028");
   TESTL(L".", L"\u2029");
index f9561be70e29a74bfda300eefaf1f2e3f4728433..876a7df1e2e331aa35bcabd098e95b317952efee 100644 (file)
@@ -25,7 +25,9 @@
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
 
+using namespace __gnu_test;
 using namespace std;
 
 void
@@ -33,7 +35,7 @@ test01()
 {
   bool test __attribute__((unused)) = true;
 
-  VERIFY(regex_match(L"\u1234", wregex(L"\\u1234")));
+  VERIFY(regex_match_debug(L"\u1234", wregex(L"\\u1234")));
 }
 
 int
index 5d8378556c660ab2eff68e9879979b316f348c9f..c5f066bec816cd8913a53f59259d4bc995f0997f 100644 (file)
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
+
+using namespace __gnu_test;
+using namespace std;
 
 void
 test01()
@@ -33,33 +37,33 @@ test01()
 
   {
     std::regex  re("pre/[za-x]", std::regex::extended);
-    VERIFY( std::regex_match("pre/z", re) );
-    VERIFY( std::regex_match("pre/a", re) );
-    VERIFY( !std::regex_match("pre/y", re) );
+    VERIFY( regex_match_debug("pre/z", re) );
+    VERIFY( regex_match_debug("pre/a", re) );
+    VERIFY( !regex_match_debug("pre/y", re) );
   }
   {
     std::regex  re("pre/[[:uPPer:]]", std::regex::extended);
-    VERIFY( std::regex_match("pre/Z", re) );
-    VERIFY( !std::regex_match("pre/_", re) );
-    VERIFY( !std::regex_match("pre/a", re) );
-    VERIFY( !std::regex_match("pre/0", re) );
+    VERIFY( regex_match_debug("pre/Z", re) );
+    VERIFY( !regex_match_debug("pre/_", re) );
+    VERIFY( !regex_match_debug("pre/a", re) );
+    VERIFY( !regex_match_debug("pre/0", re) );
   }
   {
     std::regex  re("pre/[[:lOWer:]]", std::regex::extended | std::regex::icase);
-    VERIFY( std::regex_match("pre/Z", re) );
-    VERIFY( std::regex_match("pre/a", re) );
+    VERIFY( regex_match_debug("pre/Z", re) );
+    VERIFY( regex_match_debug("pre/a", re) );
   }
   {
     std::regex  re("pre/[[:w:][.tilde.]]", std::regex::extended);
-    VERIFY( std::regex_match("pre/~", re) );
-    VERIFY( std::regex_match("pre/_", re) );
-    VERIFY( std::regex_match("pre/a", re) );
-    VERIFY( std::regex_match("pre/0", re) );
+    VERIFY( regex_match_debug("pre/~", re) );
+    VERIFY( regex_match_debug("pre/_", re) );
+    VERIFY( regex_match_debug("pre/a", re) );
+    VERIFY( regex_match_debug("pre/0", re) );
   }
   {
     std::regex  re("pre/[[=a=]]", std::regex::extended);
-    VERIFY( std::regex_match("pre/a", re) );
-    VERIFY( std::regex_match("pre/A", re) );
+    VERIFY( regex_match_debug("pre/a", re) );
+    VERIFY( regex_match_debug("pre/A", re) );
   }
 }
 
index 375f34b806456bc68635a82bae393dfe764abff1..32bc24f99822228a1484cd64bb23377a3e532042 100644 (file)
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
+
+using namespace __gnu_test;
+using namespace std;
 
 void
 test01()
@@ -35,7 +39,7 @@ test01()
   const char target[] = "aa";
   std::cmatch m;
 
-  VERIFY( std::regex_match(target, m, re) );
+  VERIFY( regex_match_debug(target, m, re) );
 
   VERIFY( re.mark_count() == 1 );
   VERIFY( m.size()  == re.mark_count()+1 );
@@ -53,9 +57,9 @@ test01()
   VERIFY( m[1].second == target+sizeof(target)-1 );
   VERIFY( m[1].matched == true );
 
-  VERIFY(!std::regex_match("", std::regex("a+", std::regex::extended)));
-  VERIFY(std::regex_match("a", std::regex("a+", std::regex::extended)));
-  VERIFY(std::regex_match("aa", std::regex("a+", std::regex::extended)));
+  VERIFY(!regex_match_debug("", std::regex("a+", std::regex::extended)));
+  VERIFY(regex_match_debug("a", std::regex("a+", std::regex::extended)));
+  VERIFY(regex_match_debug("aa", std::regex("a+", std::regex::extended)));
 }
 
 
index 79b52a88c4f6337e18d5b9961f2724d07ca891bd..90e9eafae602e769c5a48e4cbcd5e2fed6aed59f 100644 (file)
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
+
+using namespace __gnu_test;
+using namespace std;
 
 void
 test01()
@@ -35,7 +39,7 @@ test01()
   char target[] = "a";
   std::cmatch m;
 
-  VERIFY( std::regex_match(target, m, re) );
+  VERIFY( regex_match_debug(target, m, re) );
 
   VERIFY( re.mark_count() == 1 );
   VERIFY( m.size()  == re.mark_count()+1 );
@@ -53,9 +57,9 @@ test01()
   VERIFY( m[1].second == target+sizeof(target)-1 );
   VERIFY( m[1].matched == true );
 
-  VERIFY(std::regex_match("", std::regex("a?", std::regex::extended)));
-  VERIFY(std::regex_match("a", std::regex("a?", std::regex::extended)));
-  VERIFY(!std::regex_match("aa", std::regex("a?", std::regex::extended)));
+  VERIFY(regex_match_debug("", std::regex("a?", std::regex::extended)));
+  VERIFY(regex_match_debug("a", std::regex("a?", std::regex::extended)));
+  VERIFY(!regex_match_debug("aa", std::regex("a?", std::regex::extended)));
 }
 
 
index 62f825a0fb9644987caf20cc7c1d002443f4f082..f9f7b6af1fdb1f982776169b084627e01ba22538 100644 (file)
@@ -25,7 +25,9 @@
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
 
+using namespace __gnu_test;
 using namespace std;
 
 void
@@ -35,29 +37,29 @@ test01()
 
   regex re;
   re.assign("(ab){3}", std::regex::extended);
-  VERIFY(!regex_match("abab", re));
-  VERIFY(regex_match("ababab", re));
-  VERIFY(!regex_match("abababab", re));
+  VERIFY(!regex_match_debug("abab", re));
+  VERIFY(regex_match_debug("ababab", re));
+  VERIFY(!regex_match_debug("abababab", re));
   re.assign("(ab){3,}", std::regex::extended);
-  VERIFY(!regex_match("abab", re));
-  VERIFY(regex_match("ababab", re));
-  VERIFY(regex_match("abababab", re));
-  VERIFY(regex_match("ababababab", re));
+  VERIFY(!regex_match_debug("abab", re));
+  VERIFY(regex_match_debug("ababab", re));
+  VERIFY(regex_match_debug("abababab", re));
+  VERIFY(regex_match_debug("ababababab", re));
   re.assign("(ab){0,3}", std::regex::extended);
-  VERIFY(regex_match("", re));
-  VERIFY(regex_match("ab", re));
-  VERIFY(regex_match("abab", re));
-  VERIFY(regex_match("ababab", re));
-  VERIFY(!regex_match("abababab", re));
+  VERIFY(regex_match_debug("", re));
+  VERIFY(regex_match_debug("ab", re));
+  VERIFY(regex_match_debug("abab", re));
+  VERIFY(regex_match_debug("ababab", re));
+  VERIFY(!regex_match_debug("abababab", re));
   re.assign("(a|b){0,2}", std::regex::extended);
-  VERIFY(regex_match("", re));
-  VERIFY(regex_match("a", re));
-  VERIFY(regex_match("b", re));
-  VERIFY(regex_match("aa", re));
-  VERIFY(regex_match("ab", re));
-  VERIFY(regex_match("ba", re));
-  VERIFY(regex_match("bb", re));
-  VERIFY(!regex_match("aaa", re));
+  VERIFY(regex_match_debug("", re));
+  VERIFY(regex_match_debug("a", re));
+  VERIFY(regex_match_debug("b", re));
+  VERIFY(regex_match_debug("aa", re));
+  VERIFY(regex_match_debug("ab", re));
+  VERIFY(regex_match_debug("ba", re));
+  VERIFY(regex_match_debug("bb", re));
+  VERIFY(!regex_match_debug("aaa", re));
 }
 
 int
index 57628f132151b51f1c6190f692bd2239a94fca5d..cd870396781fb8ccae4b4c133eacfed445255c97 100644 (file)
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
+
+using namespace __gnu_test;
+using namespace std;
 
 void
 test01()
@@ -35,7 +39,7 @@ test01()
        std::string target("aaba");
        std::smatch m;
 
-       VERIFY( std::regex_match(target, m, re) );
+       VERIFY( regex_match_debug(target, m, re) );
 
        VERIFY( m.size()  == re.mark_count()+1 );
        VERIFY( m.empty() == false );
index 4634c7d1d35a82f4182b72941e367b869accec39..50141f0037d73d6127709b9c5e1af5837c39470a 100644 (file)
@@ -38,10 +38,12 @@ template<typename _Bi_iter, typename _Alloc,
              regex_constants::match_flag_type         __flags
                             = regex_constants::match_default)
   {
+    using namespace __detail;
     auto& __res = (vector<sub_match<_Bi_iter>, _Alloc>&)(__m);
     VERIFY( (dynamic_cast
-             <__detail::_DFSExecutor<_Bi_iter, _Alloc, _Ch_type, _Rx_traits>*>
-             (&*__detail::__get_executor(__s, __e, __res, __re, __flags))
+             <_DFSExecutor<_Bi_iter, _Alloc, _Ch_type, _Rx_traits>*>
+             (&*__get_executor<_Bi_iter, _Alloc, _Ch_type, _Rx_traits,
+             _RegexExecutorPolicy::_S_auto>(__s, __e, __res, __re, __flags))
              != nullptr) );
   }
 
index e10dba81ffaf91648ea8d4a678ba668e75fc2602..e483b0abb9d42f441fbfc243880e727b341af88c 100644 (file)
@@ -25,6 +25,9 @@
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
+
+using namespace __gnu_test;
 
 void
 test01()
@@ -35,7 +38,7 @@ test01()
   std::string target("aa");
   std::smatch m;
 
-  VERIFY( std::regex_match(target, m, re) );
+  VERIFY( regex_match_debug(target, m, re) );
 
   VERIFY( m.size()  == re.mark_count()+1 );
   VERIFY( m.empty() == false );
index e715290c2421dd904d2a854f63daab23d359e309..3879fc418aa576dbf456269493734fdeaaa08bf3 100644 (file)
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
+
+using namespace __gnu_test;
+using namespace std;
 
 void
 test01()
@@ -35,7 +39,7 @@ test01()
        std::string target("aa");
        std::smatch m;
 
-       VERIFY( std::regex_match(target, m, re) );
+       VERIFY( regex_match_debug(target, m, re) );
 
        VERIFY( m.size()  == re.mark_count()+1 );
        VERIFY( m.empty() == false );
index 62793b4a1995c320c62ef25a8d92a1fb9defe286..c2ebdf8b143d65295a96a0cc2854dc911b70b1d8 100644 (file)
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
+
+using namespace __gnu_test;
+using namespace std;
 
 void
 test01()
@@ -35,7 +39,7 @@ test01()
        std::string target("aa");
        std::smatch m;
 
-       VERIFY( std::regex_match(target, m, re) );
+       VERIFY( regex_match_debug(target, m, re) );
 
        VERIFY( m.size()  == re.mark_count()+1 );
        VERIFY( m.empty() == false );
index 6ab48ca6bafe1294bbe4f8188e3525737247137e..ba0ecd5b4c4bb8d6974b6598190ba78ff7e3066b 100644 (file)
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
+
+using namespace __gnu_test;
+using namespace std;
 
 void
 test01()
@@ -37,7 +41,7 @@ test01()
   re2.imbue(std::locale("de_DE.UTF-8"));
   re2.assign(L"[[:upper:]]*", std::regex::extended);
   std::wsmatch m2;
-  VERIFY(std::regex_match(str2, m2, re2));
+  VERIFY(regex_match_debug(str2, m2, re2));
 }
 
 int
index ee487f1983663ec65bc75a41b74a220dd9844e33..fed8e7dd17f49208ce7bf80bd8d7746fd44ebd62 100644 (file)
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
+
+using namespace __gnu_test;
+using namespace std;
 
 void
 test01()
@@ -35,7 +39,7 @@ test01()
   std::string target("xxasdfyy");
   std::smatch m;
 
-  VERIFY( std::regex_search(target, m, re) );
+  VERIFY( regex_search_debug(target, m, re) );
 
   VERIFY( m.size()  == re.mark_count()+1 );
   VERIFY( m.empty() == false );
index 3064b3b26e4bbe68e34b148629422aa5792f383c..f7bce8023d32026f5e8a7193990c679d97bbfdf2 100644 (file)
@@ -25,7 +25,9 @@
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
 
+using namespace __gnu_test;
 using namespace std;
 
 void
@@ -33,21 +35,21 @@ test01()
 {
   bool test __attribute__((unused)) = true;
 
-  VERIFY(!regex_search("2123456", regex("^1234")));
-  VERIFY(regex_search("123456", regex("^1234")));
-  VERIFY(regex_search("123456", regex("(5|^)1234")));
-  VERIFY(regex_search("5123456", regex("(5|^)1234")));
-  VERIFY(!regex_search("1234562", regex("3456$")));
-  VERIFY(regex_search("123456", regex("3456$")));
-  VERIFY(!regex_search("123456", regex("(?=1234)56")));
-  VERIFY(regex_search("123456", regex("(?=1234)123456")));
-  VERIFY(regex_search("123456", regex("(?!1234)56")));
-  VERIFY(!regex_search("123456", regex("(?!1234)123456")));
+  VERIFY(!regex_search_debug("2123456", regex("^1234")));
+  VERIFY(regex_search_debug("123456", regex("^1234")));
+  VERIFY(regex_search_debug("123456", regex("(5|^)1234")));
+  VERIFY(regex_search_debug("5123456", regex("(5|^)1234")));
+  VERIFY(!regex_search_debug("1234562", regex("3456$")));
+  VERIFY(regex_search_debug("123456", regex("3456$")));
+  VERIFY(!regex_search_debug("123456", regex("(?=1234)56")));
+  VERIFY(regex_search_debug("123456", regex("(?=1234)123456")));
+  VERIFY(regex_search_debug("123456", regex("(?!1234)56")));
+  VERIFY(!regex_search_debug("123456", regex("(?!1234)123456")));
 
-  VERIFY(regex_search("a-", regex("a\\b-")));
-  VERIFY(!regex_search("ab", regex("a\\bb")));
-  VERIFY(!regex_search("a-", regex("a\\B-")));
-  VERIFY(regex_search("ab", regex("a\\Bb")));
+  VERIFY(regex_search_debug("a-", regex("a\\b-")));
+  VERIFY(!regex_search_debug("ab", regex("a\\bb")));
+  VERIFY(!regex_search_debug("a-", regex("a\\B-")));
+  VERIFY(regex_search_debug("ab", regex("a\\Bb")));
 
   string s("This is a regular expression");
   string sol[] =
index 4be406cb072cc2d1d59323604e3a3d2db5392f59..490ab1c9159a5b465a5dd610f28666f837dc99c6 100644 (file)
@@ -25,7 +25,9 @@
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
 
+using namespace __gnu_test;
 using namespace std;
 
 void
@@ -35,32 +37,34 @@ test01()
 
   cmatch m;
   regex re("((as)(df))", regex_constants::ECMAScript | regex_constants::nosubs);
-  VERIFY(regex_search("asdf", m, re));
+  VERIFY(regex_search_debug("asdf", m, re));
   VERIFY(m.size() == 1);
   VERIFY(m[0].matched && string(m[0].first, m[0].second) == "asdf");
 
-  VERIFY( regex_search("a", regex("^a")));
-  VERIFY(!regex_search("a", regex("^a"), regex_constants::match_not_bol));
-  VERIFY( regex_search("a", regex("a$")));
-  VERIFY(!regex_search("a", regex("a$"), regex_constants::match_not_eol));
-  VERIFY( regex_search("a", regex("\\ba")));
-  VERIFY(!regex_search("a", regex("\\ba"), regex_constants::match_not_bow));
-  VERIFY( regex_search("a", regex("a\\b")));
-  VERIFY(!regex_search("a", regex("a\\b"), regex_constants::match_not_eow));
-  VERIFY( regex_search("", regex("")));
-  VERIFY(!regex_search("", regex(""), regex_constants::match_not_null));
-  VERIFY( regex_search("", regex("^$")));
-  VERIFY(!regex_search("", regex("^$"), regex_constants::match_not_null));
-  VERIFY( regex_search("aaa", m, regex("a*?"),
-                      regex_constants::match_not_null));
+  VERIFY( regex_search_debug("a", regex("^a")));
+  VERIFY(!regex_search_debug("a", regex("^a"), regex_constants::match_not_bol));
+  VERIFY( regex_search_debug("a", regex("a$")));
+  VERIFY(!regex_search_debug("a", regex("a$"), regex_constants::match_not_eol));
+  VERIFY( regex_search_debug("a", regex("\\ba")));
+  VERIFY(!regex_search_debug("a", regex("\\ba"),
+                            regex_constants::match_not_bow));
+  VERIFY( regex_search_debug("a", regex("a\\b")));
+  VERIFY(!regex_search_debug("a", regex("a\\b"),
+                            regex_constants::match_not_eow));
+  VERIFY( regex_search_debug("", regex("")));
+  VERIFY(!regex_search_debug("", regex(""), regex_constants::match_not_null));
+  VERIFY( regex_search_debug("", regex("^$")));
+  VERIFY(!regex_search_debug("", regex("^$"), regex_constants::match_not_null));
+  VERIFY( regex_search_debug("aaa", m, regex("a*?"),
+                            regex_constants::match_not_null));
   VERIFY(m[0].matched && string(m[0].first, m[0].second) == "a");
-  VERIFY( regex_search("asdf", regex("sdf")));
-  VERIFY(!regex_search("asdf", regex("sdf"),
-                      regex_constants::match_continuous));
-  VERIFY( regex_search(" a"+1, regex("\\ba"),
-                      regex_constants::match_prev_avail));
-  VERIFY( regex_search("ba"+1, regex("\\Ba"),
-                      regex_constants::match_prev_avail));
+  VERIFY( regex_search_debug("asdf", regex("sdf")));
+  VERIFY(!regex_search_debug("asdf", regex("sdf"),
+                            regex_constants::match_continuous));
+  VERIFY( regex_search_debug(" a"+1, regex("\\ba"),
+                            regex_constants::match_prev_avail));
+  VERIFY( regex_search_debug("ba"+1, regex("\\Ba"),
+                            regex_constants::match_prev_avail));
 }
 
 int
index ad37ec8649a80959bc03f05b16030857b434681b..107ced0edc8265f0e0ac6cbc3088219020c31cba 100644 (file)
@@ -25,7 +25,9 @@
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
 
+using namespace __gnu_test;
 using namespace std;
 
 void
@@ -35,30 +37,30 @@ test01()
 
   cmatch m;
 #define TEST(i, s) VERIFY(m[i].matched && string(m[i].first, m[i].second) == s)
-  VERIFY(regex_search("aaaa", m, regex("a*")));
+  VERIFY(regex_search_debug("aaaa", m, regex("a*")));
   TEST(0, "aaaa");
-  VERIFY(regex_search("aaaa", m, regex("a*?")));
+  VERIFY(regex_search_debug("aaaa", m, regex("a*?")));
   TEST(0, "");
-  VERIFY(regex_search("aaaa", m, regex("a+")));
+  VERIFY(regex_search_debug("aaaa", m, regex("a+")));
   TEST(0, "aaaa");
-  VERIFY(regex_search("aaaa", m, regex("a+?")));
+  VERIFY(regex_search_debug("aaaa", m, regex("a+?")));
   TEST(0, "a");
-  VERIFY(regex_search("a", m, regex("a?")));
+  VERIFY(regex_search_debug("a", m, regex("a?")));
   TEST(0, "a");
-  VERIFY(regex_search("a", m, regex("a??")));
+  VERIFY(regex_search_debug("a", m, regex("a??")));
   TEST(0, "");
-  VERIFY(regex_search("", m, regex("a??")));
+  VERIFY(regex_search_debug("", m, regex("a??")));
   TEST(0, "");
-  VERIFY(regex_search("aaaa", m, regex("(a+)(a+)")));
+  VERIFY(regex_search_debug("aaaa", m, regex("(a+)(a+)")));
   TEST(1, "aaa");
   TEST(2, "a");
-  VERIFY(regex_search("aaaa", m, regex("(a+?)(a+)")));
+  VERIFY(regex_search_debug("aaaa", m, regex("(a+?)(a+)")));
   TEST(1, "a");
   TEST(2, "aaa");
-  VERIFY(regex_search("aaaa", m, regex("(a+?)(a+)")));
+  VERIFY(regex_search_debug("aaaa", m, regex("(a+?)(a+)")));
   TEST(1, "a");
   TEST(2, "aaa");
-  VERIFY(regex_search("aaaa", m, regex("(a+?)(a+?)")));
+  VERIFY(regex_search_debug("aaaa", m, regex("(a+?)(a+?)")));
   TEST(1, "a");
   TEST(2, "a");
 }
index ec25875fdee07d712f511bec7278e150f6311795..c07e7efa7d4b181e6805a27a0defd6a728fe874e 100644 (file)
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
+
+using namespace __gnu_test;
+using namespace std;
 
 void
 test01()
 {
   bool test __attribute__((unused)) = true;
 
-  VERIFY(std::regex_search("", std::regex("")));
+  VERIFY(regex_search_debug("", std::regex("")));
 }
 
 int
index be0801621437e1803b49e0f2cccc490592007963..659ffdcb13ba2ea938b82b221ab22fab8efcf298 100644 (file)
 
 #include <regex>
 #include <testsuite_hooks.h>
+#include <testsuite_regex.h>
 
 using namespace std;
+using namespace __gnu_test;
 
 void
 test01()
@@ -34,8 +36,8 @@ test01()
   bool test __attribute__((unused)) = true;
 
   cmatch m;
-  VERIFY(regex_search("*** this is a string !!!", m,
-                     regex("(\\w+) (\\w+) (\\w+) (\\w+)")));
+  VERIFY(regex_search_debug("*** this is a string !!!", m,
+                           regex("(\\w+) (\\w+) (\\w+) (\\w+)")));
   VERIFY(m.format("$&|$`|$3|$4|$2|$1|$'$$$")
         == "this is a string|*** |a|string|is|this| !!!$$");
   VERIFY(m.format("&|\\3|\\4|\\2|\\1|\\",
index ebd72a672581b37e943c8c2323de986f0351c01a..17be78d9c1b9f6aaac5d7f728f28656503603538 100644 (file)
@@ -31,9 +31,12 @@ namespace __gnu_test
   // Test on a compilation of simple expressions, throw regex_error on error.
   typedef std::regex                           regex_type;
   typedef regex_type::flag_type                        flag_type;
+  typedef std::regex_constants::match_flag_type        match_flag_type;
   typedef std::regex_constants::error_type     error_type;
   typedef std::size_t                          size_type;
   typedef std::string                          string_type;
+  using std::basic_regex;
+  using std::match_results;
 
   // Utilities
   struct regex_expected_fail { };
@@ -126,5 +129,177 @@ namespace __gnu_test
       }
   }
 
+  // regex_match_debug behaves like regex_match, but will run *two* executors
+  // (if there's no back-reference) and check if their results agree. If not,
+  // an exception throws. One can use them just in the way of using regex_match.
+  template<typename _Bi_iter, typename _Alloc,
+          typename _Ch_type, typename _Rx_traits>
+    bool
+    regex_match_debug(_Bi_iter                                 __s,
+                     _Bi_iter                                 __e,
+                     match_results<_Bi_iter, _Alloc>&         __m,
+                     const basic_regex<_Ch_type, _Rx_traits>& __re,
+                     match_flag_type                          __flags
+                     = std::regex_constants::match_default)
+    {
+      using namespace std::__detail;
+      auto __res1 = __regex_algo_impl<_Bi_iter, _Alloc, _Ch_type, _Rx_traits,
+          _RegexExecutorPolicy::_S_auto, true>
+       (__s, __e, __m, __re, __flags);
+      match_results<_Bi_iter, _Alloc> __mm;
+      auto __res2 = __regex_algo_impl<_Bi_iter, _Alloc, _Ch_type, _Rx_traits,
+          _RegexExecutorPolicy::_S_force_dfs, true>
+       (__s, __e, __mm, __re, __flags);
+      if (__res1 == __res2 && __m == __mm)
+       return __res1;
+      throw(std::exception());
+    }
+
+  // No match_results version
+  template<typename _Bi_iter, typename _Ch_type, typename _Rx_traits>
+    inline bool
+    regex_match_debug(_Bi_iter                                 __first,
+                     _Bi_iter                                 __last,
+                     const basic_regex<_Ch_type, _Rx_traits>& __re,
+                     match_flag_type                          __flags
+                     = std::regex_constants::match_default)
+    {
+      match_results<_Bi_iter> __what;
+      return regex_match_debug(__first, __last, __what, __re, __flags);
+    }
+
+  // C-string version
+  template<typename _Ch_type, typename _Alloc, typename _Rx_traits>
+    inline bool
+    regex_match_debug(const _Ch_type*                          __s,
+                     match_results<const _Ch_type*, _Alloc>&  __m,
+                     const basic_regex<_Ch_type, _Rx_traits>& __re,
+                     match_flag_type                          __f
+                     = std::regex_constants::match_default)
+      { return regex_match_debug(__s, __s + _Rx_traits::length(__s),
+                                __m, __re, __f); }
+
+  // C-string version without match_results
+  template<typename _Ch_type, class _Rx_traits>
+    inline bool
+    regex_match_debug(const _Ch_type*                          __s,
+                     const basic_regex<_Ch_type, _Rx_traits>& __re,
+                     match_flag_type                          __f
+                     = std::regex_constants::match_default)
+      { return regex_match_debug(__s, __s + _Rx_traits::length(__s),
+                                __re, __f); }
+
+  // std::basic_string version
+  template<typename _Ch_traits, typename _Ch_alloc,
+           typename _Alloc, typename _Ch_type, typename _Rx_traits>
+    inline bool
+    regex_match_debug(const std::basic_string<_Ch_type, _Ch_traits,
+                       _Ch_alloc>& __s,
+                     match_results<typename std::basic_string<_Ch_type,
+                       _Ch_traits, _Ch_alloc>::const_iterator,
+                       _Alloc>& __m,
+                     const basic_regex<_Ch_type, _Rx_traits>& __re,
+                     match_flag_type                          __flags
+                     = std::regex_constants::match_default)
+      { return regex_match_debug(__s.begin(), __s.end(),
+                                __m, __re, __flags); }
+
+  // std::basic_string version without match_results
+  template<typename _Ch_traits, typename _Str_allocator,
+           typename _Ch_type, typename _Rx_traits>
+    inline bool
+    regex_match_debug(const std::basic_string<_Ch_type, _Ch_traits,
+                     _Str_allocator>&                         __s,
+                     const basic_regex<_Ch_type, _Rx_traits>& __re,
+                     match_flag_type                          __flags
+                     = std::regex_constants::match_default)
+    { return regex_match_debug(__s.begin(), __s.end(), __re, __flags); }
+
+  // regex_match_debug behaves like regex_match, but will run *two* executors
+  // (if there's no back-reference) and check if their results agree. If not,
+  // an exception throws. One can use them just in the way of using regex_match.
+  template<typename _Bi_iter, typename _Alloc,
+           typename _Ch_type, typename _Rx_traits>
+    bool
+    regex_search_debug(_Bi_iter                                 __s,
+                      _Bi_iter                                 __e,
+                      match_results<_Bi_iter, _Alloc>&         __m,
+                      const basic_regex<_Ch_type, _Rx_traits>& __re,
+                      match_flag_type   __flags
+                      = std::regex_constants::match_default)
+    {
+      using namespace std::__detail;
+      auto __res1 = __regex_algo_impl<_Bi_iter, _Alloc, _Ch_type, _Rx_traits,
+          _RegexExecutorPolicy::_S_auto, false>
+        (__s, __e, __m, __re, __flags);
+      match_results<_Bi_iter, _Alloc> __mm;
+      auto __res2 = __regex_algo_impl<_Bi_iter, _Alloc, _Ch_type, _Rx_traits,
+          _RegexExecutorPolicy::_S_force_dfs, false>
+        (__s, __e, __mm, __re, __flags);
+      if (__res1 == __res2 && __m == __mm)
+        return __res1;
+      throw(std::exception()); // Let test fail. Give it a name.
+    }
+
+  // No match_results version
+  template<typename _Bi_iter, typename _Ch_type, typename _Rx_traits>
+    inline bool
+    regex_search_debug(_Bi_iter                                 __first,
+                      _Bi_iter                                 __last,
+                      const basic_regex<_Ch_type, _Rx_traits>& __re,
+                      match_flag_type                          __flags
+                      = std::regex_constants::match_default)
+    {
+      match_results<_Bi_iter> __what;
+      return regex_search_debug(__first, __last, __what, __re, __flags);
+    }
+
+  // C-string version
+  template<typename _Ch_type, class _Alloc, class _Rx_traits>
+    inline bool
+    regex_search_debug(const _Ch_type*                          __s,
+                      match_results<const _Ch_type*, _Alloc>&  __m,
+                      const basic_regex<_Ch_type, _Rx_traits>& __e,
+                      match_flag_type                          __f
+                      = std::regex_constants::match_default)
+    { return regex_search_debug(__s, __s + _Rx_traits::length(__s),
+                               __m, __e, __f); }
+
+  // C-string version without match_results
+  template<typename _Ch_type, typename _Rx_traits>
+    inline bool
+    regex_search_debug(const _Ch_type*                          __s,
+                      const basic_regex<_Ch_type, _Rx_traits>& __e,
+                      match_flag_type                          __f
+                      = std::regex_constants::match_default)
+    { return regex_search_debug(__s, __s + _Rx_traits::length(__s),
+                               __e, __f); }
+
+  // std::basic_string version
+  template<typename _Ch_traits, typename _Ch_alloc,
+           typename _Alloc, typename _Ch_type,
+           typename _Rx_traits>
+    inline bool
+    regex_search_debug(const std::basic_string<_Ch_type, _Ch_traits,
+                      _Ch_alloc>& __s,
+                      match_results<typename std::basic_string<_Ch_type,
+                      _Ch_traits, _Ch_alloc>::const_iterator, _Alloc>&
+                      __m,
+                      const basic_regex<_Ch_type, _Rx_traits>& __e,
+                      match_flag_type                          __f
+                      = std::regex_constants::match_default)
+    { return regex_search_debug(__s.begin(), __s.end(), __m, __e, __f); }
+
+  // std::basic_string version without match_results
+  template<typename _Ch_traits, typename _String_allocator,
+           typename _Ch_type, typename _Rx_traits>
+    inline bool
+    regex_search_debug(const std::basic_string<_Ch_type, _Ch_traits,
+                      _String_allocator>&                      __s,
+                      const basic_regex<_Ch_type, _Rx_traits>& __e,
+                      match_flag_type                          __f
+                      = std::regex_constants::match_default)
+    { return regex_search_debug(__s.begin(), __s.end(), __e, __f); }
+
 } // namespace __gnu_test
 #endif