diff options
author | Tim Shen <timshen@google.com> | 2014-11-25 05:43:04 +0000 |
---|---|---|
committer | Tim Shen <timshen@gcc.gnu.org> | 2014-11-25 05:43:04 +0000 |
commit | 02ba3fc22d5b4101f99bd5b0cc5101a04cdd0eb2 (patch) | |
tree | b5ca80b80eb4fcbdf7b29b72f70f709d6d1c5f9f | |
parent | 5534b254aeaec496b1aa0cf9f9c951c9debfa97d (diff) | |
download | gcc-02ba3fc22d5b4101f99bd5b0cc5101a04cdd0eb2.zip gcc-02ba3fc22d5b4101f99bd5b0cc5101a04cdd0eb2.tar.gz gcc-02ba3fc22d5b4101f99bd5b0cc5101a04cdd0eb2.tar.bz2 |
re PR libstdc++/63920 (Any regular expression should not match an empty sequence if match_not_null is specified)
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
-rw-r--r-- | libstdc++-v3/ChangeLog | 10 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/regex_executor.h | 2 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/regex_executor.tcc | 14 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/28_regex/algorithms/regex_search/ecma/flags.cc | 2 |
4 files changed, 20 insertions, 8 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index c245d26..0c4cce9 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -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 diff --git a/libstdc++-v3/include/bits/regex_executor.h b/libstdc++-v3/include/bits/regex_executor.h index b26992c..2d7796f 100644 --- a/libstdc++-v3/include/bits/regex_executor.h +++ b/libstdc++-v3/include/bits/regex_executor.h @@ -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; diff --git a/libstdc++-v3/include/bits/regex_executor.tcc b/libstdc++-v3/include/bits/regex_executor.tcc index 38d4781..a973667 100644 --- a/libstdc++-v3/include/bits/regex_executor.tcc +++ b/libstdc++-v3/include/bits/regex_executor.tcc @@ -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; } diff --git a/libstdc++-v3/testsuite/28_regex/algorithms/regex_search/ecma/flags.cc b/libstdc++-v3/testsuite/28_regex/algorithms/regex_search/ecma/flags.cc index 45ad0f6..6b038ee 100644 --- a/libstdc++-v3/testsuite/28_regex/algorithms/regex_search/ecma/flags.cc +++ b/libstdc++-v3/testsuite/28_regex/algorithms/regex_search/ecma/flags.cc @@ -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 |