summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/28_regex/algorithms
diff options
context:
space:
mode:
authortimshen <timshen@138bc75d-0d04-0410-961f-82ee72b054a4>2014-07-01 02:10:31 +0000
committertimshen <timshen@138bc75d-0d04-0410-961f-82ee72b054a4>2014-07-01 02:10:31 +0000
commit26157a7e9d1dcbe399f8de5314c01fd12ad80a0a (patch)
tree88aab4a08a668b5a2e116189f2dd62d4878258ff /libstdc++-v3/testsuite/28_regex/algorithms
parent295f1677d75c28a4fda6bbc6652f7237c08276c0 (diff)
downloadgcc-26157a7e9d1dcbe399f8de5314c01fd12ad80a0a.tar.gz
PR libstdc++/61424
* include/bits/regex.tcc (__regex_algo_impl<>): Use DFS for ECMAScript, not just regex containing back-references. * include/bits/regex_compiler.tcc (_Compiler<>::_M_disjunction): exchange _M_next and _M_alt for alternative operator, making matching from left to right. * include/bits/regex_executor.h (_State_info<>::_M_get_sol_pos): Add position tracking fom DFS. * include/bits/regex_executor.tcc (_Executor<>::_M_main_dispatch, _Executor<>::_M_dfs): Likewise. * include/bits/regex_scanner.h: Remove unused enum entry. * testsuite/28_regex/algorithms/regex_search/61424.cc: New testcase from PR. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@212184 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/28_regex/algorithms')
-rw-r--r--libstdc++-v3/testsuite/28_regex/algorithms/regex_search/61424.cc52
1 files changed, 52 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/28_regex/algorithms/regex_search/61424.cc b/libstdc++-v3/testsuite/28_regex/algorithms/regex_search/61424.cc
new file mode 100644
index 00000000000..bdccb4a454e
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/algorithms/regex_search/61424.cc
@@ -0,0 +1,52 @@
+// { dg-options "-std=gnu++11" }
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// PR libstdc++/61424
+
+#include <regex>
+#include <testsuite_hooks.h>
+#include <testsuite_regex.h>
+
+using namespace std;
+using namespace __gnu_test;
+
+int main()
+{
+ regex_constants::syntax_option_type grammar[] = {
+ regex_constants::ECMAScript, regex_constants::extended,
+ regex_constants::awk, regex_constants::egrep
+ };
+
+ string sol[] = {
+ "tour",
+ "tournament",
+ "tournament",
+ "tournament",
+ };
+ int i = 0;
+ for (auto g : grammar)
+ {
+ regex re("tour|tournament|tourn", g);
+ const char str[] = "tournament";
+ cmatch m;
+ VERIFY(regex_search_debug(str, m, re));
+ VERIFY(sol[i] == m[0]);
+ i++;
+ }
+}