Commit 33fbbb76 by Tim Shen Committed by Tim Shen

Makefile.am: Add regex_scanner.{h,tcc}.

2013-08-26  Tim Shen  <timshen91@gmail.com>

	* include/Makefile.am: Add regex_scanner.{h,tcc}.
	* include/Makefile.in: Regenerate.
	* include/bits/regex.h (match_search): Handle the `__first == __last`
	  situation correctly.
	* include/bits/regex_compiler.h: Move _Scanner...
	* include/bits/regex_scanner.h: ...to here. New.
	* include/bits/regex_compiler.tcc: Move _Scanner...
	* include/bits/regex_scanner.tcc: ...to here, too. New.
	* include/bits/regex_executor.tcc: Use value instead of reference for
	  submatch.
	* include/std/regex: Add regex_scanner.h
	* testsuite/28_regex/algorithms/regex_match/awk/cstring_01.cc: New.
	* testsuite/28_regex/algorithms/regex_match/basic/empty_range.cc: New.
	* testsuite/28_regex/algorithms/regex_match/ecma/cstring_hex.cc: New.
	* testsuite/28_regex/algorithms/regex_match/ecma/empty_range.cc: New.
	* testsuite/28_regex/algorithms/regex_search/ecma/string_01.cc: New.

From-SVN: r202015
parent fd91cfe3
2013-08-26 Tim Shen <timshen91@gmail.com>
* include/Makefile.am: Add regex_scanner.{h,tcc}.
* include/Makefile.in: Regenerate.
* include/bits/regex.h (match_search): Handle the `__first == __last`
situation correctly.
* include/bits/regex_compiler.h: Move _Scanner...
* include/bits/regex_scanner.h: ...to here. New.
* include/bits/regex_compiler.tcc: Move _Scanner...
* include/bits/regex_scanner.tcc: ...to here, too. New.
* include/bits/regex_executor.tcc: Use value instead of reference for
submatch.
* include/std/regex: Add regex_scanner.h
* testsuite/28_regex/algorithms/regex_match/awk/cstring_01.cc: New.
* testsuite/28_regex/algorithms/regex_match/basic/empty_range.cc: New.
* testsuite/28_regex/algorithms/regex_match/ecma/cstring_hex.cc: New.
* testsuite/28_regex/algorithms/regex_match/ecma/empty_range.cc: New.
* testsuite/28_regex/algorithms/regex_search/ecma/string_01.cc: New.
2013-08-22 Tim Shen <timshen91@gmail.com>
* include/bits/regex.h: Replace 8 spaces in indentation with a tab.
......
......@@ -128,6 +128,8 @@ bits_headers = \
${bits_srcdir}/regex.h \
${bits_srcdir}/regex_constants.h \
${bits_srcdir}/regex_error.h \
${bits_srcdir}/regex_scanner.h \
${bits_srcdir}/regex_scanner.tcc \
${bits_srcdir}/regex_automaton.h \
${bits_srcdir}/regex_automaton.tcc \
${bits_srcdir}/regex_compiler.h \
......
......@@ -395,6 +395,8 @@ bits_headers = \
${bits_srcdir}/regex.h \
${bits_srcdir}/regex_constants.h \
${bits_srcdir}/regex_error.h \
${bits_srcdir}/regex_scanner.h \
${bits_srcdir}/regex_scanner.tcc \
${bits_srcdir}/regex_automaton.h \
${bits_srcdir}/regex_automaton.tcc \
${bits_srcdir}/regex_compiler.h \
......
......@@ -740,11 +740,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @throws regex_error if @p [__first, __last) is not a valid regular
* expression.
*/
template<typename _InputIterator>
basic_regex(_InputIterator __first, _InputIterator __last,
template<typename _FwdIter>
basic_regex(_FwdIter __first, _FwdIter __last,
flag_type __f = ECMAScript)
: _M_flags(__f),
_M_automaton(__detail::_Compiler<_InputIterator, _Ch_type, _Rx_traits>
_M_automaton(__detail::_Compiler<_FwdIter, _Ch_type, _Rx_traits>
(__first, __last, _M_traits, _M_flags)._M_get_nfa())
{ }
......@@ -2371,7 +2371,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
if (__re._M_automaton == nullptr)
return false;
for (auto __cur = __first; __cur != __last; ++__cur) // Any KMP-like algo?
auto __cur = __first;
// Continue when __cur == __last
do
{
__detail::__get_executor(__cur, __last, __m, __re, __flags)
->_M_search_from_first();
......@@ -2391,10 +2393,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return true;
}
}
while (__cur++ != __last);
return false;
}
/**
* Searches for a regular expression within a range.
* @param __first [IN] The start of the string to search.
......
......@@ -39,197 +39,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @{
*/
/// Matches a character range (bracket expression)
template<typename _CharT, typename _TraitsT>
struct _BracketMatcher
{
typedef typename _TraitsT::char_class_type _CharClassT;
typedef typename _TraitsT::string_type _StringT;
typedef regex_constants::syntax_option_type _FlagT;
explicit
_BracketMatcher(bool __is_non_matching,
const _TraitsT& __t,
_FlagT __flags)
: _M_is_non_matching(__is_non_matching), _M_traits(__t),
_M_flags(__flags), _M_class_set(0)
{ }
bool
operator()(_CharT) const;
void
_M_add_char(_CharT __c)
{
if (_M_flags & regex_constants::collate)
if (_M_is_icase())
_M_char_set.push_back(_M_traits.translate_nocase(__c));
else
_M_char_set.push_back(_M_traits.translate(__c));
else
_M_char_set.push_back(__c);
}
void
_M_add_collating_element(const _StringT& __s)
{
auto __st = _M_traits.lookup_collatename(&*__s.begin(), &*__s.end());
if (__st.empty())
__throw_regex_error(regex_constants::error_collate);
// TODO: digraph
_M_char_set.push_back(__st[0]);
}
void
_M_add_equivalence_class(const _StringT& __s)
{
_M_add_character_class(
_M_traits.transform_primary(&*__s.begin(), &*__s.end()));
}
void
_M_add_character_class(const _StringT& __s)
{
auto __st = _M_traits.
lookup_classname(&*__s.begin(), &*__s.end(), _M_is_icase());
if (__st == 0)
__throw_regex_error(regex_constants::error_ctype);
_M_class_set |= __st;
}
void
_M_make_range(_CharT __l, _CharT __r)
{ _M_range_set.push_back(make_pair(_M_get_str(__l), _M_get_str(__r))); }
bool
_M_is_icase() const
{ return _M_flags & regex_constants::icase; }
_StringT
_M_get_str(_CharT __c) const
{
auto __s = _StringT(1,
_M_is_icase()
? _M_traits.translate_nocase(__c)
: _M_traits.translate(__c));
return _M_traits.transform(__s.begin(), __s.end());
}
_TraitsT _M_traits;
_FlagT _M_flags;
bool _M_is_non_matching;
std::vector<_CharT> _M_char_set;
std::vector<pair<_StringT, _StringT>> _M_range_set;
_CharClassT _M_class_set;
};
/**
* @brief struct _Scanner. Scans an input range for regex tokens.
*
* The %_Scanner class interprets the regular expression pattern in
* the input range passed to its constructor as a sequence of parse
* tokens passed to the regular expression compiler. The sequence
* of tokens provided depends on the flag settings passed to the
* constructor: different regular expression grammars will interpret
* the same input pattern in syntactically different ways.
*/
template<typename _InputIter>
class _Scanner
{
public:
typedef unsigned int _StateT;
typedef typename std::iterator_traits<_InputIter>::value_type _CharT;
typedef std::basic_string<_CharT> _StringT;
typedef regex_constants::syntax_option_type _FlagT;
typedef const std::ctype<_CharT> _CtypeT;
/// Token types returned from the scanner.
enum _TokenT
{
_S_token_anychar,
_S_token_backref,
_S_token_bracket_begin,
_S_token_bracket_inverse_begin,
_S_token_bracket_end,
_S_token_char_class_name,
_S_token_closure0,
_S_token_closure1,
_S_token_collelem_multi,
_S_token_collelem_single,
_S_token_collsymbol,
_S_token_comma,
_S_token_dash,
_S_token_dup_count,
_S_token_eof,
_S_token_equiv_class_name,
_S_token_interval_begin,
_S_token_interval_end,
_S_token_line_begin,
_S_token_line_end,
_S_token_opt,
_S_token_or,
_S_token_ord_char,
_S_token_subexpr_begin,
_S_token_subexpr_end,
_S_token_word_begin,
_S_token_word_end,
_S_token_unknown
};
_Scanner(_InputIter __begin, _InputIter __end,
_FlagT __flags, std::locale __loc)
: _M_current(__begin) , _M_end(__end) , _M_flags(__flags),
_M_ctype(std::use_facet<_CtypeT>(__loc)), _M_state(0)
{ _M_advance(); }
void
_M_advance();
_TokenT
_M_token() const
{ return _M_curToken; }
const _StringT&
_M_value() const
{ return _M_curValue; }
#ifdef _GLIBCXX_DEBUG
std::ostream&
_M_print(std::ostream&);
#endif
private:
void
_M_eat_escape();
void
_M_scan_in_brace();
void
_M_scan_in_bracket();
void
_M_eat_charclass();
void
_M_eat_equivclass();
void
_M_eat_collsymbol();
static constexpr _StateT _S_state_in_brace = 1 << 0;
static constexpr _StateT _S_state_in_bracket = 1 << 1;
_InputIter _M_current;
_InputIter _M_end;
_FlagT _M_flags;
_CtypeT& _M_ctype;
_TokenT _M_curToken;
_StringT _M_curValue;
_StateT _M_state;
};
struct _BracketMatcher;
/// Builds an NFA from an input iterator interval.
template<typename _InputIter, typename _CharT, typename _TraitsT>
template<typename _FwdIter, typename _CharT, typename _TraitsT>
class _Compiler
{
public:
......@@ -237,7 +51,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef _NFA<_CharT, _TraitsT> _RegexT;
typedef regex_constants::syntax_option_type _FlagT;
_Compiler(_InputIter __b, _InputIter __e,
_Compiler(_FwdIter __b, _FwdIter __e,
const _TraitsT& __traits, _FlagT __flags);
std::shared_ptr<_RegexT>
......@@ -245,7 +59,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ return std::shared_ptr<_RegexT>(new _RegexT(_M_state_store)); }
private:
typedef _Scanner<_InputIter> _ScannerT;
typedef _Scanner<_FwdIter> _ScannerT;
typedef typename _ScannerT::_TokenT _TokenT;
typedef _StateSeq<_CharT, _TraitsT> _StateSeqT;
typedef std::stack<_StateSeqT, std::vector<_StateSeqT>> _StackT;
......@@ -276,7 +90,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
bool
_M_bracket_expression();
bool
void
_M_bracket_list(_BMatcherT& __matcher);
bool
......@@ -303,14 +117,111 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
int
_M_cur_int_value(int __radix);
bool
_M_try_char();
_CharT
_M_get_char();
const _TraitsT& _M_traits;
_ScannerT _M_scanner;
_StringT _M_cur_value;
_StringT _M_value;
_RegexT _M_state_store;
_StackT _M_stack;
_FlagT _M_flags;
};
/// Matches a character range (bracket expression)
template<typename _CharT, typename _TraitsT>
struct _BracketMatcher
{
typedef typename _TraitsT::char_class_type _CharClassT;
typedef typename _TraitsT::string_type _StringT;
typedef regex_constants::syntax_option_type _FlagT;
explicit
_BracketMatcher(bool __is_non_matching,
const _TraitsT& __t,
_FlagT __flags)
: _M_is_non_matching(__is_non_matching), _M_traits(__t),
_M_flags(__flags), _M_class_set(0)
{ }
bool
operator()(_CharT) const;
void
_M_add_char(_CharT __c)
{ _M_char_set.push_back(_M_translate(__c)); }
void
_M_add_collating_element(const _StringT& __s)
{
auto __st = _M_traits.lookup_collatename(__s.data(),
__s.data() + __s.size());
if (__st.empty())
__throw_regex_error(regex_constants::error_collate);
// TODO: digraph
_M_char_set.push_back(__st[0]);
}
void
_M_add_equivalence_class(const _StringT& __s)
{
_M_add_character_class(
_M_traits.transform_primary(__s.data(),
__s.data() + __s.size()));
}
void
_M_add_character_class(const _StringT& __s)
{
auto __st = _M_traits.
lookup_classname(__s.data(), __s.data() + __s.size(), _M_is_icase());
if (__st == 0)
__throw_regex_error(regex_constants::error_ctype);
_M_class_set |= __st;
}
void
_M_make_range(_CharT __l, _CharT __r)
{
_M_range_set.push_back(
make_pair(_M_get_str(_M_translate(__l)),
_M_get_str(_M_translate(__r))));
}
_CharT
_M_translate(_CharT __c) const
{
if (_M_flags & regex_constants::collate)
if (_M_is_icase())
return _M_traits.translate_nocase(__c);
else
return _M_traits.translate(__c);
else
return __c;
}
bool
_M_is_icase() const
{ return _M_flags & regex_constants::icase; }
_StringT
_M_get_str(_CharT __c) const
{
_StringT __s(1, __c);
return _M_traits.transform(__s.begin(), __s.end());
}
_TraitsT _M_traits;
_FlagT _M_flags;
bool _M_is_non_matching;
std::vector<_CharT> _M_char_set;
std::vector<pair<_StringT, _StringT>> _M_range_set;
_CharClassT _M_class_set;
};
//@} regex-detail
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace __detail
......
......@@ -260,7 +260,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
auto __size = __u.size();
for (auto __i = 0; __i < __size; __i++)
{
auto& __uit = __u[__i], __vit = __v[__i];
auto __uit = __u[__i], __vit = __v[__i];
if (__uit.matched && !__vit.matched)
return true;
if (!__uit.matched && __vit.matched)
......
// class template regex -*- C++ -*-
// Copyright (C) 2013 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.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/**
* @file bits/regex_scanner.h
* This is an internal header file, included by other library headers.
* Do not attempt to use it directly. @headername{regex}
*/
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __detail
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
/**
* @addtogroup regex-detail
* @{
*/
/**
* @brief struct _Scanner. Scans an input range for regex tokens.
*
* The %_Scanner class interprets the regular expression pattern in
* the input range passed to its constructor as a sequence of parse
* tokens passed to the regular expression compiler. The sequence
* of tokens provided depends on the flag settings passed to the
* constructor: different regular expression grammars will interpret
* the same input pattern in syntactically different ways.
*/
template<typename _FwdIter>
class _Scanner
{
public:
typedef typename std::iterator_traits<_FwdIter>::value_type _CharT;
typedef std::basic_string<_CharT> _StringT;
typedef regex_constants::syntax_option_type _FlagT;
typedef const std::ctype<_CharT> _CtypeT;
/// Token types returned from the scanner.
enum _TokenT
{
_S_token_anychar,
_S_token_ord_char,
_S_token_oct_num,
_S_token_hex_num,
_S_token_backref,
_S_token_subexpr_begin,
_S_token_subexpr_no_group_begin,
_S_token_subexpr_lookahead_begin,
_S_token_subexpr_neg_lookahead_begin,
_S_token_subexpr_end,
_S_token_bracket_begin,
_S_token_bracket_neg_begin,
_S_token_bracket_end,
_S_token_interval_begin,
_S_token_interval_end,
_S_token_quoted_class,
_S_token_char_class_name,
_S_token_collsymbol,
_S_token_equiv_class_name,
_S_token_opt,
_S_token_or,
_S_token_closure0,
_S_token_closure1,
_S_token_line_begin,
_S_token_line_end,
_S_token_comma,
_S_token_dup_count,
_S_token_eof,
_S_token_unknown
};
_Scanner(_FwdIter __begin, _FwdIter __end,
_FlagT __flags, std::locale __loc);
void
_M_advance();
_TokenT
_M_get_token() const
{ return _M_token; }
const _StringT&
_M_get_value() const
{ return _M_value; }
#ifdef _GLIBCXX_DEBUG
std::ostream&
_M_print(std::ostream&);
#endif
private:
enum _StateT
{
_S_state_normal,
_S_state_in_brace,
_S_state_in_bracket,
};
void
_M_scan_normal();
void
_M_scan_in_bracket();
void
_M_scan_in_brace();
void
_M_eat_escape_ecma();
void
_M_eat_escape_posix();
void
_M_eat_escape_awk();
void
_M_eat_class(char);
constexpr bool
_M_is_ecma()
{ return _M_flags & regex_constants::ECMAScript; }
constexpr bool
_M_is_basic()
{ return _M_flags & (regex_constants::basic | regex_constants::grep); }
constexpr bool
_M_is_extended()
{
return _M_flags & (regex_constants::extended
| regex_constants::egrep
| regex_constants::awk);
}
constexpr bool
_M_is_grep()
{ return _M_flags & (regex_constants::grep | regex_constants::egrep); }
constexpr bool
_M_is_awk()
{ return _M_flags & regex_constants::awk; }
_StateT _M_state;
_FwdIter _M_current;
_FwdIter _M_end;
_FlagT _M_flags;
_CtypeT& _M_ctype;
_TokenT _M_token;
_StringT _M_value;
bool _M_at_bracket_start;
public:
// TODO: make them static when this file is stable.
const std::map<char, _TokenT> _M_token_map;
const std::map<char, char> _M_ecma_escape_map;
const std::map<char, char> _M_awk_escape_map;
const std::set<char> _M_ecma_spec_char;
const std::set<char> _M_basic_spec_char;
const std::set<char> _M_extended_spec_char;
const std::map<char, char>& _M_escape_map;
const std::set<char>& _M_spec_char;
void (_Scanner::* _M_eat_escape)();
};
//@} regex-detail
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace __detail
} // namespace std
#include <bits/regex_scanner.tcc>
......@@ -56,6 +56,7 @@
#include <bits/regex_constants.h>
#include <bits/regex_error.h>
#include <bits/regex_scanner.h>
#include <bits/regex_automaton.h>
#include <bits/regex_compiler.h>
#include <bits/regex_executor.h>
......
// { dg-options "-std=gnu++11" }
//
// 2013-08-26 Tim Shen <timshen91@gmail.com>
//
// Copyright (C) 2013 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/>.
// 28.11.2 regex_match
// Tests awk escaping.
#include <regex>
#include <testsuite_hooks.h>
using namespace std;
void
test01()
{
bool test __attribute__((unused)) = true;
regex("\\[", regex_constants::awk);
VERIFY(regex_match("\"", regex("[\\\"]", regex_constants::awk)));
VERIFY(regex_match("/", regex("/", regex_constants::awk)));
VERIFY(regex_match("\a", regex("\\a", regex_constants::awk)));
VERIFY(regex_match("\"", regex("\\\"", regex_constants::awk)));
VERIFY(regex_match("5", regex("\\65", regex_constants::awk)));
VERIFY(regex_match("53", regex("\\0653", regex_constants::awk)));
}
int
main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++11" }
//
// 2013-08-26 Tim Shen <timshen91@gmail.com>
//
// Copyright (C) 2013 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/>.
// 28.11.2 regex_match
// Tests ECMAScript empty range.
#include <regex>
#include <testsuite_hooks.h>
using namespace std;
void
test01()
{
bool test __attribute__((unused)) = true;
#define FAIL(s) \
try\
{\
regex re(s, regex_constants::basic);\
VERIFY(false);\
}\
catch (...)\
{\
VERIFY(true);\
}
FAIL("[]");
FAIL("[^]");
VERIFY(regex_match("]", regex("[]]", regex_constants::basic)));
VERIFY(!regex_match("]", regex("[^]]", regex_constants::basic)));
}
int
main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++11" }
//
// 2013-08-26 Tim Shen <timshen91@gmail.com>
//
// Copyright (C) 2013 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/>.
// 28.11.2 regex_match
// Tests ECMAScript \x and \u.
#include <regex>
#include <testsuite_hooks.h>
using namespace std;
void
test01()
{
bool test __attribute__((unused)) = true;
VERIFY(regex_match(":", regex("\\x3a")));
VERIFY(regex_match(L"\u1234", wregex(L"\\u1234")));
try
{
regex("\\u400x");
VERIFY(false);
}
catch (...)
{
VERIFY(true);
}
}
int
main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++11" }
//
// 2013-08-26 Tim Shen <timshen91@gmail.com>
//
// Copyright (C) 2013 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/>.
// 28.11.2 regex_match
// Tests ECMAScript empty range.
#include <regex>
#include <testsuite_hooks.h>
using namespace std;
void
test01()
{
bool test __attribute__((unused)) = true;
VERIFY(!regex_match("x", regex("[]")));
VERIFY(regex_match("x", regex("[^]")));
VERIFY(!regex_match("]", regex("[]]")));
VERIFY(!regex_match("]", regex("[^]]")));
}
int
main()
{
test01();
return 0;
}
// { dg-options "-std=gnu++11" }
//
// 2013-08-26 Tim Shen <timshen91@gmail.com>
//
// Copyright (C) 2013 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/>.
// 28.11.3 regex_search
// Tests BRE against a std::string target.
#include <regex>
#include <testsuite_hooks.h>
void
test01()
{
bool test __attribute__((unused)) = true;
VERIFY(std::regex_search("", std::regex("")));
}
int
main()
{
test01();
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