aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorTim Shen <timshen91@gmail.com>2014-04-24 18:29:21 +0000
committerTim Shen <timshen@gcc.gnu.org>2014-04-24 18:29:21 +0000
commit836c42f6ad73f273d5713aaf80a34856efb6e617 (patch)
tree698be6a5fe0550b881f172e6a9610e64138d0f24 /libstdc++-v3
parent0e93c3dc505d1c65ea328b239d93d4a0cc0b7950 (diff)
downloadgcc-836c42f6ad73f273d5713aaf80a34856efb6e617.zip
gcc-836c42f6ad73f273d5713aaf80a34856efb6e617.tar.gz
gcc-836c42f6ad73f273d5713aaf80a34856efb6e617.tar.bz2
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
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog6
-rw-r--r--libstdc++-v3/include/bits/regex_automaton.tcc14
-rw-r--r--libstdc++-v3/testsuite/28_regex/basic_regex/multiple_quantifiers.cc4
3 files changed, 16 insertions, 8 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 83c1094..7cd2dc9 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,9 @@
+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>
PR libstdc++/43622
diff --git a/libstdc++-v3/include/bits/regex_automaton.tcc b/libstdc++-v3/include/bits/regex_automaton.tcc
index 759b053..1476ae2 100644
--- a/libstdc++-v3/include/bits/regex_automaton.tcc
+++ b/libstdc++-v3/include/bits/regex_automaton.tcc
@@ -197,20 +197,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// _M_insert_state() never return -1
auto __id = _M_nfa._M_insert_state(__dup);
__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
|| __dup._M_opcode == _S_opcode_subexpr_lookahead)
if (__dup._M_alt != _S_invalid_state_id && __m[__dup._M_alt] == -1)
__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 (long __k = 0; __k < __size; __k++)
+ for (auto __v : __m)
{
- long __v;
- if ((__v = __m[__k]) == -1)
+ if (__v == -1)
continue;
auto& __ref = _M_nfa[__v];
if (__ref._M_next != _S_invalid_state_id)
diff --git a/libstdc++-v3/testsuite/28_regex/basic_regex/multiple_quantifiers.cc b/libstdc++-v3/testsuite/28_regex/basic_regex/multiple_quantifiers.cc
index 5670cbb..8243eea 100644
--- a/libstdc++-v3/testsuite/28_regex/basic_regex/multiple_quantifiers.cc
+++ b/libstdc++-v3/testsuite/28_regex/basic_regex/multiple_quantifiers.cc
@@ -21,7 +21,10 @@
// Tests multiple consecutive quantifiers
#include <regex>
+#include <testsuite_hooks.h>
+#include <testsuite_regex.h>
+using namespace __gnu_test;
using namespace std;
int
@@ -29,5 +32,6 @@ main()
{
regex re1("a++");
regex re2("(a+)+");
+ VERIFY(regex_match_debug("aa", regex("(a)*{3}")));
return 0;
}