]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
regex_automaton.tcc (_StateSeq<>::_M_clone()): Do _M_alt before _M_next.
authorTim Shen <timshen91@gmail.com>
Thu, 24 Apr 2014 18:29:21 +0000 (18:29 +0000)
committerTim Shen <timshen@gcc.gnu.org>
Thu, 24 Apr 2014 18:29:21 +0000 (18:29 +0000)
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

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/regex_automaton.tcc
libstdc++-v3/testsuite/28_regex/basic_regex/multiple_quantifiers.cc

index 83c10944a3bdd6822fd208388b8a4f20be1aae63..7cd2dc90f372b13f31431d903232e98a4406b5a9 100644 (file)
@@ -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
index 759b053c5eff486696d828858ee7c8ee111c4e8e..1476ae20a5b92bdf7b8ddb75d69162f0da568945 100644 (file)
@@ -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)
index 5670cbb8e3b72a6cd2c1a601105ffe081ab12b66..8243eea930a2cd194a8554f4115d662e96a7e216 100644 (file)
 // 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;
 }