From 26157a7e9d1dcbe399f8de5314c01fd12ad80a0a Mon Sep 17 00:00:00 2001 From: timshen Date: Tue, 1 Jul 2014 02:10:31 +0000 Subject: 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 --- .../28_regex/algorithms/regex_search/61424.cc | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 libstdc++-v3/testsuite/28_regex/algorithms/regex_search/61424.cc (limited to 'libstdc++-v3/testsuite/28_regex/algorithms') 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 +// . + +// PR libstdc++/61424 + +#include +#include +#include + +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++; + } +} -- cgit v1.2.1