Commit 836c42f6 by Tim Shen Committed by Tim Shen

regex_automaton.tcc (_StateSeq<>::_M_clone()): Do _M_alt before _M_next.

2014-04-24  Tim Shen  <timshen91@gmail.com>

	* include/bits/regex_automaton.tcc (_StateSeq<>::_M_clone()):
	Do _M_alt before _M_next.
	* testsuite/28_regex/basic_regex/multiple_quantifiers.cc: Add testcases.

From-SVN: r209756
parent 0e93c3dc
2014-04-24 Tim Shen <timshen91@gmail.com>
* include/bits/regex_automaton.tcc (_StateSeq<>::_M_clone()):
Do _M_alt before _M_next.
* testsuite/28_regex/basic_regex/multiple_quantifiers.cc: Add testcases.
2014-04-24 Marc Glisse <marc.glisse@inria.fr> 2014-04-24 Marc Glisse <marc.glisse@inria.fr>
PR libstdc++/43622 PR libstdc++/43622
......
...@@ -197,20 +197,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -197,20 +197,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// _M_insert_state() never return -1 // _M_insert_state() never return -1
auto __id = _M_nfa._M_insert_state(__dup); auto __id = _M_nfa._M_insert_state(__dup);
__m[__u] = __id; __m[__u] = __id;
if (__u == _M_end)
continue;
if (__dup._M_next != _S_invalid_state_id && __m[__dup._M_next] == -1)
__stack.push(__dup._M_next);
if (__dup._M_opcode == _S_opcode_alternative if (__dup._M_opcode == _S_opcode_alternative
|| __dup._M_opcode == _S_opcode_subexpr_lookahead) || __dup._M_opcode == _S_opcode_subexpr_lookahead)
if (__dup._M_alt != _S_invalid_state_id && __m[__dup._M_alt] == -1) if (__dup._M_alt != _S_invalid_state_id && __m[__dup._M_alt] == -1)
__stack.push(__dup._M_alt); __stack.push(__dup._M_alt);
if (__u == _M_end)
continue;
if (__dup._M_next != _S_invalid_state_id && __m[__dup._M_next] == -1)
__stack.push(__dup._M_next);
} }
long __size = static_cast<long>(__m.size()); for (auto __v : __m)
for (long __k = 0; __k < __size; __k++)
{ {
long __v; if (__v == -1)
if ((__v = __m[__k]) == -1)
continue; continue;
auto& __ref = _M_nfa[__v]; auto& __ref = _M_nfa[__v];
if (__ref._M_next != _S_invalid_state_id) if (__ref._M_next != _S_invalid_state_id)
......
...@@ -21,7 +21,10 @@ ...@@ -21,7 +21,10 @@
// Tests multiple consecutive quantifiers // Tests multiple consecutive quantifiers
#include <regex> #include <regex>
#include <testsuite_hooks.h>
#include <testsuite_regex.h>
using namespace __gnu_test;
using namespace std; using namespace std;
int int
...@@ -29,5 +32,6 @@ main() ...@@ -29,5 +32,6 @@ main()
{ {
regex re1("a++"); regex re1("a++");
regex re2("(a+)+"); regex re2("(a+)+");
VERIFY(regex_match_debug("aa", regex("(a)*{3}")));
return 0; return 0;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment