2013-10-02 Tim Shen <timshen91@gmail.com>

* include/bits/regex_compiler.h
	(_BracketMatcher<>::_M_add_equivalence_class): Implement it correctly.
	* include/bits/regex_compiler.tcc (_BracketMatcher<>::operator()):
	Add _M_equiv_set support.
	* testsuite/28_regex/algorithms/regex_match/extended/
	cstring_bracket_01.cc: Add new "[[=a=]]" testcase.

From-SVN: r203117
This commit is contained in:
Tim Shen 2013-10-02 15:13:18 +00:00 committed by Tim Shen
parent 90926a2da5
commit 756aa0c302
4 changed files with 30 additions and 10 deletions

View File

@ -1,3 +1,12 @@
2013-10-02 Tim Shen <timshen91@gmail.com>
* include/bits/regex_compiler.h
(_BracketMatcher<>::_M_add_equivalence_class): Implement it correctly.
* include/bits/regex_compiler.tcc (_BracketMatcher<>::operator()):
Add _M_equiv_set support.
* testsuite/28_regex/algorithms/regex_match/extended/
cstring_bracket_01.cc: Add new "[[=a=]]" testcase.
2013-10-01 Tim Shen <timshen91@gmail.com>
* doc/xml/manual/status_cxx2011.xml: Change "is not implemented" to

View File

@ -213,19 +213,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
void
_M_add_equivalence_class(const _StringT& __s)
{
_M_add_character_class(
_M_traits.transform_primary(__s.data(),
__s.data() + __s.size()));
auto __st = _M_traits.lookup_collatename(__s.data(),
__s.data() + __s.size());
if (__st.empty())
__throw_regex_error(regex_constants::error_collate);
__st = _M_traits.transform_primary(__st.data(),
__st.data() + __st.size());
_M_equiv_set.insert(__st);
}
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)
auto __mask = _M_traits.lookup_classname(__s.data(),
__s.data() + __s.size(),
_M_is_icase());
if (__mask == 0)
__throw_regex_error(regex_constants::error_ctype);
_M_class_set |= __st;
_M_class_set |= __mask;
}
void
@ -260,6 +265,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
std::set<_CharT> _M_char_set;
std::set<_StringT> _M_equiv_set;
std::set<pair<_StringT, _StringT>> _M_range_set;
const _TraitsT& _M_traits;
_CharClassT _M_class_set;

View File

@ -437,9 +437,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator()(_CharT __ch) const
{
bool __ret = false;
if (_M_traits.isctype(__ch, _M_class_set))
__ret = true;
else if (_M_char_set.count(_M_translate(__ch)))
if (_M_traits.isctype(__ch, _M_class_set)
|| _M_char_set.count(_M_translate(__ch))
|| _M_equiv_set.count(_M_traits.transform_primary(&__ch, &__ch+1)))
__ret = true;
else
{

View File

@ -56,6 +56,11 @@ test01()
VERIFY( std::regex_match("pre/a", re) );
VERIFY( std::regex_match("pre/0", re) );
}
{
std::regex re("pre/[[=a=]]", std::regex::extended);
VERIFY( std::regex_match("pre/a", re) );
VERIFY( std::regex_match("pre/A", re) );
}
}
int