re PR libstdc++/63920 (Any regular expression should not match an empty sequence...
authorTim Shen <timshen@google.com>
Tue, 25 Nov 2014 05:43:04 +0000 (05:43 +0000)
committerTim Shen <timshen@gcc.gnu.org>
Tue, 25 Nov 2014 05:43:04 +0000 (05:43 +0000)
PR libstdc++/63920
* include/bits/regex_executor.h: Make _M_begin non const.
* include/bits/regex_executor.tcc (_Executor<>::_M_search): Increase
_M_begin in search algorithm, so that _M_begin is treated as
"current start position" for each search iteration.
* testsuite/28_regex/algorithms/regex_search/ecma/flags.cc: New
testcase.

From-SVN: r218037

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/regex_executor.h
libstdc++-v3/include/bits/regex_executor.tcc
libstdc++-v3/testsuite/28_regex/algorithms/regex_search/ecma/flags.cc

index c245d26b6703861a155778b3ffdb5ef1f8b32175..0c4cce9ed36a402e2190d6d6bf89edf3e9d333d2 100644 (file)
@@ -1,3 +1,13 @@
+2014-11-25  Tim Shen  <timshen@google.com>
+
+       PR libstdc++/63920
+       * include/bits/regex_executor.h: Make _M_begin non const.
+       * include/bits/regex_executor.tcc (_Executor<>::_M_search): Increase
+       _M_begin in search algorithm, so that _M_begin is treated as
+       "current start position" for each search iteration.
+       * testsuite/28_regex/algorithms/regex_search/ecma/flags.cc: New
+       testcase.
+
 2014-11-21  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR bootstrap/63784
index b26992c9a4be2d6f1faa88388b9e7ca3c705f181..2d7796fba8010f38b07735bfb185cf293002386a 100644 (file)
@@ -205,7 +205,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     public:
       _ResultsVec                                           _M_cur_results;
       _BiIter                                               _M_current;
-      const _BiIter                                         _M_begin;
+      _BiIter                                               _M_begin;
       const _BiIter                                         _M_end;
       const _RegexT&                                        _M_re;
       const _NFAT&                                          _M_nfa;
index 38d4781b0c53e09662728e997b2cbfa3104c8cdd..a9736675bf60a70164b108fe8e5f3d05078ec58f 100644 (file)
@@ -39,17 +39,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     bool _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>::
     _M_search()
     {
+      if (_M_search_from_first())
+       return true;
       if (_M_flags & regex_constants::match_continuous)
-       return _M_search_from_first();
-      auto __cur = _M_begin;
-      do
+       return false;
+      _M_flags |= regex_constants::match_prev_avail;
+      while (_M_begin != _M_end)
        {
-         _M_current = __cur;
-         if (_M_main(_Match_mode::_Prefix))
+         ++_M_begin;
+         if (_M_search_from_first())
            return true;
        }
-      // Continue when __cur == _M_end
-      while (__cur++ != _M_end);
       return false;
     }
 
index 45ad0f63e567fe03a309b99dd90b4ebe68f93aac..6b038ee9333a546bde512f3a2442f538ed6f45ee 100644 (file)
@@ -65,6 +65,8 @@ test01()
                             regex_constants::match_prev_avail));
   VERIFY( regex_search_debug("ba"+1, regex("\\Ba"),
                             regex_constants::match_prev_avail));
+  // PR libstdc++/63920
+  VERIFY(!regex_search_debug("a", regex("b*"), regex_constants::match_not_null));
 }
 
 int